documentation.d.ts 3.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409
  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. * @returns a new forward Vector3
  2762. */
  2763. static Forward(): Vector3;
  2764. /**
  2765. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2766. * @returns a new forward Vector3
  2767. */
  2768. static Backward(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2771. * @returns a new right Vector3
  2772. */
  2773. static Right(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2776. * @returns a new left Vector3
  2777. */
  2778. static Left(): Vector3;
  2779. /**
  2780. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2781. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2782. * @param vector defines the Vector3 to transform
  2783. * @param transformation defines the transformation matrix
  2784. * @returns the transformed Vector3
  2785. */
  2786. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2787. /**
  2788. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2789. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2790. * @param vector defines the Vector3 to transform
  2791. * @param transformation defines the transformation matrix
  2792. * @param result defines the Vector3 where to store the result
  2793. */
  2794. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2795. /**
  2796. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2797. * This method computes tranformed coordinates only, not transformed direction vectors
  2798. * @param x define the x coordinate of the source vector
  2799. * @param y define the y coordinate of the source vector
  2800. * @param z define the z coordinate of the source vector
  2801. * @param transformation defines the transformation matrix
  2802. * @param result defines the Vector3 where to store the result
  2803. */
  2804. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2805. /**
  2806. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2807. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @returns the new Vector3
  2811. */
  2812. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2813. /**
  2814. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2815. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2816. * @param vector defines the Vector3 to transform
  2817. * @param transformation defines the transformation matrix
  2818. * @param result defines the Vector3 where to store the result
  2819. */
  2820. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2821. /**
  2822. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2823. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2824. * @param x define the x coordinate of the source vector
  2825. * @param y define the y coordinate of the source vector
  2826. * @param z define the z coordinate of the source vector
  2827. * @param transformation defines the transformation matrix
  2828. * @param result defines the Vector3 where to store the result
  2829. */
  2830. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2831. /**
  2832. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2833. * @param value1 defines the first control point
  2834. * @param value2 defines the second control point
  2835. * @param value3 defines the third control point
  2836. * @param value4 defines the fourth control point
  2837. * @param amount defines the amount on the spline to use
  2838. * @returns the new Vector3
  2839. */
  2840. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2841. /**
  2842. * 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"
  2843. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2844. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2845. * @param value defines the current value
  2846. * @param min defines the lower range value
  2847. * @param max defines the upper range value
  2848. * @returns the new Vector3
  2849. */
  2850. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2851. /**
  2852. * 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"
  2853. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2854. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2855. * @param value defines the current value
  2856. * @param min defines the lower range value
  2857. * @param max defines the upper range value
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2861. /**
  2862. * Checks if a given vector is inside a specific range
  2863. * @param v defines the vector to test
  2864. * @param min defines the minimum range
  2865. * @param max defines the maximum range
  2866. */
  2867. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2868. /**
  2869. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2870. * @param value1 defines the first control point
  2871. * @param tangent1 defines the first tangent vector
  2872. * @param value2 defines the second control point
  2873. * @param tangent2 defines the second tangent vector
  2874. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2875. * @returns the new Vector3
  2876. */
  2877. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2878. /**
  2879. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2880. * @param start defines the start value
  2881. * @param end defines the end value
  2882. * @param amount max defines amount between both (between 0 and 1)
  2883. * @returns the new Vector3
  2884. */
  2885. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2886. /**
  2887. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2888. * @param start defines the start value
  2889. * @param end defines the end value
  2890. * @param amount max defines amount between both (between 0 and 1)
  2891. * @param result defines the Vector3 where to store the result
  2892. */
  2893. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2894. /**
  2895. * Returns the dot product (float) between the vectors "left" and "right"
  2896. * @param left defines the left operand
  2897. * @param right defines the right operand
  2898. * @returns the dot product
  2899. */
  2900. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2901. /**
  2902. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2903. * The cross product is then orthogonal to both "left" and "right"
  2904. * @param left defines the left operand
  2905. * @param right defines the right operand
  2906. * @returns the cross product
  2907. */
  2908. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2909. /**
  2910. * Sets the given vector "result" with the cross product of "left" and "right"
  2911. * The cross product is then orthogonal to both "left" and "right"
  2912. * @param left defines the left operand
  2913. * @param right defines the right operand
  2914. * @param result defines the Vector3 where to store the result
  2915. */
  2916. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2917. /**
  2918. * Returns a new Vector3 as the normalization of the given vector
  2919. * @param vector defines the Vector3 to normalize
  2920. * @returns the new Vector3
  2921. */
  2922. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2923. /**
  2924. * Sets the given vector "result" with the normalization of the given first vector
  2925. * @param vector defines the Vector3 to normalize
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2929. /**
  2930. * Project a Vector3 onto screen space
  2931. * @param vector defines the Vector3 to project
  2932. * @param world defines the world matrix to use
  2933. * @param transform defines the transform (view x projection) matrix to use
  2934. * @param viewport defines the screen viewport to use
  2935. * @returns the new Vector3
  2936. */
  2937. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2938. /** @hidden */
  2939. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2940. /**
  2941. * Unproject from screen space to object space
  2942. * @param source defines the screen space Vector3 to use
  2943. * @param viewportWidth defines the current width of the viewport
  2944. * @param viewportHeight defines the current height of the viewport
  2945. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2946. * @param transform defines the transform (view x projection) matrix to use
  2947. * @returns the new Vector3
  2948. */
  2949. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2950. /**
  2951. * Unproject from screen space to object space
  2952. * @param source defines the screen space Vector3 to use
  2953. * @param viewportWidth defines the current width of the viewport
  2954. * @param viewportHeight defines the current height of the viewport
  2955. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2956. * @param view defines the view matrix to use
  2957. * @param projection defines the projection matrix to use
  2958. * @returns the new Vector3
  2959. */
  2960. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2961. /**
  2962. * Unproject from screen space to object space
  2963. * @param source defines the screen space Vector3 to use
  2964. * @param viewportWidth defines the current width of the viewport
  2965. * @param viewportHeight defines the current height of the viewport
  2966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2967. * @param view defines the view matrix to use
  2968. * @param projection defines the projection matrix to use
  2969. * @param result defines the Vector3 where to store the result
  2970. */
  2971. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2972. /**
  2973. * Unproject from screen space to object space
  2974. * @param sourceX defines the screen space x coordinate to use
  2975. * @param sourceY defines the screen space y coordinate to use
  2976. * @param sourceZ defines the screen space z coordinate to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2985. /**
  2986. * Gets the minimal coordinate values between two Vector3
  2987. * @param left defines the first operand
  2988. * @param right defines the second operand
  2989. * @returns the new Vector3
  2990. */
  2991. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2992. /**
  2993. * Gets the maximal coordinate values between two Vector3
  2994. * @param left defines the first operand
  2995. * @param right defines the second operand
  2996. * @returns the new Vector3
  2997. */
  2998. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2999. /**
  3000. * Returns the distance between the vectors "value1" and "value2"
  3001. * @param value1 defines the first operand
  3002. * @param value2 defines the second operand
  3003. * @returns the distance
  3004. */
  3005. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3006. /**
  3007. * Returns the squared distance between the vectors "value1" and "value2"
  3008. * @param value1 defines the first operand
  3009. * @param value2 defines the second operand
  3010. * @returns the squared distance
  3011. */
  3012. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3013. /**
  3014. * Returns a new Vector3 located at the center between "value1" and "value2"
  3015. * @param value1 defines the first operand
  3016. * @param value2 defines the second operand
  3017. * @returns the new Vector3
  3018. */
  3019. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3020. /**
  3021. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3022. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3023. * to something in order to rotate it from its local system to the given target system
  3024. * Note: axis1, axis2 and axis3 are normalized during this operation
  3025. * @param axis1 defines the first axis
  3026. * @param axis2 defines the second axis
  3027. * @param axis3 defines the third axis
  3028. * @returns a new Vector3
  3029. */
  3030. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3031. /**
  3032. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3033. * @param axis1 defines the first axis
  3034. * @param axis2 defines the second axis
  3035. * @param axis3 defines the third axis
  3036. * @param ref defines the Vector3 where to store the result
  3037. */
  3038. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3039. }
  3040. /**
  3041. * Vector4 class created for EulerAngle class conversion to Quaternion
  3042. */
  3043. export class Vector4 {
  3044. /** x value of the vector */
  3045. x: number;
  3046. /** y value of the vector */
  3047. y: number;
  3048. /** z value of the vector */
  3049. z: number;
  3050. /** w value of the vector */
  3051. w: number;
  3052. /**
  3053. * Creates a Vector4 object from the given floats.
  3054. * @param x x value of the vector
  3055. * @param y y value of the vector
  3056. * @param z z value of the vector
  3057. * @param w w value of the vector
  3058. */
  3059. constructor(
  3060. /** x value of the vector */
  3061. x: number,
  3062. /** y value of the vector */
  3063. y: number,
  3064. /** z value of the vector */
  3065. z: number,
  3066. /** w value of the vector */
  3067. w: number);
  3068. /**
  3069. * Returns the string with the Vector4 coordinates.
  3070. * @returns a string containing all the vector values
  3071. */
  3072. toString(): string;
  3073. /**
  3074. * Returns the string "Vector4".
  3075. * @returns "Vector4"
  3076. */
  3077. getClassName(): string;
  3078. /**
  3079. * Returns the Vector4 hash code.
  3080. * @returns a unique hash code
  3081. */
  3082. getHashCode(): number;
  3083. /**
  3084. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3085. * @returns the resulting array
  3086. */
  3087. asArray(): number[];
  3088. /**
  3089. * Populates the given array from the given index with the Vector4 coordinates.
  3090. * @param array array to populate
  3091. * @param index index of the array to start at (default: 0)
  3092. * @returns the Vector4.
  3093. */
  3094. toArray(array: FloatArray, index?: number): Vector4;
  3095. /**
  3096. * Adds the given vector to the current Vector4.
  3097. * @param otherVector the vector to add
  3098. * @returns the updated Vector4.
  3099. */
  3100. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3101. /**
  3102. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3103. * @param otherVector the vector to add
  3104. * @returns the resulting vector
  3105. */
  3106. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3107. /**
  3108. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3109. * @param otherVector the vector to add
  3110. * @param result the vector to store the result
  3111. * @returns the current Vector4.
  3112. */
  3113. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3114. /**
  3115. * Subtract in place the given vector from the current Vector4.
  3116. * @param otherVector the vector to subtract
  3117. * @returns the updated Vector4.
  3118. */
  3119. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3120. /**
  3121. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3122. * @param otherVector the vector to add
  3123. * @returns the new vector with the result
  3124. */
  3125. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3126. /**
  3127. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3128. * @param otherVector the vector to subtract
  3129. * @param result the vector to store the result
  3130. * @returns the current Vector4.
  3131. */
  3132. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3133. /**
  3134. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3135. */
  3136. /**
  3137. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. * @param x value to subtract
  3139. * @param y value to subtract
  3140. * @param z value to subtract
  3141. * @param w value to subtract
  3142. * @returns new vector containing the result
  3143. */
  3144. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3145. /**
  3146. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3147. * @param x value to subtract
  3148. * @param y value to subtract
  3149. * @param z value to subtract
  3150. * @param w value to subtract
  3151. * @param result the vector to store the result in
  3152. * @returns the current Vector4.
  3153. */
  3154. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3155. /**
  3156. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3157. * @returns a new vector with the negated values
  3158. */
  3159. negate(): Vector4;
  3160. /**
  3161. * Negate this vector in place
  3162. * @returns this
  3163. */
  3164. negateInPlace(): Vector4;
  3165. /**
  3166. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3167. * @param result defines the Vector3 object where to store the result
  3168. * @returns the current Vector4
  3169. */
  3170. negateToRef(result: Vector4): Vector4;
  3171. /**
  3172. * Multiplies the current Vector4 coordinates by scale (float).
  3173. * @param scale the number to scale with
  3174. * @returns the updated Vector4.
  3175. */
  3176. scaleInPlace(scale: number): Vector4;
  3177. /**
  3178. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3179. * @param scale the number to scale with
  3180. * @returns a new vector with the result
  3181. */
  3182. scale(scale: number): Vector4;
  3183. /**
  3184. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3185. * @param scale the number to scale with
  3186. * @param result a vector to store the result in
  3187. * @returns the current Vector4.
  3188. */
  3189. scaleToRef(scale: number, result: Vector4): Vector4;
  3190. /**
  3191. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3192. * @param scale defines the scale factor
  3193. * @param result defines the Vector4 object where to store the result
  3194. * @returns the unmodified current Vector4
  3195. */
  3196. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3197. /**
  3198. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3199. * @param otherVector the vector to compare against
  3200. * @returns true if they are equal
  3201. */
  3202. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3203. /**
  3204. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3205. * @param otherVector vector to compare against
  3206. * @param epsilon (Default: very small number)
  3207. * @returns true if they are equal
  3208. */
  3209. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3210. /**
  3211. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3212. * @param x x value to compare against
  3213. * @param y y value to compare against
  3214. * @param z z value to compare against
  3215. * @param w w value to compare against
  3216. * @returns true if equal
  3217. */
  3218. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3219. /**
  3220. * Multiplies in place the current Vector4 by the given one.
  3221. * @param otherVector vector to multiple with
  3222. * @returns the updated Vector4.
  3223. */
  3224. multiplyInPlace(otherVector: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3227. * @param otherVector vector to multiple with
  3228. * @returns resulting new vector
  3229. */
  3230. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3231. /**
  3232. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3233. * @param otherVector vector to multiple with
  3234. * @param result vector to store the result
  3235. * @returns the current Vector4.
  3236. */
  3237. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3240. * @param x x value multiply with
  3241. * @param y y value multiply with
  3242. * @param z z value multiply with
  3243. * @param w w value multiply with
  3244. * @returns resulting new vector
  3245. */
  3246. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3247. /**
  3248. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3249. * @param otherVector vector to devide with
  3250. * @returns resulting new vector
  3251. */
  3252. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3255. * @param otherVector vector to devide with
  3256. * @param result vector to store the result
  3257. * @returns the current Vector4.
  3258. */
  3259. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3260. /**
  3261. * Divides the current Vector3 coordinates by the given ones.
  3262. * @param otherVector vector to devide with
  3263. * @returns the updated Vector3.
  3264. */
  3265. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3268. * @param other defines the second operand
  3269. * @returns the current updated Vector4
  3270. */
  3271. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3272. /**
  3273. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3274. * @param other defines the second operand
  3275. * @returns the current updated Vector4
  3276. */
  3277. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3278. /**
  3279. * Gets a new Vector4 from current Vector4 floored values
  3280. * @returns a new Vector4
  3281. */
  3282. floor(): Vector4;
  3283. /**
  3284. * Gets a new Vector4 from current Vector3 floored values
  3285. * @returns a new Vector4
  3286. */
  3287. fract(): Vector4;
  3288. /**
  3289. * Returns the Vector4 length (float).
  3290. * @returns the length
  3291. */
  3292. length(): number;
  3293. /**
  3294. * Returns the Vector4 squared length (float).
  3295. * @returns the length squared
  3296. */
  3297. lengthSquared(): number;
  3298. /**
  3299. * Normalizes in place the Vector4.
  3300. * @returns the updated Vector4.
  3301. */
  3302. normalize(): Vector4;
  3303. /**
  3304. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3305. * @returns this converted to a new vector3
  3306. */
  3307. toVector3(): Vector3;
  3308. /**
  3309. * Returns a new Vector4 copied from the current one.
  3310. * @returns the new cloned vector
  3311. */
  3312. clone(): Vector4;
  3313. /**
  3314. * Updates the current Vector4 with the given one coordinates.
  3315. * @param source the source vector to copy from
  3316. * @returns the updated Vector4.
  3317. */
  3318. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3319. /**
  3320. * Updates the current Vector4 coordinates with the given floats.
  3321. * @param x float to copy from
  3322. * @param y float to copy from
  3323. * @param z float to copy from
  3324. * @param w float to copy from
  3325. * @returns the updated Vector4.
  3326. */
  3327. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3328. /**
  3329. * Updates the current Vector4 coordinates with the given floats.
  3330. * @param x float to set from
  3331. * @param y float to set from
  3332. * @param z float to set from
  3333. * @param w float to set from
  3334. * @returns the updated Vector4.
  3335. */
  3336. set(x: number, y: number, z: number, w: number): Vector4;
  3337. /**
  3338. * Copies the given float to the current Vector3 coordinates
  3339. * @param v defines the x, y, z and w coordinates of the operand
  3340. * @returns the current updated Vector3
  3341. */
  3342. setAll(v: number): Vector4;
  3343. /**
  3344. * Returns a new Vector4 set from the starting index of the given array.
  3345. * @param array the array to pull values from
  3346. * @param offset the offset into the array to start at
  3347. * @returns the new vector
  3348. */
  3349. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3350. /**
  3351. * Updates the given vector "result" from the starting index of the given array.
  3352. * @param array the array to pull values from
  3353. * @param offset the offset into the array to start at
  3354. * @param result the vector to store the result in
  3355. */
  3356. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3357. /**
  3358. * Updates the given vector "result" from the starting index of the given Float32Array.
  3359. * @param array the array to pull values from
  3360. * @param offset the offset into the array to start at
  3361. * @param result the vector to store the result in
  3362. */
  3363. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3364. /**
  3365. * Updates the given vector "result" coordinates from the given floats.
  3366. * @param x float to set from
  3367. * @param y float to set from
  3368. * @param z float to set from
  3369. * @param w float to set from
  3370. * @param result the vector to the floats in
  3371. */
  3372. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3373. /**
  3374. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3375. * @returns the new vector
  3376. */
  3377. static Zero(): Vector4;
  3378. /**
  3379. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3380. * @returns the new vector
  3381. */
  3382. static One(): Vector4;
  3383. /**
  3384. * Returns a new normalized Vector4 from the given one.
  3385. * @param vector the vector to normalize
  3386. * @returns the vector
  3387. */
  3388. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Updates the given vector "result" from the normalization of the given one.
  3391. * @param vector the vector to normalize
  3392. * @param result the vector to store the result in
  3393. */
  3394. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3395. /**
  3396. * Returns a vector with the minimum values from the left and right vectors
  3397. * @param left left vector to minimize
  3398. * @param right right vector to minimize
  3399. * @returns a new vector with the minimum of the left and right vector values
  3400. */
  3401. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Returns a vector with the maximum values from the left and right vectors
  3404. * @param left left vector to maximize
  3405. * @param right right vector to maximize
  3406. * @returns a new vector with the maximum of the left and right vector values
  3407. */
  3408. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Returns the distance (float) between the vectors "value1" and "value2".
  3411. * @param value1 value to calulate the distance between
  3412. * @param value2 value to calulate the distance between
  3413. * @return the distance between the two vectors
  3414. */
  3415. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3416. /**
  3417. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3418. * @param value1 value to calulate the distance between
  3419. * @param value2 value to calulate the distance between
  3420. * @return the distance between the two vectors squared
  3421. */
  3422. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3423. /**
  3424. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3425. * @param value1 value to calulate the center between
  3426. * @param value2 value to calulate the center between
  3427. * @return the center between the two vectors
  3428. */
  3429. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3430. /**
  3431. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3432. * This methods computes transformed normalized direction vectors only.
  3433. * @param vector the vector to transform
  3434. * @param transformation the transformation matrix to apply
  3435. * @returns the new vector
  3436. */
  3437. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3438. /**
  3439. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3440. * This methods computes transformed normalized direction vectors only.
  3441. * @param vector the vector to transform
  3442. * @param transformation the transformation matrix to apply
  3443. * @param result the vector to store the result in
  3444. */
  3445. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3446. /**
  3447. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3448. * This methods computes transformed normalized direction vectors only.
  3449. * @param x value to transform
  3450. * @param y value to transform
  3451. * @param z value to transform
  3452. * @param w value to transform
  3453. * @param transformation the transformation matrix to apply
  3454. * @param result the vector to store the results in
  3455. */
  3456. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3457. /**
  3458. * Creates a new Vector4 from a Vector3
  3459. * @param source defines the source data
  3460. * @param w defines the 4th component (default is 0)
  3461. * @returns a new Vector4
  3462. */
  3463. static FromVector3(source: Vector3, w?: number): Vector4;
  3464. }
  3465. /**
  3466. * Class used to store quaternion data
  3467. * @see https://en.wikipedia.org/wiki/Quaternion
  3468. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3469. */
  3470. export class Quaternion {
  3471. /** defines the first component (0 by default) */
  3472. x: number;
  3473. /** defines the second component (0 by default) */
  3474. y: number;
  3475. /** defines the third component (0 by default) */
  3476. z: number;
  3477. /** defines the fourth component (1.0 by default) */
  3478. w: number;
  3479. /**
  3480. * Creates a new Quaternion from the given floats
  3481. * @param x defines the first component (0 by default)
  3482. * @param y defines the second component (0 by default)
  3483. * @param z defines the third component (0 by default)
  3484. * @param w defines the fourth component (1.0 by default)
  3485. */
  3486. constructor(
  3487. /** defines the first component (0 by default) */
  3488. x?: number,
  3489. /** defines the second component (0 by default) */
  3490. y?: number,
  3491. /** defines the third component (0 by default) */
  3492. z?: number,
  3493. /** defines the fourth component (1.0 by default) */
  3494. w?: number);
  3495. /**
  3496. * Gets a string representation for the current quaternion
  3497. * @returns a string with the Quaternion coordinates
  3498. */
  3499. toString(): string;
  3500. /**
  3501. * Gets the class name of the quaternion
  3502. * @returns the string "Quaternion"
  3503. */
  3504. getClassName(): string;
  3505. /**
  3506. * Gets a hash code for this quaternion
  3507. * @returns the quaternion hash code
  3508. */
  3509. getHashCode(): number;
  3510. /**
  3511. * Copy the quaternion to an array
  3512. * @returns a new array populated with 4 elements from the quaternion coordinates
  3513. */
  3514. asArray(): number[];
  3515. /**
  3516. * Check if two quaternions are equals
  3517. * @param otherQuaternion defines the second operand
  3518. * @return true if the current quaternion and the given one coordinates are strictly equals
  3519. */
  3520. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3521. /**
  3522. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3523. * @param otherQuaternion defines the other quaternion
  3524. * @param epsilon defines the minimal distance to consider equality
  3525. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3526. */
  3527. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3528. /**
  3529. * Clone the current quaternion
  3530. * @returns a new quaternion copied from the current one
  3531. */
  3532. clone(): Quaternion;
  3533. /**
  3534. * Copy a quaternion to the current one
  3535. * @param other defines the other quaternion
  3536. * @returns the updated current quaternion
  3537. */
  3538. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3539. /**
  3540. * Updates the current quaternion with the given float coordinates
  3541. * @param x defines the x coordinate
  3542. * @param y defines the y coordinate
  3543. * @param z defines the z coordinate
  3544. * @param w defines the w coordinate
  3545. * @returns the updated current quaternion
  3546. */
  3547. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3548. /**
  3549. * Updates the current quaternion from the given float coordinates
  3550. * @param x defines the x coordinate
  3551. * @param y defines the y coordinate
  3552. * @param z defines the z coordinate
  3553. * @param w defines the w coordinate
  3554. * @returns the updated current quaternion
  3555. */
  3556. set(x: number, y: number, z: number, w: number): Quaternion;
  3557. /**
  3558. * Adds two quaternions
  3559. * @param other defines the second operand
  3560. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3561. */
  3562. add(other: DeepImmutable<Quaternion>): Quaternion;
  3563. /**
  3564. * Add a quaternion to the current one
  3565. * @param other defines the quaternion to add
  3566. * @returns the current quaternion
  3567. */
  3568. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3569. /**
  3570. * Subtract two quaternions
  3571. * @param other defines the second operand
  3572. * @returns a new quaternion as the subtraction result of the given one from the current one
  3573. */
  3574. subtract(other: Quaternion): Quaternion;
  3575. /**
  3576. * Multiplies the current quaternion by a scale factor
  3577. * @param value defines the scale factor
  3578. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3579. */
  3580. scale(value: number): Quaternion;
  3581. /**
  3582. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3583. * @param scale defines the scale factor
  3584. * @param result defines the Quaternion object where to store the result
  3585. * @returns the unmodified current quaternion
  3586. */
  3587. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies in place the current quaternion by a scale factor
  3590. * @param value defines the scale factor
  3591. * @returns the current modified quaternion
  3592. */
  3593. scaleInPlace(value: number): Quaternion;
  3594. /**
  3595. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3596. * @param scale defines the scale factor
  3597. * @param result defines the Quaternion object where to store the result
  3598. * @returns the unmodified current quaternion
  3599. */
  3600. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3601. /**
  3602. * Multiplies two quaternions
  3603. * @param q1 defines the second operand
  3604. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3605. */
  3606. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3607. /**
  3608. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3609. * @param q1 defines the second operand
  3610. * @param result defines the target quaternion
  3611. * @returns the current quaternion
  3612. */
  3613. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3614. /**
  3615. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3616. * @param q1 defines the second operand
  3617. * @returns the currentupdated quaternion
  3618. */
  3619. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3620. /**
  3621. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3622. * @param ref defines the target quaternion
  3623. * @returns the current quaternion
  3624. */
  3625. conjugateToRef(ref: Quaternion): Quaternion;
  3626. /**
  3627. * Conjugates in place (1-q) the current quaternion
  3628. * @returns the current updated quaternion
  3629. */
  3630. conjugateInPlace(): Quaternion;
  3631. /**
  3632. * Conjugates in place (1-q) the current quaternion
  3633. * @returns a new quaternion
  3634. */
  3635. conjugate(): Quaternion;
  3636. /**
  3637. * Gets length of current quaternion
  3638. * @returns the quaternion length (float)
  3639. */
  3640. length(): number;
  3641. /**
  3642. * Normalize in place the current quaternion
  3643. * @returns the current updated quaternion
  3644. */
  3645. normalize(): Quaternion;
  3646. /**
  3647. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3648. * @param order is a reserved parameter and is ignore for now
  3649. * @returns a new Vector3 containing the Euler angles
  3650. */
  3651. toEulerAngles(order?: string): Vector3;
  3652. /**
  3653. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3654. * @param result defines the vector which will be filled with the Euler angles
  3655. * @param order is a reserved parameter and is ignore for now
  3656. * @returns the current unchanged quaternion
  3657. */
  3658. toEulerAnglesToRef(result: Vector3): Quaternion;
  3659. /**
  3660. * Updates the given rotation matrix with the current quaternion values
  3661. * @param result defines the target matrix
  3662. * @returns the current unchanged quaternion
  3663. */
  3664. toRotationMatrix(result: Matrix): Quaternion;
  3665. /**
  3666. * Updates the current quaternion from the given rotation matrix values
  3667. * @param matrix defines the source matrix
  3668. * @returns the current updated quaternion
  3669. */
  3670. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3671. /**
  3672. * Creates a new quaternion from a rotation matrix
  3673. * @param matrix defines the source matrix
  3674. * @returns a new quaternion created from the given rotation matrix values
  3675. */
  3676. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3677. /**
  3678. * Updates the given quaternion with the given rotation matrix values
  3679. * @param matrix defines the source matrix
  3680. * @param result defines the target quaternion
  3681. */
  3682. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3683. /**
  3684. * Returns the dot product (float) between the quaternions "left" and "right"
  3685. * @param left defines the left operand
  3686. * @param right defines the right operand
  3687. * @returns the dot product
  3688. */
  3689. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3690. /**
  3691. * Checks if the two quaternions are close to each other
  3692. * @param quat0 defines the first quaternion to check
  3693. * @param quat1 defines the second quaternion to check
  3694. * @returns true if the two quaternions are close to each other
  3695. */
  3696. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3697. /**
  3698. * Creates an empty quaternion
  3699. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3700. */
  3701. static Zero(): Quaternion;
  3702. /**
  3703. * Inverse a given quaternion
  3704. * @param q defines the source quaternion
  3705. * @returns a new quaternion as the inverted current quaternion
  3706. */
  3707. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3708. /**
  3709. * Inverse a given quaternion
  3710. * @param q defines the source quaternion
  3711. * @param result the quaternion the result will be stored in
  3712. * @returns the result quaternion
  3713. */
  3714. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3715. /**
  3716. * Creates an identity quaternion
  3717. * @returns the identity quaternion
  3718. */
  3719. static Identity(): Quaternion;
  3720. /**
  3721. * Gets a boolean indicating if the given quaternion is identity
  3722. * @param quaternion defines the quaternion to check
  3723. * @returns true if the quaternion is identity
  3724. */
  3725. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3726. /**
  3727. * Creates a quaternion from a rotation around an axis
  3728. * @param axis defines the axis to use
  3729. * @param angle defines the angle to use
  3730. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3731. */
  3732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3733. /**
  3734. * Creates a rotation around an axis and stores it into the given quaternion
  3735. * @param axis defines the axis to use
  3736. * @param angle defines the angle to use
  3737. * @param result defines the target quaternion
  3738. * @returns the target quaternion
  3739. */
  3740. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3741. /**
  3742. * Creates a new quaternion from data stored into an array
  3743. * @param array defines the data source
  3744. * @param offset defines the offset in the source array where the data starts
  3745. * @returns a new quaternion
  3746. */
  3747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3748. /**
  3749. * Updates the given quaternion "result" from the starting index of the given array.
  3750. * @param array the array to pull values from
  3751. * @param offset the offset into the array to start at
  3752. * @param result the quaternion to store the result in
  3753. */
  3754. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3755. /**
  3756. * Create a quaternion from Euler rotation angles
  3757. * @param x Pitch
  3758. * @param y Yaw
  3759. * @param z Roll
  3760. * @returns the new Quaternion
  3761. */
  3762. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3763. /**
  3764. * Updates a quaternion from Euler rotation angles
  3765. * @param x Pitch
  3766. * @param y Yaw
  3767. * @param z Roll
  3768. * @param result the quaternion to store the result
  3769. * @returns the updated quaternion
  3770. */
  3771. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Create a quaternion from Euler rotation vector
  3774. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3775. * @returns the new Quaternion
  3776. */
  3777. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3778. /**
  3779. * Updates a quaternion from Euler rotation vector
  3780. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3781. * @param result the quaternion to store the result
  3782. * @returns the updated quaternion
  3783. */
  3784. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3785. /**
  3786. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3787. * @param yaw defines the rotation around Y axis
  3788. * @param pitch defines the rotation around X axis
  3789. * @param roll defines the rotation around Z axis
  3790. * @returns the new quaternion
  3791. */
  3792. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3793. /**
  3794. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3795. * @param yaw defines the rotation around Y axis
  3796. * @param pitch defines the rotation around X axis
  3797. * @param roll defines the rotation around Z axis
  3798. * @param result defines the target quaternion
  3799. */
  3800. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3801. /**
  3802. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3803. * @param alpha defines the rotation around first axis
  3804. * @param beta defines the rotation around second axis
  3805. * @param gamma defines the rotation around third axis
  3806. * @returns the new quaternion
  3807. */
  3808. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3811. * @param alpha defines the rotation around first axis
  3812. * @param beta defines the rotation around second axis
  3813. * @param gamma defines the rotation around third axis
  3814. * @param result defines the target quaternion
  3815. */
  3816. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3817. /**
  3818. * 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)
  3819. * @param axis1 defines the first axis
  3820. * @param axis2 defines the second axis
  3821. * @param axis3 defines the third axis
  3822. * @returns the new quaternion
  3823. */
  3824. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3825. /**
  3826. * 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
  3827. * @param axis1 defines the first axis
  3828. * @param axis2 defines the second axis
  3829. * @param axis3 defines the third axis
  3830. * @param ref defines the target quaternion
  3831. */
  3832. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3833. /**
  3834. * Interpolates between two quaternions
  3835. * @param left defines first quaternion
  3836. * @param right defines second quaternion
  3837. * @param amount defines the gradient to use
  3838. * @returns the new interpolated quaternion
  3839. */
  3840. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3841. /**
  3842. * Interpolates between two quaternions and stores it into a target quaternion
  3843. * @param left defines first quaternion
  3844. * @param right defines second quaternion
  3845. * @param amount defines the gradient to use
  3846. * @param result defines the target quaternion
  3847. */
  3848. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3849. /**
  3850. * Interpolate between two quaternions using Hermite interpolation
  3851. * @param value1 defines first quaternion
  3852. * @param tangent1 defines the incoming tangent
  3853. * @param value2 defines second quaternion
  3854. * @param tangent2 defines the outgoing tangent
  3855. * @param amount defines the target quaternion
  3856. * @returns the new interpolated quaternion
  3857. */
  3858. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3859. }
  3860. /**
  3861. * Class used to store matrix data (4x4)
  3862. */
  3863. export class Matrix {
  3864. private static _updateFlagSeed;
  3865. private static _identityReadOnly;
  3866. private _isIdentity;
  3867. private _isIdentityDirty;
  3868. private _isIdentity3x2;
  3869. private _isIdentity3x2Dirty;
  3870. /**
  3871. * Gets the update flag of the matrix which is an unique number for the matrix.
  3872. * It will be incremented every time the matrix data change.
  3873. * You can use it to speed the comparison between two versions of the same matrix.
  3874. */
  3875. updateFlag: number;
  3876. private readonly _m;
  3877. /**
  3878. * Gets the internal data of the matrix
  3879. */
  3880. get m(): DeepImmutable<Float32Array>;
  3881. /** @hidden */
  3882. _markAsUpdated(): void;
  3883. /** @hidden */
  3884. private _updateIdentityStatus;
  3885. /**
  3886. * Creates an empty matrix (filled with zeros)
  3887. */
  3888. constructor();
  3889. /**
  3890. * Check if the current matrix is identity
  3891. * @returns true is the matrix is the identity matrix
  3892. */
  3893. isIdentity(): boolean;
  3894. /**
  3895. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3896. * @returns true is the matrix is the identity matrix
  3897. */
  3898. isIdentityAs3x2(): boolean;
  3899. /**
  3900. * Gets the determinant of the matrix
  3901. * @returns the matrix determinant
  3902. */
  3903. determinant(): number;
  3904. /**
  3905. * Returns the matrix as a Float32Array
  3906. * @returns the matrix underlying array
  3907. */
  3908. toArray(): DeepImmutable<Float32Array>;
  3909. /**
  3910. * Returns the matrix as a Float32Array
  3911. * @returns the matrix underlying array.
  3912. */
  3913. asArray(): DeepImmutable<Float32Array>;
  3914. /**
  3915. * Inverts the current matrix in place
  3916. * @returns the current inverted matrix
  3917. */
  3918. invert(): Matrix;
  3919. /**
  3920. * Sets all the matrix elements to zero
  3921. * @returns the current matrix
  3922. */
  3923. reset(): Matrix;
  3924. /**
  3925. * Adds the current matrix with a second one
  3926. * @param other defines the matrix to add
  3927. * @returns a new matrix as the addition of the current matrix and the given one
  3928. */
  3929. add(other: DeepImmutable<Matrix>): Matrix;
  3930. /**
  3931. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3932. * @param other defines the matrix to add
  3933. * @param result defines the target matrix
  3934. * @returns the current matrix
  3935. */
  3936. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3937. /**
  3938. * Adds in place the given matrix to the current matrix
  3939. * @param other defines the second operand
  3940. * @returns the current updated matrix
  3941. */
  3942. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3943. /**
  3944. * Sets the given matrix to the current inverted Matrix
  3945. * @param other defines the target matrix
  3946. * @returns the unmodified current matrix
  3947. */
  3948. invertToRef(other: Matrix): Matrix;
  3949. /**
  3950. * add a value at the specified position in the current Matrix
  3951. * @param index the index of the value within the matrix. between 0 and 15.
  3952. * @param value the value to be added
  3953. * @returns the current updated matrix
  3954. */
  3955. addAtIndex(index: number, value: number): Matrix;
  3956. /**
  3957. * mutiply the specified position in the current Matrix by a value
  3958. * @param index the index of the value within the matrix. between 0 and 15.
  3959. * @param value the value to be added
  3960. * @returns the current updated matrix
  3961. */
  3962. multiplyAtIndex(index: number, value: number): Matrix;
  3963. /**
  3964. * Inserts the translation vector (using 3 floats) in the current matrix
  3965. * @param x defines the 1st component of the translation
  3966. * @param y defines the 2nd component of the translation
  3967. * @param z defines the 3rd component of the translation
  3968. * @returns the current updated matrix
  3969. */
  3970. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3971. /**
  3972. * Adds the translation vector (using 3 floats) in the current matrix
  3973. * @param x defines the 1st component of the translation
  3974. * @param y defines the 2nd component of the translation
  3975. * @param z defines the 3rd component of the translation
  3976. * @returns the current updated matrix
  3977. */
  3978. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3979. /**
  3980. * Inserts the translation vector in the current matrix
  3981. * @param vector3 defines the translation to insert
  3982. * @returns the current updated matrix
  3983. */
  3984. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3985. /**
  3986. * Gets the translation value of the current matrix
  3987. * @returns a new Vector3 as the extracted translation from the matrix
  3988. */
  3989. getTranslation(): Vector3;
  3990. /**
  3991. * Fill a Vector3 with the extracted translation from the matrix
  3992. * @param result defines the Vector3 where to store the translation
  3993. * @returns the current matrix
  3994. */
  3995. getTranslationToRef(result: Vector3): Matrix;
  3996. /**
  3997. * Remove rotation and scaling part from the matrix
  3998. * @returns the updated matrix
  3999. */
  4000. removeRotationAndScaling(): Matrix;
  4001. /**
  4002. * Multiply two matrices
  4003. * @param other defines the second operand
  4004. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4005. */
  4006. multiply(other: DeepImmutable<Matrix>): Matrix;
  4007. /**
  4008. * Copy the current matrix from the given one
  4009. * @param other defines the source matrix
  4010. * @returns the current updated matrix
  4011. */
  4012. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4013. /**
  4014. * Populates the given array from the starting index with the current matrix values
  4015. * @param array defines the target array
  4016. * @param offset defines the offset in the target array where to start storing values
  4017. * @returns the current matrix
  4018. */
  4019. copyToArray(array: Float32Array, offset?: number): Matrix;
  4020. /**
  4021. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4022. * @param other defines the second operand
  4023. * @param result defines the matrix where to store the multiplication
  4024. * @returns the current matrix
  4025. */
  4026. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4027. /**
  4028. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4029. * @param other defines the second operand
  4030. * @param result defines the array where to store the multiplication
  4031. * @param offset defines the offset in the target array where to start storing values
  4032. * @returns the current matrix
  4033. */
  4034. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4035. /**
  4036. * Check equality between this matrix and a second one
  4037. * @param value defines the second matrix to compare
  4038. * @returns true is the current matrix and the given one values are strictly equal
  4039. */
  4040. equals(value: DeepImmutable<Matrix>): boolean;
  4041. /**
  4042. * Clone the current matrix
  4043. * @returns a new matrix from the current matrix
  4044. */
  4045. clone(): Matrix;
  4046. /**
  4047. * Returns the name of the current matrix class
  4048. * @returns the string "Matrix"
  4049. */
  4050. getClassName(): string;
  4051. /**
  4052. * Gets the hash code of the current matrix
  4053. * @returns the hash code
  4054. */
  4055. getHashCode(): number;
  4056. /**
  4057. * Decomposes the current Matrix into a translation, rotation and scaling components
  4058. * @param scale defines the scale vector3 given as a reference to update
  4059. * @param rotation defines the rotation quaternion given as a reference to update
  4060. * @param translation defines the translation vector3 given as a reference to update
  4061. * @returns true if operation was successful
  4062. */
  4063. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4064. /**
  4065. * Gets specific row of the matrix
  4066. * @param index defines the number of the row to get
  4067. * @returns the index-th row of the current matrix as a new Vector4
  4068. */
  4069. getRow(index: number): Nullable<Vector4>;
  4070. /**
  4071. * Sets the index-th row of the current matrix to the vector4 values
  4072. * @param index defines the number of the row to set
  4073. * @param row defines the target vector4
  4074. * @returns the updated current matrix
  4075. */
  4076. setRow(index: number, row: Vector4): Matrix;
  4077. /**
  4078. * Compute the transpose of the matrix
  4079. * @returns the new transposed matrix
  4080. */
  4081. transpose(): Matrix;
  4082. /**
  4083. * Compute the transpose of the matrix and store it in a given matrix
  4084. * @param result defines the target matrix
  4085. * @returns the current matrix
  4086. */
  4087. transposeToRef(result: Matrix): Matrix;
  4088. /**
  4089. * Sets the index-th row of the current matrix with the given 4 x float values
  4090. * @param index defines the row index
  4091. * @param x defines the x component to set
  4092. * @param y defines the y component to set
  4093. * @param z defines the z component to set
  4094. * @param w defines the w component to set
  4095. * @returns the updated current matrix
  4096. */
  4097. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4098. /**
  4099. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4100. * @param scale defines the scale factor
  4101. * @returns a new matrix
  4102. */
  4103. scale(scale: number): Matrix;
  4104. /**
  4105. * Scale the current matrix values by a factor to a given result matrix
  4106. * @param scale defines the scale factor
  4107. * @param result defines the matrix to store the result
  4108. * @returns the current matrix
  4109. */
  4110. scaleToRef(scale: number, result: Matrix): Matrix;
  4111. /**
  4112. * Scale the current matrix values by a factor and add the result to a given matrix
  4113. * @param scale defines the scale factor
  4114. * @param result defines the Matrix to store the result
  4115. * @returns the current matrix
  4116. */
  4117. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4118. /**
  4119. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4120. * @param ref matrix to store the result
  4121. */
  4122. toNormalMatrix(ref: Matrix): void;
  4123. /**
  4124. * Gets only rotation part of the current matrix
  4125. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4126. */
  4127. getRotationMatrix(): Matrix;
  4128. /**
  4129. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4130. * @param result defines the target matrix to store data to
  4131. * @returns the current matrix
  4132. */
  4133. getRotationMatrixToRef(result: Matrix): Matrix;
  4134. /**
  4135. * Toggles model matrix from being right handed to left handed in place and vice versa
  4136. */
  4137. toggleModelMatrixHandInPlace(): void;
  4138. /**
  4139. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4140. */
  4141. toggleProjectionMatrixHandInPlace(): void;
  4142. /**
  4143. * Creates a matrix from an array
  4144. * @param array defines the source array
  4145. * @param offset defines an offset in the source array
  4146. * @returns a new Matrix set from the starting index of the given array
  4147. */
  4148. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4149. /**
  4150. * Copy the content of an array into a given matrix
  4151. * @param array defines the source array
  4152. * @param offset defines an offset in the source array
  4153. * @param result defines the target matrix
  4154. */
  4155. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4156. /**
  4157. * Stores an array into a matrix after having multiplied each component by a given factor
  4158. * @param array defines the source array
  4159. * @param offset defines the offset in the source array
  4160. * @param scale defines the scaling factor
  4161. * @param result defines the target matrix
  4162. */
  4163. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4164. /**
  4165. * Gets an identity matrix that must not be updated
  4166. */
  4167. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4168. /**
  4169. * Stores a list of values (16) inside a given matrix
  4170. * @param initialM11 defines 1st value of 1st row
  4171. * @param initialM12 defines 2nd value of 1st row
  4172. * @param initialM13 defines 3rd value of 1st row
  4173. * @param initialM14 defines 4th value of 1st row
  4174. * @param initialM21 defines 1st value of 2nd row
  4175. * @param initialM22 defines 2nd value of 2nd row
  4176. * @param initialM23 defines 3rd value of 2nd row
  4177. * @param initialM24 defines 4th value of 2nd row
  4178. * @param initialM31 defines 1st value of 3rd row
  4179. * @param initialM32 defines 2nd value of 3rd row
  4180. * @param initialM33 defines 3rd value of 3rd row
  4181. * @param initialM34 defines 4th value of 3rd row
  4182. * @param initialM41 defines 1st value of 4th row
  4183. * @param initialM42 defines 2nd value of 4th row
  4184. * @param initialM43 defines 3rd value of 4th row
  4185. * @param initialM44 defines 4th value of 4th row
  4186. * @param result defines the target matrix
  4187. */
  4188. 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;
  4189. /**
  4190. * Creates new matrix from a list of values (16)
  4191. * @param initialM11 defines 1st value of 1st row
  4192. * @param initialM12 defines 2nd value of 1st row
  4193. * @param initialM13 defines 3rd value of 1st row
  4194. * @param initialM14 defines 4th value of 1st row
  4195. * @param initialM21 defines 1st value of 2nd row
  4196. * @param initialM22 defines 2nd value of 2nd row
  4197. * @param initialM23 defines 3rd value of 2nd row
  4198. * @param initialM24 defines 4th value of 2nd row
  4199. * @param initialM31 defines 1st value of 3rd row
  4200. * @param initialM32 defines 2nd value of 3rd row
  4201. * @param initialM33 defines 3rd value of 3rd row
  4202. * @param initialM34 defines 4th value of 3rd row
  4203. * @param initialM41 defines 1st value of 4th row
  4204. * @param initialM42 defines 2nd value of 4th row
  4205. * @param initialM43 defines 3rd value of 4th row
  4206. * @param initialM44 defines 4th value of 4th row
  4207. * @returns the new matrix
  4208. */
  4209. 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;
  4210. /**
  4211. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4212. * @param scale defines the scale vector3
  4213. * @param rotation defines the rotation quaternion
  4214. * @param translation defines the translation vector3
  4215. * @returns a new matrix
  4216. */
  4217. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4218. /**
  4219. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4220. * @param scale defines the scale vector3
  4221. * @param rotation defines the rotation quaternion
  4222. * @param translation defines the translation vector3
  4223. * @param result defines the target matrix
  4224. */
  4225. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4226. /**
  4227. * Creates a new identity matrix
  4228. * @returns a new identity matrix
  4229. */
  4230. static Identity(): Matrix;
  4231. /**
  4232. * Creates a new identity matrix and stores the result in a given matrix
  4233. * @param result defines the target matrix
  4234. */
  4235. static IdentityToRef(result: Matrix): void;
  4236. /**
  4237. * Creates a new zero matrix
  4238. * @returns a new zero matrix
  4239. */
  4240. static Zero(): Matrix;
  4241. /**
  4242. * Creates a new rotation matrix for "angle" radians around the X axis
  4243. * @param angle defines the angle (in radians) to use
  4244. * @return the new matrix
  4245. */
  4246. static RotationX(angle: number): Matrix;
  4247. /**
  4248. * Creates a new matrix as the invert of a given matrix
  4249. * @param source defines the source matrix
  4250. * @returns the new matrix
  4251. */
  4252. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4253. /**
  4254. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4255. * @param angle defines the angle (in radians) to use
  4256. * @param result defines the target matrix
  4257. */
  4258. static RotationXToRef(angle: number, result: Matrix): void;
  4259. /**
  4260. * Creates a new rotation matrix for "angle" radians around the Y axis
  4261. * @param angle defines the angle (in radians) to use
  4262. * @return the new matrix
  4263. */
  4264. static RotationY(angle: number): Matrix;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4267. * @param angle defines the angle (in radians) to use
  4268. * @param result defines the target matrix
  4269. */
  4270. static RotationYToRef(angle: number, result: Matrix): void;
  4271. /**
  4272. * Creates a new rotation matrix for "angle" radians around the Z axis
  4273. * @param angle defines the angle (in radians) to use
  4274. * @return the new matrix
  4275. */
  4276. static RotationZ(angle: number): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4279. * @param angle defines the angle (in radians) to use
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationZToRef(angle: number, result: Matrix): void;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the given axis
  4285. * @param axis defines the axis to use
  4286. * @param angle defines the angle (in radians) to use
  4287. * @return the new matrix
  4288. */
  4289. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4290. /**
  4291. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4292. * @param axis defines the axis to use
  4293. * @param angle defines the angle (in radians) to use
  4294. * @param result defines the target matrix
  4295. */
  4296. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4297. /**
  4298. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4299. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4300. * @param from defines the vector to align
  4301. * @param to defines the vector to align to
  4302. * @param result defines the target matrix
  4303. */
  4304. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4305. /**
  4306. * Creates a rotation matrix
  4307. * @param yaw defines the yaw angle in radians (Y axis)
  4308. * @param pitch defines the pitch angle in radians (X axis)
  4309. * @param roll defines the roll angle in radians (X axis)
  4310. * @returns the new rotation matrix
  4311. */
  4312. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4313. /**
  4314. * Creates a rotation matrix and stores it in a given matrix
  4315. * @param yaw defines the yaw angle in radians (Y axis)
  4316. * @param pitch defines the pitch angle in radians (X axis)
  4317. * @param roll defines the roll angle in radians (X axis)
  4318. * @param result defines the target matrix
  4319. */
  4320. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4321. /**
  4322. * Creates a scaling matrix
  4323. * @param x defines the scale factor on X axis
  4324. * @param y defines the scale factor on Y axis
  4325. * @param z defines the scale factor on Z axis
  4326. * @returns the new matrix
  4327. */
  4328. static Scaling(x: number, y: number, z: number): Matrix;
  4329. /**
  4330. * Creates a scaling matrix and stores it in a given matrix
  4331. * @param x defines the scale factor on X axis
  4332. * @param y defines the scale factor on Y axis
  4333. * @param z defines the scale factor on Z axis
  4334. * @param result defines the target matrix
  4335. */
  4336. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4337. /**
  4338. * Creates a translation matrix
  4339. * @param x defines the translation on X axis
  4340. * @param y defines the translation on Y axis
  4341. * @param z defines the translationon Z axis
  4342. * @returns the new matrix
  4343. */
  4344. static Translation(x: number, y: number, z: number): Matrix;
  4345. /**
  4346. * Creates a translation matrix and stores it in a given matrix
  4347. * @param x defines the translation on X axis
  4348. * @param y defines the translation on Y axis
  4349. * @param z defines the translationon Z axis
  4350. * @param result defines the target matrix
  4351. */
  4352. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4353. /**
  4354. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4355. * @param startValue defines the start value
  4356. * @param endValue defines the end value
  4357. * @param gradient defines the gradient factor
  4358. * @returns the new matrix
  4359. */
  4360. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4361. /**
  4362. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4363. * @param startValue defines the start value
  4364. * @param endValue defines the end value
  4365. * @param gradient defines the gradient factor
  4366. * @param result defines the Matrix object where to store data
  4367. */
  4368. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4369. /**
  4370. * Builds a new matrix whose values are computed by:
  4371. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4372. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4373. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4374. * @param startValue defines the first matrix
  4375. * @param endValue defines the second matrix
  4376. * @param gradient defines the gradient between the two matrices
  4377. * @returns the new matrix
  4378. */
  4379. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4380. /**
  4381. * Update a matrix to values which are computed by:
  4382. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4383. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4384. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4385. * @param startValue defines the first matrix
  4386. * @param endValue defines the second matrix
  4387. * @param gradient defines the gradient between the two matrices
  4388. * @param result defines the target matrix
  4389. */
  4390. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4391. /**
  4392. * 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"
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @returns the new matrix
  4398. */
  4399. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4400. /**
  4401. * 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".
  4402. * This function works in left handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @param result defines the target matrix
  4407. */
  4408. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4409. /**
  4410. * 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"
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @returns the new matrix
  4416. */
  4417. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4418. /**
  4419. * 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".
  4420. * This function works in right handed mode
  4421. * @param eye defines the final position of the entity
  4422. * @param target defines where the entity should look at
  4423. * @param up defines the up vector for the entity
  4424. * @param result defines the target matrix
  4425. */
  4426. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4427. /**
  4428. * Create a left-handed orthographic projection matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @returns a new matrix as a left-handed orthographic projection matrix
  4434. */
  4435. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4436. /**
  4437. * Store a left-handed orthographic projection to a given matrix
  4438. * @param width defines the viewport width
  4439. * @param height defines the viewport height
  4440. * @param znear defines the near clip plane
  4441. * @param zfar defines the far clip plane
  4442. * @param result defines the target matrix
  4443. */
  4444. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4445. /**
  4446. * Create a left-handed orthographic projection matrix
  4447. * @param left defines the viewport left coordinate
  4448. * @param right defines the viewport right coordinate
  4449. * @param bottom defines the viewport bottom coordinate
  4450. * @param top defines the viewport top coordinate
  4451. * @param znear defines the near clip plane
  4452. * @param zfar defines the far clip plane
  4453. * @returns a new matrix as a left-handed orthographic projection matrix
  4454. */
  4455. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4456. /**
  4457. * Stores a left-handed orthographic projection into a given matrix
  4458. * @param left defines the viewport left coordinate
  4459. * @param right defines the viewport right coordinate
  4460. * @param bottom defines the viewport bottom coordinate
  4461. * @param top defines the viewport top coordinate
  4462. * @param znear defines the near clip plane
  4463. * @param zfar defines the far clip plane
  4464. * @param result defines the target matrix
  4465. */
  4466. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4467. /**
  4468. * Creates a right-handed orthographic projection matrix
  4469. * @param left defines the viewport left coordinate
  4470. * @param right defines the viewport right coordinate
  4471. * @param bottom defines the viewport bottom coordinate
  4472. * @param top defines the viewport top coordinate
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @returns a new matrix as a right-handed orthographic projection matrix
  4476. */
  4477. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4478. /**
  4479. * Stores a right-handed orthographic projection into a given matrix
  4480. * @param left defines the viewport left coordinate
  4481. * @param right defines the viewport right coordinate
  4482. * @param bottom defines the viewport bottom coordinate
  4483. * @param top defines the viewport top coordinate
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. */
  4488. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param width defines the viewport width
  4492. * @param height defines the viewport height
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Creates a left-handed perspective projection matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @returns a new matrix as a left-handed perspective projection matrix
  4505. */
  4506. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4507. /**
  4508. * Stores a left-handed perspective projection into a given matrix
  4509. * @param fov defines the horizontal field of view
  4510. * @param aspect defines the aspect ratio
  4511. * @param znear defines the near clip plane
  4512. * @param zfar defines the far clip plane
  4513. * @param result defines the target matrix
  4514. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4515. */
  4516. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4517. /**
  4518. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4519. * @param fov defines the horizontal field of view
  4520. * @param aspect defines the aspect ratio
  4521. * @param znear defines the near clip plane
  4522. * @param zfar not used as infinity is used as far clip
  4523. * @param result defines the target matrix
  4524. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4525. */
  4526. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4527. /**
  4528. * Creates a right-handed perspective projection matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @returns a new matrix as a right-handed perspective projection matrix
  4534. */
  4535. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4536. /**
  4537. * Stores a right-handed perspective projection into a given matrix
  4538. * @param fov defines the horizontal field of view
  4539. * @param aspect defines the aspect ratio
  4540. * @param znear defines the near clip plane
  4541. * @param zfar defines the far clip plane
  4542. * @param result defines the target matrix
  4543. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4544. */
  4545. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4546. /**
  4547. * Stores a right-handed perspective projection into a given matrix
  4548. * @param fov defines the horizontal field of view
  4549. * @param aspect defines the aspect ratio
  4550. * @param znear defines the near clip plane
  4551. * @param zfar not used as infinity is used as far clip
  4552. * @param result defines the target matrix
  4553. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4554. */
  4555. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4556. /**
  4557. * Stores a perspective projection for WebVR info a given matrix
  4558. * @param fov defines the field of view
  4559. * @param znear defines the near clip plane
  4560. * @param zfar defines the far clip plane
  4561. * @param result defines the target matrix
  4562. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4563. */
  4564. static PerspectiveFovWebVRToRef(fov: {
  4565. upDegrees: number;
  4566. downDegrees: number;
  4567. leftDegrees: number;
  4568. rightDegrees: number;
  4569. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4570. /**
  4571. * Computes a complete transformation matrix
  4572. * @param viewport defines the viewport to use
  4573. * @param world defines the world matrix
  4574. * @param view defines the view matrix
  4575. * @param projection defines the projection matrix
  4576. * @param zmin defines the near clip plane
  4577. * @param zmax defines the far clip plane
  4578. * @returns the transformation matrix
  4579. */
  4580. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4581. /**
  4582. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4583. * @param matrix defines the matrix to use
  4584. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4585. */
  4586. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4587. /**
  4588. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4589. * @param matrix defines the matrix to use
  4590. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4591. */
  4592. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4593. /**
  4594. * Compute the transpose of a given matrix
  4595. * @param matrix defines the matrix to transpose
  4596. * @returns the new matrix
  4597. */
  4598. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4599. /**
  4600. * Compute the transpose of a matrix and store it in a target matrix
  4601. * @param matrix defines the matrix to transpose
  4602. * @param result defines the target matrix
  4603. */
  4604. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4605. /**
  4606. * Computes a reflection matrix from a plane
  4607. * @param plane defines the reflection plane
  4608. * @returns a new matrix
  4609. */
  4610. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4611. /**
  4612. * Computes a reflection matrix from a plane
  4613. * @param plane defines the reflection plane
  4614. * @param result defines the target matrix
  4615. */
  4616. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4617. /**
  4618. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4619. * @param xaxis defines the value of the 1st axis
  4620. * @param yaxis defines the value of the 2nd axis
  4621. * @param zaxis defines the value of the 3rd axis
  4622. * @param result defines the target matrix
  4623. */
  4624. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4625. /**
  4626. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4627. * @param quat defines the quaternion to use
  4628. * @param result defines the target matrix
  4629. */
  4630. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4631. }
  4632. /**
  4633. * @hidden
  4634. */
  4635. export class TmpVectors {
  4636. static Vector2: Vector2[];
  4637. static Vector3: Vector3[];
  4638. static Vector4: Vector4[];
  4639. static Quaternion: Quaternion[];
  4640. static Matrix: Matrix[];
  4641. }
  4642. }
  4643. declare module BABYLON {
  4644. /**
  4645. * Defines potential orientation for back face culling
  4646. */
  4647. export enum Orientation {
  4648. /**
  4649. * Clockwise
  4650. */
  4651. CW = 0,
  4652. /** Counter clockwise */
  4653. CCW = 1
  4654. }
  4655. /** Class used to represent a Bezier curve */
  4656. export class BezierCurve {
  4657. /**
  4658. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4659. * @param t defines the time
  4660. * @param x1 defines the left coordinate on X axis
  4661. * @param y1 defines the left coordinate on Y axis
  4662. * @param x2 defines the right coordinate on X axis
  4663. * @param y2 defines the right coordinate on Y axis
  4664. * @returns the interpolated value
  4665. */
  4666. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4667. }
  4668. /**
  4669. * Defines angle representation
  4670. */
  4671. export class Angle {
  4672. private _radians;
  4673. /**
  4674. * Creates an Angle object of "radians" radians (float).
  4675. * @param radians the angle in radians
  4676. */
  4677. constructor(radians: number);
  4678. /**
  4679. * Get value in degrees
  4680. * @returns the Angle value in degrees (float)
  4681. */
  4682. degrees(): number;
  4683. /**
  4684. * Get value in radians
  4685. * @returns the Angle value in radians (float)
  4686. */
  4687. radians(): number;
  4688. /**
  4689. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4690. * @param a defines first vector
  4691. * @param b defines second vector
  4692. * @returns a new Angle
  4693. */
  4694. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4695. /**
  4696. * Gets a new Angle object from the given float in radians
  4697. * @param radians defines the angle value in radians
  4698. * @returns a new Angle
  4699. */
  4700. static FromRadians(radians: number): Angle;
  4701. /**
  4702. * Gets a new Angle object from the given float in degrees
  4703. * @param degrees defines the angle value in degrees
  4704. * @returns a new Angle
  4705. */
  4706. static FromDegrees(degrees: number): Angle;
  4707. }
  4708. /**
  4709. * This represents an arc in a 2d space.
  4710. */
  4711. export class Arc2 {
  4712. /** Defines the start point of the arc */
  4713. startPoint: Vector2;
  4714. /** Defines the mid point of the arc */
  4715. midPoint: Vector2;
  4716. /** Defines the end point of the arc */
  4717. endPoint: Vector2;
  4718. /**
  4719. * Defines the center point of the arc.
  4720. */
  4721. centerPoint: Vector2;
  4722. /**
  4723. * Defines the radius of the arc.
  4724. */
  4725. radius: number;
  4726. /**
  4727. * Defines the angle of the arc (from mid point to end point).
  4728. */
  4729. angle: Angle;
  4730. /**
  4731. * Defines the start angle of the arc (from start point to middle point).
  4732. */
  4733. startAngle: Angle;
  4734. /**
  4735. * Defines the orientation of the arc (clock wise/counter clock wise).
  4736. */
  4737. orientation: Orientation;
  4738. /**
  4739. * Creates an Arc object from the three given points : start, middle and end.
  4740. * @param startPoint Defines the start point of the arc
  4741. * @param midPoint Defines the midlle point of the arc
  4742. * @param endPoint Defines the end point of the arc
  4743. */
  4744. constructor(
  4745. /** Defines the start point of the arc */
  4746. startPoint: Vector2,
  4747. /** Defines the mid point of the arc */
  4748. midPoint: Vector2,
  4749. /** Defines the end point of the arc */
  4750. endPoint: Vector2);
  4751. }
  4752. /**
  4753. * Represents a 2D path made up of multiple 2D points
  4754. */
  4755. export class Path2 {
  4756. private _points;
  4757. private _length;
  4758. /**
  4759. * If the path start and end point are the same
  4760. */
  4761. closed: boolean;
  4762. /**
  4763. * Creates a Path2 object from the starting 2D coordinates x and y.
  4764. * @param x the starting points x value
  4765. * @param y the starting points y value
  4766. */
  4767. constructor(x: number, y: number);
  4768. /**
  4769. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4770. * @param x the added points x value
  4771. * @param y the added points y value
  4772. * @returns the updated Path2.
  4773. */
  4774. addLineTo(x: number, y: number): Path2;
  4775. /**
  4776. * 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.
  4777. * @param midX middle point x value
  4778. * @param midY middle point y value
  4779. * @param endX end point x value
  4780. * @param endY end point y value
  4781. * @param numberOfSegments (default: 36)
  4782. * @returns the updated Path2.
  4783. */
  4784. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4785. /**
  4786. * Closes the Path2.
  4787. * @returns the Path2.
  4788. */
  4789. close(): Path2;
  4790. /**
  4791. * Gets the sum of the distance between each sequential point in the path
  4792. * @returns the Path2 total length (float).
  4793. */
  4794. length(): number;
  4795. /**
  4796. * Gets the points which construct the path
  4797. * @returns the Path2 internal array of points.
  4798. */
  4799. getPoints(): Vector2[];
  4800. /**
  4801. * Retreives the point at the distance aways from the starting point
  4802. * @param normalizedLengthPosition the length along the path to retreive the point from
  4803. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4804. */
  4805. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4806. /**
  4807. * Creates a new path starting from an x and y position
  4808. * @param x starting x value
  4809. * @param y starting y value
  4810. * @returns a new Path2 starting at the coordinates (x, y).
  4811. */
  4812. static StartingAt(x: number, y: number): Path2;
  4813. }
  4814. /**
  4815. * Represents a 3D path made up of multiple 3D points
  4816. */
  4817. export class Path3D {
  4818. /**
  4819. * an array of Vector3, the curve axis of the Path3D
  4820. */
  4821. path: Vector3[];
  4822. private _curve;
  4823. private _distances;
  4824. private _tangents;
  4825. private _normals;
  4826. private _binormals;
  4827. private _raw;
  4828. private _alignTangentsWithPath;
  4829. private readonly _pointAtData;
  4830. /**
  4831. * new Path3D(path, normal, raw)
  4832. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4833. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4834. * @param path an array of Vector3, the curve axis of the Path3D
  4835. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4836. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4837. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4838. */
  4839. constructor(
  4840. /**
  4841. * an array of Vector3, the curve axis of the Path3D
  4842. */
  4843. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4844. /**
  4845. * Returns the Path3D array of successive Vector3 designing its curve.
  4846. * @returns the Path3D array of successive Vector3 designing its curve.
  4847. */
  4848. getCurve(): Vector3[];
  4849. /**
  4850. * Returns the Path3D array of successive Vector3 designing its curve.
  4851. * @returns the Path3D array of successive Vector3 designing its curve.
  4852. */
  4853. getPoints(): Vector3[];
  4854. /**
  4855. * @returns the computed length (float) of the path.
  4856. */
  4857. length(): number;
  4858. /**
  4859. * Returns an array populated with tangent vectors on each Path3D curve point.
  4860. * @returns an array populated with tangent vectors on each Path3D curve point.
  4861. */
  4862. getTangents(): Vector3[];
  4863. /**
  4864. * Returns an array populated with normal vectors on each Path3D curve point.
  4865. * @returns an array populated with normal vectors on each Path3D curve point.
  4866. */
  4867. getNormals(): Vector3[];
  4868. /**
  4869. * Returns an array populated with binormal vectors on each Path3D curve point.
  4870. * @returns an array populated with binormal vectors on each Path3D curve point.
  4871. */
  4872. getBinormals(): Vector3[];
  4873. /**
  4874. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4875. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4876. */
  4877. getDistances(): number[];
  4878. /**
  4879. * Returns an interpolated point along this path
  4880. * @param position the position of the point along this path, from 0.0 to 1.0
  4881. * @returns a new Vector3 as the point
  4882. */
  4883. getPointAt(position: number): Vector3;
  4884. /**
  4885. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4886. * @param position the position of the point along this path, from 0.0 to 1.0
  4887. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4888. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4889. */
  4890. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4891. /**
  4892. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4893. * @param position the position of the point along this path, from 0.0 to 1.0
  4894. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4895. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4896. */
  4897. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4898. /**
  4899. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4900. * @param position the position of the point along this path, from 0.0 to 1.0
  4901. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4902. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4903. */
  4904. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4905. /**
  4906. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4907. * @param position the position of the point along this path, from 0.0 to 1.0
  4908. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4909. */
  4910. getDistanceAt(position: number): number;
  4911. /**
  4912. * Returns the array index of the previous point of an interpolated point along this path
  4913. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4914. * @returns the array index
  4915. */
  4916. getPreviousPointIndexAt(position: number): number;
  4917. /**
  4918. * 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)
  4919. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4920. * @returns the sub position
  4921. */
  4922. getSubPositionAt(position: number): number;
  4923. /**
  4924. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4925. * @param target the vector of which to get the closest position to
  4926. * @returns the position of the closest virtual point on this path to the target vector
  4927. */
  4928. getClosestPositionTo(target: Vector3): number;
  4929. /**
  4930. * Returns a sub path (slice) of this path
  4931. * @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
  4932. * @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
  4933. * @returns a sub path (slice) of this path
  4934. */
  4935. slice(start?: number, end?: number): Path3D;
  4936. /**
  4937. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4938. * @param path path which all values are copied into the curves points
  4939. * @param firstNormal which should be projected onto the curve
  4940. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4941. * @returns the same object updated.
  4942. */
  4943. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4944. private _compute;
  4945. private _getFirstNonNullVector;
  4946. private _getLastNonNullVector;
  4947. private _normalVector;
  4948. /**
  4949. * Updates the point at data for an interpolated point along this curve
  4950. * @param position the position of the point along this curve, from 0.0 to 1.0
  4951. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4952. * @returns the (updated) point at data
  4953. */
  4954. private _updatePointAtData;
  4955. /**
  4956. * Updates the point at data from the specified parameters
  4957. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4958. * @param point the interpolated point
  4959. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4960. */
  4961. private _setPointAtData;
  4962. /**
  4963. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4964. */
  4965. private _updateInterpolationMatrix;
  4966. }
  4967. /**
  4968. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4969. * A Curve3 is designed from a series of successive Vector3.
  4970. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4971. */
  4972. export class Curve3 {
  4973. private _points;
  4974. private _length;
  4975. /**
  4976. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4978. * @param v1 (Vector3) the control point
  4979. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4980. * @param nbPoints (integer) the wanted number of points in the curve
  4981. * @returns the created Curve3
  4982. */
  4983. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4984. /**
  4985. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4986. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4987. * @param v1 (Vector3) the first control point
  4988. * @param v2 (Vector3) the second control point
  4989. * @param v3 (Vector3) the end point of the Cubic Bezier
  4990. * @param nbPoints (integer) the wanted number of points in the curve
  4991. * @returns the created Curve3
  4992. */
  4993. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4994. /**
  4995. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4996. * @param p1 (Vector3) the origin point of the Hermite Spline
  4997. * @param t1 (Vector3) the tangent vector at the origin point
  4998. * @param p2 (Vector3) the end point of the Hermite Spline
  4999. * @param t2 (Vector3) the tangent vector at the end point
  5000. * @param nbPoints (integer) the wanted number of points in the curve
  5001. * @returns the created Curve3
  5002. */
  5003. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5004. /**
  5005. * Returns a Curve3 object along a CatmullRom Spline curve :
  5006. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5007. * @param nbPoints (integer) the wanted number of points between each curve control points
  5008. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5009. * @returns the created Curve3
  5010. */
  5011. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5012. /**
  5013. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5014. * A Curve3 is designed from a series of successive Vector3.
  5015. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5016. * @param points points which make up the curve
  5017. */
  5018. constructor(points: Vector3[]);
  5019. /**
  5020. * @returns the Curve3 stored array of successive Vector3
  5021. */
  5022. getPoints(): Vector3[];
  5023. /**
  5024. * @returns the computed length (float) of the curve.
  5025. */
  5026. length(): number;
  5027. /**
  5028. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5029. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5030. * curveA and curveB keep unchanged.
  5031. * @param curve the curve to continue from this curve
  5032. * @returns the newly constructed curve
  5033. */
  5034. continue(curve: DeepImmutable<Curve3>): Curve3;
  5035. private _computeLength;
  5036. }
  5037. }
  5038. declare module BABYLON {
  5039. /**
  5040. * This represents the main contract an easing function should follow.
  5041. * Easing functions are used throughout the animation system.
  5042. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5043. */
  5044. export interface IEasingFunction {
  5045. /**
  5046. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5047. * of the easing function.
  5048. * The link below provides some of the most common examples of easing functions.
  5049. * @see https://easings.net/
  5050. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5051. * @returns the corresponding value on the curve defined by the easing function
  5052. */
  5053. ease(gradient: number): number;
  5054. }
  5055. /**
  5056. * Base class used for every default easing function.
  5057. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5058. */
  5059. export class EasingFunction implements IEasingFunction {
  5060. /**
  5061. * Interpolation follows the mathematical formula associated with the easing function.
  5062. */
  5063. static readonly EASINGMODE_EASEIN: number;
  5064. /**
  5065. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5066. */
  5067. static readonly EASINGMODE_EASEOUT: number;
  5068. /**
  5069. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5070. */
  5071. static readonly EASINGMODE_EASEINOUT: number;
  5072. private _easingMode;
  5073. /**
  5074. * Sets the easing mode of the current function.
  5075. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5076. */
  5077. setEasingMode(easingMode: number): void;
  5078. /**
  5079. * Gets the current easing mode.
  5080. * @returns the easing mode
  5081. */
  5082. getEasingMode(): number;
  5083. /**
  5084. * @hidden
  5085. */
  5086. easeInCore(gradient: number): number;
  5087. /**
  5088. * Given an input gradient between 0 and 1, this returns the corresponding value
  5089. * of the easing function.
  5090. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5091. * @returns the corresponding value on the curve defined by the easing function
  5092. */
  5093. ease(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a circle shape (see link below).
  5097. * @see https://easings.net/#easeInCirc
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class CircleEase extends EasingFunction implements IEasingFunction {
  5101. /** @hidden */
  5102. easeInCore(gradient: number): number;
  5103. }
  5104. /**
  5105. * Easing function with a ease back shape (see link below).
  5106. * @see https://easings.net/#easeInBack
  5107. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5108. */
  5109. export class BackEase extends EasingFunction implements IEasingFunction {
  5110. /** Defines the amplitude of the function */
  5111. amplitude: number;
  5112. /**
  5113. * Instantiates a back ease easing
  5114. * @see https://easings.net/#easeInBack
  5115. * @param amplitude Defines the amplitude of the function
  5116. */
  5117. constructor(
  5118. /** Defines the amplitude of the function */
  5119. amplitude?: number);
  5120. /** @hidden */
  5121. easeInCore(gradient: number): number;
  5122. }
  5123. /**
  5124. * Easing function with a bouncing shape (see link below).
  5125. * @see https://easings.net/#easeInBounce
  5126. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5127. */
  5128. export class BounceEase extends EasingFunction implements IEasingFunction {
  5129. /** Defines the number of bounces */
  5130. bounces: number;
  5131. /** Defines the amplitude of the bounce */
  5132. bounciness: number;
  5133. /**
  5134. * Instantiates a bounce easing
  5135. * @see https://easings.net/#easeInBounce
  5136. * @param bounces Defines the number of bounces
  5137. * @param bounciness Defines the amplitude of the bounce
  5138. */
  5139. constructor(
  5140. /** Defines the number of bounces */
  5141. bounces?: number,
  5142. /** Defines the amplitude of the bounce */
  5143. bounciness?: number);
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with a power of 3 shape (see link below).
  5149. * @see https://easings.net/#easeInCubic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class CubicEase extends EasingFunction implements IEasingFunction {
  5153. /** @hidden */
  5154. easeInCore(gradient: number): number;
  5155. }
  5156. /**
  5157. * Easing function with an elastic shape (see link below).
  5158. * @see https://easings.net/#easeInElastic
  5159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5160. */
  5161. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5162. /** Defines the number of oscillations*/
  5163. oscillations: number;
  5164. /** Defines the amplitude of the oscillations*/
  5165. springiness: number;
  5166. /**
  5167. * Instantiates an elastic easing function
  5168. * @see https://easings.net/#easeInElastic
  5169. * @param oscillations Defines the number of oscillations
  5170. * @param springiness Defines the amplitude of the oscillations
  5171. */
  5172. constructor(
  5173. /** Defines the number of oscillations*/
  5174. oscillations?: number,
  5175. /** Defines the amplitude of the oscillations*/
  5176. springiness?: number);
  5177. /** @hidden */
  5178. easeInCore(gradient: number): number;
  5179. }
  5180. /**
  5181. * Easing function with an exponential shape (see link below).
  5182. * @see https://easings.net/#easeInExpo
  5183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5184. */
  5185. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5186. /** Defines the exponent of the function */
  5187. exponent: number;
  5188. /**
  5189. * Instantiates an exponential easing function
  5190. * @see https://easings.net/#easeInExpo
  5191. * @param exponent Defines the exponent of the function
  5192. */
  5193. constructor(
  5194. /** Defines the exponent of the function */
  5195. exponent?: number);
  5196. /** @hidden */
  5197. easeInCore(gradient: number): number;
  5198. }
  5199. /**
  5200. * Easing function with a power shape (see link below).
  5201. * @see https://easings.net/#easeInQuad
  5202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5203. */
  5204. export class PowerEase extends EasingFunction implements IEasingFunction {
  5205. /** Defines the power of the function */
  5206. power: number;
  5207. /**
  5208. * Instantiates an power base easing function
  5209. * @see https://easings.net/#easeInQuad
  5210. * @param power Defines the power of the function
  5211. */
  5212. constructor(
  5213. /** Defines the power of the function */
  5214. power?: number);
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 2 shape (see link below).
  5220. * @see https://easings.net/#easeInQuad
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 4 shape (see link below).
  5229. * @see https://easings.net/#easeInQuart
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a power of 5 shape (see link below).
  5238. * @see https://easings.net/#easeInQuint
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a sin shape (see link below).
  5247. * @see https://easings.net/#easeInSine
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class SineEase extends EasingFunction implements IEasingFunction {
  5251. /** @hidden */
  5252. easeInCore(gradient: number): number;
  5253. }
  5254. /**
  5255. * Easing function with a bezier shape (see link below).
  5256. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5258. */
  5259. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5260. /** Defines the x component of the start tangent in the bezier curve */
  5261. x1: number;
  5262. /** Defines the y component of the start tangent in the bezier curve */
  5263. y1: number;
  5264. /** Defines the x component of the end tangent in the bezier curve */
  5265. x2: number;
  5266. /** Defines the y component of the end tangent in the bezier curve */
  5267. y2: number;
  5268. /**
  5269. * Instantiates a bezier function
  5270. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5271. * @param x1 Defines the x component of the start tangent in the bezier curve
  5272. * @param y1 Defines the y component of the start tangent in the bezier curve
  5273. * @param x2 Defines the x component of the end tangent in the bezier curve
  5274. * @param y2 Defines the y component of the end tangent in the bezier curve
  5275. */
  5276. constructor(
  5277. /** Defines the x component of the start tangent in the bezier curve */
  5278. x1?: number,
  5279. /** Defines the y component of the start tangent in the bezier curve */
  5280. y1?: number,
  5281. /** Defines the x component of the end tangent in the bezier curve */
  5282. x2?: number,
  5283. /** Defines the y component of the end tangent in the bezier curve */
  5284. y2?: number);
  5285. /** @hidden */
  5286. easeInCore(gradient: number): number;
  5287. }
  5288. }
  5289. declare module BABYLON {
  5290. /**
  5291. * Class used to hold a RBG color
  5292. */
  5293. export class Color3 {
  5294. /**
  5295. * Defines the red component (between 0 and 1, default is 0)
  5296. */
  5297. r: number;
  5298. /**
  5299. * Defines the green component (between 0 and 1, default is 0)
  5300. */
  5301. g: number;
  5302. /**
  5303. * Defines the blue component (between 0 and 1, default is 0)
  5304. */
  5305. b: number;
  5306. /**
  5307. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5308. * @param r defines the red component (between 0 and 1, default is 0)
  5309. * @param g defines the green component (between 0 and 1, default is 0)
  5310. * @param b defines the blue component (between 0 and 1, default is 0)
  5311. */
  5312. constructor(
  5313. /**
  5314. * Defines the red component (between 0 and 1, default is 0)
  5315. */
  5316. r?: number,
  5317. /**
  5318. * Defines the green component (between 0 and 1, default is 0)
  5319. */
  5320. g?: number,
  5321. /**
  5322. * Defines the blue component (between 0 and 1, default is 0)
  5323. */
  5324. b?: number);
  5325. /**
  5326. * Creates a string with the Color3 current values
  5327. * @returns the string representation of the Color3 object
  5328. */
  5329. toString(): string;
  5330. /**
  5331. * Returns the string "Color3"
  5332. * @returns "Color3"
  5333. */
  5334. getClassName(): string;
  5335. /**
  5336. * Compute the Color3 hash code
  5337. * @returns an unique number that can be used to hash Color3 objects
  5338. */
  5339. getHashCode(): number;
  5340. /**
  5341. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5342. * @param array defines the array where to store the r,g,b components
  5343. * @param index defines an optional index in the target array to define where to start storing values
  5344. * @returns the current Color3 object
  5345. */
  5346. toArray(array: FloatArray, index?: number): Color3;
  5347. /**
  5348. * Returns a new Color4 object from the current Color3 and the given alpha
  5349. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5350. * @returns a new Color4 object
  5351. */
  5352. toColor4(alpha?: number): Color4;
  5353. /**
  5354. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5355. * @returns the new array
  5356. */
  5357. asArray(): number[];
  5358. /**
  5359. * Returns the luminance value
  5360. * @returns a float value
  5361. */
  5362. toLuminance(): number;
  5363. /**
  5364. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5365. * @param otherColor defines the second operand
  5366. * @returns the new Color3 object
  5367. */
  5368. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5369. /**
  5370. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5371. * @param otherColor defines the second operand
  5372. * @param result defines the Color3 object where to store the result
  5373. * @returns the current Color3
  5374. */
  5375. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5376. /**
  5377. * Determines equality between Color3 objects
  5378. * @param otherColor defines the second operand
  5379. * @returns true if the rgb values are equal to the given ones
  5380. */
  5381. equals(otherColor: DeepImmutable<Color3>): boolean;
  5382. /**
  5383. * Determines equality between the current Color3 object and a set of r,b,g values
  5384. * @param r defines the red component to check
  5385. * @param g defines the green component to check
  5386. * @param b defines the blue component to check
  5387. * @returns true if the rgb values are equal to the given ones
  5388. */
  5389. equalsFloats(r: number, g: number, b: number): boolean;
  5390. /**
  5391. * Multiplies in place each rgb value by scale
  5392. * @param scale defines the scaling factor
  5393. * @returns the updated Color3
  5394. */
  5395. scale(scale: number): Color3;
  5396. /**
  5397. * Multiplies the rgb values by scale and stores the result into "result"
  5398. * @param scale defines the scaling factor
  5399. * @param result defines the Color3 object where to store the result
  5400. * @returns the unmodified current Color3
  5401. */
  5402. scaleToRef(scale: number, result: Color3): Color3;
  5403. /**
  5404. * Scale the current Color3 values by a factor and add the result to a given Color3
  5405. * @param scale defines the scale factor
  5406. * @param result defines color to store the result into
  5407. * @returns the unmodified current Color3
  5408. */
  5409. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5410. /**
  5411. * Clamps the rgb values by the min and max values and stores the result into "result"
  5412. * @param min defines minimum clamping value (default is 0)
  5413. * @param max defines maximum clamping value (default is 1)
  5414. * @param result defines color to store the result into
  5415. * @returns the original Color3
  5416. */
  5417. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5418. /**
  5419. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5420. * @param otherColor defines the second operand
  5421. * @returns the new Color3
  5422. */
  5423. add(otherColor: DeepImmutable<Color3>): Color3;
  5424. /**
  5425. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5426. * @param otherColor defines the second operand
  5427. * @param result defines Color3 object to store the result into
  5428. * @returns the unmodified current Color3
  5429. */
  5430. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5431. /**
  5432. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5433. * @param otherColor defines the second operand
  5434. * @returns the new Color3
  5435. */
  5436. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5437. /**
  5438. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5439. * @param otherColor defines the second operand
  5440. * @param result defines Color3 object to store the result into
  5441. * @returns the unmodified current Color3
  5442. */
  5443. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5444. /**
  5445. * Copy the current object
  5446. * @returns a new Color3 copied the current one
  5447. */
  5448. clone(): Color3;
  5449. /**
  5450. * Copies the rgb values from the source in the current Color3
  5451. * @param source defines the source Color3 object
  5452. * @returns the updated Color3 object
  5453. */
  5454. copyFrom(source: DeepImmutable<Color3>): Color3;
  5455. /**
  5456. * Updates the Color3 rgb values from the given floats
  5457. * @param r defines the red component to read from
  5458. * @param g defines the green component to read from
  5459. * @param b defines the blue component to read from
  5460. * @returns the current Color3 object
  5461. */
  5462. copyFromFloats(r: number, g: number, b: number): Color3;
  5463. /**
  5464. * Updates the Color3 rgb values from the given floats
  5465. * @param r defines the red component to read from
  5466. * @param g defines the green component to read from
  5467. * @param b defines the blue component to read from
  5468. * @returns the current Color3 object
  5469. */
  5470. set(r: number, g: number, b: number): Color3;
  5471. /**
  5472. * Compute the Color3 hexadecimal code as a string
  5473. * @returns a string containing the hexadecimal representation of the Color3 object
  5474. */
  5475. toHexString(): string;
  5476. /**
  5477. * Computes a new Color3 converted from the current one to linear space
  5478. * @returns a new Color3 object
  5479. */
  5480. toLinearSpace(): Color3;
  5481. /**
  5482. * Converts current color in rgb space to HSV values
  5483. * @returns a new color3 representing the HSV values
  5484. */
  5485. toHSV(): Color3;
  5486. /**
  5487. * Converts current color in rgb space to HSV values
  5488. * @param result defines the Color3 where to store the HSV values
  5489. */
  5490. toHSVToRef(result: Color3): void;
  5491. /**
  5492. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5493. * @param convertedColor defines the Color3 object where to store the linear space version
  5494. * @returns the unmodified Color3
  5495. */
  5496. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5497. /**
  5498. * Computes a new Color3 converted from the current one to gamma space
  5499. * @returns a new Color3 object
  5500. */
  5501. toGammaSpace(): Color3;
  5502. /**
  5503. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5504. * @param convertedColor defines the Color3 object where to store the gamma space version
  5505. * @returns the unmodified Color3
  5506. */
  5507. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5508. private static _BlackReadOnly;
  5509. /**
  5510. * Convert Hue, saturation and value to a Color3 (RGB)
  5511. * @param hue defines the hue
  5512. * @param saturation defines the saturation
  5513. * @param value defines the value
  5514. * @param result defines the Color3 where to store the RGB values
  5515. */
  5516. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5517. /**
  5518. * Creates a new Color3 from the string containing valid hexadecimal values
  5519. * @param hex defines a string containing valid hexadecimal values
  5520. * @returns a new Color3 object
  5521. */
  5522. static FromHexString(hex: string): Color3;
  5523. /**
  5524. * Creates a new Color3 from the starting index of the given array
  5525. * @param array defines the source array
  5526. * @param offset defines an offset in the source array
  5527. * @returns a new Color3 object
  5528. */
  5529. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5530. /**
  5531. * Creates a new Color3 from integer values (< 256)
  5532. * @param r defines the red component to read from (value between 0 and 255)
  5533. * @param g defines the green component to read from (value between 0 and 255)
  5534. * @param b defines the blue component to read from (value between 0 and 255)
  5535. * @returns a new Color3 object
  5536. */
  5537. static FromInts(r: number, g: number, b: number): Color3;
  5538. /**
  5539. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5540. * @param start defines the start Color3 value
  5541. * @param end defines the end Color3 value
  5542. * @param amount defines the gradient value between start and end
  5543. * @returns a new Color3 object
  5544. */
  5545. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5546. /**
  5547. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5548. * @param left defines the start value
  5549. * @param right defines the end value
  5550. * @param amount defines the gradient factor
  5551. * @param result defines the Color3 object where to store the result
  5552. */
  5553. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5554. /**
  5555. * Returns a Color3 value containing a red color
  5556. * @returns a new Color3 object
  5557. */
  5558. static Red(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a green color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Green(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a blue color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Blue(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a black color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Black(): Color3;
  5574. /**
  5575. * Gets a Color3 value containing a black color that must not be updated
  5576. */
  5577. static get BlackReadOnly(): DeepImmutable<Color3>;
  5578. /**
  5579. * Returns a Color3 value containing a white color
  5580. * @returns a new Color3 object
  5581. */
  5582. static White(): Color3;
  5583. /**
  5584. * Returns a Color3 value containing a purple color
  5585. * @returns a new Color3 object
  5586. */
  5587. static Purple(): Color3;
  5588. /**
  5589. * Returns a Color3 value containing a magenta color
  5590. * @returns a new Color3 object
  5591. */
  5592. static Magenta(): Color3;
  5593. /**
  5594. * Returns a Color3 value containing a yellow color
  5595. * @returns a new Color3 object
  5596. */
  5597. static Yellow(): Color3;
  5598. /**
  5599. * Returns a Color3 value containing a gray color
  5600. * @returns a new Color3 object
  5601. */
  5602. static Gray(): Color3;
  5603. /**
  5604. * Returns a Color3 value containing a teal color
  5605. * @returns a new Color3 object
  5606. */
  5607. static Teal(): Color3;
  5608. /**
  5609. * Returns a Color3 value containing a random color
  5610. * @returns a new Color3 object
  5611. */
  5612. static Random(): Color3;
  5613. }
  5614. /**
  5615. * Class used to hold a RBGA color
  5616. */
  5617. export class Color4 {
  5618. /**
  5619. * Defines the red component (between 0 and 1, default is 0)
  5620. */
  5621. r: number;
  5622. /**
  5623. * Defines the green component (between 0 and 1, default is 0)
  5624. */
  5625. g: number;
  5626. /**
  5627. * Defines the blue component (between 0 and 1, default is 0)
  5628. */
  5629. b: number;
  5630. /**
  5631. * Defines the alpha component (between 0 and 1, default is 1)
  5632. */
  5633. a: number;
  5634. /**
  5635. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5636. * @param r defines the red component (between 0 and 1, default is 0)
  5637. * @param g defines the green component (between 0 and 1, default is 0)
  5638. * @param b defines the blue component (between 0 and 1, default is 0)
  5639. * @param a defines the alpha component (between 0 and 1, default is 1)
  5640. */
  5641. constructor(
  5642. /**
  5643. * Defines the red component (between 0 and 1, default is 0)
  5644. */
  5645. r?: number,
  5646. /**
  5647. * Defines the green component (between 0 and 1, default is 0)
  5648. */
  5649. g?: number,
  5650. /**
  5651. * Defines the blue component (between 0 and 1, default is 0)
  5652. */
  5653. b?: number,
  5654. /**
  5655. * Defines the alpha component (between 0 and 1, default is 1)
  5656. */
  5657. a?: number);
  5658. /**
  5659. * Adds in place the given Color4 values to the current Color4 object
  5660. * @param right defines the second operand
  5661. * @returns the current updated Color4 object
  5662. */
  5663. addInPlace(right: DeepImmutable<Color4>): Color4;
  5664. /**
  5665. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5666. * @returns the new array
  5667. */
  5668. asArray(): number[];
  5669. /**
  5670. * Stores from the starting index in the given array the Color4 successive values
  5671. * @param array defines the array where to store the r,g,b components
  5672. * @param index defines an optional index in the target array to define where to start storing values
  5673. * @returns the current Color4 object
  5674. */
  5675. toArray(array: number[], index?: number): Color4;
  5676. /**
  5677. * Determines equality between Color4 objects
  5678. * @param otherColor defines the second operand
  5679. * @returns true if the rgba values are equal to the given ones
  5680. */
  5681. equals(otherColor: DeepImmutable<Color4>): boolean;
  5682. /**
  5683. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5684. * @param right defines the second operand
  5685. * @returns a new Color4 object
  5686. */
  5687. add(right: DeepImmutable<Color4>): Color4;
  5688. /**
  5689. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5690. * @param right defines the second operand
  5691. * @returns a new Color4 object
  5692. */
  5693. subtract(right: DeepImmutable<Color4>): Color4;
  5694. /**
  5695. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5696. * @param right defines the second operand
  5697. * @param result defines the Color4 object where to store the result
  5698. * @returns the current Color4 object
  5699. */
  5700. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5701. /**
  5702. * Creates a new Color4 with the current Color4 values multiplied by scale
  5703. * @param scale defines the scaling factor to apply
  5704. * @returns a new Color4 object
  5705. */
  5706. scale(scale: number): Color4;
  5707. /**
  5708. * Multiplies the current Color4 values by scale and stores the result in "result"
  5709. * @param scale defines the scaling factor to apply
  5710. * @param result defines the Color4 object where to store the result
  5711. * @returns the current unmodified Color4
  5712. */
  5713. scaleToRef(scale: number, result: Color4): Color4;
  5714. /**
  5715. * Scale the current Color4 values by a factor and add the result to a given Color4
  5716. * @param scale defines the scale factor
  5717. * @param result defines the Color4 object where to store the result
  5718. * @returns the unmodified current Color4
  5719. */
  5720. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5721. /**
  5722. * Clamps the rgb values by the min and max values and stores the result into "result"
  5723. * @param min defines minimum clamping value (default is 0)
  5724. * @param max defines maximum clamping value (default is 1)
  5725. * @param result defines color to store the result into.
  5726. * @returns the cuurent Color4
  5727. */
  5728. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5729. /**
  5730. * Multipy an Color4 value by another and return a new Color4 object
  5731. * @param color defines the Color4 value to multiply by
  5732. * @returns a new Color4 object
  5733. */
  5734. multiply(color: Color4): Color4;
  5735. /**
  5736. * Multipy a Color4 value by another and push the result in a reference value
  5737. * @param color defines the Color4 value to multiply by
  5738. * @param result defines the Color4 to fill the result in
  5739. * @returns the result Color4
  5740. */
  5741. multiplyToRef(color: Color4, result: Color4): Color4;
  5742. /**
  5743. * Creates a string with the Color4 current values
  5744. * @returns the string representation of the Color4 object
  5745. */
  5746. toString(): string;
  5747. /**
  5748. * Returns the string "Color4"
  5749. * @returns "Color4"
  5750. */
  5751. getClassName(): string;
  5752. /**
  5753. * Compute the Color4 hash code
  5754. * @returns an unique number that can be used to hash Color4 objects
  5755. */
  5756. getHashCode(): number;
  5757. /**
  5758. * Creates a new Color4 copied from the current one
  5759. * @returns a new Color4 object
  5760. */
  5761. clone(): Color4;
  5762. /**
  5763. * Copies the given Color4 values into the current one
  5764. * @param source defines the source Color4 object
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFrom(source: Color4): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Copies the given float values into the current one
  5779. * @param r defines the red component to read from
  5780. * @param g defines the green component to read from
  5781. * @param b defines the blue component to read from
  5782. * @param a defines the alpha component to read from
  5783. * @returns the current updated Color4 object
  5784. */
  5785. set(r: number, g: number, b: number, a: number): Color4;
  5786. /**
  5787. * Compute the Color4 hexadecimal code as a string
  5788. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5789. * @returns a string containing the hexadecimal representation of the Color4 object
  5790. */
  5791. toHexString(returnAsColor3?: boolean): string;
  5792. /**
  5793. * Computes a new Color4 converted from the current one to linear space
  5794. * @returns a new Color4 object
  5795. */
  5796. toLinearSpace(): Color4;
  5797. /**
  5798. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5799. * @param convertedColor defines the Color4 object where to store the linear space version
  5800. * @returns the unmodified Color4
  5801. */
  5802. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5803. /**
  5804. * Computes a new Color4 converted from the current one to gamma space
  5805. * @returns a new Color4 object
  5806. */
  5807. toGammaSpace(): Color4;
  5808. /**
  5809. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5810. * @param convertedColor defines the Color4 object where to store the gamma space version
  5811. * @returns the unmodified Color4
  5812. */
  5813. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5814. /**
  5815. * Creates a new Color4 from the string containing valid hexadecimal values
  5816. * @param hex defines a string containing valid hexadecimal values
  5817. * @returns a new Color4 object
  5818. */
  5819. static FromHexString(hex: string): Color4;
  5820. /**
  5821. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5822. * @param left defines the start value
  5823. * @param right defines the end value
  5824. * @param amount defines the gradient factor
  5825. * @returns a new Color4 object
  5826. */
  5827. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5828. /**
  5829. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5830. * @param left defines the start value
  5831. * @param right defines the end value
  5832. * @param amount defines the gradient factor
  5833. * @param result defines the Color4 object where to store data
  5834. */
  5835. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5836. /**
  5837. * Creates a new Color4 from a Color3 and an alpha value
  5838. * @param color3 defines the source Color3 to read from
  5839. * @param alpha defines the alpha component (1.0 by default)
  5840. * @returns a new Color4 object
  5841. */
  5842. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5843. /**
  5844. * Creates a new Color4 from the starting index element of the given array
  5845. * @param array defines the source array to read from
  5846. * @param offset defines the offset in the source array
  5847. * @returns a new Color4 object
  5848. */
  5849. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5850. /**
  5851. * Creates a new Color3 from integer values (< 256)
  5852. * @param r defines the red component to read from (value between 0 and 255)
  5853. * @param g defines the green component to read from (value between 0 and 255)
  5854. * @param b defines the blue component to read from (value between 0 and 255)
  5855. * @param a defines the alpha component to read from (value between 0 and 255)
  5856. * @returns a new Color3 object
  5857. */
  5858. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5859. /**
  5860. * Check the content of a given array and convert it to an array containing RGBA data
  5861. * If the original array was already containing count * 4 values then it is returned directly
  5862. * @param colors defines the array to check
  5863. * @param count defines the number of RGBA data to expect
  5864. * @returns an array containing count * 4 values (RGBA)
  5865. */
  5866. static CheckColors4(colors: number[], count: number): number[];
  5867. }
  5868. /**
  5869. * @hidden
  5870. */
  5871. export class TmpColors {
  5872. static Color3: Color3[];
  5873. static Color4: Color4[];
  5874. }
  5875. }
  5876. declare module BABYLON {
  5877. /**
  5878. * Defines an interface which represents an animation key frame
  5879. */
  5880. export interface IAnimationKey {
  5881. /**
  5882. * Frame of the key frame
  5883. */
  5884. frame: number;
  5885. /**
  5886. * Value at the specifies key frame
  5887. */
  5888. value: any;
  5889. /**
  5890. * The input tangent for the cubic hermite spline
  5891. */
  5892. inTangent?: any;
  5893. /**
  5894. * The output tangent for the cubic hermite spline
  5895. */
  5896. outTangent?: any;
  5897. /**
  5898. * The animation interpolation type
  5899. */
  5900. interpolation?: AnimationKeyInterpolation;
  5901. }
  5902. /**
  5903. * Enum for the animation key frame interpolation type
  5904. */
  5905. export enum AnimationKeyInterpolation {
  5906. /**
  5907. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5908. */
  5909. STEP = 1
  5910. }
  5911. }
  5912. declare module BABYLON {
  5913. /**
  5914. * Represents the range of an animation
  5915. */
  5916. export class AnimationRange {
  5917. /**The name of the animation range**/
  5918. name: string;
  5919. /**The starting frame of the animation */
  5920. from: number;
  5921. /**The ending frame of the animation*/
  5922. to: number;
  5923. /**
  5924. * Initializes the range of an animation
  5925. * @param name The name of the animation range
  5926. * @param from The starting frame of the animation
  5927. * @param to The ending frame of the animation
  5928. */
  5929. constructor(
  5930. /**The name of the animation range**/
  5931. name: string,
  5932. /**The starting frame of the animation */
  5933. from: number,
  5934. /**The ending frame of the animation*/
  5935. to: number);
  5936. /**
  5937. * Makes a copy of the animation range
  5938. * @returns A copy of the animation range
  5939. */
  5940. clone(): AnimationRange;
  5941. }
  5942. }
  5943. declare module BABYLON {
  5944. /**
  5945. * Composed of a frame, and an action function
  5946. */
  5947. export class AnimationEvent {
  5948. /** The frame for which the event is triggered **/
  5949. frame: number;
  5950. /** The event to perform when triggered **/
  5951. action: (currentFrame: number) => void;
  5952. /** Specifies if the event should be triggered only once**/
  5953. onlyOnce?: boolean | undefined;
  5954. /**
  5955. * Specifies if the animation event is done
  5956. */
  5957. isDone: boolean;
  5958. /**
  5959. * Initializes the animation event
  5960. * @param frame The frame for which the event is triggered
  5961. * @param action The event to perform when triggered
  5962. * @param onlyOnce Specifies if the event should be triggered only once
  5963. */
  5964. constructor(
  5965. /** The frame for which the event is triggered **/
  5966. frame: number,
  5967. /** The event to perform when triggered **/
  5968. action: (currentFrame: number) => void,
  5969. /** Specifies if the event should be triggered only once**/
  5970. onlyOnce?: boolean | undefined);
  5971. /** @hidden */
  5972. _clone(): AnimationEvent;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * Interface used to define a behavior
  5978. */
  5979. export interface Behavior<T> {
  5980. /** gets or sets behavior's name */
  5981. name: string;
  5982. /**
  5983. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5984. */
  5985. init(): void;
  5986. /**
  5987. * Called when the behavior is attached to a target
  5988. * @param target defines the target where the behavior is attached to
  5989. */
  5990. attach(target: T): void;
  5991. /**
  5992. * Called when the behavior is detached from its target
  5993. */
  5994. detach(): void;
  5995. }
  5996. /**
  5997. * Interface implemented by classes supporting behaviors
  5998. */
  5999. export interface IBehaviorAware<T> {
  6000. /**
  6001. * Attach a behavior
  6002. * @param behavior defines the behavior to attach
  6003. * @returns the current host
  6004. */
  6005. addBehavior(behavior: Behavior<T>): T;
  6006. /**
  6007. * Remove a behavior from the current object
  6008. * @param behavior defines the behavior to detach
  6009. * @returns the current host
  6010. */
  6011. removeBehavior(behavior: Behavior<T>): T;
  6012. /**
  6013. * Gets a behavior using its name to search
  6014. * @param name defines the name to search
  6015. * @returns the behavior or null if not found
  6016. */
  6017. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6018. }
  6019. }
  6020. declare module BABYLON {
  6021. /**
  6022. * Defines an array and its length.
  6023. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6024. */
  6025. export interface ISmartArrayLike<T> {
  6026. /**
  6027. * The data of the array.
  6028. */
  6029. data: Array<T>;
  6030. /**
  6031. * The active length of the array.
  6032. */
  6033. length: number;
  6034. }
  6035. /**
  6036. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6037. */
  6038. export class SmartArray<T> implements ISmartArrayLike<T> {
  6039. /**
  6040. * The full set of data from the array.
  6041. */
  6042. data: Array<T>;
  6043. /**
  6044. * The active length of the array.
  6045. */
  6046. length: number;
  6047. protected _id: number;
  6048. /**
  6049. * Instantiates a Smart Array.
  6050. * @param capacity defines the default capacity of the array.
  6051. */
  6052. constructor(capacity: number);
  6053. /**
  6054. * Pushes a value at the end of the active data.
  6055. * @param value defines the object to push in the array.
  6056. */
  6057. push(value: T): void;
  6058. /**
  6059. * Iterates over the active data and apply the lambda to them.
  6060. * @param func defines the action to apply on each value.
  6061. */
  6062. forEach(func: (content: T) => void): void;
  6063. /**
  6064. * Sorts the full sets of data.
  6065. * @param compareFn defines the comparison function to apply.
  6066. */
  6067. sort(compareFn: (a: T, b: T) => number): void;
  6068. /**
  6069. * Resets the active data to an empty array.
  6070. */
  6071. reset(): void;
  6072. /**
  6073. * Releases all the data from the array as well as the array.
  6074. */
  6075. dispose(): void;
  6076. /**
  6077. * Concats the active data with a given array.
  6078. * @param array defines the data to concatenate with.
  6079. */
  6080. concat(array: any): void;
  6081. /**
  6082. * Returns the position of a value in the active data.
  6083. * @param value defines the value to find the index for
  6084. * @returns the index if found in the active data otherwise -1
  6085. */
  6086. indexOf(value: T): number;
  6087. /**
  6088. * Returns whether an element is part of the active data.
  6089. * @param value defines the value to look for
  6090. * @returns true if found in the active data otherwise false
  6091. */
  6092. contains(value: T): boolean;
  6093. private static _GlobalId;
  6094. }
  6095. /**
  6096. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6097. * The data in this array can only be present once
  6098. */
  6099. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6100. private _duplicateId;
  6101. /**
  6102. * Pushes a value at the end of the active data.
  6103. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6104. * @param value defines the object to push in the array.
  6105. */
  6106. push(value: T): void;
  6107. /**
  6108. * Pushes a value at the end of the active data.
  6109. * If the data is already present, it won t be added again
  6110. * @param value defines the object to push in the array.
  6111. * @returns true if added false if it was already present
  6112. */
  6113. pushNoDuplicate(value: T): boolean;
  6114. /**
  6115. * Resets the active data to an empty array.
  6116. */
  6117. reset(): void;
  6118. /**
  6119. * Concats the active data with a given array.
  6120. * This ensures no dupplicate will be present in the result.
  6121. * @param array defines the data to concatenate with.
  6122. */
  6123. concatWithNoDuplicate(array: any): void;
  6124. }
  6125. }
  6126. declare module BABYLON {
  6127. /**
  6128. * @ignore
  6129. * This is a list of all the different input types that are available in the application.
  6130. * Fo instance: ArcRotateCameraGamepadInput...
  6131. */
  6132. export var CameraInputTypes: {};
  6133. /**
  6134. * This is the contract to implement in order to create a new input class.
  6135. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6136. */
  6137. export interface ICameraInput<TCamera extends Camera> {
  6138. /**
  6139. * Defines the camera the input is attached to.
  6140. */
  6141. camera: Nullable<TCamera>;
  6142. /**
  6143. * Gets the class name of the current intput.
  6144. * @returns the class name
  6145. */
  6146. getClassName(): string;
  6147. /**
  6148. * Get the friendly name associated with the input class.
  6149. * @returns the input friendly name
  6150. */
  6151. getSimpleName(): string;
  6152. /**
  6153. * Attach the input controls to a specific dom element to get the input from.
  6154. * @param element Defines the element the controls should be listened from
  6155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6156. */
  6157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6158. /**
  6159. * Detach the current controls from the specified dom element.
  6160. * @param element Defines the element to stop listening the inputs from
  6161. */
  6162. detachControl(element: Nullable<HTMLElement>): void;
  6163. /**
  6164. * Update the current camera state depending on the inputs that have been used this frame.
  6165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6166. */
  6167. checkInputs?: () => void;
  6168. }
  6169. /**
  6170. * Represents a map of input types to input instance or input index to input instance.
  6171. */
  6172. export interface CameraInputsMap<TCamera extends Camera> {
  6173. /**
  6174. * Accessor to the input by input type.
  6175. */
  6176. [name: string]: ICameraInput<TCamera>;
  6177. /**
  6178. * Accessor to the input by input index.
  6179. */
  6180. [idx: number]: ICameraInput<TCamera>;
  6181. }
  6182. /**
  6183. * This represents the input manager used within a camera.
  6184. * It helps dealing with all the different kind of input attached to a camera.
  6185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6186. */
  6187. export class CameraInputsManager<TCamera extends Camera> {
  6188. /**
  6189. * Defines the list of inputs attahed to the camera.
  6190. */
  6191. attached: CameraInputsMap<TCamera>;
  6192. /**
  6193. * Defines the dom element the camera is collecting inputs from.
  6194. * This is null if the controls have not been attached.
  6195. */
  6196. attachedElement: Nullable<HTMLElement>;
  6197. /**
  6198. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6199. */
  6200. noPreventDefault: boolean;
  6201. /**
  6202. * Defined the camera the input manager belongs to.
  6203. */
  6204. camera: TCamera;
  6205. /**
  6206. * Update the current camera state depending on the inputs that have been used this frame.
  6207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6208. */
  6209. checkInputs: () => void;
  6210. /**
  6211. * Instantiate a new Camera Input Manager.
  6212. * @param camera Defines the camera the input manager blongs to
  6213. */
  6214. constructor(camera: TCamera);
  6215. /**
  6216. * Add an input method to a camera
  6217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6218. * @param input camera input method
  6219. */
  6220. add(input: ICameraInput<TCamera>): void;
  6221. /**
  6222. * Remove a specific input method from a camera
  6223. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6224. * @param inputToRemove camera input method
  6225. */
  6226. remove(inputToRemove: ICameraInput<TCamera>): void;
  6227. /**
  6228. * Remove a specific input type from a camera
  6229. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6230. * @param inputType the type of the input to remove
  6231. */
  6232. removeByType(inputType: string): void;
  6233. private _addCheckInputs;
  6234. /**
  6235. * Attach the input controls to the currently attached dom element to listen the events from.
  6236. * @param input Defines the input to attach
  6237. */
  6238. attachInput(input: ICameraInput<TCamera>): void;
  6239. /**
  6240. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6241. * @param element Defines the dom element to collect the events from
  6242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6243. */
  6244. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6245. /**
  6246. * Detach the current manager inputs controls from a specific dom element.
  6247. * @param element Defines the dom element to collect the events from
  6248. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6249. */
  6250. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6251. /**
  6252. * Rebuild the dynamic inputCheck function from the current list of
  6253. * defined inputs in the manager.
  6254. */
  6255. rebuildInputCheck(): void;
  6256. /**
  6257. * Remove all attached input methods from a camera
  6258. */
  6259. clear(): void;
  6260. /**
  6261. * Serialize the current input manager attached to a camera.
  6262. * This ensures than once parsed,
  6263. * the input associated to the camera will be identical to the current ones
  6264. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6265. */
  6266. serialize(serializedCamera: any): void;
  6267. /**
  6268. * Parses an input manager serialized JSON to restore the previous list of inputs
  6269. * and states associated to a camera.
  6270. * @param parsedCamera Defines the JSON to parse
  6271. */
  6272. parse(parsedCamera: any): void;
  6273. }
  6274. }
  6275. declare module BABYLON {
  6276. /**
  6277. * Class used to store data that will be store in GPU memory
  6278. */
  6279. export class Buffer {
  6280. private _engine;
  6281. private _buffer;
  6282. /** @hidden */
  6283. _data: Nullable<DataArray>;
  6284. private _updatable;
  6285. private _instanced;
  6286. private _divisor;
  6287. /**
  6288. * Gets the byte stride.
  6289. */
  6290. readonly byteStride: number;
  6291. /**
  6292. * Constructor
  6293. * @param engine the engine
  6294. * @param data the data to use for this buffer
  6295. * @param updatable whether the data is updatable
  6296. * @param stride the stride (optional)
  6297. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6298. * @param instanced whether the buffer is instanced (optional)
  6299. * @param useBytes set to true if the stride in in bytes (optional)
  6300. * @param divisor sets an optional divisor for instances (1 by default)
  6301. */
  6302. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6303. /**
  6304. * Create a new VertexBuffer based on the current buffer
  6305. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6306. * @param offset defines offset in the buffer (0 by default)
  6307. * @param size defines the size in floats of attributes (position is 3 for instance)
  6308. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6309. * @param instanced defines if the vertex buffer contains indexed data
  6310. * @param useBytes defines if the offset and stride are in bytes *
  6311. * @param divisor sets an optional divisor for instances (1 by default)
  6312. * @returns the new vertex buffer
  6313. */
  6314. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6315. /**
  6316. * Gets a boolean indicating if the Buffer is updatable?
  6317. * @returns true if the buffer is updatable
  6318. */
  6319. isUpdatable(): boolean;
  6320. /**
  6321. * Gets current buffer's data
  6322. * @returns a DataArray or null
  6323. */
  6324. getData(): Nullable<DataArray>;
  6325. /**
  6326. * Gets underlying native buffer
  6327. * @returns underlying native buffer
  6328. */
  6329. getBuffer(): Nullable<DataBuffer>;
  6330. /**
  6331. * Gets the stride in float32 units (i.e. byte stride / 4).
  6332. * May not be an integer if the byte stride is not divisible by 4.
  6333. * @returns the stride in float32 units
  6334. * @deprecated Please use byteStride instead.
  6335. */
  6336. getStrideSize(): number;
  6337. /**
  6338. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6339. * @param data defines the data to store
  6340. */
  6341. create(data?: Nullable<DataArray>): void;
  6342. /** @hidden */
  6343. _rebuild(): void;
  6344. /**
  6345. * Update current buffer data
  6346. * @param data defines the data to store
  6347. */
  6348. update(data: DataArray): void;
  6349. /**
  6350. * Updates the data directly.
  6351. * @param data the new data
  6352. * @param offset the new offset
  6353. * @param vertexCount the vertex count (optional)
  6354. * @param useBytes set to true if the offset is in bytes
  6355. */
  6356. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6357. /**
  6358. * Release all resources
  6359. */
  6360. dispose(): void;
  6361. }
  6362. /**
  6363. * Specialized buffer used to store vertex data
  6364. */
  6365. export class VertexBuffer {
  6366. /** @hidden */
  6367. _buffer: Buffer;
  6368. private _kind;
  6369. private _size;
  6370. private _ownsBuffer;
  6371. private _instanced;
  6372. private _instanceDivisor;
  6373. /**
  6374. * The byte type.
  6375. */
  6376. static readonly BYTE: number;
  6377. /**
  6378. * The unsigned byte type.
  6379. */
  6380. static readonly UNSIGNED_BYTE: number;
  6381. /**
  6382. * The short type.
  6383. */
  6384. static readonly SHORT: number;
  6385. /**
  6386. * The unsigned short type.
  6387. */
  6388. static readonly UNSIGNED_SHORT: number;
  6389. /**
  6390. * The integer type.
  6391. */
  6392. static readonly INT: number;
  6393. /**
  6394. * The unsigned integer type.
  6395. */
  6396. static readonly UNSIGNED_INT: number;
  6397. /**
  6398. * The float type.
  6399. */
  6400. static readonly FLOAT: number;
  6401. /**
  6402. * Gets or sets the instance divisor when in instanced mode
  6403. */
  6404. get instanceDivisor(): number;
  6405. set instanceDivisor(value: number);
  6406. /**
  6407. * Gets the byte stride.
  6408. */
  6409. readonly byteStride: number;
  6410. /**
  6411. * Gets the byte offset.
  6412. */
  6413. readonly byteOffset: number;
  6414. /**
  6415. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6416. */
  6417. readonly normalized: boolean;
  6418. /**
  6419. * Gets the data type of each component in the array.
  6420. */
  6421. readonly type: number;
  6422. /**
  6423. * Constructor
  6424. * @param engine the engine
  6425. * @param data the data to use for this vertex buffer
  6426. * @param kind the vertex buffer kind
  6427. * @param updatable whether the data is updatable
  6428. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6429. * @param stride the stride (optional)
  6430. * @param instanced whether the buffer is instanced (optional)
  6431. * @param offset the offset of the data (optional)
  6432. * @param size the number of components (optional)
  6433. * @param type the type of the component (optional)
  6434. * @param normalized whether the data contains normalized data (optional)
  6435. * @param useBytes set to true if stride and offset are in bytes (optional)
  6436. * @param divisor defines the instance divisor to use (1 by default)
  6437. */
  6438. 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);
  6439. /** @hidden */
  6440. _rebuild(): void;
  6441. /**
  6442. * Returns the kind of the VertexBuffer (string)
  6443. * @returns a string
  6444. */
  6445. getKind(): string;
  6446. /**
  6447. * Gets a boolean indicating if the VertexBuffer is updatable?
  6448. * @returns true if the buffer is updatable
  6449. */
  6450. isUpdatable(): boolean;
  6451. /**
  6452. * Gets current buffer's data
  6453. * @returns a DataArray or null
  6454. */
  6455. getData(): Nullable<DataArray>;
  6456. /**
  6457. * Gets underlying native buffer
  6458. * @returns underlying native buffer
  6459. */
  6460. getBuffer(): Nullable<DataBuffer>;
  6461. /**
  6462. * Gets the stride in float32 units (i.e. byte stride / 4).
  6463. * May not be an integer if the byte stride is not divisible by 4.
  6464. * @returns the stride in float32 units
  6465. * @deprecated Please use byteStride instead.
  6466. */
  6467. getStrideSize(): number;
  6468. /**
  6469. * Returns the offset as a multiple of the type byte length.
  6470. * @returns the offset in bytes
  6471. * @deprecated Please use byteOffset instead.
  6472. */
  6473. getOffset(): number;
  6474. /**
  6475. * Returns the number of components per vertex attribute (integer)
  6476. * @returns the size in float
  6477. */
  6478. getSize(): number;
  6479. /**
  6480. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6481. * @returns true if this buffer is instanced
  6482. */
  6483. getIsInstanced(): boolean;
  6484. /**
  6485. * Returns the instancing divisor, zero for non-instanced (integer).
  6486. * @returns a number
  6487. */
  6488. getInstanceDivisor(): number;
  6489. /**
  6490. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6491. * @param data defines the data to store
  6492. */
  6493. create(data?: DataArray): void;
  6494. /**
  6495. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6496. * This function will create a new buffer if the current one is not updatable
  6497. * @param data defines the data to store
  6498. */
  6499. update(data: DataArray): void;
  6500. /**
  6501. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6502. * Returns the directly updated WebGLBuffer.
  6503. * @param data the new data
  6504. * @param offset the new offset
  6505. * @param useBytes set to true if the offset is in bytes
  6506. */
  6507. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6508. /**
  6509. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6510. */
  6511. dispose(): void;
  6512. /**
  6513. * Enumerates each value of this vertex buffer as numbers.
  6514. * @param count the number of values to enumerate
  6515. * @param callback the callback function called for each value
  6516. */
  6517. forEach(count: number, callback: (value: number, index: number) => void): void;
  6518. /**
  6519. * Positions
  6520. */
  6521. static readonly PositionKind: string;
  6522. /**
  6523. * Normals
  6524. */
  6525. static readonly NormalKind: string;
  6526. /**
  6527. * Tangents
  6528. */
  6529. static readonly TangentKind: string;
  6530. /**
  6531. * Texture coordinates
  6532. */
  6533. static readonly UVKind: string;
  6534. /**
  6535. * Texture coordinates 2
  6536. */
  6537. static readonly UV2Kind: string;
  6538. /**
  6539. * Texture coordinates 3
  6540. */
  6541. static readonly UV3Kind: string;
  6542. /**
  6543. * Texture coordinates 4
  6544. */
  6545. static readonly UV4Kind: string;
  6546. /**
  6547. * Texture coordinates 5
  6548. */
  6549. static readonly UV5Kind: string;
  6550. /**
  6551. * Texture coordinates 6
  6552. */
  6553. static readonly UV6Kind: string;
  6554. /**
  6555. * Colors
  6556. */
  6557. static readonly ColorKind: string;
  6558. /**
  6559. * Matrix indices (for bones)
  6560. */
  6561. static readonly MatricesIndicesKind: string;
  6562. /**
  6563. * Matrix weights (for bones)
  6564. */
  6565. static readonly MatricesWeightsKind: string;
  6566. /**
  6567. * Additional matrix indices (for bones)
  6568. */
  6569. static readonly MatricesIndicesExtraKind: string;
  6570. /**
  6571. * Additional matrix weights (for bones)
  6572. */
  6573. static readonly MatricesWeightsExtraKind: string;
  6574. /**
  6575. * Deduces the stride given a kind.
  6576. * @param kind The kind string to deduce
  6577. * @returns The deduced stride
  6578. */
  6579. static DeduceStride(kind: string): number;
  6580. /**
  6581. * Gets the byte length of the given type.
  6582. * @param type the type
  6583. * @returns the number of bytes
  6584. */
  6585. static GetTypeByteLength(type: number): number;
  6586. /**
  6587. * Enumerates each value of the given parameters as numbers.
  6588. * @param data the data to enumerate
  6589. * @param byteOffset the byte offset of the data
  6590. * @param byteStride the byte stride of the data
  6591. * @param componentCount the number of components per element
  6592. * @param componentType the type of the component
  6593. * @param count the number of values to enumerate
  6594. * @param normalized whether the data is normalized
  6595. * @param callback the callback function called for each value
  6596. */
  6597. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6598. private static _GetFloatValue;
  6599. }
  6600. }
  6601. declare module BABYLON {
  6602. /**
  6603. * @hidden
  6604. */
  6605. export class IntersectionInfo {
  6606. bu: Nullable<number>;
  6607. bv: Nullable<number>;
  6608. distance: number;
  6609. faceId: number;
  6610. subMeshId: number;
  6611. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6612. }
  6613. }
  6614. declare module BABYLON {
  6615. /**
  6616. * Represens a plane by the equation ax + by + cz + d = 0
  6617. */
  6618. export class Plane {
  6619. private static _TmpMatrix;
  6620. /**
  6621. * Normal of the plane (a,b,c)
  6622. */
  6623. normal: Vector3;
  6624. /**
  6625. * d component of the plane
  6626. */
  6627. d: number;
  6628. /**
  6629. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6630. * @param a a component of the plane
  6631. * @param b b component of the plane
  6632. * @param c c component of the plane
  6633. * @param d d component of the plane
  6634. */
  6635. constructor(a: number, b: number, c: number, d: number);
  6636. /**
  6637. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6638. */
  6639. asArray(): number[];
  6640. /**
  6641. * @returns a new plane copied from the current Plane.
  6642. */
  6643. clone(): Plane;
  6644. /**
  6645. * @returns the string "Plane".
  6646. */
  6647. getClassName(): string;
  6648. /**
  6649. * @returns the Plane hash code.
  6650. */
  6651. getHashCode(): number;
  6652. /**
  6653. * Normalize the current Plane in place.
  6654. * @returns the updated Plane.
  6655. */
  6656. normalize(): Plane;
  6657. /**
  6658. * Applies a transformation the plane and returns the result
  6659. * @param transformation the transformation matrix to be applied to the plane
  6660. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6661. */
  6662. transform(transformation: DeepImmutable<Matrix>): Plane;
  6663. /**
  6664. * Calcualtte the dot product between the point and the plane normal
  6665. * @param point point to calculate the dot product with
  6666. * @returns the dot product (float) of the point coordinates and the plane normal.
  6667. */
  6668. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6669. /**
  6670. * Updates the current Plane from the plane defined by the three given points.
  6671. * @param point1 one of the points used to contruct the plane
  6672. * @param point2 one of the points used to contruct the plane
  6673. * @param point3 one of the points used to contruct the plane
  6674. * @returns the updated Plane.
  6675. */
  6676. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6677. /**
  6678. * Checks if the plane is facing a given direction
  6679. * @param direction the direction to check if the plane is facing
  6680. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6681. * @returns True is the vector "direction" is the same side than the plane normal.
  6682. */
  6683. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6684. /**
  6685. * Calculates the distance to a point
  6686. * @param point point to calculate distance to
  6687. * @returns the signed distance (float) from the given point to the Plane.
  6688. */
  6689. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6690. /**
  6691. * Creates a plane from an array
  6692. * @param array the array to create a plane from
  6693. * @returns a new Plane from the given array.
  6694. */
  6695. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6696. /**
  6697. * Creates a plane from three points
  6698. * @param point1 point used to create the plane
  6699. * @param point2 point used to create the plane
  6700. * @param point3 point used to create the plane
  6701. * @returns a new Plane defined by the three given points.
  6702. */
  6703. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6704. /**
  6705. * Creates a plane from an origin point and a normal
  6706. * @param origin origin of the plane to be constructed
  6707. * @param normal normal of the plane to be constructed
  6708. * @returns a new Plane the normal vector to this plane at the given origin point.
  6709. * Note : the vector "normal" is updated because normalized.
  6710. */
  6711. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6712. /**
  6713. * Calculates the distance from a plane and a point
  6714. * @param origin origin of the plane to be constructed
  6715. * @param normal normal of the plane to be constructed
  6716. * @param point point to calculate distance to
  6717. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6718. */
  6719. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6720. }
  6721. }
  6722. declare module BABYLON {
  6723. /**
  6724. * Class used to store bounding sphere information
  6725. */
  6726. export class BoundingSphere {
  6727. /**
  6728. * Gets the center of the bounding sphere in local space
  6729. */
  6730. readonly center: Vector3;
  6731. /**
  6732. * Radius of the bounding sphere in local space
  6733. */
  6734. radius: number;
  6735. /**
  6736. * Gets the center of the bounding sphere in world space
  6737. */
  6738. readonly centerWorld: Vector3;
  6739. /**
  6740. * Radius of the bounding sphere in world space
  6741. */
  6742. radiusWorld: number;
  6743. /**
  6744. * Gets the minimum vector in local space
  6745. */
  6746. readonly minimum: Vector3;
  6747. /**
  6748. * Gets the maximum vector in local space
  6749. */
  6750. readonly maximum: Vector3;
  6751. private _worldMatrix;
  6752. private static readonly TmpVector3;
  6753. /**
  6754. * Creates a new bounding sphere
  6755. * @param min defines the minimum vector (in local space)
  6756. * @param max defines the maximum vector (in local space)
  6757. * @param worldMatrix defines the new world matrix
  6758. */
  6759. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6760. /**
  6761. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6762. * @param min defines the new minimum vector (in local space)
  6763. * @param max defines the new maximum vector (in local space)
  6764. * @param worldMatrix defines the new world matrix
  6765. */
  6766. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6767. /**
  6768. * Scale the current bounding sphere by applying a scale factor
  6769. * @param factor defines the scale factor to apply
  6770. * @returns the current bounding box
  6771. */
  6772. scale(factor: number): BoundingSphere;
  6773. /**
  6774. * Gets the world matrix of the bounding box
  6775. * @returns a matrix
  6776. */
  6777. getWorldMatrix(): DeepImmutable<Matrix>;
  6778. /** @hidden */
  6779. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6780. /**
  6781. * Tests if the bounding sphere is intersecting the frustum planes
  6782. * @param frustumPlanes defines the frustum planes to test
  6783. * @returns true if there is an intersection
  6784. */
  6785. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6786. /**
  6787. * Tests if the bounding sphere center is in between the frustum planes.
  6788. * Used for optimistic fast inclusion.
  6789. * @param frustumPlanes defines the frustum planes to test
  6790. * @returns true if the sphere center is in between the frustum planes
  6791. */
  6792. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6793. /**
  6794. * Tests if a point is inside the bounding sphere
  6795. * @param point defines the point to test
  6796. * @returns true if the point is inside the bounding sphere
  6797. */
  6798. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6799. /**
  6800. * Checks if two sphere intersct
  6801. * @param sphere0 sphere 0
  6802. * @param sphere1 sphere 1
  6803. * @returns true if the speres intersect
  6804. */
  6805. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6806. }
  6807. }
  6808. declare module BABYLON {
  6809. /**
  6810. * Class used to store bounding box information
  6811. */
  6812. export class BoundingBox implements ICullable {
  6813. /**
  6814. * Gets the 8 vectors representing the bounding box in local space
  6815. */
  6816. readonly vectors: Vector3[];
  6817. /**
  6818. * Gets the center of the bounding box in local space
  6819. */
  6820. readonly center: Vector3;
  6821. /**
  6822. * Gets the center of the bounding box in world space
  6823. */
  6824. readonly centerWorld: Vector3;
  6825. /**
  6826. * Gets the extend size in local space
  6827. */
  6828. readonly extendSize: Vector3;
  6829. /**
  6830. * Gets the extend size in world space
  6831. */
  6832. readonly extendSizeWorld: Vector3;
  6833. /**
  6834. * Gets the OBB (object bounding box) directions
  6835. */
  6836. readonly directions: Vector3[];
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in world space
  6839. */
  6840. readonly vectorsWorld: Vector3[];
  6841. /**
  6842. * Gets the minimum vector in world space
  6843. */
  6844. readonly minimumWorld: Vector3;
  6845. /**
  6846. * Gets the maximum vector in world space
  6847. */
  6848. readonly maximumWorld: Vector3;
  6849. /**
  6850. * Gets the minimum vector in local space
  6851. */
  6852. readonly minimum: Vector3;
  6853. /**
  6854. * Gets the maximum vector in local space
  6855. */
  6856. readonly maximum: Vector3;
  6857. private _worldMatrix;
  6858. private static readonly TmpVector3;
  6859. /**
  6860. * @hidden
  6861. */
  6862. _tag: number;
  6863. /**
  6864. * Creates a new bounding box
  6865. * @param min defines the minimum vector (in local space)
  6866. * @param max defines the maximum vector (in local space)
  6867. * @param worldMatrix defines the new world matrix
  6868. */
  6869. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6870. /**
  6871. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6872. * @param min defines the new minimum vector (in local space)
  6873. * @param max defines the new maximum vector (in local space)
  6874. * @param worldMatrix defines the new world matrix
  6875. */
  6876. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6877. /**
  6878. * Scale the current bounding box by applying a scale factor
  6879. * @param factor defines the scale factor to apply
  6880. * @returns the current bounding box
  6881. */
  6882. scale(factor: number): BoundingBox;
  6883. /**
  6884. * Gets the world matrix of the bounding box
  6885. * @returns a matrix
  6886. */
  6887. getWorldMatrix(): DeepImmutable<Matrix>;
  6888. /** @hidden */
  6889. _update(world: DeepImmutable<Matrix>): void;
  6890. /**
  6891. * Tests if the bounding box is intersecting the frustum planes
  6892. * @param frustumPlanes defines the frustum planes to test
  6893. * @returns true if there is an intersection
  6894. */
  6895. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6896. /**
  6897. * Tests if the bounding box is entirely inside the frustum planes
  6898. * @param frustumPlanes defines the frustum planes to test
  6899. * @returns true if there is an inclusion
  6900. */
  6901. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6902. /**
  6903. * Tests if a point is inside the bounding box
  6904. * @param point defines the point to test
  6905. * @returns true if the point is inside the bounding box
  6906. */
  6907. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6908. /**
  6909. * Tests if the bounding box intersects with a bounding sphere
  6910. * @param sphere defines the sphere to test
  6911. * @returns true if there is an intersection
  6912. */
  6913. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6914. /**
  6915. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6916. * @param min defines the min vector to use
  6917. * @param max defines the max vector to use
  6918. * @returns true if there is an intersection
  6919. */
  6920. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6921. /**
  6922. * Tests if two bounding boxes are intersections
  6923. * @param box0 defines the first box to test
  6924. * @param box1 defines the second box to test
  6925. * @returns true if there is an intersection
  6926. */
  6927. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6928. /**
  6929. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6930. * @param minPoint defines the minimum vector of the bounding box
  6931. * @param maxPoint defines the maximum vector of the bounding box
  6932. * @param sphereCenter defines the sphere center
  6933. * @param sphereRadius defines the sphere radius
  6934. * @returns true if there is an intersection
  6935. */
  6936. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6937. /**
  6938. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6939. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @return true if there is an inclusion
  6942. */
  6943. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6946. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6947. * @param frustumPlanes defines the frustum planes to test
  6948. * @return true if there is an intersection
  6949. */
  6950. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6951. }
  6952. }
  6953. declare module BABYLON {
  6954. /** @hidden */
  6955. export class Collider {
  6956. /** Define if a collision was found */
  6957. collisionFound: boolean;
  6958. /**
  6959. * Define last intersection point in local space
  6960. */
  6961. intersectionPoint: Vector3;
  6962. /**
  6963. * Define last collided mesh
  6964. */
  6965. collidedMesh: Nullable<AbstractMesh>;
  6966. private _collisionPoint;
  6967. private _planeIntersectionPoint;
  6968. private _tempVector;
  6969. private _tempVector2;
  6970. private _tempVector3;
  6971. private _tempVector4;
  6972. private _edge;
  6973. private _baseToVertex;
  6974. private _destinationPoint;
  6975. private _slidePlaneNormal;
  6976. private _displacementVector;
  6977. /** @hidden */
  6978. _radius: Vector3;
  6979. /** @hidden */
  6980. _retry: number;
  6981. private _velocity;
  6982. private _basePoint;
  6983. private _epsilon;
  6984. /** @hidden */
  6985. _velocityWorldLength: number;
  6986. /** @hidden */
  6987. _basePointWorld: Vector3;
  6988. private _velocityWorld;
  6989. private _normalizedVelocity;
  6990. /** @hidden */
  6991. _initialVelocity: Vector3;
  6992. /** @hidden */
  6993. _initialPosition: Vector3;
  6994. private _nearestDistance;
  6995. private _collisionMask;
  6996. get collisionMask(): number;
  6997. set collisionMask(mask: number);
  6998. /**
  6999. * Gets the plane normal used to compute the sliding response (in local space)
  7000. */
  7001. get slidePlaneNormal(): Vector3;
  7002. /** @hidden */
  7003. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7004. /** @hidden */
  7005. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7006. /** @hidden */
  7007. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7008. /** @hidden */
  7009. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7010. /** @hidden */
  7011. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7012. /** @hidden */
  7013. _getResponse(pos: Vector3, vel: Vector3): void;
  7014. }
  7015. }
  7016. declare module BABYLON {
  7017. /**
  7018. * Interface for cullable objects
  7019. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7020. */
  7021. export interface ICullable {
  7022. /**
  7023. * Checks if the object or part of the object is in the frustum
  7024. * @param frustumPlanes Camera near/planes
  7025. * @returns true if the object is in frustum otherwise false
  7026. */
  7027. isInFrustum(frustumPlanes: Plane[]): boolean;
  7028. /**
  7029. * Checks if a cullable object (mesh...) is in the camera frustum
  7030. * Unlike isInFrustum this cheks the full bounding box
  7031. * @param frustumPlanes Camera near/planes
  7032. * @returns true if the object is in frustum otherwise false
  7033. */
  7034. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7035. }
  7036. /**
  7037. * Info for a bounding data of a mesh
  7038. */
  7039. export class BoundingInfo implements ICullable {
  7040. /**
  7041. * Bounding box for the mesh
  7042. */
  7043. readonly boundingBox: BoundingBox;
  7044. /**
  7045. * Bounding sphere for the mesh
  7046. */
  7047. readonly boundingSphere: BoundingSphere;
  7048. private _isLocked;
  7049. private static readonly TmpVector3;
  7050. /**
  7051. * Constructs bounding info
  7052. * @param minimum min vector of the bounding box/sphere
  7053. * @param maximum max vector of the bounding box/sphere
  7054. * @param worldMatrix defines the new world matrix
  7055. */
  7056. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7057. /**
  7058. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7059. * @param min defines the new minimum vector (in local space)
  7060. * @param max defines the new maximum vector (in local space)
  7061. * @param worldMatrix defines the new world matrix
  7062. */
  7063. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7064. /**
  7065. * min vector of the bounding box/sphere
  7066. */
  7067. get minimum(): Vector3;
  7068. /**
  7069. * max vector of the bounding box/sphere
  7070. */
  7071. get maximum(): Vector3;
  7072. /**
  7073. * If the info is locked and won't be updated to avoid perf overhead
  7074. */
  7075. get isLocked(): boolean;
  7076. set isLocked(value: boolean);
  7077. /**
  7078. * Updates the bounding sphere and box
  7079. * @param world world matrix to be used to update
  7080. */
  7081. update(world: DeepImmutable<Matrix>): void;
  7082. /**
  7083. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7084. * @param center New center of the bounding info
  7085. * @param extend New extend of the bounding info
  7086. * @returns the current bounding info
  7087. */
  7088. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7089. /**
  7090. * Scale the current bounding info by applying a scale factor
  7091. * @param factor defines the scale factor to apply
  7092. * @returns the current bounding info
  7093. */
  7094. scale(factor: number): BoundingInfo;
  7095. /**
  7096. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7097. * @param frustumPlanes defines the frustum to test
  7098. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7099. * @returns true if the bounding info is in the frustum planes
  7100. */
  7101. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7102. /**
  7103. * Gets the world distance between the min and max points of the bounding box
  7104. */
  7105. get diagonalLength(): number;
  7106. /**
  7107. * Checks if a cullable object (mesh...) is in the camera frustum
  7108. * Unlike isInFrustum this cheks the full bounding box
  7109. * @param frustumPlanes Camera near/planes
  7110. * @returns true if the object is in frustum otherwise false
  7111. */
  7112. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7113. /** @hidden */
  7114. _checkCollision(collider: Collider): boolean;
  7115. /**
  7116. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7117. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7118. * @param point the point to check intersection with
  7119. * @returns if the point intersects
  7120. */
  7121. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7122. /**
  7123. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7124. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7125. * @param boundingInfo the bounding info to check intersection with
  7126. * @param precise if the intersection should be done using OBB
  7127. * @returns if the bounding info intersects
  7128. */
  7129. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7130. }
  7131. }
  7132. declare module BABYLON {
  7133. /**
  7134. * Extracts minimum and maximum values from a list of indexed positions
  7135. * @param positions defines the positions to use
  7136. * @param indices defines the indices to the positions
  7137. * @param indexStart defines the start index
  7138. * @param indexCount defines the end index
  7139. * @param bias defines bias value to add to the result
  7140. * @return minimum and maximum values
  7141. */
  7142. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7143. minimum: Vector3;
  7144. maximum: Vector3;
  7145. };
  7146. /**
  7147. * Extracts minimum and maximum values from a list of positions
  7148. * @param positions defines the positions to use
  7149. * @param start defines the start index in the positions array
  7150. * @param count defines the number of positions to handle
  7151. * @param bias defines bias value to add to the result
  7152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7153. * @return minimum and maximum values
  7154. */
  7155. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7156. minimum: Vector3;
  7157. maximum: Vector3;
  7158. };
  7159. }
  7160. declare module BABYLON {
  7161. /** @hidden */
  7162. export class WebGLDataBuffer extends DataBuffer {
  7163. private _buffer;
  7164. constructor(resource: WebGLBuffer);
  7165. get underlyingResource(): any;
  7166. }
  7167. }
  7168. declare module BABYLON {
  7169. /** @hidden */
  7170. export class WebGLPipelineContext implements IPipelineContext {
  7171. engine: ThinEngine;
  7172. program: Nullable<WebGLProgram>;
  7173. context?: WebGLRenderingContext;
  7174. vertexShader?: WebGLShader;
  7175. fragmentShader?: WebGLShader;
  7176. isParallelCompiled: boolean;
  7177. onCompiled?: () => void;
  7178. transformFeedback?: WebGLTransformFeedback | null;
  7179. vertexCompilationError: Nullable<string>;
  7180. fragmentCompilationError: Nullable<string>;
  7181. programLinkError: Nullable<string>;
  7182. programValidationError: Nullable<string>;
  7183. get isAsync(): boolean;
  7184. get isReady(): boolean;
  7185. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7186. _getVertexShaderCode(): string | null;
  7187. _getFragmentShaderCode(): string | null;
  7188. }
  7189. }
  7190. declare module BABYLON {
  7191. interface ThinEngine {
  7192. /**
  7193. * Create an uniform buffer
  7194. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7195. * @param elements defines the content of the uniform buffer
  7196. * @returns the webGL uniform buffer
  7197. */
  7198. createUniformBuffer(elements: FloatArray): DataBuffer;
  7199. /**
  7200. * Create a dynamic uniform buffer
  7201. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7202. * @param elements defines the content of the uniform buffer
  7203. * @returns the webGL uniform buffer
  7204. */
  7205. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7206. /**
  7207. * Update an existing uniform buffer
  7208. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7209. * @param uniformBuffer defines the target uniform buffer
  7210. * @param elements defines the content to update
  7211. * @param offset defines the offset in the uniform buffer where update should start
  7212. * @param count defines the size of the data to update
  7213. */
  7214. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7215. /**
  7216. * Bind an uniform buffer to the current webGL context
  7217. * @param buffer defines the buffer to bind
  7218. */
  7219. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7220. /**
  7221. * Bind a buffer to the current webGL context at a given location
  7222. * @param buffer defines the buffer to bind
  7223. * @param location defines the index where to bind the buffer
  7224. */
  7225. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7226. /**
  7227. * Bind a specific block at a given index in a specific shader program
  7228. * @param pipelineContext defines the pipeline context to use
  7229. * @param blockName defines the block name
  7230. * @param index defines the index where to bind the block
  7231. */
  7232. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7233. }
  7234. }
  7235. declare module BABYLON {
  7236. /**
  7237. * Uniform buffer objects.
  7238. *
  7239. * Handles blocks of uniform on the GPU.
  7240. *
  7241. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7242. *
  7243. * For more information, please refer to :
  7244. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7245. */
  7246. export class UniformBuffer {
  7247. private _engine;
  7248. private _buffer;
  7249. private _data;
  7250. private _bufferData;
  7251. private _dynamic?;
  7252. private _uniformLocations;
  7253. private _uniformSizes;
  7254. private _uniformLocationPointer;
  7255. private _needSync;
  7256. private _noUBO;
  7257. private _currentEffect;
  7258. /** @hidden */
  7259. _alreadyBound: boolean;
  7260. private static _MAX_UNIFORM_SIZE;
  7261. private static _tempBuffer;
  7262. /**
  7263. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7264. * This is dynamic to allow compat with webgl 1 and 2.
  7265. * You will need to pass the name of the uniform as well as the value.
  7266. */
  7267. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7268. /**
  7269. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7270. * This is dynamic to allow compat with webgl 1 and 2.
  7271. * You will need to pass the name of the uniform as well as the value.
  7272. */
  7273. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7274. /**
  7275. * Lambda to Update a single float in a uniform buffer.
  7276. * This is dynamic to allow compat with webgl 1 and 2.
  7277. * You will need to pass the name of the uniform as well as the value.
  7278. */
  7279. updateFloat: (name: string, x: number) => void;
  7280. /**
  7281. * Lambda to Update a vec2 of float in a uniform buffer.
  7282. * This is dynamic to allow compat with webgl 1 and 2.
  7283. * You will need to pass the name of the uniform as well as the value.
  7284. */
  7285. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7286. /**
  7287. * Lambda to Update a vec3 of float in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7292. /**
  7293. * Lambda to Update a vec4 of float in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7298. /**
  7299. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateMatrix: (name: string, mat: Matrix) => void;
  7304. /**
  7305. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateVector3: (name: string, vector: Vector3) => void;
  7310. /**
  7311. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateVector4: (name: string, vector: Vector4) => void;
  7316. /**
  7317. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7318. * This is dynamic to allow compat with webgl 1 and 2.
  7319. * You will need to pass the name of the uniform as well as the value.
  7320. */
  7321. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7322. /**
  7323. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7324. * This is dynamic to allow compat with webgl 1 and 2.
  7325. * You will need to pass the name of the uniform as well as the value.
  7326. */
  7327. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7328. /**
  7329. * Instantiates a new Uniform buffer objects.
  7330. *
  7331. * Handles blocks of uniform on the GPU.
  7332. *
  7333. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7334. *
  7335. * For more information, please refer to :
  7336. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7337. * @param engine Define the engine the buffer is associated with
  7338. * @param data Define the data contained in the buffer
  7339. * @param dynamic Define if the buffer is updatable
  7340. */
  7341. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7342. /**
  7343. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7344. * or just falling back on setUniformXXX calls.
  7345. */
  7346. get useUbo(): boolean;
  7347. /**
  7348. * Indicates if the WebGL underlying uniform buffer is in sync
  7349. * with the javascript cache data.
  7350. */
  7351. get isSync(): boolean;
  7352. /**
  7353. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7354. * Also, a dynamic UniformBuffer will disable cache verification and always
  7355. * update the underlying WebGL uniform buffer to the GPU.
  7356. * @returns if Dynamic, otherwise false
  7357. */
  7358. isDynamic(): boolean;
  7359. /**
  7360. * The data cache on JS side.
  7361. * @returns the underlying data as a float array
  7362. */
  7363. getData(): Float32Array;
  7364. /**
  7365. * The underlying WebGL Uniform buffer.
  7366. * @returns the webgl buffer
  7367. */
  7368. getBuffer(): Nullable<DataBuffer>;
  7369. /**
  7370. * std140 layout specifies how to align data within an UBO structure.
  7371. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7372. * for specs.
  7373. */
  7374. private _fillAlignment;
  7375. /**
  7376. * Adds an uniform in the buffer.
  7377. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7378. * for the layout to be correct !
  7379. * @param name Name of the uniform, as used in the uniform block in the shader.
  7380. * @param size Data size, or data directly.
  7381. */
  7382. addUniform(name: string, size: number | number[]): void;
  7383. /**
  7384. * Adds a Matrix 4x4 to the uniform buffer.
  7385. * @param name Name of the uniform, as used in the uniform block in the shader.
  7386. * @param mat A 4x4 matrix.
  7387. */
  7388. addMatrix(name: string, mat: Matrix): void;
  7389. /**
  7390. * Adds a vec2 to the uniform buffer.
  7391. * @param name Name of the uniform, as used in the uniform block in the shader.
  7392. * @param x Define the x component value of the vec2
  7393. * @param y Define the y component value of the vec2
  7394. */
  7395. addFloat2(name: string, x: number, y: number): void;
  7396. /**
  7397. * Adds a vec3 to the uniform buffer.
  7398. * @param name Name of the uniform, as used in the uniform block in the shader.
  7399. * @param x Define the x component value of the vec3
  7400. * @param y Define the y component value of the vec3
  7401. * @param z Define the z component value of the vec3
  7402. */
  7403. addFloat3(name: string, x: number, y: number, z: number): void;
  7404. /**
  7405. * Adds a vec3 to the uniform buffer.
  7406. * @param name Name of the uniform, as used in the uniform block in the shader.
  7407. * @param color Define the vec3 from a Color
  7408. */
  7409. addColor3(name: string, color: Color3): void;
  7410. /**
  7411. * Adds a vec4 to the uniform buffer.
  7412. * @param name Name of the uniform, as used in the uniform block in the shader.
  7413. * @param color Define the rgb components from a Color
  7414. * @param alpha Define the a component of the vec4
  7415. */
  7416. addColor4(name: string, color: Color3, alpha: number): void;
  7417. /**
  7418. * Adds a vec3 to the uniform buffer.
  7419. * @param name Name of the uniform, as used in the uniform block in the shader.
  7420. * @param vector Define the vec3 components from a Vector
  7421. */
  7422. addVector3(name: string, vector: Vector3): void;
  7423. /**
  7424. * Adds a Matrix 3x3 to the uniform buffer.
  7425. * @param name Name of the uniform, as used in the uniform block in the shader.
  7426. */
  7427. addMatrix3x3(name: string): void;
  7428. /**
  7429. * Adds a Matrix 2x2 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. */
  7432. addMatrix2x2(name: string): void;
  7433. /**
  7434. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7435. */
  7436. create(): void;
  7437. /** @hidden */
  7438. _rebuild(): void;
  7439. /**
  7440. * Updates the WebGL Uniform Buffer on the GPU.
  7441. * If the `dynamic` flag is set to true, no cache comparison is done.
  7442. * Otherwise, the buffer will be updated only if the cache differs.
  7443. */
  7444. update(): void;
  7445. /**
  7446. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7447. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7448. * @param data Define the flattened data
  7449. * @param size Define the size of the data.
  7450. */
  7451. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7452. private _valueCache;
  7453. private _cacheMatrix;
  7454. private _updateMatrix3x3ForUniform;
  7455. private _updateMatrix3x3ForEffect;
  7456. private _updateMatrix2x2ForEffect;
  7457. private _updateMatrix2x2ForUniform;
  7458. private _updateFloatForEffect;
  7459. private _updateFloatForUniform;
  7460. private _updateFloat2ForEffect;
  7461. private _updateFloat2ForUniform;
  7462. private _updateFloat3ForEffect;
  7463. private _updateFloat3ForUniform;
  7464. private _updateFloat4ForEffect;
  7465. private _updateFloat4ForUniform;
  7466. private _updateMatrixForEffect;
  7467. private _updateMatrixForUniform;
  7468. private _updateVector3ForEffect;
  7469. private _updateVector3ForUniform;
  7470. private _updateVector4ForEffect;
  7471. private _updateVector4ForUniform;
  7472. private _updateColor3ForEffect;
  7473. private _updateColor3ForUniform;
  7474. private _updateColor4ForEffect;
  7475. private _updateColor4ForUniform;
  7476. /**
  7477. * Sets a sampler uniform on the effect.
  7478. * @param name Define the name of the sampler.
  7479. * @param texture Define the texture to set in the sampler
  7480. */
  7481. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7482. /**
  7483. * Directly updates the value of the uniform in the cache AND on the GPU.
  7484. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7485. * @param data Define the flattened data
  7486. */
  7487. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7488. /**
  7489. * Binds this uniform buffer to an effect.
  7490. * @param effect Define the effect to bind the buffer to
  7491. * @param name Name of the uniform block in the shader.
  7492. */
  7493. bindToEffect(effect: Effect, name: string): void;
  7494. /**
  7495. * Disposes the uniform buffer.
  7496. */
  7497. dispose(): void;
  7498. }
  7499. }
  7500. declare module BABYLON {
  7501. /**
  7502. * Enum that determines the text-wrapping mode to use.
  7503. */
  7504. export enum InspectableType {
  7505. /**
  7506. * Checkbox for booleans
  7507. */
  7508. Checkbox = 0,
  7509. /**
  7510. * Sliders for numbers
  7511. */
  7512. Slider = 1,
  7513. /**
  7514. * Vector3
  7515. */
  7516. Vector3 = 2,
  7517. /**
  7518. * Quaternions
  7519. */
  7520. Quaternion = 3,
  7521. /**
  7522. * Color3
  7523. */
  7524. Color3 = 4,
  7525. /**
  7526. * String
  7527. */
  7528. String = 5
  7529. }
  7530. /**
  7531. * Interface used to define custom inspectable properties.
  7532. * This interface is used by the inspector to display custom property grids
  7533. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7534. */
  7535. export interface IInspectable {
  7536. /**
  7537. * Gets the label to display
  7538. */
  7539. label: string;
  7540. /**
  7541. * Gets the name of the property to edit
  7542. */
  7543. propertyName: string;
  7544. /**
  7545. * Gets the type of the editor to use
  7546. */
  7547. type: InspectableType;
  7548. /**
  7549. * Gets the minimum value of the property when using in "slider" mode
  7550. */
  7551. min?: number;
  7552. /**
  7553. * Gets the maximum value of the property when using in "slider" mode
  7554. */
  7555. max?: number;
  7556. /**
  7557. * Gets the setp to use when using in "slider" mode
  7558. */
  7559. step?: number;
  7560. }
  7561. }
  7562. declare module BABYLON {
  7563. /**
  7564. * Class used to provide helper for timing
  7565. */
  7566. export class TimingTools {
  7567. /**
  7568. * Polyfill for setImmediate
  7569. * @param action defines the action to execute after the current execution block
  7570. */
  7571. static SetImmediate(action: () => void): void;
  7572. }
  7573. }
  7574. declare module BABYLON {
  7575. /**
  7576. * Class used to enable instatition of objects by class name
  7577. */
  7578. export class InstantiationTools {
  7579. /**
  7580. * Use this object to register external classes like custom textures or material
  7581. * to allow the laoders to instantiate them
  7582. */
  7583. static RegisteredExternalClasses: {
  7584. [key: string]: Object;
  7585. };
  7586. /**
  7587. * Tries to instantiate a new object from a given class name
  7588. * @param className defines the class name to instantiate
  7589. * @returns the new object or null if the system was not able to do the instantiation
  7590. */
  7591. static Instantiate(className: string): any;
  7592. }
  7593. }
  7594. declare module BABYLON {
  7595. /**
  7596. * Define options used to create a depth texture
  7597. */
  7598. export class DepthTextureCreationOptions {
  7599. /** Specifies whether or not a stencil should be allocated in the texture */
  7600. generateStencil?: boolean;
  7601. /** Specifies whether or not bilinear filtering is enable on the texture */
  7602. bilinearFiltering?: boolean;
  7603. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7604. comparisonFunction?: number;
  7605. /** Specifies if the created texture is a cube texture */
  7606. isCube?: boolean;
  7607. }
  7608. }
  7609. declare module BABYLON {
  7610. interface ThinEngine {
  7611. /**
  7612. * Creates a depth stencil cube texture.
  7613. * This is only available in WebGL 2.
  7614. * @param size The size of face edge in the cube texture.
  7615. * @param options The options defining the cube texture.
  7616. * @returns The cube texture
  7617. */
  7618. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7619. /**
  7620. * Creates a cube texture
  7621. * @param rootUrl defines the url where the files to load is located
  7622. * @param scene defines the current scene
  7623. * @param files defines the list of files to load (1 per face)
  7624. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7625. * @param onLoad defines an optional callback raised when the texture is loaded
  7626. * @param onError defines an optional callback raised if there is an issue to load the texture
  7627. * @param format defines the format of the data
  7628. * @param forcedExtension defines the extension to use to pick the right loader
  7629. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7630. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7631. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7632. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7633. * @returns the cube texture as an InternalTexture
  7634. */
  7635. 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;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @returns the cube texture as an InternalTexture
  7647. */
  7648. 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;
  7649. /**
  7650. * Creates a cube texture
  7651. * @param rootUrl defines the url where the files to load is located
  7652. * @param scene defines the current scene
  7653. * @param files defines the list of files to load (1 per face)
  7654. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7655. * @param onLoad defines an optional callback raised when the texture is loaded
  7656. * @param onError defines an optional callback raised if there is an issue to load the texture
  7657. * @param format defines the format of the data
  7658. * @param forcedExtension defines the extension to use to pick the right loader
  7659. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7660. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7661. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7662. * @returns the cube texture as an InternalTexture
  7663. */
  7664. 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;
  7665. /** @hidden */
  7666. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /** @hidden */
  7670. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7671. /** @hidden */
  7672. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7673. /**
  7674. * @hidden
  7675. */
  7676. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7677. }
  7678. }
  7679. declare module BABYLON {
  7680. /**
  7681. * Class for creating a cube texture
  7682. */
  7683. export class CubeTexture extends BaseTexture {
  7684. private _delayedOnLoad;
  7685. /**
  7686. * Observable triggered once the texture has been loaded.
  7687. */
  7688. onLoadObservable: Observable<CubeTexture>;
  7689. /**
  7690. * The url of the texture
  7691. */
  7692. url: string;
  7693. /**
  7694. * Gets or sets the center of the bounding box associated with the cube texture.
  7695. * It must define where the camera used to render the texture was set
  7696. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7697. */
  7698. boundingBoxPosition: Vector3;
  7699. private _boundingBoxSize;
  7700. /**
  7701. * Gets or sets the size of the bounding box associated with the cube texture
  7702. * When defined, the cubemap will switch to local mode
  7703. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7704. * @example https://www.babylonjs-playground.com/#RNASML
  7705. */
  7706. set boundingBoxSize(value: Vector3);
  7707. /**
  7708. * Returns the bounding box size
  7709. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7710. */
  7711. get boundingBoxSize(): Vector3;
  7712. protected _rotationY: number;
  7713. /**
  7714. * Sets texture matrix rotation angle around Y axis in radians.
  7715. */
  7716. set rotationY(value: number);
  7717. /**
  7718. * Gets texture matrix rotation angle around Y axis radians.
  7719. */
  7720. get rotationY(): number;
  7721. /**
  7722. * Are mip maps generated for this texture or not.
  7723. */
  7724. get noMipmap(): boolean;
  7725. private _noMipmap;
  7726. private _files;
  7727. protected _forcedExtension: Nullable<string>;
  7728. private _extensions;
  7729. private _textureMatrix;
  7730. private _format;
  7731. private _createPolynomials;
  7732. /** @hidden */
  7733. _prefiltered: boolean;
  7734. /**
  7735. * Creates a cube texture from an array of image urls
  7736. * @param files defines an array of image urls
  7737. * @param scene defines the hosting scene
  7738. * @param noMipmap specifies if mip maps are not used
  7739. * @returns a cube texture
  7740. */
  7741. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7742. /**
  7743. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7744. * @param url defines the url of the prefiltered texture
  7745. * @param scene defines the scene the texture is attached to
  7746. * @param forcedExtension defines the extension of the file if different from the url
  7747. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7748. * @return the prefiltered texture
  7749. */
  7750. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7751. /**
  7752. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7753. * as prefiltered data.
  7754. * @param rootUrl defines the url of the texture or the root name of the six images
  7755. * @param scene defines the scene the texture is attached to
  7756. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7757. * @param noMipmap defines if mipmaps should be created or not
  7758. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7759. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7760. * @param onError defines a callback triggered in case of error during load
  7761. * @param format defines the internal format to use for the texture once loaded
  7762. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7763. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7764. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7765. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7766. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7767. * @return the cube texture
  7768. */
  7769. 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);
  7770. /**
  7771. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7772. */
  7773. get isPrefiltered(): boolean;
  7774. /**
  7775. * Get the current class name of the texture useful for serialization or dynamic coding.
  7776. * @returns "CubeTexture"
  7777. */
  7778. getClassName(): string;
  7779. /**
  7780. * Update the url (and optional buffer) of this texture if url was null during construction.
  7781. * @param url the url of the texture
  7782. * @param forcedExtension defines the extension to use
  7783. * @param onLoad callback called when the texture is loaded (defaults to null)
  7784. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7785. */
  7786. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7787. /**
  7788. * Delays loading of the cube texture
  7789. * @param forcedExtension defines the extension to use
  7790. */
  7791. delayLoad(forcedExtension?: string): void;
  7792. /**
  7793. * Returns the reflection texture matrix
  7794. * @returns the reflection texture matrix
  7795. */
  7796. getReflectionTextureMatrix(): Matrix;
  7797. /**
  7798. * Sets the reflection texture matrix
  7799. * @param value Reflection texture matrix
  7800. */
  7801. setReflectionTextureMatrix(value: Matrix): void;
  7802. /**
  7803. * Parses text to create a cube texture
  7804. * @param parsedTexture define the serialized text to read from
  7805. * @param scene defines the hosting scene
  7806. * @param rootUrl defines the root url of the cube texture
  7807. * @returns a cube texture
  7808. */
  7809. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7810. /**
  7811. * Makes a clone, or deep copy, of the cube texture
  7812. * @returns a new cube texture
  7813. */
  7814. clone(): CubeTexture;
  7815. }
  7816. }
  7817. declare module BABYLON {
  7818. /**
  7819. * Manages the defines for the Material
  7820. */
  7821. export class MaterialDefines {
  7822. /** @hidden */
  7823. protected _keys: string[];
  7824. private _isDirty;
  7825. /** @hidden */
  7826. _renderId: number;
  7827. /** @hidden */
  7828. _areLightsDirty: boolean;
  7829. /** @hidden */
  7830. _areLightsDisposed: boolean;
  7831. /** @hidden */
  7832. _areAttributesDirty: boolean;
  7833. /** @hidden */
  7834. _areTexturesDirty: boolean;
  7835. /** @hidden */
  7836. _areFresnelDirty: boolean;
  7837. /** @hidden */
  7838. _areMiscDirty: boolean;
  7839. /** @hidden */
  7840. _areImageProcessingDirty: boolean;
  7841. /** @hidden */
  7842. _normals: boolean;
  7843. /** @hidden */
  7844. _uvs: boolean;
  7845. /** @hidden */
  7846. _needNormals: boolean;
  7847. /** @hidden */
  7848. _needUVs: boolean;
  7849. [id: string]: any;
  7850. /**
  7851. * Specifies if the material needs to be re-calculated
  7852. */
  7853. get isDirty(): boolean;
  7854. /**
  7855. * Marks the material to indicate that it has been re-calculated
  7856. */
  7857. markAsProcessed(): void;
  7858. /**
  7859. * Marks the material to indicate that it needs to be re-calculated
  7860. */
  7861. markAsUnprocessed(): void;
  7862. /**
  7863. * Marks the material to indicate all of its defines need to be re-calculated
  7864. */
  7865. markAllAsDirty(): void;
  7866. /**
  7867. * Marks the material to indicate that image processing needs to be re-calculated
  7868. */
  7869. markAsImageProcessingDirty(): void;
  7870. /**
  7871. * Marks the material to indicate the lights need to be re-calculated
  7872. * @param disposed Defines whether the light is dirty due to dispose or not
  7873. */
  7874. markAsLightDirty(disposed?: boolean): void;
  7875. /**
  7876. * Marks the attribute state as changed
  7877. */
  7878. markAsAttributesDirty(): void;
  7879. /**
  7880. * Marks the texture state as changed
  7881. */
  7882. markAsTexturesDirty(): void;
  7883. /**
  7884. * Marks the fresnel state as changed
  7885. */
  7886. markAsFresnelDirty(): void;
  7887. /**
  7888. * Marks the misc state as changed
  7889. */
  7890. markAsMiscDirty(): void;
  7891. /**
  7892. * Rebuilds the material defines
  7893. */
  7894. rebuild(): void;
  7895. /**
  7896. * Specifies if two material defines are equal
  7897. * @param other - A material define instance to compare to
  7898. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7899. */
  7900. isEqual(other: MaterialDefines): boolean;
  7901. /**
  7902. * Clones this instance's defines to another instance
  7903. * @param other - material defines to clone values to
  7904. */
  7905. cloneTo(other: MaterialDefines): void;
  7906. /**
  7907. * Resets the material define values
  7908. */
  7909. reset(): void;
  7910. /**
  7911. * Converts the material define values to a string
  7912. * @returns - String of material define information
  7913. */
  7914. toString(): string;
  7915. }
  7916. }
  7917. declare module BABYLON {
  7918. /**
  7919. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7920. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7921. * 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;
  7922. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7923. */
  7924. export class ColorCurves {
  7925. private _dirty;
  7926. private _tempColor;
  7927. private _globalCurve;
  7928. private _highlightsCurve;
  7929. private _midtonesCurve;
  7930. private _shadowsCurve;
  7931. private _positiveCurve;
  7932. private _negativeCurve;
  7933. private _globalHue;
  7934. private _globalDensity;
  7935. private _globalSaturation;
  7936. private _globalExposure;
  7937. /**
  7938. * Gets the global Hue value.
  7939. * 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).
  7940. */
  7941. get globalHue(): number;
  7942. /**
  7943. * Sets the global Hue value.
  7944. * 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).
  7945. */
  7946. set globalHue(value: number);
  7947. /**
  7948. * Gets the global Density value.
  7949. * 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.
  7950. * Values less than zero provide a filter of opposite hue.
  7951. */
  7952. get globalDensity(): number;
  7953. /**
  7954. * Sets the global Density value.
  7955. * 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.
  7956. * Values less than zero provide a filter of opposite hue.
  7957. */
  7958. set globalDensity(value: number);
  7959. /**
  7960. * Gets the global Saturation value.
  7961. * 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.
  7962. */
  7963. get globalSaturation(): number;
  7964. /**
  7965. * Sets the global Saturation value.
  7966. * 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.
  7967. */
  7968. set globalSaturation(value: number);
  7969. /**
  7970. * Gets the global Exposure value.
  7971. * 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.
  7972. */
  7973. get globalExposure(): number;
  7974. /**
  7975. * Sets the global Exposure value.
  7976. * 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.
  7977. */
  7978. set globalExposure(value: number);
  7979. private _highlightsHue;
  7980. private _highlightsDensity;
  7981. private _highlightsSaturation;
  7982. private _highlightsExposure;
  7983. /**
  7984. * Gets the highlights Hue value.
  7985. * 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).
  7986. */
  7987. get highlightsHue(): number;
  7988. /**
  7989. * Sets the highlights Hue value.
  7990. * 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).
  7991. */
  7992. set highlightsHue(value: number);
  7993. /**
  7994. * Gets the highlights Density value.
  7995. * 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.
  7996. * Values less than zero provide a filter of opposite hue.
  7997. */
  7998. get highlightsDensity(): number;
  7999. /**
  8000. * Sets the highlights Density value.
  8001. * 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.
  8002. * Values less than zero provide a filter of opposite hue.
  8003. */
  8004. set highlightsDensity(value: number);
  8005. /**
  8006. * Gets the highlights Saturation value.
  8007. * 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.
  8008. */
  8009. get highlightsSaturation(): number;
  8010. /**
  8011. * Sets the highlights Saturation value.
  8012. * 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.
  8013. */
  8014. set highlightsSaturation(value: number);
  8015. /**
  8016. * Gets the highlights Exposure value.
  8017. * 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.
  8018. */
  8019. get highlightsExposure(): number;
  8020. /**
  8021. * Sets the highlights Exposure value.
  8022. * 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.
  8023. */
  8024. set highlightsExposure(value: number);
  8025. private _midtonesHue;
  8026. private _midtonesDensity;
  8027. private _midtonesSaturation;
  8028. private _midtonesExposure;
  8029. /**
  8030. * Gets the midtones Hue value.
  8031. * 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).
  8032. */
  8033. get midtonesHue(): number;
  8034. /**
  8035. * Sets the midtones Hue value.
  8036. * 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).
  8037. */
  8038. set midtonesHue(value: number);
  8039. /**
  8040. * Gets the midtones Density value.
  8041. * 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.
  8042. * Values less than zero provide a filter of opposite hue.
  8043. */
  8044. get midtonesDensity(): number;
  8045. /**
  8046. * Sets the midtones Density value.
  8047. * 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.
  8048. * Values less than zero provide a filter of opposite hue.
  8049. */
  8050. set midtonesDensity(value: number);
  8051. /**
  8052. * Gets the midtones Saturation value.
  8053. * 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.
  8054. */
  8055. get midtonesSaturation(): number;
  8056. /**
  8057. * Sets the midtones Saturation value.
  8058. * 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.
  8059. */
  8060. set midtonesSaturation(value: number);
  8061. /**
  8062. * Gets the midtones Exposure value.
  8063. * 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.
  8064. */
  8065. get midtonesExposure(): number;
  8066. /**
  8067. * Sets the midtones Exposure value.
  8068. * 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.
  8069. */
  8070. set midtonesExposure(value: number);
  8071. private _shadowsHue;
  8072. private _shadowsDensity;
  8073. private _shadowsSaturation;
  8074. private _shadowsExposure;
  8075. /**
  8076. * Gets the shadows Hue value.
  8077. * 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).
  8078. */
  8079. get shadowsHue(): number;
  8080. /**
  8081. * Sets the shadows Hue value.
  8082. * 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).
  8083. */
  8084. set shadowsHue(value: number);
  8085. /**
  8086. * Gets the shadows Density value.
  8087. * 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.
  8088. * Values less than zero provide a filter of opposite hue.
  8089. */
  8090. get shadowsDensity(): number;
  8091. /**
  8092. * Sets the shadows Density value.
  8093. * 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.
  8094. * Values less than zero provide a filter of opposite hue.
  8095. */
  8096. set shadowsDensity(value: number);
  8097. /**
  8098. * Gets the shadows Saturation value.
  8099. * 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.
  8100. */
  8101. get shadowsSaturation(): number;
  8102. /**
  8103. * Sets the shadows Saturation value.
  8104. * 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.
  8105. */
  8106. set shadowsSaturation(value: number);
  8107. /**
  8108. * Gets the shadows Exposure value.
  8109. * 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.
  8110. */
  8111. get shadowsExposure(): number;
  8112. /**
  8113. * Sets the shadows Exposure value.
  8114. * 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.
  8115. */
  8116. set shadowsExposure(value: number);
  8117. /**
  8118. * Returns the class name
  8119. * @returns The class name
  8120. */
  8121. getClassName(): string;
  8122. /**
  8123. * Binds the color curves to the shader.
  8124. * @param colorCurves The color curve to bind
  8125. * @param effect The effect to bind to
  8126. * @param positiveUniform The positive uniform shader parameter
  8127. * @param neutralUniform The neutral uniform shader parameter
  8128. * @param negativeUniform The negative uniform shader parameter
  8129. */
  8130. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8131. /**
  8132. * Prepare the list of uniforms associated with the ColorCurves effects.
  8133. * @param uniformsList The list of uniforms used in the effect
  8134. */
  8135. static PrepareUniforms(uniformsList: string[]): void;
  8136. /**
  8137. * Returns color grading data based on a hue, density, saturation and exposure value.
  8138. * @param filterHue The hue of the color filter.
  8139. * @param filterDensity The density of the color filter.
  8140. * @param saturation The saturation.
  8141. * @param exposure The exposure.
  8142. * @param result The result data container.
  8143. */
  8144. private getColorGradingDataToRef;
  8145. /**
  8146. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8147. * @param value The input slider value in range [-100,100].
  8148. * @returns Adjusted value.
  8149. */
  8150. private static applyColorGradingSliderNonlinear;
  8151. /**
  8152. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8153. * @param hue The hue (H) input.
  8154. * @param saturation The saturation (S) input.
  8155. * @param brightness The brightness (B) input.
  8156. * @result An RGBA color represented as Vector4.
  8157. */
  8158. private static fromHSBToRef;
  8159. /**
  8160. * Returns a value clamped between min and max
  8161. * @param value The value to clamp
  8162. * @param min The minimum of value
  8163. * @param max The maximum of value
  8164. * @returns The clamped value.
  8165. */
  8166. private static clamp;
  8167. /**
  8168. * Clones the current color curve instance.
  8169. * @return The cloned curves
  8170. */
  8171. clone(): ColorCurves;
  8172. /**
  8173. * Serializes the current color curve instance to a json representation.
  8174. * @return a JSON representation
  8175. */
  8176. serialize(): any;
  8177. /**
  8178. * Parses the color curve from a json representation.
  8179. * @param source the JSON source to parse
  8180. * @return The parsed curves
  8181. */
  8182. static Parse(source: any): ColorCurves;
  8183. }
  8184. }
  8185. declare module BABYLON {
  8186. /**
  8187. * Interface to follow in your material defines to integrate easily the
  8188. * Image proccessing functions.
  8189. * @hidden
  8190. */
  8191. export interface IImageProcessingConfigurationDefines {
  8192. IMAGEPROCESSING: boolean;
  8193. VIGNETTE: boolean;
  8194. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8195. VIGNETTEBLENDMODEOPAQUE: boolean;
  8196. TONEMAPPING: boolean;
  8197. TONEMAPPING_ACES: boolean;
  8198. CONTRAST: boolean;
  8199. EXPOSURE: boolean;
  8200. COLORCURVES: boolean;
  8201. COLORGRADING: boolean;
  8202. COLORGRADING3D: boolean;
  8203. SAMPLER3DGREENDEPTH: boolean;
  8204. SAMPLER3DBGRMAP: boolean;
  8205. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8206. }
  8207. /**
  8208. * @hidden
  8209. */
  8210. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8211. IMAGEPROCESSING: boolean;
  8212. VIGNETTE: boolean;
  8213. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8214. VIGNETTEBLENDMODEOPAQUE: boolean;
  8215. TONEMAPPING: boolean;
  8216. TONEMAPPING_ACES: boolean;
  8217. CONTRAST: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. EXPOSURE: boolean;
  8225. constructor();
  8226. }
  8227. /**
  8228. * This groups together the common properties used for image processing either in direct forward pass
  8229. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8230. * or not.
  8231. */
  8232. export class ImageProcessingConfiguration {
  8233. /**
  8234. * Default tone mapping applied in BabylonJS.
  8235. */
  8236. static readonly TONEMAPPING_STANDARD: number;
  8237. /**
  8238. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8239. * to other engines rendering to increase portability.
  8240. */
  8241. static readonly TONEMAPPING_ACES: number;
  8242. /**
  8243. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8244. */
  8245. colorCurves: Nullable<ColorCurves>;
  8246. private _colorCurvesEnabled;
  8247. /**
  8248. * Gets wether the color curves effect is enabled.
  8249. */
  8250. get colorCurvesEnabled(): boolean;
  8251. /**
  8252. * Sets wether the color curves effect is enabled.
  8253. */
  8254. set colorCurvesEnabled(value: boolean);
  8255. private _colorGradingTexture;
  8256. /**
  8257. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8258. */
  8259. get colorGradingTexture(): Nullable<BaseTexture>;
  8260. /**
  8261. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8262. */
  8263. set colorGradingTexture(value: Nullable<BaseTexture>);
  8264. private _colorGradingEnabled;
  8265. /**
  8266. * Gets wether the color grading effect is enabled.
  8267. */
  8268. get colorGradingEnabled(): boolean;
  8269. /**
  8270. * Sets wether the color grading effect is enabled.
  8271. */
  8272. set colorGradingEnabled(value: boolean);
  8273. private _colorGradingWithGreenDepth;
  8274. /**
  8275. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8276. */
  8277. get colorGradingWithGreenDepth(): boolean;
  8278. /**
  8279. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8280. */
  8281. set colorGradingWithGreenDepth(value: boolean);
  8282. private _colorGradingBGR;
  8283. /**
  8284. * Gets wether the color grading texture contains BGR values.
  8285. */
  8286. get colorGradingBGR(): boolean;
  8287. /**
  8288. * Sets wether the color grading texture contains BGR values.
  8289. */
  8290. set colorGradingBGR(value: boolean);
  8291. /** @hidden */
  8292. _exposure: number;
  8293. /**
  8294. * Gets the Exposure used in the effect.
  8295. */
  8296. get exposure(): number;
  8297. /**
  8298. * Sets the Exposure used in the effect.
  8299. */
  8300. set exposure(value: number);
  8301. private _toneMappingEnabled;
  8302. /**
  8303. * Gets wether the tone mapping effect is enabled.
  8304. */
  8305. get toneMappingEnabled(): boolean;
  8306. /**
  8307. * Sets wether the tone mapping effect is enabled.
  8308. */
  8309. set toneMappingEnabled(value: boolean);
  8310. private _toneMappingType;
  8311. /**
  8312. * Gets the type of tone mapping effect.
  8313. */
  8314. get toneMappingType(): number;
  8315. /**
  8316. * Sets the type of tone mapping effect used in BabylonJS.
  8317. */
  8318. set toneMappingType(value: number);
  8319. protected _contrast: number;
  8320. /**
  8321. * Gets the contrast used in the effect.
  8322. */
  8323. get contrast(): number;
  8324. /**
  8325. * Sets the contrast used in the effect.
  8326. */
  8327. set contrast(value: number);
  8328. /**
  8329. * Vignette stretch size.
  8330. */
  8331. vignetteStretch: number;
  8332. /**
  8333. * Vignette centre X Offset.
  8334. */
  8335. vignetteCentreX: number;
  8336. /**
  8337. * Vignette centre Y Offset.
  8338. */
  8339. vignetteCentreY: number;
  8340. /**
  8341. * Vignette weight or intensity of the vignette effect.
  8342. */
  8343. vignetteWeight: number;
  8344. /**
  8345. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8346. * if vignetteEnabled is set to true.
  8347. */
  8348. vignetteColor: Color4;
  8349. /**
  8350. * Camera field of view used by the Vignette effect.
  8351. */
  8352. vignetteCameraFov: number;
  8353. private _vignetteBlendMode;
  8354. /**
  8355. * Gets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. get vignetteBlendMode(): number;
  8358. /**
  8359. * Sets the vignette blend mode allowing different kind of effect.
  8360. */
  8361. set vignetteBlendMode(value: number);
  8362. private _vignetteEnabled;
  8363. /**
  8364. * Gets wether the vignette effect is enabled.
  8365. */
  8366. get vignetteEnabled(): boolean;
  8367. /**
  8368. * Sets wether the vignette effect is enabled.
  8369. */
  8370. set vignetteEnabled(value: boolean);
  8371. private _applyByPostProcess;
  8372. /**
  8373. * Gets wether the image processing is applied through a post process or not.
  8374. */
  8375. get applyByPostProcess(): boolean;
  8376. /**
  8377. * Sets wether the image processing is applied through a post process or not.
  8378. */
  8379. set applyByPostProcess(value: boolean);
  8380. private _isEnabled;
  8381. /**
  8382. * Gets wether the image processing is enabled or not.
  8383. */
  8384. get isEnabled(): boolean;
  8385. /**
  8386. * Sets wether the image processing is enabled or not.
  8387. */
  8388. set isEnabled(value: boolean);
  8389. /**
  8390. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8391. */
  8392. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8393. /**
  8394. * Method called each time the image processing information changes requires to recompile the effect.
  8395. */
  8396. protected _updateParameters(): void;
  8397. /**
  8398. * Gets the current class name.
  8399. * @return "ImageProcessingConfiguration"
  8400. */
  8401. getClassName(): string;
  8402. /**
  8403. * Prepare the list of uniforms associated with the Image Processing effects.
  8404. * @param uniforms The list of uniforms used in the effect
  8405. * @param defines the list of defines currently in use
  8406. */
  8407. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8408. /**
  8409. * Prepare the list of samplers associated with the Image Processing effects.
  8410. * @param samplersList The list of uniforms used in the effect
  8411. * @param defines the list of defines currently in use
  8412. */
  8413. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8414. /**
  8415. * Prepare the list of defines associated to the shader.
  8416. * @param defines the list of defines to complete
  8417. * @param forPostProcess Define if we are currently in post process mode or not
  8418. */
  8419. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8420. /**
  8421. * Returns true if all the image processing information are ready.
  8422. * @returns True if ready, otherwise, false
  8423. */
  8424. isReady(): boolean;
  8425. /**
  8426. * Binds the image processing to the shader.
  8427. * @param effect The effect to bind to
  8428. * @param overrideAspectRatio Override the aspect ratio of the effect
  8429. */
  8430. bind(effect: Effect, overrideAspectRatio?: number): void;
  8431. /**
  8432. * Clones the current image processing instance.
  8433. * @return The cloned image processing
  8434. */
  8435. clone(): ImageProcessingConfiguration;
  8436. /**
  8437. * Serializes the current image processing instance to a json representation.
  8438. * @return a JSON representation
  8439. */
  8440. serialize(): any;
  8441. /**
  8442. * Parses the image processing from a json representation.
  8443. * @param source the JSON source to parse
  8444. * @return The parsed image processing
  8445. */
  8446. static Parse(source: any): ImageProcessingConfiguration;
  8447. private static _VIGNETTEMODE_MULTIPLY;
  8448. private static _VIGNETTEMODE_OPAQUE;
  8449. /**
  8450. * Used to apply the vignette as a mix with the pixel color.
  8451. */
  8452. static get VIGNETTEMODE_MULTIPLY(): number;
  8453. /**
  8454. * Used to apply the vignette as a replacement of the pixel color.
  8455. */
  8456. static get VIGNETTEMODE_OPAQUE(): number;
  8457. }
  8458. }
  8459. declare module BABYLON {
  8460. /** @hidden */
  8461. export var postprocessVertexShader: {
  8462. name: string;
  8463. shader: string;
  8464. };
  8465. }
  8466. declare module BABYLON {
  8467. interface ThinEngine {
  8468. /**
  8469. * Creates a new render target texture
  8470. * @param size defines the size of the texture
  8471. * @param options defines the options used to create the texture
  8472. * @returns a new render target texture stored in an InternalTexture
  8473. */
  8474. createRenderTargetTexture(size: number | {
  8475. width: number;
  8476. height: number;
  8477. layers?: number;
  8478. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8479. /**
  8480. * Creates a depth stencil texture.
  8481. * This is only available in WebGL 2 or with the depth texture extension available.
  8482. * @param size The size of face edge in the texture.
  8483. * @param options The options defining the texture.
  8484. * @returns The texture
  8485. */
  8486. createDepthStencilTexture(size: number | {
  8487. width: number;
  8488. height: number;
  8489. layers?: number;
  8490. }, options: DepthTextureCreationOptions): InternalTexture;
  8491. /** @hidden */
  8492. _createDepthStencilTexture(size: number | {
  8493. width: number;
  8494. height: number;
  8495. layers?: number;
  8496. }, options: DepthTextureCreationOptions): InternalTexture;
  8497. }
  8498. }
  8499. declare module BABYLON {
  8500. /** Defines supported spaces */
  8501. export enum Space {
  8502. /** Local (object) space */
  8503. LOCAL = 0,
  8504. /** World space */
  8505. WORLD = 1,
  8506. /** Bone space */
  8507. BONE = 2
  8508. }
  8509. /** Defines the 3 main axes */
  8510. export class Axis {
  8511. /** X axis */
  8512. static X: Vector3;
  8513. /** Y axis */
  8514. static Y: Vector3;
  8515. /** Z axis */
  8516. static Z: Vector3;
  8517. }
  8518. }
  8519. declare module BABYLON {
  8520. /**
  8521. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8522. * This is the base of the follow, arc rotate cameras and Free camera
  8523. * @see http://doc.babylonjs.com/features/cameras
  8524. */
  8525. export class TargetCamera extends Camera {
  8526. private static _RigCamTransformMatrix;
  8527. private static _TargetTransformMatrix;
  8528. private static _TargetFocalPoint;
  8529. /**
  8530. * Define the current direction the camera is moving to
  8531. */
  8532. cameraDirection: Vector3;
  8533. /**
  8534. * Define the current rotation the camera is rotating to
  8535. */
  8536. cameraRotation: Vector2;
  8537. /**
  8538. * When set, the up vector of the camera will be updated by the rotation of the camera
  8539. */
  8540. updateUpVectorFromRotation: boolean;
  8541. private _tmpQuaternion;
  8542. /**
  8543. * Define the current rotation of the camera
  8544. */
  8545. rotation: Vector3;
  8546. /**
  8547. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8548. */
  8549. rotationQuaternion: Quaternion;
  8550. /**
  8551. * Define the current speed of the camera
  8552. */
  8553. speed: number;
  8554. /**
  8555. * Add constraint to the camera to prevent it to move freely in all directions and
  8556. * around all axis.
  8557. */
  8558. noRotationConstraint: boolean;
  8559. /**
  8560. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8561. * panning
  8562. */
  8563. invertRotation: boolean;
  8564. /**
  8565. * Speed multiplier for inverse camera panning
  8566. */
  8567. inverseRotationSpeed: number;
  8568. /**
  8569. * Define the current target of the camera as an object or a position.
  8570. */
  8571. lockedTarget: any;
  8572. /** @hidden */
  8573. _currentTarget: Vector3;
  8574. /** @hidden */
  8575. _initialFocalDistance: number;
  8576. /** @hidden */
  8577. _viewMatrix: Matrix;
  8578. /** @hidden */
  8579. _camMatrix: Matrix;
  8580. /** @hidden */
  8581. _cameraTransformMatrix: Matrix;
  8582. /** @hidden */
  8583. _cameraRotationMatrix: Matrix;
  8584. /** @hidden */
  8585. _referencePoint: Vector3;
  8586. /** @hidden */
  8587. _transformedReferencePoint: Vector3;
  8588. protected _globalCurrentTarget: Vector3;
  8589. protected _globalCurrentUpVector: Vector3;
  8590. /** @hidden */
  8591. _reset: () => void;
  8592. private _defaultUp;
  8593. /**
  8594. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8595. * This is the base of the follow, arc rotate cameras and Free camera
  8596. * @see http://doc.babylonjs.com/features/cameras
  8597. * @param name Defines the name of the camera in the scene
  8598. * @param position Defines the start position of the camera in the scene
  8599. * @param scene Defines the scene the camera belongs to
  8600. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8601. */
  8602. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8603. /**
  8604. * Gets the position in front of the camera at a given distance.
  8605. * @param distance The distance from the camera we want the position to be
  8606. * @returns the position
  8607. */
  8608. getFrontPosition(distance: number): Vector3;
  8609. /** @hidden */
  8610. _getLockedTargetPosition(): Nullable<Vector3>;
  8611. private _storedPosition;
  8612. private _storedRotation;
  8613. private _storedRotationQuaternion;
  8614. /**
  8615. * Store current camera state of the camera (fov, position, rotation, etc..)
  8616. * @returns the camera
  8617. */
  8618. storeState(): Camera;
  8619. /**
  8620. * Restored camera state. You must call storeState() first
  8621. * @returns whether it was successful or not
  8622. * @hidden
  8623. */
  8624. _restoreStateValues(): boolean;
  8625. /** @hidden */
  8626. _initCache(): void;
  8627. /** @hidden */
  8628. _updateCache(ignoreParentClass?: boolean): void;
  8629. /** @hidden */
  8630. _isSynchronizedViewMatrix(): boolean;
  8631. /** @hidden */
  8632. _computeLocalCameraSpeed(): number;
  8633. /**
  8634. * Defines the target the camera should look at.
  8635. * @param target Defines the new target as a Vector or a mesh
  8636. */
  8637. setTarget(target: Vector3): void;
  8638. /**
  8639. * Return the current target position of the camera. This value is expressed in local space.
  8640. * @returns the target position
  8641. */
  8642. getTarget(): Vector3;
  8643. /** @hidden */
  8644. _decideIfNeedsToMove(): boolean;
  8645. /** @hidden */
  8646. _updatePosition(): void;
  8647. /** @hidden */
  8648. _checkInputs(): void;
  8649. protected _updateCameraRotationMatrix(): void;
  8650. /**
  8651. * 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)
  8652. * @returns the current camera
  8653. */
  8654. private _rotateUpVectorWithCameraRotationMatrix;
  8655. private _cachedRotationZ;
  8656. private _cachedQuaternionRotationZ;
  8657. /** @hidden */
  8658. _getViewMatrix(): Matrix;
  8659. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8660. /**
  8661. * @hidden
  8662. */
  8663. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8664. /**
  8665. * @hidden
  8666. */
  8667. _updateRigCameras(): void;
  8668. private _getRigCamPositionAndTarget;
  8669. /**
  8670. * Gets the current object class name.
  8671. * @return the class name
  8672. */
  8673. getClassName(): string;
  8674. }
  8675. }
  8676. declare module BABYLON {
  8677. /**
  8678. * Gather the list of keyboard event types as constants.
  8679. */
  8680. export class KeyboardEventTypes {
  8681. /**
  8682. * The keydown event is fired when a key becomes active (pressed).
  8683. */
  8684. static readonly KEYDOWN: number;
  8685. /**
  8686. * The keyup event is fired when a key has been released.
  8687. */
  8688. static readonly KEYUP: number;
  8689. }
  8690. /**
  8691. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8692. */
  8693. export class KeyboardInfo {
  8694. /**
  8695. * Defines the type of event (KeyboardEventTypes)
  8696. */
  8697. type: number;
  8698. /**
  8699. * Defines the related dom event
  8700. */
  8701. event: KeyboardEvent;
  8702. /**
  8703. * Instantiates a new keyboard info.
  8704. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8705. * @param type Defines the type of event (KeyboardEventTypes)
  8706. * @param event Defines the related dom event
  8707. */
  8708. constructor(
  8709. /**
  8710. * Defines the type of event (KeyboardEventTypes)
  8711. */
  8712. type: number,
  8713. /**
  8714. * Defines the related dom event
  8715. */
  8716. event: KeyboardEvent);
  8717. }
  8718. /**
  8719. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8720. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8721. */
  8722. export class KeyboardInfoPre extends KeyboardInfo {
  8723. /**
  8724. * Defines the type of event (KeyboardEventTypes)
  8725. */
  8726. type: number;
  8727. /**
  8728. * Defines the related dom event
  8729. */
  8730. event: KeyboardEvent;
  8731. /**
  8732. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8733. */
  8734. skipOnPointerObservable: boolean;
  8735. /**
  8736. * Instantiates a new keyboard pre info.
  8737. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8738. * @param type Defines the type of event (KeyboardEventTypes)
  8739. * @param event Defines the related dom event
  8740. */
  8741. constructor(
  8742. /**
  8743. * Defines the type of event (KeyboardEventTypes)
  8744. */
  8745. type: number,
  8746. /**
  8747. * Defines the related dom event
  8748. */
  8749. event: KeyboardEvent);
  8750. }
  8751. }
  8752. declare module BABYLON {
  8753. /**
  8754. * Manage the keyboard inputs to control the movement of a free camera.
  8755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8756. */
  8757. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8758. /**
  8759. * Defines the camera the input is attached to.
  8760. */
  8761. camera: FreeCamera;
  8762. /**
  8763. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8764. */
  8765. keysUp: number[];
  8766. /**
  8767. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8768. */
  8769. keysUpward: number[];
  8770. /**
  8771. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8772. */
  8773. keysDown: number[];
  8774. /**
  8775. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8776. */
  8777. keysDownward: number[];
  8778. /**
  8779. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8780. */
  8781. keysLeft: number[];
  8782. /**
  8783. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8784. */
  8785. keysRight: number[];
  8786. private _keys;
  8787. private _onCanvasBlurObserver;
  8788. private _onKeyboardObserver;
  8789. private _engine;
  8790. private _scene;
  8791. /**
  8792. * Attach the input controls to a specific dom element to get the input from.
  8793. * @param element Defines the element the controls should be listened from
  8794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8795. */
  8796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8797. /**
  8798. * Detach the current controls from the specified dom element.
  8799. * @param element Defines the element to stop listening the inputs from
  8800. */
  8801. detachControl(element: Nullable<HTMLElement>): void;
  8802. /**
  8803. * Update the current camera state depending on the inputs that have been used this frame.
  8804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8805. */
  8806. checkInputs(): void;
  8807. /**
  8808. * Gets the class name of the current intput.
  8809. * @returns the class name
  8810. */
  8811. getClassName(): string;
  8812. /** @hidden */
  8813. _onLostFocus(): void;
  8814. /**
  8815. * Get the friendly name associated with the input class.
  8816. * @returns the input friendly name
  8817. */
  8818. getSimpleName(): string;
  8819. }
  8820. }
  8821. declare module BABYLON {
  8822. /**
  8823. * Interface describing all the common properties and methods a shadow light needs to implement.
  8824. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8825. * as well as binding the different shadow properties to the effects.
  8826. */
  8827. export interface IShadowLight extends Light {
  8828. /**
  8829. * The light id in the scene (used in scene.findLighById for instance)
  8830. */
  8831. id: string;
  8832. /**
  8833. * The position the shdow will be casted from.
  8834. */
  8835. position: Vector3;
  8836. /**
  8837. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8838. */
  8839. direction: Vector3;
  8840. /**
  8841. * The transformed position. Position of the light in world space taking parenting in account.
  8842. */
  8843. transformedPosition: Vector3;
  8844. /**
  8845. * The transformed direction. Direction of the light in world space taking parenting in account.
  8846. */
  8847. transformedDirection: Vector3;
  8848. /**
  8849. * The friendly name of the light in the scene.
  8850. */
  8851. name: string;
  8852. /**
  8853. * Defines the shadow projection clipping minimum z value.
  8854. */
  8855. shadowMinZ: number;
  8856. /**
  8857. * Defines the shadow projection clipping maximum z value.
  8858. */
  8859. shadowMaxZ: number;
  8860. /**
  8861. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8862. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8863. */
  8864. computeTransformedInformation(): boolean;
  8865. /**
  8866. * Gets the scene the light belongs to.
  8867. * @returns The scene
  8868. */
  8869. getScene(): Scene;
  8870. /**
  8871. * Callback defining a custom Projection Matrix Builder.
  8872. * This can be used to override the default projection matrix computation.
  8873. */
  8874. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8875. /**
  8876. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8877. * @param matrix The materix to updated with the projection information
  8878. * @param viewMatrix The transform matrix of the light
  8879. * @param renderList The list of mesh to render in the map
  8880. * @returns The current light
  8881. */
  8882. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8883. /**
  8884. * Gets the current depth scale used in ESM.
  8885. * @returns The scale
  8886. */
  8887. getDepthScale(): number;
  8888. /**
  8889. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8890. * @returns true if a cube texture needs to be use
  8891. */
  8892. needCube(): boolean;
  8893. /**
  8894. * Detects if the projection matrix requires to be recomputed this frame.
  8895. * @returns true if it requires to be recomputed otherwise, false.
  8896. */
  8897. needProjectionMatrixCompute(): boolean;
  8898. /**
  8899. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8900. */
  8901. forceProjectionMatrixCompute(): void;
  8902. /**
  8903. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8904. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8905. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8906. */
  8907. getShadowDirection(faceIndex?: number): Vector3;
  8908. /**
  8909. * Gets the minZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the min for
  8911. * @returns the depth min z
  8912. */
  8913. getDepthMinZ(activeCamera: Camera): number;
  8914. /**
  8915. * Gets the maxZ used for shadow according to both the scene and the light.
  8916. * @param activeCamera The camera we are returning the max for
  8917. * @returns the depth max z
  8918. */
  8919. getDepthMaxZ(activeCamera: Camera): number;
  8920. }
  8921. /**
  8922. * Base implementation IShadowLight
  8923. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8924. */
  8925. export abstract class ShadowLight extends Light implements IShadowLight {
  8926. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8927. protected _position: Vector3;
  8928. protected _setPosition(value: Vector3): void;
  8929. /**
  8930. * Sets the position the shadow will be casted from. Also use as the light position for both
  8931. * point and spot lights.
  8932. */
  8933. get position(): Vector3;
  8934. /**
  8935. * Sets the position the shadow will be casted from. Also use as the light position for both
  8936. * point and spot lights.
  8937. */
  8938. set position(value: Vector3);
  8939. protected _direction: Vector3;
  8940. protected _setDirection(value: Vector3): void;
  8941. /**
  8942. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8943. * Also use as the light direction on spot and directional lights.
  8944. */
  8945. get direction(): Vector3;
  8946. /**
  8947. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8948. * Also use as the light direction on spot and directional lights.
  8949. */
  8950. set direction(value: Vector3);
  8951. protected _shadowMinZ: number;
  8952. /**
  8953. * Gets the shadow projection clipping minimum z value.
  8954. */
  8955. get shadowMinZ(): number;
  8956. /**
  8957. * Sets the shadow projection clipping minimum z value.
  8958. */
  8959. set shadowMinZ(value: number);
  8960. protected _shadowMaxZ: number;
  8961. /**
  8962. * Sets the shadow projection clipping maximum z value.
  8963. */
  8964. get shadowMaxZ(): number;
  8965. /**
  8966. * Gets the shadow projection clipping maximum z value.
  8967. */
  8968. set shadowMaxZ(value: number);
  8969. /**
  8970. * Callback defining a custom Projection Matrix Builder.
  8971. * This can be used to override the default projection matrix computation.
  8972. */
  8973. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8974. /**
  8975. * The transformed position. Position of the light in world space taking parenting in account.
  8976. */
  8977. transformedPosition: Vector3;
  8978. /**
  8979. * The transformed direction. Direction of the light in world space taking parenting in account.
  8980. */
  8981. transformedDirection: Vector3;
  8982. private _needProjectionMatrixCompute;
  8983. /**
  8984. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8985. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8986. */
  8987. computeTransformedInformation(): boolean;
  8988. /**
  8989. * Return the depth scale used for the shadow map.
  8990. * @returns the depth scale.
  8991. */
  8992. getDepthScale(): number;
  8993. /**
  8994. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8995. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8996. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8997. */
  8998. getShadowDirection(faceIndex?: number): Vector3;
  8999. /**
  9000. * Returns the ShadowLight absolute position in the World.
  9001. * @returns the position vector in world space
  9002. */
  9003. getAbsolutePosition(): Vector3;
  9004. /**
  9005. * Sets the ShadowLight direction toward the passed target.
  9006. * @param target The point to target in local space
  9007. * @returns the updated ShadowLight direction
  9008. */
  9009. setDirectionToTarget(target: Vector3): Vector3;
  9010. /**
  9011. * Returns the light rotation in euler definition.
  9012. * @returns the x y z rotation in local space.
  9013. */
  9014. getRotation(): Vector3;
  9015. /**
  9016. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9017. * @returns true if a cube texture needs to be use
  9018. */
  9019. needCube(): boolean;
  9020. /**
  9021. * Detects if the projection matrix requires to be recomputed this frame.
  9022. * @returns true if it requires to be recomputed otherwise, false.
  9023. */
  9024. needProjectionMatrixCompute(): boolean;
  9025. /**
  9026. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9027. */
  9028. forceProjectionMatrixCompute(): void;
  9029. /** @hidden */
  9030. _initCache(): void;
  9031. /** @hidden */
  9032. _isSynchronized(): boolean;
  9033. /**
  9034. * Computes the world matrix of the node
  9035. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9036. * @returns the world matrix
  9037. */
  9038. computeWorldMatrix(force?: boolean): Matrix;
  9039. /**
  9040. * Gets the minZ used for shadow according to both the scene and the light.
  9041. * @param activeCamera The camera we are returning the min for
  9042. * @returns the depth min z
  9043. */
  9044. getDepthMinZ(activeCamera: Camera): number;
  9045. /**
  9046. * Gets the maxZ used for shadow according to both the scene and the light.
  9047. * @param activeCamera The camera we are returning the max for
  9048. * @returns the depth max z
  9049. */
  9050. getDepthMaxZ(activeCamera: Camera): number;
  9051. /**
  9052. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9053. * @param matrix The materix to updated with the projection information
  9054. * @param viewMatrix The transform matrix of the light
  9055. * @param renderList The list of mesh to render in the map
  9056. * @returns The current light
  9057. */
  9058. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9059. }
  9060. }
  9061. declare module BABYLON {
  9062. /**
  9063. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9064. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9065. */
  9066. export class EffectFallbacks implements IEffectFallbacks {
  9067. private _defines;
  9068. private _currentRank;
  9069. private _maxRank;
  9070. private _mesh;
  9071. /**
  9072. * Removes the fallback from the bound mesh.
  9073. */
  9074. unBindMesh(): void;
  9075. /**
  9076. * Adds a fallback on the specified property.
  9077. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9078. * @param define The name of the define in the shader
  9079. */
  9080. addFallback(rank: number, define: string): void;
  9081. /**
  9082. * Sets the mesh to use CPU skinning when needing to fallback.
  9083. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9084. * @param mesh The mesh to use the fallbacks.
  9085. */
  9086. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9087. /**
  9088. * Checks to see if more fallbacks are still availible.
  9089. */
  9090. get hasMoreFallbacks(): boolean;
  9091. /**
  9092. * Removes the defines that should be removed when falling back.
  9093. * @param currentDefines defines the current define statements for the shader.
  9094. * @param effect defines the current effect we try to compile
  9095. * @returns The resulting defines with defines of the current rank removed.
  9096. */
  9097. reduce(currentDefines: string, effect: Effect): string;
  9098. }
  9099. }
  9100. declare module BABYLON {
  9101. /**
  9102. * "Static Class" containing the most commonly used helper while dealing with material for
  9103. * rendering purpose.
  9104. *
  9105. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9106. *
  9107. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9108. */
  9109. export class MaterialHelper {
  9110. /**
  9111. * Bind the current view position to an effect.
  9112. * @param effect The effect to be bound
  9113. * @param scene The scene the eyes position is used from
  9114. */
  9115. static BindEyePosition(effect: Effect, scene: Scene): void;
  9116. /**
  9117. * Helps preparing the defines values about the UVs in used in the effect.
  9118. * UVs are shared as much as we can accross channels in the shaders.
  9119. * @param texture The texture we are preparing the UVs for
  9120. * @param defines The defines to update
  9121. * @param key The channel key "diffuse", "specular"... used in the shader
  9122. */
  9123. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9124. /**
  9125. * Binds a texture matrix value to its corrsponding uniform
  9126. * @param texture The texture to bind the matrix for
  9127. * @param uniformBuffer The uniform buffer receivin the data
  9128. * @param key The channel key "diffuse", "specular"... used in the shader
  9129. */
  9130. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9131. /**
  9132. * Gets the current status of the fog (should it be enabled?)
  9133. * @param mesh defines the mesh to evaluate for fog support
  9134. * @param scene defines the hosting scene
  9135. * @returns true if fog must be enabled
  9136. */
  9137. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9138. /**
  9139. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9140. * @param mesh defines the current mesh
  9141. * @param scene defines the current scene
  9142. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9143. * @param pointsCloud defines if point cloud rendering has to be turned on
  9144. * @param fogEnabled defines if fog has to be turned on
  9145. * @param alphaTest defines if alpha testing has to be turned on
  9146. * @param defines defines the current list of defines
  9147. */
  9148. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9149. /**
  9150. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9151. * @param scene defines the current scene
  9152. * @param engine defines the current engine
  9153. * @param defines specifies the list of active defines
  9154. * @param useInstances defines if instances have to be turned on
  9155. * @param useClipPlane defines if clip plane have to be turned on
  9156. */
  9157. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9158. /**
  9159. * Prepares the defines for bones
  9160. * @param mesh The mesh containing the geometry data we will draw
  9161. * @param defines The defines to update
  9162. */
  9163. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9164. /**
  9165. * Prepares the defines for morph targets
  9166. * @param mesh The mesh containing the geometry data we will draw
  9167. * @param defines The defines to update
  9168. */
  9169. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9170. /**
  9171. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9172. * @param mesh The mesh containing the geometry data we will draw
  9173. * @param defines The defines to update
  9174. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9175. * @param useBones Precise whether bones should be used or not (override mesh info)
  9176. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9177. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9178. * @returns false if defines are considered not dirty and have not been checked
  9179. */
  9180. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9181. /**
  9182. * Prepares the defines related to multiview
  9183. * @param scene The scene we are intending to draw
  9184. * @param defines The defines to update
  9185. */
  9186. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9187. /**
  9188. * Prepares the defines related to the light information passed in parameter
  9189. * @param scene The scene we are intending to draw
  9190. * @param mesh The mesh the effect is compiling for
  9191. * @param light The light the effect is compiling for
  9192. * @param lightIndex The index of the light
  9193. * @param defines The defines to update
  9194. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9195. * @param state Defines the current state regarding what is needed (normals, etc...)
  9196. */
  9197. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9198. needNormals: boolean;
  9199. needRebuild: boolean;
  9200. shadowEnabled: boolean;
  9201. specularEnabled: boolean;
  9202. lightmapMode: boolean;
  9203. }): void;
  9204. /**
  9205. * Prepares the defines related to the light information passed in parameter
  9206. * @param scene The scene we are intending to draw
  9207. * @param mesh The mesh the effect is compiling for
  9208. * @param defines The defines to update
  9209. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9210. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9211. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9212. * @returns true if normals will be required for the rest of the effect
  9213. */
  9214. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9215. /**
  9216. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9217. * @param lightIndex defines the light index
  9218. * @param uniformsList The uniform list
  9219. * @param samplersList The sampler list
  9220. * @param projectedLightTexture defines if projected texture must be used
  9221. * @param uniformBuffersList defines an optional list of uniform buffers
  9222. */
  9223. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9224. /**
  9225. * Prepares the uniforms and samplers list to be used in the effect
  9226. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9227. * @param samplersList The sampler list
  9228. * @param defines The defines helping in the list generation
  9229. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9230. */
  9231. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9232. /**
  9233. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9234. * @param defines The defines to update while falling back
  9235. * @param fallbacks The authorized effect fallbacks
  9236. * @param maxSimultaneousLights The maximum number of lights allowed
  9237. * @param rank the current rank of the Effect
  9238. * @returns The newly affected rank
  9239. */
  9240. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9241. private static _TmpMorphInfluencers;
  9242. /**
  9243. * Prepares the list of attributes required for morph targets according to the effect defines.
  9244. * @param attribs The current list of supported attribs
  9245. * @param mesh The mesh to prepare the morph targets attributes for
  9246. * @param influencers The number of influencers
  9247. */
  9248. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9249. /**
  9250. * Prepares the list of attributes required for morph targets according to the effect defines.
  9251. * @param attribs The current list of supported attribs
  9252. * @param mesh The mesh to prepare the morph targets attributes for
  9253. * @param defines The current Defines of the effect
  9254. */
  9255. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9256. /**
  9257. * Prepares the list of attributes required for bones according to the effect defines.
  9258. * @param attribs The current list of supported attribs
  9259. * @param mesh The mesh to prepare the bones attributes for
  9260. * @param defines The current Defines of the effect
  9261. * @param fallbacks The current efffect fallback strategy
  9262. */
  9263. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9264. /**
  9265. * Check and prepare the list of attributes required for instances according to the effect defines.
  9266. * @param attribs The current list of supported attribs
  9267. * @param defines The current MaterialDefines of the effect
  9268. */
  9269. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9270. /**
  9271. * Add the list of attributes required for instances to the attribs array.
  9272. * @param attribs The current list of supported attribs
  9273. */
  9274. static PushAttributesForInstances(attribs: string[]): void;
  9275. /**
  9276. * Binds the light information to the effect.
  9277. * @param light The light containing the generator
  9278. * @param effect The effect we are binding the data to
  9279. * @param lightIndex The light index in the effect used to render
  9280. */
  9281. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9282. /**
  9283. * Binds the lights information from the scene to the effect for the given mesh.
  9284. * @param light Light to bind
  9285. * @param lightIndex Light index
  9286. * @param scene The scene where the light belongs to
  9287. * @param effect The effect we are binding the data to
  9288. * @param useSpecular Defines if specular is supported
  9289. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9290. */
  9291. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9292. /**
  9293. * Binds the lights information from the scene to the effect for the given mesh.
  9294. * @param scene The scene the lights belongs to
  9295. * @param mesh The mesh we are binding the information to render
  9296. * @param effect The effect we are binding the data to
  9297. * @param defines The generated defines for the effect
  9298. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9299. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9300. */
  9301. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9302. private static _tempFogColor;
  9303. /**
  9304. * Binds the fog information from the scene to the effect for the given mesh.
  9305. * @param scene The scene the lights belongs to
  9306. * @param mesh The mesh we are binding the information to render
  9307. * @param effect The effect we are binding the data to
  9308. * @param linearSpace Defines if the fog effect is applied in linear space
  9309. */
  9310. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9311. /**
  9312. * Binds the bones information from the mesh to the effect.
  9313. * @param mesh The mesh we are binding the information to render
  9314. * @param effect The effect we are binding the data to
  9315. */
  9316. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9317. /**
  9318. * Binds the morph targets information from the mesh to the effect.
  9319. * @param abstractMesh The mesh we are binding the information to render
  9320. * @param effect The effect we are binding the data to
  9321. */
  9322. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9323. /**
  9324. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9325. * @param defines The generated defines used in the effect
  9326. * @param effect The effect we are binding the data to
  9327. * @param scene The scene we are willing to render with logarithmic scale for
  9328. */
  9329. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9330. /**
  9331. * Binds the clip plane information from the scene to the effect.
  9332. * @param scene The scene the clip plane information are extracted from
  9333. * @param effect The effect we are binding the data to
  9334. */
  9335. static BindClipPlane(effect: Effect, scene: Scene): void;
  9336. }
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var packingFunctions: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var shadowMapFragmentDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var clipPlaneFragmentDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var clipPlaneFragment: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var shadowMapFragment: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var shadowMapPixelShader: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var bonesDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var morphTargetsVertexGlobalDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var morphTargetsVertexDeclaration: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var instancesDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var helperFunctions: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var shadowMapVertexDeclaration: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /** @hidden */
  9424. export var clipPlaneVertexDeclaration: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module BABYLON {
  9430. /** @hidden */
  9431. export var morphTargetsVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module BABYLON {
  9437. /** @hidden */
  9438. export var instancesVertex: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module BABYLON {
  9444. /** @hidden */
  9445. export var bonesVertex: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module BABYLON {
  9451. /** @hidden */
  9452. export var shadowMapVertexNormalBias: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module BABYLON {
  9458. /** @hidden */
  9459. export var shadowMapVertexMetric: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module BABYLON {
  9465. /** @hidden */
  9466. export var clipPlaneVertex: {
  9467. name: string;
  9468. shader: string;
  9469. };
  9470. }
  9471. declare module BABYLON {
  9472. /** @hidden */
  9473. export var shadowMapVertexShader: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module BABYLON {
  9479. /** @hidden */
  9480. export var depthBoxBlurPixelShader: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module BABYLON {
  9486. /**
  9487. * Class representing a ray with position and direction
  9488. */
  9489. export class Ray {
  9490. /** origin point */
  9491. origin: Vector3;
  9492. /** direction */
  9493. direction: Vector3;
  9494. /** length of the ray */
  9495. length: number;
  9496. private static readonly TmpVector3;
  9497. private _tmpRay;
  9498. /**
  9499. * Creates a new ray
  9500. * @param origin origin point
  9501. * @param direction direction
  9502. * @param length length of the ray
  9503. */
  9504. constructor(
  9505. /** origin point */
  9506. origin: Vector3,
  9507. /** direction */
  9508. direction: Vector3,
  9509. /** length of the ray */
  9510. length?: number);
  9511. /**
  9512. * Checks if the ray intersects a box
  9513. * This does not account for the ray lenght by design to improve perfs.
  9514. * @param minimum bound of the box
  9515. * @param maximum bound of the box
  9516. * @param intersectionTreshold extra extend to be added to the box in all direction
  9517. * @returns if the box was hit
  9518. */
  9519. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9520. /**
  9521. * Checks if the ray intersects a box
  9522. * This does not account for the ray lenght by design to improve perfs.
  9523. * @param box the bounding box to check
  9524. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9525. * @returns if the box was hit
  9526. */
  9527. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9528. /**
  9529. * If the ray hits a sphere
  9530. * @param sphere the bounding sphere to check
  9531. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9532. * @returns true if it hits the sphere
  9533. */
  9534. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9535. /**
  9536. * If the ray hits a triange
  9537. * @param vertex0 triangle vertex
  9538. * @param vertex1 triangle vertex
  9539. * @param vertex2 triangle vertex
  9540. * @returns intersection information if hit
  9541. */
  9542. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9543. /**
  9544. * Checks if ray intersects a plane
  9545. * @param plane the plane to check
  9546. * @returns the distance away it was hit
  9547. */
  9548. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9549. /**
  9550. * Calculate the intercept of a ray on a given axis
  9551. * @param axis to check 'x' | 'y' | 'z'
  9552. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9553. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9554. */
  9555. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9556. /**
  9557. * Checks if ray intersects a mesh
  9558. * @param mesh the mesh to check
  9559. * @param fastCheck if only the bounding box should checked
  9560. * @returns picking info of the intersecton
  9561. */
  9562. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9563. /**
  9564. * Checks if ray intersects a mesh
  9565. * @param meshes the meshes to check
  9566. * @param fastCheck if only the bounding box should checked
  9567. * @param results array to store result in
  9568. * @returns Array of picking infos
  9569. */
  9570. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9571. private _comparePickingInfo;
  9572. private static smallnum;
  9573. private static rayl;
  9574. /**
  9575. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9576. * @param sega the first point of the segment to test the intersection against
  9577. * @param segb the second point of the segment to test the intersection against
  9578. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9579. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9580. */
  9581. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9582. /**
  9583. * Update the ray from viewport position
  9584. * @param x position
  9585. * @param y y position
  9586. * @param viewportWidth viewport width
  9587. * @param viewportHeight viewport height
  9588. * @param world world matrix
  9589. * @param view view matrix
  9590. * @param projection projection matrix
  9591. * @returns this ray updated
  9592. */
  9593. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9594. /**
  9595. * Creates a ray with origin and direction of 0,0,0
  9596. * @returns the new ray
  9597. */
  9598. static Zero(): Ray;
  9599. /**
  9600. * Creates a new ray from screen space and viewport
  9601. * @param x position
  9602. * @param y y position
  9603. * @param viewportWidth viewport width
  9604. * @param viewportHeight viewport height
  9605. * @param world world matrix
  9606. * @param view view matrix
  9607. * @param projection projection matrix
  9608. * @returns new ray
  9609. */
  9610. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9611. /**
  9612. * 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
  9613. * transformed to the given world matrix.
  9614. * @param origin The origin point
  9615. * @param end The end point
  9616. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9617. * @returns the new ray
  9618. */
  9619. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9620. /**
  9621. * Transforms a ray by a matrix
  9622. * @param ray ray to transform
  9623. * @param matrix matrix to apply
  9624. * @returns the resulting new ray
  9625. */
  9626. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9627. /**
  9628. * Transforms a ray by a matrix
  9629. * @param ray ray to transform
  9630. * @param matrix matrix to apply
  9631. * @param result ray to store result in
  9632. */
  9633. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9634. /**
  9635. * Unproject a ray from screen space to object space
  9636. * @param sourceX defines the screen space x coordinate to use
  9637. * @param sourceY defines the screen space y coordinate to use
  9638. * @param viewportWidth defines the current width of the viewport
  9639. * @param viewportHeight defines the current height of the viewport
  9640. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9641. * @param view defines the view matrix to use
  9642. * @param projection defines the projection matrix to use
  9643. */
  9644. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9645. }
  9646. /**
  9647. * Type used to define predicate used to select faces when a mesh intersection is detected
  9648. */
  9649. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9650. interface Scene {
  9651. /** @hidden */
  9652. _tempPickingRay: Nullable<Ray>;
  9653. /** @hidden */
  9654. _cachedRayForTransform: Ray;
  9655. /** @hidden */
  9656. _pickWithRayInverseMatrix: Matrix;
  9657. /** @hidden */
  9658. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9659. /** @hidden */
  9660. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9661. }
  9662. }
  9663. declare module BABYLON {
  9664. /**
  9665. * Groups all the scene component constants in one place to ease maintenance.
  9666. * @hidden
  9667. */
  9668. export class SceneComponentConstants {
  9669. static readonly NAME_EFFECTLAYER: string;
  9670. static readonly NAME_LAYER: string;
  9671. static readonly NAME_LENSFLARESYSTEM: string;
  9672. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9673. static readonly NAME_PARTICLESYSTEM: string;
  9674. static readonly NAME_GAMEPAD: string;
  9675. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9676. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9677. static readonly NAME_DEPTHRENDERER: string;
  9678. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9679. static readonly NAME_SPRITE: string;
  9680. static readonly NAME_OUTLINERENDERER: string;
  9681. static readonly NAME_PROCEDURALTEXTURE: string;
  9682. static readonly NAME_SHADOWGENERATOR: string;
  9683. static readonly NAME_OCTREE: string;
  9684. static readonly NAME_PHYSICSENGINE: string;
  9685. static readonly NAME_AUDIO: string;
  9686. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9687. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9688. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9689. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9690. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9691. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9692. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9693. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9694. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9695. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9696. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9697. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9698. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9699. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9700. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9701. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9702. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9703. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9704. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9705. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9706. static readonly STEP_AFTERRENDER_AUDIO: number;
  9707. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9708. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9709. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9710. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9711. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9712. static readonly STEP_POINTERMOVE_SPRITE: number;
  9713. static readonly STEP_POINTERDOWN_SPRITE: number;
  9714. static readonly STEP_POINTERUP_SPRITE: number;
  9715. }
  9716. /**
  9717. * This represents a scene component.
  9718. *
  9719. * This is used to decouple the dependency the scene is having on the different workloads like
  9720. * layers, post processes...
  9721. */
  9722. export interface ISceneComponent {
  9723. /**
  9724. * The name of the component. Each component must have a unique name.
  9725. */
  9726. name: string;
  9727. /**
  9728. * The scene the component belongs to.
  9729. */
  9730. scene: Scene;
  9731. /**
  9732. * Register the component to one instance of a scene.
  9733. */
  9734. register(): void;
  9735. /**
  9736. * Rebuilds the elements related to this component in case of
  9737. * context lost for instance.
  9738. */
  9739. rebuild(): void;
  9740. /**
  9741. * Disposes the component and the associated ressources.
  9742. */
  9743. dispose(): void;
  9744. }
  9745. /**
  9746. * This represents a SERIALIZABLE scene component.
  9747. *
  9748. * This extends Scene Component to add Serialization methods on top.
  9749. */
  9750. export interface ISceneSerializableComponent extends ISceneComponent {
  9751. /**
  9752. * Adds all the elements from the container to the scene
  9753. * @param container the container holding the elements
  9754. */
  9755. addFromContainer(container: AbstractScene): void;
  9756. /**
  9757. * Removes all the elements in the container from the scene
  9758. * @param container contains the elements to remove
  9759. * @param dispose if the removed element should be disposed (default: false)
  9760. */
  9761. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9762. /**
  9763. * Serializes the component data to the specified json object
  9764. * @param serializationObject The object to serialize to
  9765. */
  9766. serialize(serializationObject: any): void;
  9767. }
  9768. /**
  9769. * Strong typing of a Mesh related stage step action
  9770. */
  9771. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9772. /**
  9773. * Strong typing of a Evaluate Sub Mesh related stage step action
  9774. */
  9775. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9776. /**
  9777. * Strong typing of a Active Mesh related stage step action
  9778. */
  9779. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9780. /**
  9781. * Strong typing of a Camera related stage step action
  9782. */
  9783. export type CameraStageAction = (camera: Camera) => void;
  9784. /**
  9785. * Strong typing of a Camera Frame buffer related stage step action
  9786. */
  9787. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9788. /**
  9789. * Strong typing of a Render Target related stage step action
  9790. */
  9791. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9792. /**
  9793. * Strong typing of a RenderingGroup related stage step action
  9794. */
  9795. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9796. /**
  9797. * Strong typing of a Mesh Render related stage step action
  9798. */
  9799. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9800. /**
  9801. * Strong typing of a simple stage step action
  9802. */
  9803. export type SimpleStageAction = () => void;
  9804. /**
  9805. * Strong typing of a render target action.
  9806. */
  9807. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9808. /**
  9809. * Strong typing of a pointer move action.
  9810. */
  9811. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9812. /**
  9813. * Strong typing of a pointer up/down action.
  9814. */
  9815. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9816. /**
  9817. * Representation of a stage in the scene (Basically a list of ordered steps)
  9818. * @hidden
  9819. */
  9820. export class Stage<T extends Function> extends Array<{
  9821. index: number;
  9822. component: ISceneComponent;
  9823. action: T;
  9824. }> {
  9825. /**
  9826. * Hide ctor from the rest of the world.
  9827. * @param items The items to add.
  9828. */
  9829. private constructor();
  9830. /**
  9831. * Creates a new Stage.
  9832. * @returns A new instance of a Stage
  9833. */
  9834. static Create<T extends Function>(): Stage<T>;
  9835. /**
  9836. * Registers a step in an ordered way in the targeted stage.
  9837. * @param index Defines the position to register the step in
  9838. * @param component Defines the component attached to the step
  9839. * @param action Defines the action to launch during the step
  9840. */
  9841. registerStep(index: number, component: ISceneComponent, action: T): void;
  9842. /**
  9843. * Clears all the steps from the stage.
  9844. */
  9845. clear(): void;
  9846. }
  9847. }
  9848. declare module BABYLON {
  9849. interface Scene {
  9850. /** @hidden */
  9851. _pointerOverSprite: Nullable<Sprite>;
  9852. /** @hidden */
  9853. _pickedDownSprite: Nullable<Sprite>;
  9854. /** @hidden */
  9855. _tempSpritePickingRay: Nullable<Ray>;
  9856. /**
  9857. * All of the sprite managers added to this scene
  9858. * @see http://doc.babylonjs.com/babylon101/sprites
  9859. */
  9860. spriteManagers: Array<ISpriteManager>;
  9861. /**
  9862. * An event triggered when sprites rendering is about to start
  9863. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9864. */
  9865. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9866. /**
  9867. * An event triggered when sprites rendering is done
  9868. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9869. */
  9870. onAfterSpritesRenderingObservable: Observable<Scene>;
  9871. /** @hidden */
  9872. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9873. /** Launch a ray to try to pick a sprite in the scene
  9874. * @param x position on screen
  9875. * @param y position on screen
  9876. * @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
  9877. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9878. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9879. * @returns a PickingInfo
  9880. */
  9881. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9882. /** Use the given ray to pick a sprite in the scene
  9883. * @param ray The ray (in world space) to use to pick meshes
  9884. * @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
  9885. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9886. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9887. * @returns a PickingInfo
  9888. */
  9889. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9890. /** @hidden */
  9891. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9892. /** Launch a ray to try to pick sprites in the scene
  9893. * @param x position on screen
  9894. * @param y position on screen
  9895. * @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
  9896. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9897. * @returns a PickingInfo array
  9898. */
  9899. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9900. /** Use the given ray to pick sprites in the scene
  9901. * @param ray The ray (in world space) to use to pick meshes
  9902. * @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
  9903. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9904. * @returns a PickingInfo array
  9905. */
  9906. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9907. /**
  9908. * Force the sprite under the pointer
  9909. * @param sprite defines the sprite to use
  9910. */
  9911. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9912. /**
  9913. * Gets the sprite under the pointer
  9914. * @returns a Sprite or null if no sprite is under the pointer
  9915. */
  9916. getPointerOverSprite(): Nullable<Sprite>;
  9917. }
  9918. /**
  9919. * Defines the sprite scene component responsible to manage sprites
  9920. * in a given scene.
  9921. */
  9922. export class SpriteSceneComponent implements ISceneComponent {
  9923. /**
  9924. * The component name helpfull to identify the component in the list of scene components.
  9925. */
  9926. readonly name: string;
  9927. /**
  9928. * The scene the component belongs to.
  9929. */
  9930. scene: Scene;
  9931. /** @hidden */
  9932. private _spritePredicate;
  9933. /**
  9934. * Creates a new instance of the component for the given scene
  9935. * @param scene Defines the scene to register the component in
  9936. */
  9937. constructor(scene: Scene);
  9938. /**
  9939. * Registers the component in a given scene
  9940. */
  9941. register(): void;
  9942. /**
  9943. * Rebuilds the elements related to this component in case of
  9944. * context lost for instance.
  9945. */
  9946. rebuild(): void;
  9947. /**
  9948. * Disposes the component and the associated ressources.
  9949. */
  9950. dispose(): void;
  9951. private _pickSpriteButKeepRay;
  9952. private _pointerMove;
  9953. private _pointerDown;
  9954. private _pointerUp;
  9955. }
  9956. }
  9957. declare module BABYLON {
  9958. /** @hidden */
  9959. export var fogFragmentDeclaration: {
  9960. name: string;
  9961. shader: string;
  9962. };
  9963. }
  9964. declare module BABYLON {
  9965. /** @hidden */
  9966. export var fogFragment: {
  9967. name: string;
  9968. shader: string;
  9969. };
  9970. }
  9971. declare module BABYLON {
  9972. /** @hidden */
  9973. export var spritesPixelShader: {
  9974. name: string;
  9975. shader: string;
  9976. };
  9977. }
  9978. declare module BABYLON {
  9979. /** @hidden */
  9980. export var fogVertexDeclaration: {
  9981. name: string;
  9982. shader: string;
  9983. };
  9984. }
  9985. declare module BABYLON {
  9986. /** @hidden */
  9987. export var spritesVertexShader: {
  9988. name: string;
  9989. shader: string;
  9990. };
  9991. }
  9992. declare module BABYLON {
  9993. /**
  9994. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9995. */
  9996. export interface ISpriteManager extends IDisposable {
  9997. /**
  9998. * Restricts the camera to viewing objects with the same layerMask.
  9999. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10000. */
  10001. layerMask: number;
  10002. /**
  10003. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10004. */
  10005. isPickable: boolean;
  10006. /**
  10007. * Specifies the rendering group id for this mesh (0 by default)
  10008. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10009. */
  10010. renderingGroupId: number;
  10011. /**
  10012. * Defines the list of sprites managed by the manager.
  10013. */
  10014. sprites: Array<Sprite>;
  10015. /**
  10016. * Tests the intersection of a sprite with a specific ray.
  10017. * @param ray The ray we are sending to test the collision
  10018. * @param camera The camera space we are sending rays in
  10019. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10020. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10021. * @returns picking info or null.
  10022. */
  10023. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10024. /**
  10025. * Intersects the sprites with a ray
  10026. * @param ray defines the ray to intersect with
  10027. * @param camera defines the current active camera
  10028. * @param predicate defines a predicate used to select candidate sprites
  10029. * @returns null if no hit or a PickingInfo array
  10030. */
  10031. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10032. /**
  10033. * Renders the list of sprites on screen.
  10034. */
  10035. render(): void;
  10036. }
  10037. /**
  10038. * Class used to manage multiple sprites on the same spritesheet
  10039. * @see http://doc.babylonjs.com/babylon101/sprites
  10040. */
  10041. export class SpriteManager implements ISpriteManager {
  10042. /** defines the manager's name */
  10043. name: string;
  10044. /** Gets the list of sprites */
  10045. sprites: Sprite[];
  10046. /** Gets or sets the rendering group id (0 by default) */
  10047. renderingGroupId: number;
  10048. /** Gets or sets camera layer mask */
  10049. layerMask: number;
  10050. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10051. fogEnabled: boolean;
  10052. /** Gets or sets a boolean indicating if the sprites are pickable */
  10053. isPickable: boolean;
  10054. /** Defines the default width of a cell in the spritesheet */
  10055. cellWidth: number;
  10056. /** Defines the default height of a cell in the spritesheet */
  10057. cellHeight: number;
  10058. /** Associative array from JSON sprite data file */
  10059. private _cellData;
  10060. /** Array of sprite names from JSON sprite data file */
  10061. private _spriteMap;
  10062. /** True when packed cell data from JSON file is ready*/
  10063. private _packedAndReady;
  10064. private _textureContent;
  10065. /**
  10066. * An event triggered when the manager is disposed.
  10067. */
  10068. onDisposeObservable: Observable<SpriteManager>;
  10069. private _onDisposeObserver;
  10070. /**
  10071. * Callback called when the manager is disposed
  10072. */
  10073. set onDispose(callback: () => void);
  10074. private _capacity;
  10075. private _fromPacked;
  10076. private _spriteTexture;
  10077. private _epsilon;
  10078. private _scene;
  10079. private _vertexData;
  10080. private _buffer;
  10081. private _vertexBuffers;
  10082. private _indexBuffer;
  10083. private _effectBase;
  10084. private _effectFog;
  10085. /**
  10086. * Gets or sets the spritesheet texture
  10087. */
  10088. get texture(): Texture;
  10089. set texture(value: Texture);
  10090. private _blendMode;
  10091. /**
  10092. * Blend mode use to render the particle, it can be any of
  10093. * the static Constants.ALPHA_x properties provided in this class.
  10094. * Default value is Constants.ALPHA_COMBINE
  10095. */
  10096. get blendMode(): number;
  10097. set blendMode(blendMode: number);
  10098. /** Disables writing to the depth buffer when rendering the sprites.
  10099. * It can be handy to disable depth writing when using textures without alpha channel
  10100. * and setting some specific blend modes.
  10101. */
  10102. disableDepthWrite: boolean;
  10103. /**
  10104. * Creates a new sprite manager
  10105. * @param name defines the manager's name
  10106. * @param imgUrl defines the sprite sheet url
  10107. * @param capacity defines the maximum allowed number of sprites
  10108. * @param cellSize defines the size of a sprite cell
  10109. * @param scene defines the hosting scene
  10110. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10111. * @param samplingMode defines the smapling mode to use with spritesheet
  10112. * @param fromPacked set to false; do not alter
  10113. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10114. */
  10115. constructor(
  10116. /** defines the manager's name */
  10117. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10118. private _makePacked;
  10119. private _appendSpriteVertex;
  10120. private _checkTextureAlpha;
  10121. /**
  10122. * Intersects the sprites with a ray
  10123. * @param ray defines the ray to intersect with
  10124. * @param camera defines the current active camera
  10125. * @param predicate defines a predicate used to select candidate sprites
  10126. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10127. * @returns null if no hit or a PickingInfo
  10128. */
  10129. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10130. /**
  10131. * Intersects the sprites with a ray
  10132. * @param ray defines the ray to intersect with
  10133. * @param camera defines the current active camera
  10134. * @param predicate defines a predicate used to select candidate sprites
  10135. * @returns null if no hit or a PickingInfo array
  10136. */
  10137. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10138. /**
  10139. * Render all child sprites
  10140. */
  10141. render(): void;
  10142. /**
  10143. * Release associated resources
  10144. */
  10145. dispose(): void;
  10146. }
  10147. }
  10148. declare module BABYLON {
  10149. /** Interface used by value gradients (color, factor, ...) */
  10150. export interface IValueGradient {
  10151. /**
  10152. * Gets or sets the gradient value (between 0 and 1)
  10153. */
  10154. gradient: number;
  10155. }
  10156. /** Class used to store color4 gradient */
  10157. export class ColorGradient implements IValueGradient {
  10158. /**
  10159. * Gets or sets the gradient value (between 0 and 1)
  10160. */
  10161. gradient: number;
  10162. /**
  10163. * Gets or sets first associated color
  10164. */
  10165. color1: Color4;
  10166. /**
  10167. * Gets or sets second associated color
  10168. */
  10169. color2?: Color4 | undefined;
  10170. /**
  10171. * Creates a new color4 gradient
  10172. * @param gradient gets or sets the gradient value (between 0 and 1)
  10173. * @param color1 gets or sets first associated color
  10174. * @param color2 gets or sets first second color
  10175. */
  10176. constructor(
  10177. /**
  10178. * Gets or sets the gradient value (between 0 and 1)
  10179. */
  10180. gradient: number,
  10181. /**
  10182. * Gets or sets first associated color
  10183. */
  10184. color1: Color4,
  10185. /**
  10186. * Gets or sets second associated color
  10187. */
  10188. color2?: Color4 | undefined);
  10189. /**
  10190. * Will get a color picked randomly between color1 and color2.
  10191. * If color2 is undefined then color1 will be used
  10192. * @param result defines the target Color4 to store the result in
  10193. */
  10194. getColorToRef(result: Color4): void;
  10195. }
  10196. /** Class used to store color 3 gradient */
  10197. export class Color3Gradient implements IValueGradient {
  10198. /**
  10199. * Gets or sets the gradient value (between 0 and 1)
  10200. */
  10201. gradient: number;
  10202. /**
  10203. * Gets or sets the associated color
  10204. */
  10205. color: Color3;
  10206. /**
  10207. * Creates a new color3 gradient
  10208. * @param gradient gets or sets the gradient value (between 0 and 1)
  10209. * @param color gets or sets associated color
  10210. */
  10211. constructor(
  10212. /**
  10213. * Gets or sets the gradient value (between 0 and 1)
  10214. */
  10215. gradient: number,
  10216. /**
  10217. * Gets or sets the associated color
  10218. */
  10219. color: Color3);
  10220. }
  10221. /** Class used to store factor gradient */
  10222. export class FactorGradient implements IValueGradient {
  10223. /**
  10224. * Gets or sets the gradient value (between 0 and 1)
  10225. */
  10226. gradient: number;
  10227. /**
  10228. * Gets or sets first associated factor
  10229. */
  10230. factor1: number;
  10231. /**
  10232. * Gets or sets second associated factor
  10233. */
  10234. factor2?: number | undefined;
  10235. /**
  10236. * Creates a new factor gradient
  10237. * @param gradient gets or sets the gradient value (between 0 and 1)
  10238. * @param factor1 gets or sets first associated factor
  10239. * @param factor2 gets or sets second associated factor
  10240. */
  10241. constructor(
  10242. /**
  10243. * Gets or sets the gradient value (between 0 and 1)
  10244. */
  10245. gradient: number,
  10246. /**
  10247. * Gets or sets first associated factor
  10248. */
  10249. factor1: number,
  10250. /**
  10251. * Gets or sets second associated factor
  10252. */
  10253. factor2?: number | undefined);
  10254. /**
  10255. * Will get a number picked randomly between factor1 and factor2.
  10256. * If factor2 is undefined then factor1 will be used
  10257. * @returns the picked number
  10258. */
  10259. getFactor(): number;
  10260. }
  10261. /**
  10262. * Helper used to simplify some generic gradient tasks
  10263. */
  10264. export class GradientHelper {
  10265. /**
  10266. * Gets the current gradient from an array of IValueGradient
  10267. * @param ratio defines the current ratio to get
  10268. * @param gradients defines the array of IValueGradient
  10269. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10270. */
  10271. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10272. }
  10273. }
  10274. declare module BABYLON {
  10275. /**
  10276. * Interface for the size containing width and height
  10277. */
  10278. export interface ISize {
  10279. /**
  10280. * Width
  10281. */
  10282. width: number;
  10283. /**
  10284. * Heighht
  10285. */
  10286. height: number;
  10287. }
  10288. /**
  10289. * Size containing widht and height
  10290. */
  10291. export class Size implements ISize {
  10292. /**
  10293. * Width
  10294. */
  10295. width: number;
  10296. /**
  10297. * Height
  10298. */
  10299. height: number;
  10300. /**
  10301. * Creates a Size object from the given width and height (floats).
  10302. * @param width width of the new size
  10303. * @param height height of the new size
  10304. */
  10305. constructor(width: number, height: number);
  10306. /**
  10307. * Returns a string with the Size width and height
  10308. * @returns a string with the Size width and height
  10309. */
  10310. toString(): string;
  10311. /**
  10312. * "Size"
  10313. * @returns the string "Size"
  10314. */
  10315. getClassName(): string;
  10316. /**
  10317. * Returns the Size hash code.
  10318. * @returns a hash code for a unique width and height
  10319. */
  10320. getHashCode(): number;
  10321. /**
  10322. * Updates the current size from the given one.
  10323. * @param src the given size
  10324. */
  10325. copyFrom(src: Size): void;
  10326. /**
  10327. * Updates in place the current Size from the given floats.
  10328. * @param width width of the new size
  10329. * @param height height of the new size
  10330. * @returns the updated Size.
  10331. */
  10332. copyFromFloats(width: number, height: number): Size;
  10333. /**
  10334. * Updates in place the current Size from the given floats.
  10335. * @param width width to set
  10336. * @param height height to set
  10337. * @returns the updated Size.
  10338. */
  10339. set(width: number, height: number): Size;
  10340. /**
  10341. * Multiplies the width and height by numbers
  10342. * @param w factor to multiple the width by
  10343. * @param h factor to multiple the height by
  10344. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10345. */
  10346. multiplyByFloats(w: number, h: number): Size;
  10347. /**
  10348. * Clones the size
  10349. * @returns a new Size copied from the given one.
  10350. */
  10351. clone(): Size;
  10352. /**
  10353. * True if the current Size and the given one width and height are strictly equal.
  10354. * @param other the other size to compare against
  10355. * @returns True if the current Size and the given one width and height are strictly equal.
  10356. */
  10357. equals(other: Size): boolean;
  10358. /**
  10359. * The surface of the Size : width * height (float).
  10360. */
  10361. get surface(): number;
  10362. /**
  10363. * Create a new size of zero
  10364. * @returns a new Size set to (0.0, 0.0)
  10365. */
  10366. static Zero(): Size;
  10367. /**
  10368. * Sums the width and height of two sizes
  10369. * @param otherSize size to add to this size
  10370. * @returns a new Size set as the addition result of the current Size and the given one.
  10371. */
  10372. add(otherSize: Size): Size;
  10373. /**
  10374. * Subtracts the width and height of two
  10375. * @param otherSize size to subtract to this size
  10376. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10377. */
  10378. subtract(otherSize: Size): Size;
  10379. /**
  10380. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10381. * @param start starting size to lerp between
  10382. * @param end end size to lerp between
  10383. * @param amount amount to lerp between the start and end values
  10384. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10385. */
  10386. static Lerp(start: Size, end: Size, amount: number): Size;
  10387. }
  10388. }
  10389. declare module BABYLON {
  10390. interface ThinEngine {
  10391. /**
  10392. * Creates a dynamic texture
  10393. * @param width defines the width of the texture
  10394. * @param height defines the height of the texture
  10395. * @param generateMipMaps defines if the engine should generate the mip levels
  10396. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10397. * @returns the dynamic texture inside an InternalTexture
  10398. */
  10399. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10400. /**
  10401. * Update the content of a dynamic texture
  10402. * @param texture defines the texture to update
  10403. * @param canvas defines the canvas containing the source
  10404. * @param invertY defines if data must be stored with Y axis inverted
  10405. * @param premulAlpha defines if alpha is stored as premultiplied
  10406. * @param format defines the format of the data
  10407. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10408. */
  10409. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10410. }
  10411. }
  10412. declare module BABYLON {
  10413. /**
  10414. * Helper class used to generate a canvas to manipulate images
  10415. */
  10416. export class CanvasGenerator {
  10417. /**
  10418. * Create a new canvas (or offscreen canvas depending on the context)
  10419. * @param width defines the expected width
  10420. * @param height defines the expected height
  10421. * @return a new canvas or offscreen canvas
  10422. */
  10423. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10424. }
  10425. }
  10426. declare module BABYLON {
  10427. /**
  10428. * A class extending Texture allowing drawing on a texture
  10429. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10430. */
  10431. export class DynamicTexture extends Texture {
  10432. private _generateMipMaps;
  10433. private _canvas;
  10434. private _context;
  10435. private _engine;
  10436. /**
  10437. * Creates a DynamicTexture
  10438. * @param name defines the name of the texture
  10439. * @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
  10440. * @param scene defines the scene where you want the texture
  10441. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10442. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10443. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10444. */
  10445. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10446. /**
  10447. * Get the current class name of the texture useful for serialization or dynamic coding.
  10448. * @returns "DynamicTexture"
  10449. */
  10450. getClassName(): string;
  10451. /**
  10452. * Gets the current state of canRescale
  10453. */
  10454. get canRescale(): boolean;
  10455. private _recreate;
  10456. /**
  10457. * Scales the texture
  10458. * @param ratio the scale factor to apply to both width and height
  10459. */
  10460. scale(ratio: number): void;
  10461. /**
  10462. * Resizes the texture
  10463. * @param width the new width
  10464. * @param height the new height
  10465. */
  10466. scaleTo(width: number, height: number): void;
  10467. /**
  10468. * Gets the context of the canvas used by the texture
  10469. * @returns the canvas context of the dynamic texture
  10470. */
  10471. getContext(): CanvasRenderingContext2D;
  10472. /**
  10473. * Clears the texture
  10474. */
  10475. clear(): void;
  10476. /**
  10477. * Updates the texture
  10478. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10479. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10480. */
  10481. update(invertY?: boolean, premulAlpha?: boolean): void;
  10482. /**
  10483. * Draws text onto the texture
  10484. * @param text defines the text to be drawn
  10485. * @param x defines the placement of the text from the left
  10486. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10487. * @param font defines the font to be used with font-style, font-size, font-name
  10488. * @param color defines the color used for the text
  10489. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10490. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10491. * @param update defines whether texture is immediately update (default is true)
  10492. */
  10493. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10494. /**
  10495. * Clones the texture
  10496. * @returns the clone of the texture.
  10497. */
  10498. clone(): DynamicTexture;
  10499. /**
  10500. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10501. * @returns a serialized dynamic texture object
  10502. */
  10503. serialize(): any;
  10504. /** @hidden */
  10505. _rebuild(): void;
  10506. }
  10507. }
  10508. declare module BABYLON {
  10509. interface Engine {
  10510. /**
  10511. * Creates a raw texture
  10512. * @param data defines the data to store in the texture
  10513. * @param width defines the width of the texture
  10514. * @param height defines the height of the texture
  10515. * @param format defines the format of the data
  10516. * @param generateMipMaps defines if the engine should generate the mip levels
  10517. * @param invertY defines if data must be stored with Y axis inverted
  10518. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10519. * @param compression defines the compression used (null by default)
  10520. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10521. * @returns the raw texture inside an InternalTexture
  10522. */
  10523. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10524. /**
  10525. * Update a raw texture
  10526. * @param texture defines the texture to update
  10527. * @param data defines the data to store in the texture
  10528. * @param format defines the format of the data
  10529. * @param invertY defines if data must be stored with Y axis inverted
  10530. */
  10531. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10532. /**
  10533. * Update a raw texture
  10534. * @param texture defines the texture to update
  10535. * @param data defines the data to store in the texture
  10536. * @param format defines the format of the data
  10537. * @param invertY defines if data must be stored with Y axis inverted
  10538. * @param compression defines the compression used (null by default)
  10539. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10540. */
  10541. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10542. /**
  10543. * Creates a new raw cube texture
  10544. * @param data defines the array of data to use to create each face
  10545. * @param size defines the size of the textures
  10546. * @param format defines the format of the data
  10547. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10548. * @param generateMipMaps defines if the engine should generate the mip levels
  10549. * @param invertY defines if data must be stored with Y axis inverted
  10550. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10551. * @param compression defines the compression used (null by default)
  10552. * @returns the cube texture as an InternalTexture
  10553. */
  10554. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10555. /**
  10556. * Update a raw cube texture
  10557. * @param texture defines the texture to udpdate
  10558. * @param data defines the data to store
  10559. * @param format defines the data format
  10560. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10561. * @param invertY defines if data must be stored with Y axis inverted
  10562. */
  10563. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10564. /**
  10565. * Update a raw cube texture
  10566. * @param texture defines the texture to udpdate
  10567. * @param data defines the data to store
  10568. * @param format defines the data format
  10569. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10570. * @param invertY defines if data must be stored with Y axis inverted
  10571. * @param compression defines the compression used (null by default)
  10572. */
  10573. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10574. /**
  10575. * Update a raw cube texture
  10576. * @param texture defines the texture to udpdate
  10577. * @param data defines the data to store
  10578. * @param format defines the data format
  10579. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10580. * @param invertY defines if data must be stored with Y axis inverted
  10581. * @param compression defines the compression used (null by default)
  10582. * @param level defines which level of the texture to update
  10583. */
  10584. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10585. /**
  10586. * Creates a new raw cube texture from a specified url
  10587. * @param url defines the url where the data is located
  10588. * @param scene defines the current scene
  10589. * @param size defines the size of the textures
  10590. * @param format defines the format of the data
  10591. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10592. * @param noMipmap defines if the engine should avoid generating the mip levels
  10593. * @param callback defines a callback used to extract texture data from loaded data
  10594. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10595. * @param onLoad defines a callback called when texture is loaded
  10596. * @param onError defines a callback called if there is an error
  10597. * @returns the cube texture as an InternalTexture
  10598. */
  10599. 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;
  10600. /**
  10601. * Creates a new raw cube texture from a specified url
  10602. * @param url defines the url where the data is located
  10603. * @param scene defines the current scene
  10604. * @param size defines the size of the textures
  10605. * @param format defines the format of the data
  10606. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10607. * @param noMipmap defines if the engine should avoid generating the mip levels
  10608. * @param callback defines a callback used to extract texture data from loaded data
  10609. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10610. * @param onLoad defines a callback called when texture is loaded
  10611. * @param onError defines a callback called if there is an error
  10612. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10613. * @param invertY defines if data must be stored with Y axis inverted
  10614. * @returns the cube texture as an InternalTexture
  10615. */
  10616. 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;
  10617. /**
  10618. * Creates a new raw 3D texture
  10619. * @param data defines the data used to create the texture
  10620. * @param width defines the width of the texture
  10621. * @param height defines the height of the texture
  10622. * @param depth defines the depth of the texture
  10623. * @param format defines the format of the texture
  10624. * @param generateMipMaps defines if the engine must generate mip levels
  10625. * @param invertY defines if data must be stored with Y axis inverted
  10626. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10627. * @param compression defines the compressed used (can be null)
  10628. * @param textureType defines the compressed used (can be null)
  10629. * @returns a new raw 3D texture (stored in an InternalTexture)
  10630. */
  10631. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10632. /**
  10633. * Update a raw 3D texture
  10634. * @param texture defines the texture to update
  10635. * @param data defines the data to store
  10636. * @param format defines the data format
  10637. * @param invertY defines if data must be stored with Y axis inverted
  10638. */
  10639. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10640. /**
  10641. * Update a raw 3D texture
  10642. * @param texture defines the texture to update
  10643. * @param data defines the data to store
  10644. * @param format defines the data format
  10645. * @param invertY defines if data must be stored with Y axis inverted
  10646. * @param compression defines the used compression (can be null)
  10647. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10648. */
  10649. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10650. /**
  10651. * Creates a new raw 2D array texture
  10652. * @param data defines the data used to create the texture
  10653. * @param width defines the width of the texture
  10654. * @param height defines the height of the texture
  10655. * @param depth defines the number of layers of the texture
  10656. * @param format defines the format of the texture
  10657. * @param generateMipMaps defines if the engine must generate mip levels
  10658. * @param invertY defines if data must be stored with Y axis inverted
  10659. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10660. * @param compression defines the compressed used (can be null)
  10661. * @param textureType defines the compressed used (can be null)
  10662. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10663. */
  10664. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10665. /**
  10666. * Update a raw 2D array texture
  10667. * @param texture defines the texture to update
  10668. * @param data defines the data to store
  10669. * @param format defines the data format
  10670. * @param invertY defines if data must be stored with Y axis inverted
  10671. */
  10672. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10673. /**
  10674. * Update a raw 2D array texture
  10675. * @param texture defines the texture to update
  10676. * @param data defines the data to store
  10677. * @param format defines the data format
  10678. * @param invertY defines if data must be stored with Y axis inverted
  10679. * @param compression defines the used compression (can be null)
  10680. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10681. */
  10682. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10683. }
  10684. }
  10685. declare module BABYLON {
  10686. /**
  10687. * Raw texture can help creating a texture directly from an array of data.
  10688. * This can be super useful if you either get the data from an uncompressed source or
  10689. * if you wish to create your texture pixel by pixel.
  10690. */
  10691. export class RawTexture extends Texture {
  10692. /**
  10693. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10694. */
  10695. format: number;
  10696. private _engine;
  10697. /**
  10698. * Instantiates a new RawTexture.
  10699. * Raw texture can help creating a texture directly from an array of data.
  10700. * This can be super useful if you either get the data from an uncompressed source or
  10701. * if you wish to create your texture pixel by pixel.
  10702. * @param data define the array of data to use to create the texture
  10703. * @param width define the width of the texture
  10704. * @param height define the height of the texture
  10705. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10706. * @param scene define the scene the texture belongs to
  10707. * @param generateMipMaps define whether mip maps should be generated or not
  10708. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10709. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10710. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10711. */
  10712. constructor(data: ArrayBufferView, width: number, height: number,
  10713. /**
  10714. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10715. */
  10716. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10717. /**
  10718. * Updates the texture underlying data.
  10719. * @param data Define the new data of the texture
  10720. */
  10721. update(data: ArrayBufferView): void;
  10722. /**
  10723. * Creates a luminance texture from some data.
  10724. * @param data Define the texture data
  10725. * @param width Define the width of the texture
  10726. * @param height Define the height of the texture
  10727. * @param scene Define the scene the texture belongs to
  10728. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10731. * @returns the luminance texture
  10732. */
  10733. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10734. /**
  10735. * Creates a luminance alpha texture from some data.
  10736. * @param data Define the texture data
  10737. * @param width Define the width of the texture
  10738. * @param height Define the height of the texture
  10739. * @param scene Define the scene the texture belongs to
  10740. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10741. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10742. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10743. * @returns the luminance alpha texture
  10744. */
  10745. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10746. /**
  10747. * Creates an alpha texture from some data.
  10748. * @param data Define the texture data
  10749. * @param width Define the width of the texture
  10750. * @param height Define the height of the texture
  10751. * @param scene Define the scene the texture belongs to
  10752. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10753. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10754. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10755. * @returns the alpha texture
  10756. */
  10757. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10758. /**
  10759. * Creates a RGB texture from some data.
  10760. * @param data Define the texture data
  10761. * @param width Define the width of the texture
  10762. * @param height Define the height of the texture
  10763. * @param scene Define the scene the texture belongs to
  10764. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10765. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10766. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10767. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10768. * @returns the RGB alpha texture
  10769. */
  10770. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10771. /**
  10772. * Creates a RGBA texture from some data.
  10773. * @param data Define the texture data
  10774. * @param width Define the width of the texture
  10775. * @param height Define the height of the texture
  10776. * @param scene Define the scene the texture belongs to
  10777. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10778. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10779. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10780. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10781. * @returns the RGBA texture
  10782. */
  10783. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10784. /**
  10785. * Creates a R texture from some data.
  10786. * @param data Define the texture data
  10787. * @param width Define the width of the texture
  10788. * @param height Define the height of the texture
  10789. * @param scene Define the scene the texture belongs to
  10790. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10791. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10792. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10793. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10794. * @returns the R texture
  10795. */
  10796. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10797. }
  10798. }
  10799. declare module BABYLON {
  10800. interface AbstractScene {
  10801. /**
  10802. * The list of procedural textures added to the scene
  10803. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10804. */
  10805. proceduralTextures: Array<ProceduralTexture>;
  10806. }
  10807. /**
  10808. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10809. * in a given scene.
  10810. */
  10811. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10812. /**
  10813. * The component name helpfull to identify the component in the list of scene components.
  10814. */
  10815. readonly name: string;
  10816. /**
  10817. * The scene the component belongs to.
  10818. */
  10819. scene: Scene;
  10820. /**
  10821. * Creates a new instance of the component for the given scene
  10822. * @param scene Defines the scene to register the component in
  10823. */
  10824. constructor(scene: Scene);
  10825. /**
  10826. * Registers the component in a given scene
  10827. */
  10828. register(): void;
  10829. /**
  10830. * Rebuilds the elements related to this component in case of
  10831. * context lost for instance.
  10832. */
  10833. rebuild(): void;
  10834. /**
  10835. * Disposes the component and the associated ressources.
  10836. */
  10837. dispose(): void;
  10838. private _beforeClear;
  10839. }
  10840. }
  10841. declare module BABYLON {
  10842. interface ThinEngine {
  10843. /**
  10844. * Creates a new render target cube texture
  10845. * @param size defines the size of the texture
  10846. * @param options defines the options used to create the texture
  10847. * @returns a new render target cube texture stored in an InternalTexture
  10848. */
  10849. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10850. }
  10851. }
  10852. declare module BABYLON {
  10853. /** @hidden */
  10854. export var proceduralVertexShader: {
  10855. name: string;
  10856. shader: string;
  10857. };
  10858. }
  10859. declare module BABYLON {
  10860. /**
  10861. * 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.
  10862. * This is the base class of any Procedural texture and contains most of the shareable code.
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10864. */
  10865. export class ProceduralTexture extends Texture {
  10866. isCube: boolean;
  10867. /**
  10868. * Define if the texture is enabled or not (disabled texture will not render)
  10869. */
  10870. isEnabled: boolean;
  10871. /**
  10872. * Define if the texture must be cleared before rendering (default is true)
  10873. */
  10874. autoClear: boolean;
  10875. /**
  10876. * Callback called when the texture is generated
  10877. */
  10878. onGenerated: () => void;
  10879. /**
  10880. * Event raised when the texture is generated
  10881. */
  10882. onGeneratedObservable: Observable<ProceduralTexture>;
  10883. /** @hidden */
  10884. _generateMipMaps: boolean;
  10885. /** @hidden **/
  10886. _effect: Effect;
  10887. /** @hidden */
  10888. _textures: {
  10889. [key: string]: Texture;
  10890. };
  10891. /** @hidden */
  10892. protected _fallbackTexture: Nullable<Texture>;
  10893. private _size;
  10894. private _currentRefreshId;
  10895. private _frameId;
  10896. private _refreshRate;
  10897. private _vertexBuffers;
  10898. private _indexBuffer;
  10899. private _uniforms;
  10900. private _samplers;
  10901. private _fragment;
  10902. private _floats;
  10903. private _ints;
  10904. private _floatsArrays;
  10905. private _colors3;
  10906. private _colors4;
  10907. private _vectors2;
  10908. private _vectors3;
  10909. private _matrices;
  10910. private _fallbackTextureUsed;
  10911. private _engine;
  10912. private _cachedDefines;
  10913. private _contentUpdateId;
  10914. private _contentData;
  10915. /**
  10916. * Instantiates a new procedural texture.
  10917. * 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.
  10918. * This is the base class of any Procedural texture and contains most of the shareable code.
  10919. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10920. * @param name Define the name of the texture
  10921. * @param size Define the size of the texture to create
  10922. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10923. * @param scene Define the scene the texture belongs to
  10924. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10925. * @param generateMipMaps Define if the texture should creates mip maps or not
  10926. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10927. */
  10928. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10929. /**
  10930. * The effect that is created when initializing the post process.
  10931. * @returns The created effect corresponding the the postprocess.
  10932. */
  10933. getEffect(): Effect;
  10934. /**
  10935. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10936. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10937. */
  10938. getContent(): Nullable<ArrayBufferView>;
  10939. private _createIndexBuffer;
  10940. /** @hidden */
  10941. _rebuild(): void;
  10942. /**
  10943. * Resets the texture in order to recreate its associated resources.
  10944. * This can be called in case of context loss
  10945. */
  10946. reset(): void;
  10947. protected _getDefines(): string;
  10948. /**
  10949. * Is the texture ready to be used ? (rendered at least once)
  10950. * @returns true if ready, otherwise, false.
  10951. */
  10952. isReady(): boolean;
  10953. /**
  10954. * Resets the refresh counter of the texture and start bak from scratch.
  10955. * Could be useful to regenerate the texture if it is setup to render only once.
  10956. */
  10957. resetRefreshCounter(): void;
  10958. /**
  10959. * Set the fragment shader to use in order to render the texture.
  10960. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10961. */
  10962. setFragment(fragment: any): void;
  10963. /**
  10964. * Define the refresh rate of the texture or the rendering frequency.
  10965. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10966. */
  10967. get refreshRate(): number;
  10968. set refreshRate(value: number);
  10969. /** @hidden */
  10970. _shouldRender(): boolean;
  10971. /**
  10972. * Get the size the texture is rendering at.
  10973. * @returns the size (texture is always squared)
  10974. */
  10975. getRenderSize(): number;
  10976. /**
  10977. * Resize the texture to new value.
  10978. * @param size Define the new size the texture should have
  10979. * @param generateMipMaps Define whether the new texture should create mip maps
  10980. */
  10981. resize(size: number, generateMipMaps: boolean): void;
  10982. private _checkUniform;
  10983. /**
  10984. * Set a texture in the shader program used to render.
  10985. * @param name Define the name of the uniform samplers as defined in the shader
  10986. * @param texture Define the texture to bind to this sampler
  10987. * @return the texture itself allowing "fluent" like uniform updates
  10988. */
  10989. setTexture(name: string, texture: Texture): ProceduralTexture;
  10990. /**
  10991. * Set a float in the shader.
  10992. * @param name Define the name of the uniform as defined in the shader
  10993. * @param value Define the value to give to the uniform
  10994. * @return the texture itself allowing "fluent" like uniform updates
  10995. */
  10996. setFloat(name: string, value: number): ProceduralTexture;
  10997. /**
  10998. * Set a int in the shader.
  10999. * @param name Define the name of the uniform as defined in the shader
  11000. * @param value Define the value to give to the uniform
  11001. * @return the texture itself allowing "fluent" like uniform updates
  11002. */
  11003. setInt(name: string, value: number): ProceduralTexture;
  11004. /**
  11005. * Set an array of floats in the shader.
  11006. * @param name Define the name of the uniform as defined in the shader
  11007. * @param value Define the value to give to the uniform
  11008. * @return the texture itself allowing "fluent" like uniform updates
  11009. */
  11010. setFloats(name: string, value: number[]): ProceduralTexture;
  11011. /**
  11012. * Set a vec3 in the shader from a Color3.
  11013. * @param name Define the name of the uniform as defined in the shader
  11014. * @param value Define the value to give to the uniform
  11015. * @return the texture itself allowing "fluent" like uniform updates
  11016. */
  11017. setColor3(name: string, value: Color3): ProceduralTexture;
  11018. /**
  11019. * Set a vec4 in the shader from a Color4.
  11020. * @param name Define the name of the uniform as defined in the shader
  11021. * @param value Define the value to give to the uniform
  11022. * @return the texture itself allowing "fluent" like uniform updates
  11023. */
  11024. setColor4(name: string, value: Color4): ProceduralTexture;
  11025. /**
  11026. * Set a vec2 in the shader from a Vector2.
  11027. * @param name Define the name of the uniform as defined in the shader
  11028. * @param value Define the value to give to the uniform
  11029. * @return the texture itself allowing "fluent" like uniform updates
  11030. */
  11031. setVector2(name: string, value: Vector2): ProceduralTexture;
  11032. /**
  11033. * Set a vec3 in the shader from a Vector3.
  11034. * @param name Define the name of the uniform as defined in the shader
  11035. * @param value Define the value to give to the uniform
  11036. * @return the texture itself allowing "fluent" like uniform updates
  11037. */
  11038. setVector3(name: string, value: Vector3): ProceduralTexture;
  11039. /**
  11040. * Set a mat4 in the shader from a MAtrix.
  11041. * @param name Define the name of the uniform as defined in the shader
  11042. * @param value Define the value to give to the uniform
  11043. * @return the texture itself allowing "fluent" like uniform updates
  11044. */
  11045. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11046. /**
  11047. * Render the texture to its associated render target.
  11048. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11049. */
  11050. render(useCameraPostProcess?: boolean): void;
  11051. /**
  11052. * Clone the texture.
  11053. * @returns the cloned texture
  11054. */
  11055. clone(): ProceduralTexture;
  11056. /**
  11057. * Dispose the texture and release its asoociated resources.
  11058. */
  11059. dispose(): void;
  11060. }
  11061. }
  11062. declare module BABYLON {
  11063. /**
  11064. * This represents the base class for particle system in Babylon.
  11065. * 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.
  11066. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11067. * @example https://doc.babylonjs.com/babylon101/particles
  11068. */
  11069. export class BaseParticleSystem {
  11070. /**
  11071. * Source color is added to the destination color without alpha affecting the result
  11072. */
  11073. static BLENDMODE_ONEONE: number;
  11074. /**
  11075. * Blend current color and particle color using particle’s alpha
  11076. */
  11077. static BLENDMODE_STANDARD: number;
  11078. /**
  11079. * Add current color and particle color multiplied by particle’s alpha
  11080. */
  11081. static BLENDMODE_ADD: number;
  11082. /**
  11083. * Multiply current color with particle color
  11084. */
  11085. static BLENDMODE_MULTIPLY: number;
  11086. /**
  11087. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11088. */
  11089. static BLENDMODE_MULTIPLYADD: number;
  11090. /**
  11091. * List of animations used by the particle system.
  11092. */
  11093. animations: Animation[];
  11094. /**
  11095. * Gets or sets the unique id of the particle system
  11096. */
  11097. uniqueId: number;
  11098. /**
  11099. * The id of the Particle system.
  11100. */
  11101. id: string;
  11102. /**
  11103. * The friendly name of the Particle system.
  11104. */
  11105. name: string;
  11106. /**
  11107. * Snippet ID if the particle system was created from the snippet server
  11108. */
  11109. snippetId: string;
  11110. /**
  11111. * The rendering group used by the Particle system to chose when to render.
  11112. */
  11113. renderingGroupId: number;
  11114. /**
  11115. * The emitter represents the Mesh or position we are attaching the particle system to.
  11116. */
  11117. emitter: Nullable<AbstractMesh | Vector3>;
  11118. /**
  11119. * The maximum number of particles to emit per frame
  11120. */
  11121. emitRate: number;
  11122. /**
  11123. * If you want to launch only a few particles at once, that can be done, as well.
  11124. */
  11125. manualEmitCount: number;
  11126. /**
  11127. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11128. */
  11129. updateSpeed: number;
  11130. /**
  11131. * The amount of time the particle system is running (depends of the overall update speed).
  11132. */
  11133. targetStopDuration: number;
  11134. /**
  11135. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11136. */
  11137. disposeOnStop: boolean;
  11138. /**
  11139. * Minimum power of emitting particles.
  11140. */
  11141. minEmitPower: number;
  11142. /**
  11143. * Maximum power of emitting particles.
  11144. */
  11145. maxEmitPower: number;
  11146. /**
  11147. * Minimum life time of emitting particles.
  11148. */
  11149. minLifeTime: number;
  11150. /**
  11151. * Maximum life time of emitting particles.
  11152. */
  11153. maxLifeTime: number;
  11154. /**
  11155. * Minimum Size of emitting particles.
  11156. */
  11157. minSize: number;
  11158. /**
  11159. * Maximum Size of emitting particles.
  11160. */
  11161. maxSize: number;
  11162. /**
  11163. * Minimum scale of emitting particles on X axis.
  11164. */
  11165. minScaleX: number;
  11166. /**
  11167. * Maximum scale of emitting particles on X axis.
  11168. */
  11169. maxScaleX: number;
  11170. /**
  11171. * Minimum scale of emitting particles on Y axis.
  11172. */
  11173. minScaleY: number;
  11174. /**
  11175. * Maximum scale of emitting particles on Y axis.
  11176. */
  11177. maxScaleY: number;
  11178. /**
  11179. * Gets or sets the minimal initial rotation in radians.
  11180. */
  11181. minInitialRotation: number;
  11182. /**
  11183. * Gets or sets the maximal initial rotation in radians.
  11184. */
  11185. maxInitialRotation: number;
  11186. /**
  11187. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11188. */
  11189. minAngularSpeed: number;
  11190. /**
  11191. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11192. */
  11193. maxAngularSpeed: number;
  11194. /**
  11195. * The texture used to render each particle. (this can be a spritesheet)
  11196. */
  11197. particleTexture: Nullable<Texture>;
  11198. /**
  11199. * The layer mask we are rendering the particles through.
  11200. */
  11201. layerMask: number;
  11202. /**
  11203. * This can help using your own shader to render the particle system.
  11204. * The according effect will be created
  11205. */
  11206. customShader: any;
  11207. /**
  11208. * By default particle system starts as soon as they are created. This prevents the
  11209. * automatic start to happen and let you decide when to start emitting particles.
  11210. */
  11211. preventAutoStart: boolean;
  11212. private _noiseTexture;
  11213. /**
  11214. * Gets or sets a texture used to add random noise to particle positions
  11215. */
  11216. get noiseTexture(): Nullable<ProceduralTexture>;
  11217. set noiseTexture(value: Nullable<ProceduralTexture>);
  11218. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11219. noiseStrength: Vector3;
  11220. /**
  11221. * Callback triggered when the particle animation is ending.
  11222. */
  11223. onAnimationEnd: Nullable<() => void>;
  11224. /**
  11225. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11226. */
  11227. blendMode: number;
  11228. /**
  11229. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11230. * to override the particles.
  11231. */
  11232. forceDepthWrite: boolean;
  11233. /** 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 */
  11234. preWarmCycles: number;
  11235. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11236. preWarmStepOffset: number;
  11237. /**
  11238. * 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)
  11239. */
  11240. spriteCellChangeSpeed: number;
  11241. /**
  11242. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11243. */
  11244. startSpriteCellID: number;
  11245. /**
  11246. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11247. */
  11248. endSpriteCellID: number;
  11249. /**
  11250. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11251. */
  11252. spriteCellWidth: number;
  11253. /**
  11254. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11255. */
  11256. spriteCellHeight: number;
  11257. /**
  11258. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11259. */
  11260. spriteRandomStartCell: boolean;
  11261. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11262. translationPivot: Vector2;
  11263. /** @hidden */
  11264. protected _isAnimationSheetEnabled: boolean;
  11265. /**
  11266. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11267. */
  11268. beginAnimationOnStart: boolean;
  11269. /**
  11270. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11271. */
  11272. beginAnimationFrom: number;
  11273. /**
  11274. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11275. */
  11276. beginAnimationTo: number;
  11277. /**
  11278. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11279. */
  11280. beginAnimationLoop: boolean;
  11281. /**
  11282. * Gets or sets a world offset applied to all particles
  11283. */
  11284. worldOffset: Vector3;
  11285. /**
  11286. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11287. */
  11288. get isAnimationSheetEnabled(): boolean;
  11289. set isAnimationSheetEnabled(value: boolean);
  11290. /**
  11291. * Get hosting scene
  11292. * @returns the scene
  11293. */
  11294. getScene(): Scene;
  11295. /**
  11296. * You can use gravity if you want to give an orientation to your particles.
  11297. */
  11298. gravity: Vector3;
  11299. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11300. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11301. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11302. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11303. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11304. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11305. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11306. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11307. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11308. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11309. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11310. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11311. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11312. /**
  11313. * Defines the delay in milliseconds before starting the system (0 by default)
  11314. */
  11315. startDelay: number;
  11316. /**
  11317. * Gets the current list of drag gradients.
  11318. * You must use addDragGradient and removeDragGradient to udpate this list
  11319. * @returns the list of drag gradients
  11320. */
  11321. getDragGradients(): Nullable<Array<FactorGradient>>;
  11322. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11323. limitVelocityDamping: number;
  11324. /**
  11325. * Gets the current list of limit velocity gradients.
  11326. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11327. * @returns the list of limit velocity gradients
  11328. */
  11329. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11330. /**
  11331. * Gets the current list of color gradients.
  11332. * You must use addColorGradient and removeColorGradient to udpate this list
  11333. * @returns the list of color gradients
  11334. */
  11335. getColorGradients(): Nullable<Array<ColorGradient>>;
  11336. /**
  11337. * Gets the current list of size gradients.
  11338. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11339. * @returns the list of size gradients
  11340. */
  11341. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11342. /**
  11343. * Gets the current list of color remap gradients.
  11344. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11345. * @returns the list of color remap gradients
  11346. */
  11347. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11348. /**
  11349. * Gets the current list of alpha remap gradients.
  11350. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11351. * @returns the list of alpha remap gradients
  11352. */
  11353. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11354. /**
  11355. * Gets the current list of life time gradients.
  11356. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11357. * @returns the list of life time gradients
  11358. */
  11359. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11360. /**
  11361. * Gets the current list of angular speed gradients.
  11362. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11363. * @returns the list of angular speed gradients
  11364. */
  11365. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11366. /**
  11367. * Gets the current list of velocity gradients.
  11368. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11369. * @returns the list of velocity gradients
  11370. */
  11371. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11372. /**
  11373. * Gets the current list of start size gradients.
  11374. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11375. * @returns the list of start size gradients
  11376. */
  11377. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11378. /**
  11379. * Gets the current list of emit rate gradients.
  11380. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11381. * @returns the list of emit rate gradients
  11382. */
  11383. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11384. /**
  11385. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11386. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11387. */
  11388. get direction1(): Vector3;
  11389. set direction1(value: Vector3);
  11390. /**
  11391. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11392. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11393. */
  11394. get direction2(): Vector3;
  11395. set direction2(value: Vector3);
  11396. /**
  11397. * 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.
  11398. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11399. */
  11400. get minEmitBox(): Vector3;
  11401. set minEmitBox(value: Vector3);
  11402. /**
  11403. * 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.
  11404. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11405. */
  11406. get maxEmitBox(): Vector3;
  11407. set maxEmitBox(value: Vector3);
  11408. /**
  11409. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11410. */
  11411. color1: Color4;
  11412. /**
  11413. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11414. */
  11415. color2: Color4;
  11416. /**
  11417. * Color the particle will have at the end of its lifetime
  11418. */
  11419. colorDead: Color4;
  11420. /**
  11421. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11422. */
  11423. textureMask: Color4;
  11424. /**
  11425. * The particle emitter type defines the emitter used by the particle system.
  11426. * It can be for example box, sphere, or cone...
  11427. */
  11428. particleEmitterType: IParticleEmitterType;
  11429. /** @hidden */
  11430. _isSubEmitter: boolean;
  11431. /**
  11432. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11433. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11434. */
  11435. billboardMode: number;
  11436. protected _isBillboardBased: boolean;
  11437. /**
  11438. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11439. */
  11440. get isBillboardBased(): boolean;
  11441. set isBillboardBased(value: boolean);
  11442. /**
  11443. * The scene the particle system belongs to.
  11444. */
  11445. protected _scene: Scene;
  11446. /**
  11447. * Local cache of defines for image processing.
  11448. */
  11449. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11450. /**
  11451. * Default configuration related to image processing available in the standard Material.
  11452. */
  11453. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11454. /**
  11455. * Gets the image processing configuration used either in this material.
  11456. */
  11457. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11458. /**
  11459. * Sets the Default image processing configuration used either in the this material.
  11460. *
  11461. * If sets to null, the scene one is in use.
  11462. */
  11463. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11464. /**
  11465. * Attaches a new image processing configuration to the Standard Material.
  11466. * @param configuration
  11467. */
  11468. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11469. /** @hidden */
  11470. protected _reset(): void;
  11471. /** @hidden */
  11472. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11473. /**
  11474. * Instantiates a particle system.
  11475. * 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.
  11476. * @param name The name of the particle system
  11477. */
  11478. constructor(name: string);
  11479. /**
  11480. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11481. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11482. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11483. * @returns the emitter
  11484. */
  11485. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11486. /**
  11487. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11488. * @param radius The radius of the hemisphere to emit from
  11489. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11490. * @returns the emitter
  11491. */
  11492. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11493. /**
  11494. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11495. * @param radius The radius of the sphere to emit from
  11496. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11497. * @returns the emitter
  11498. */
  11499. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11500. /**
  11501. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11502. * @param radius The radius of the sphere to emit from
  11503. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11504. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11505. * @returns the emitter
  11506. */
  11507. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11508. /**
  11509. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11510. * @param radius The radius of the emission cylinder
  11511. * @param height The height of the emission cylinder
  11512. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11513. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11514. * @returns the emitter
  11515. */
  11516. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11517. /**
  11518. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11519. * @param radius The radius of the cylinder to emit from
  11520. * @param height The height of the emission cylinder
  11521. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11522. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11523. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11524. * @returns the emitter
  11525. */
  11526. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11527. /**
  11528. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11529. * @param radius The radius of the cone to emit from
  11530. * @param angle The base angle of the cone
  11531. * @returns the emitter
  11532. */
  11533. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11534. /**
  11535. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11536. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11537. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11538. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11539. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11540. * @returns the emitter
  11541. */
  11542. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11543. }
  11544. }
  11545. declare module BABYLON {
  11546. /**
  11547. * Type of sub emitter
  11548. */
  11549. export enum SubEmitterType {
  11550. /**
  11551. * Attached to the particle over it's lifetime
  11552. */
  11553. ATTACHED = 0,
  11554. /**
  11555. * Created when the particle dies
  11556. */
  11557. END = 1
  11558. }
  11559. /**
  11560. * Sub emitter class used to emit particles from an existing particle
  11561. */
  11562. export class SubEmitter {
  11563. /**
  11564. * the particle system to be used by the sub emitter
  11565. */
  11566. particleSystem: ParticleSystem;
  11567. /**
  11568. * Type of the submitter (Default: END)
  11569. */
  11570. type: SubEmitterType;
  11571. /**
  11572. * 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)
  11573. * Note: This only is supported when using an emitter of type Mesh
  11574. */
  11575. inheritDirection: boolean;
  11576. /**
  11577. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11578. */
  11579. inheritedVelocityAmount: number;
  11580. /**
  11581. * Creates a sub emitter
  11582. * @param particleSystem the particle system to be used by the sub emitter
  11583. */
  11584. constructor(
  11585. /**
  11586. * the particle system to be used by the sub emitter
  11587. */
  11588. particleSystem: ParticleSystem);
  11589. /**
  11590. * Clones the sub emitter
  11591. * @returns the cloned sub emitter
  11592. */
  11593. clone(): SubEmitter;
  11594. /**
  11595. * Serialize current object to a JSON object
  11596. * @returns the serialized object
  11597. */
  11598. serialize(): any;
  11599. /** @hidden */
  11600. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11601. /**
  11602. * Creates a new SubEmitter from a serialized JSON version
  11603. * @param serializationObject defines the JSON object to read from
  11604. * @param scene defines the hosting scene
  11605. * @param rootUrl defines the rootUrl for data loading
  11606. * @returns a new SubEmitter
  11607. */
  11608. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11609. /** Release associated resources */
  11610. dispose(): void;
  11611. }
  11612. }
  11613. declare module BABYLON {
  11614. /** @hidden */
  11615. export var imageProcessingDeclaration: {
  11616. name: string;
  11617. shader: string;
  11618. };
  11619. }
  11620. declare module BABYLON {
  11621. /** @hidden */
  11622. export var imageProcessingFunctions: {
  11623. name: string;
  11624. shader: string;
  11625. };
  11626. }
  11627. declare module BABYLON {
  11628. /** @hidden */
  11629. export var particlesPixelShader: {
  11630. name: string;
  11631. shader: string;
  11632. };
  11633. }
  11634. declare module BABYLON {
  11635. /** @hidden */
  11636. export var particlesVertexShader: {
  11637. name: string;
  11638. shader: string;
  11639. };
  11640. }
  11641. declare module BABYLON {
  11642. /**
  11643. * This represents a particle system in Babylon.
  11644. * 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.
  11645. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11646. * @example https://doc.babylonjs.com/babylon101/particles
  11647. */
  11648. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11649. /**
  11650. * Billboard mode will only apply to Y axis
  11651. */
  11652. static readonly BILLBOARDMODE_Y: number;
  11653. /**
  11654. * Billboard mode will apply to all axes
  11655. */
  11656. static readonly BILLBOARDMODE_ALL: number;
  11657. /**
  11658. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11659. */
  11660. static readonly BILLBOARDMODE_STRETCHED: number;
  11661. /**
  11662. * This function can be defined to provide custom update for active particles.
  11663. * This function will be called instead of regular update (age, position, color, etc.).
  11664. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11665. */
  11666. updateFunction: (particles: Particle[]) => void;
  11667. private _emitterWorldMatrix;
  11668. /**
  11669. * This function can be defined to specify initial direction for every new particle.
  11670. * It by default use the emitterType defined function
  11671. */
  11672. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11673. /**
  11674. * This function can be defined to specify initial position for every new particle.
  11675. * It by default use the emitterType defined function
  11676. */
  11677. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11678. /**
  11679. * @hidden
  11680. */
  11681. _inheritedVelocityOffset: Vector3;
  11682. /**
  11683. * An event triggered when the system is disposed
  11684. */
  11685. onDisposeObservable: Observable<ParticleSystem>;
  11686. private _onDisposeObserver;
  11687. /**
  11688. * Sets a callback that will be triggered when the system is disposed
  11689. */
  11690. set onDispose(callback: () => void);
  11691. private _particles;
  11692. private _epsilon;
  11693. private _capacity;
  11694. private _stockParticles;
  11695. private _newPartsExcess;
  11696. private _vertexData;
  11697. private _vertexBuffer;
  11698. private _vertexBuffers;
  11699. private _spriteBuffer;
  11700. private _indexBuffer;
  11701. private _effect;
  11702. private _customEffect;
  11703. private _cachedDefines;
  11704. private _scaledColorStep;
  11705. private _colorDiff;
  11706. private _scaledDirection;
  11707. private _scaledGravity;
  11708. private _currentRenderId;
  11709. private _alive;
  11710. private _useInstancing;
  11711. private _started;
  11712. private _stopped;
  11713. private _actualFrame;
  11714. private _scaledUpdateSpeed;
  11715. private _vertexBufferSize;
  11716. /** @hidden */
  11717. _currentEmitRateGradient: Nullable<FactorGradient>;
  11718. /** @hidden */
  11719. _currentEmitRate1: number;
  11720. /** @hidden */
  11721. _currentEmitRate2: number;
  11722. /** @hidden */
  11723. _currentStartSizeGradient: Nullable<FactorGradient>;
  11724. /** @hidden */
  11725. _currentStartSize1: number;
  11726. /** @hidden */
  11727. _currentStartSize2: number;
  11728. private readonly _rawTextureWidth;
  11729. private _rampGradientsTexture;
  11730. private _useRampGradients;
  11731. /** Gets or sets a boolean indicating that ramp gradients must be used
  11732. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11733. */
  11734. get useRampGradients(): boolean;
  11735. set useRampGradients(value: boolean);
  11736. /**
  11737. * 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.
  11738. * 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: [])
  11739. */
  11740. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11741. private _subEmitters;
  11742. /**
  11743. * @hidden
  11744. * If the particle systems emitter should be disposed when the particle system is disposed
  11745. */
  11746. _disposeEmitterOnDispose: boolean;
  11747. /**
  11748. * The current active Sub-systems, this property is used by the root particle system only.
  11749. */
  11750. activeSubSystems: Array<ParticleSystem>;
  11751. /**
  11752. * Specifies if the particles are updated in emitter local space or world space
  11753. */
  11754. isLocal: boolean;
  11755. private _rootParticleSystem;
  11756. /**
  11757. * Gets the current list of active particles
  11758. */
  11759. get particles(): Particle[];
  11760. /**
  11761. * Gets the number of particles active at the same time.
  11762. * @returns The number of active particles.
  11763. */
  11764. getActiveCount(): number;
  11765. /**
  11766. * Returns the string "ParticleSystem"
  11767. * @returns a string containing the class name
  11768. */
  11769. getClassName(): string;
  11770. /**
  11771. * Gets a boolean indicating that the system is stopping
  11772. * @returns true if the system is currently stopping
  11773. */
  11774. isStopping(): boolean;
  11775. /**
  11776. * Instantiates a particle system.
  11777. * 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.
  11778. * @param name The name of the particle system
  11779. * @param capacity The max number of particles alive at the same time
  11780. * @param scene The scene the particle system belongs to
  11781. * @param customEffect a custom effect used to change the way particles are rendered by default
  11782. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11783. * @param epsilon Offset used to render the particles
  11784. */
  11785. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11786. private _addFactorGradient;
  11787. private _removeFactorGradient;
  11788. /**
  11789. * Adds a new life time gradient
  11790. * @param gradient defines the gradient to use (between 0 and 1)
  11791. * @param factor defines the life time factor to affect to the specified gradient
  11792. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11793. * @returns the current particle system
  11794. */
  11795. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11796. /**
  11797. * Remove a specific life time gradient
  11798. * @param gradient defines the gradient to remove
  11799. * @returns the current particle system
  11800. */
  11801. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11802. /**
  11803. * Adds a new size gradient
  11804. * @param gradient defines the gradient to use (between 0 and 1)
  11805. * @param factor defines the size factor to affect to the specified gradient
  11806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11807. * @returns the current particle system
  11808. */
  11809. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11810. /**
  11811. * Remove a specific size gradient
  11812. * @param gradient defines the gradient to remove
  11813. * @returns the current particle system
  11814. */
  11815. removeSizeGradient(gradient: number): IParticleSystem;
  11816. /**
  11817. * Adds a new color remap gradient
  11818. * @param gradient defines the gradient to use (between 0 and 1)
  11819. * @param min defines the color remap minimal range
  11820. * @param max defines the color remap maximal range
  11821. * @returns the current particle system
  11822. */
  11823. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11824. /**
  11825. * Remove a specific color remap gradient
  11826. * @param gradient defines the gradient to remove
  11827. * @returns the current particle system
  11828. */
  11829. removeColorRemapGradient(gradient: number): IParticleSystem;
  11830. /**
  11831. * Adds a new alpha remap gradient
  11832. * @param gradient defines the gradient to use (between 0 and 1)
  11833. * @param min defines the alpha remap minimal range
  11834. * @param max defines the alpha remap maximal range
  11835. * @returns the current particle system
  11836. */
  11837. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11838. /**
  11839. * Remove a specific alpha remap gradient
  11840. * @param gradient defines the gradient to remove
  11841. * @returns the current particle system
  11842. */
  11843. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11844. /**
  11845. * Adds a new angular speed gradient
  11846. * @param gradient defines the gradient to use (between 0 and 1)
  11847. * @param factor defines the angular speed to affect to the specified gradient
  11848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11849. * @returns the current particle system
  11850. */
  11851. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11852. /**
  11853. * Remove a specific angular speed gradient
  11854. * @param gradient defines the gradient to remove
  11855. * @returns the current particle system
  11856. */
  11857. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11858. /**
  11859. * Adds a new velocity gradient
  11860. * @param gradient defines the gradient to use (between 0 and 1)
  11861. * @param factor defines the velocity to affect to the specified gradient
  11862. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11863. * @returns the current particle system
  11864. */
  11865. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11866. /**
  11867. * Remove a specific velocity gradient
  11868. * @param gradient defines the gradient to remove
  11869. * @returns the current particle system
  11870. */
  11871. removeVelocityGradient(gradient: number): IParticleSystem;
  11872. /**
  11873. * Adds a new limit velocity gradient
  11874. * @param gradient defines the gradient to use (between 0 and 1)
  11875. * @param factor defines the limit velocity value to affect to the specified gradient
  11876. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11877. * @returns the current particle system
  11878. */
  11879. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11880. /**
  11881. * Remove a specific limit velocity gradient
  11882. * @param gradient defines the gradient to remove
  11883. * @returns the current particle system
  11884. */
  11885. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11886. /**
  11887. * Adds a new drag gradient
  11888. * @param gradient defines the gradient to use (between 0 and 1)
  11889. * @param factor defines the drag value to affect to the specified gradient
  11890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11891. * @returns the current particle system
  11892. */
  11893. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11894. /**
  11895. * Remove a specific drag gradient
  11896. * @param gradient defines the gradient to remove
  11897. * @returns the current particle system
  11898. */
  11899. removeDragGradient(gradient: number): IParticleSystem;
  11900. /**
  11901. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11902. * @param gradient defines the gradient to use (between 0 and 1)
  11903. * @param factor defines the emit rate value to affect to the specified gradient
  11904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11905. * @returns the current particle system
  11906. */
  11907. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11908. /**
  11909. * Remove a specific emit rate gradient
  11910. * @param gradient defines the gradient to remove
  11911. * @returns the current particle system
  11912. */
  11913. removeEmitRateGradient(gradient: number): IParticleSystem;
  11914. /**
  11915. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11916. * @param gradient defines the gradient to use (between 0 and 1)
  11917. * @param factor defines the start size value to affect to the specified gradient
  11918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11919. * @returns the current particle system
  11920. */
  11921. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11922. /**
  11923. * Remove a specific start size gradient
  11924. * @param gradient defines the gradient to remove
  11925. * @returns the current particle system
  11926. */
  11927. removeStartSizeGradient(gradient: number): IParticleSystem;
  11928. private _createRampGradientTexture;
  11929. /**
  11930. * Gets the current list of ramp gradients.
  11931. * You must use addRampGradient and removeRampGradient to udpate this list
  11932. * @returns the list of ramp gradients
  11933. */
  11934. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11935. /** Force the system to rebuild all gradients that need to be resync */
  11936. forceRefreshGradients(): void;
  11937. private _syncRampGradientTexture;
  11938. /**
  11939. * Adds a new ramp gradient used to remap particle colors
  11940. * @param gradient defines the gradient to use (between 0 and 1)
  11941. * @param color defines the color to affect to the specified gradient
  11942. * @returns the current particle system
  11943. */
  11944. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11945. /**
  11946. * Remove a specific ramp gradient
  11947. * @param gradient defines the gradient to remove
  11948. * @returns the current particle system
  11949. */
  11950. removeRampGradient(gradient: number): ParticleSystem;
  11951. /**
  11952. * Adds a new color gradient
  11953. * @param gradient defines the gradient to use (between 0 and 1)
  11954. * @param color1 defines the color to affect to the specified gradient
  11955. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11956. * @returns this particle system
  11957. */
  11958. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11959. /**
  11960. * Remove a specific color gradient
  11961. * @param gradient defines the gradient to remove
  11962. * @returns this particle system
  11963. */
  11964. removeColorGradient(gradient: number): IParticleSystem;
  11965. private _fetchR;
  11966. protected _reset(): void;
  11967. private _resetEffect;
  11968. private _createVertexBuffers;
  11969. private _createIndexBuffer;
  11970. /**
  11971. * Gets the maximum number of particles active at the same time.
  11972. * @returns The max number of active particles.
  11973. */
  11974. getCapacity(): number;
  11975. /**
  11976. * Gets whether there are still active particles in the system.
  11977. * @returns True if it is alive, otherwise false.
  11978. */
  11979. isAlive(): boolean;
  11980. /**
  11981. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11982. * @returns True if it has been started, otherwise false.
  11983. */
  11984. isStarted(): boolean;
  11985. private _prepareSubEmitterInternalArray;
  11986. /**
  11987. * Starts the particle system and begins to emit
  11988. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11989. */
  11990. start(delay?: number): void;
  11991. /**
  11992. * Stops the particle system.
  11993. * @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.
  11994. */
  11995. stop(stopSubEmitters?: boolean): void;
  11996. /**
  11997. * Remove all active particles
  11998. */
  11999. reset(): void;
  12000. /**
  12001. * @hidden (for internal use only)
  12002. */
  12003. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12004. /**
  12005. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12006. * Its lifetime will start back at 0.
  12007. */
  12008. recycleParticle: (particle: Particle) => void;
  12009. private _stopSubEmitters;
  12010. private _createParticle;
  12011. private _removeFromRoot;
  12012. private _emitFromParticle;
  12013. private _update;
  12014. /** @hidden */
  12015. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12016. /** @hidden */
  12017. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12018. /** @hidden */
  12019. private _getEffect;
  12020. /**
  12021. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12022. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12023. */
  12024. animate(preWarmOnly?: boolean): void;
  12025. private _appendParticleVertices;
  12026. /**
  12027. * Rebuilds the particle system.
  12028. */
  12029. rebuild(): void;
  12030. /**
  12031. * Is this system ready to be used/rendered
  12032. * @return true if the system is ready
  12033. */
  12034. isReady(): boolean;
  12035. private _render;
  12036. /**
  12037. * Renders the particle system in its current state.
  12038. * @returns the current number of particles
  12039. */
  12040. render(): number;
  12041. /**
  12042. * Disposes the particle system and free the associated resources
  12043. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12044. */
  12045. dispose(disposeTexture?: boolean): void;
  12046. /**
  12047. * Clones the particle system.
  12048. * @param name The name of the cloned object
  12049. * @param newEmitter The new emitter to use
  12050. * @returns the cloned particle system
  12051. */
  12052. clone(name: string, newEmitter: any): ParticleSystem;
  12053. /**
  12054. * Serializes the particle system to a JSON object
  12055. * @param serializeTexture defines if the texture must be serialized as well
  12056. * @returns the JSON object
  12057. */
  12058. serialize(serializeTexture?: boolean): any;
  12059. /** @hidden */
  12060. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12061. /** @hidden */
  12062. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12063. /**
  12064. * Parses a JSON object to create a particle system.
  12065. * @param parsedParticleSystem The JSON object to parse
  12066. * @param scene The scene to create the particle system in
  12067. * @param rootUrl The root url to use to load external dependencies like texture
  12068. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12069. * @returns the Parsed particle system
  12070. */
  12071. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12072. }
  12073. }
  12074. declare module BABYLON {
  12075. /**
  12076. * A particle represents one of the element emitted by a particle system.
  12077. * This is mainly define by its coordinates, direction, velocity and age.
  12078. */
  12079. export class Particle {
  12080. /**
  12081. * The particle system the particle belongs to.
  12082. */
  12083. particleSystem: ParticleSystem;
  12084. private static _Count;
  12085. /**
  12086. * Unique ID of the particle
  12087. */
  12088. id: number;
  12089. /**
  12090. * The world position of the particle in the scene.
  12091. */
  12092. position: Vector3;
  12093. /**
  12094. * The world direction of the particle in the scene.
  12095. */
  12096. direction: Vector3;
  12097. /**
  12098. * The color of the particle.
  12099. */
  12100. color: Color4;
  12101. /**
  12102. * The color change of the particle per step.
  12103. */
  12104. colorStep: Color4;
  12105. /**
  12106. * Defines how long will the life of the particle be.
  12107. */
  12108. lifeTime: number;
  12109. /**
  12110. * The current age of the particle.
  12111. */
  12112. age: number;
  12113. /**
  12114. * The current size of the particle.
  12115. */
  12116. size: number;
  12117. /**
  12118. * The current scale of the particle.
  12119. */
  12120. scale: Vector2;
  12121. /**
  12122. * The current angle of the particle.
  12123. */
  12124. angle: number;
  12125. /**
  12126. * Defines how fast is the angle changing.
  12127. */
  12128. angularSpeed: number;
  12129. /**
  12130. * Defines the cell index used by the particle to be rendered from a sprite.
  12131. */
  12132. cellIndex: number;
  12133. /**
  12134. * The information required to support color remapping
  12135. */
  12136. remapData: Vector4;
  12137. /** @hidden */
  12138. _randomCellOffset?: number;
  12139. /** @hidden */
  12140. _initialDirection: Nullable<Vector3>;
  12141. /** @hidden */
  12142. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12143. /** @hidden */
  12144. _initialStartSpriteCellID: number;
  12145. /** @hidden */
  12146. _initialEndSpriteCellID: number;
  12147. /** @hidden */
  12148. _currentColorGradient: Nullable<ColorGradient>;
  12149. /** @hidden */
  12150. _currentColor1: Color4;
  12151. /** @hidden */
  12152. _currentColor2: Color4;
  12153. /** @hidden */
  12154. _currentSizeGradient: Nullable<FactorGradient>;
  12155. /** @hidden */
  12156. _currentSize1: number;
  12157. /** @hidden */
  12158. _currentSize2: number;
  12159. /** @hidden */
  12160. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12161. /** @hidden */
  12162. _currentAngularSpeed1: number;
  12163. /** @hidden */
  12164. _currentAngularSpeed2: number;
  12165. /** @hidden */
  12166. _currentVelocityGradient: Nullable<FactorGradient>;
  12167. /** @hidden */
  12168. _currentVelocity1: number;
  12169. /** @hidden */
  12170. _currentVelocity2: number;
  12171. /** @hidden */
  12172. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12173. /** @hidden */
  12174. _currentLimitVelocity1: number;
  12175. /** @hidden */
  12176. _currentLimitVelocity2: number;
  12177. /** @hidden */
  12178. _currentDragGradient: Nullable<FactorGradient>;
  12179. /** @hidden */
  12180. _currentDrag1: number;
  12181. /** @hidden */
  12182. _currentDrag2: number;
  12183. /** @hidden */
  12184. _randomNoiseCoordinates1: Vector3;
  12185. /** @hidden */
  12186. _randomNoiseCoordinates2: Vector3;
  12187. /** @hidden */
  12188. _localPosition?: Vector3;
  12189. /**
  12190. * Creates a new instance Particle
  12191. * @param particleSystem the particle system the particle belongs to
  12192. */
  12193. constructor(
  12194. /**
  12195. * The particle system the particle belongs to.
  12196. */
  12197. particleSystem: ParticleSystem);
  12198. private updateCellInfoFromSystem;
  12199. /**
  12200. * Defines how the sprite cell index is updated for the particle
  12201. */
  12202. updateCellIndex(): void;
  12203. /** @hidden */
  12204. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12205. /** @hidden */
  12206. _inheritParticleInfoToSubEmitters(): void;
  12207. /** @hidden */
  12208. _reset(): void;
  12209. /**
  12210. * Copy the properties of particle to another one.
  12211. * @param other the particle to copy the information to.
  12212. */
  12213. copyTo(other: Particle): void;
  12214. }
  12215. }
  12216. declare module BABYLON {
  12217. /**
  12218. * Particle emitter represents a volume emitting particles.
  12219. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12220. */
  12221. export interface IParticleEmitterType {
  12222. /**
  12223. * Called by the particle System when the direction is computed for the created particle.
  12224. * @param worldMatrix is the world matrix of the particle system
  12225. * @param directionToUpdate is the direction vector to update with the result
  12226. * @param particle is the particle we are computed the direction for
  12227. * @param isLocal defines if the direction should be set in local space
  12228. */
  12229. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12230. /**
  12231. * Called by the particle System when the position is computed for the created particle.
  12232. * @param worldMatrix is the world matrix of the particle system
  12233. * @param positionToUpdate is the position vector to update with the result
  12234. * @param particle is the particle we are computed the position for
  12235. * @param isLocal defines if the position should be set in local space
  12236. */
  12237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12238. /**
  12239. * Clones the current emitter and returns a copy of it
  12240. * @returns the new emitter
  12241. */
  12242. clone(): IParticleEmitterType;
  12243. /**
  12244. * Called by the GPUParticleSystem to setup the update shader
  12245. * @param effect defines the update shader
  12246. */
  12247. applyToShader(effect: Effect): void;
  12248. /**
  12249. * Returns a string to use to update the GPU particles update shader
  12250. * @returns the effect defines string
  12251. */
  12252. getEffectDefines(): string;
  12253. /**
  12254. * Returns a string representing the class name
  12255. * @returns a string containing the class name
  12256. */
  12257. getClassName(): string;
  12258. /**
  12259. * Serializes the particle system to a JSON object.
  12260. * @returns the JSON object
  12261. */
  12262. serialize(): any;
  12263. /**
  12264. * Parse properties from a JSON object
  12265. * @param serializationObject defines the JSON object
  12266. * @param scene defines the hosting scene
  12267. */
  12268. parse(serializationObject: any, scene: Scene): void;
  12269. }
  12270. }
  12271. declare module BABYLON {
  12272. /**
  12273. * Particle emitter emitting particles from the inside of a box.
  12274. * It emits the particles randomly between 2 given directions.
  12275. */
  12276. export class BoxParticleEmitter implements IParticleEmitterType {
  12277. /**
  12278. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12279. */
  12280. direction1: Vector3;
  12281. /**
  12282. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12283. */
  12284. direction2: Vector3;
  12285. /**
  12286. * 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.
  12287. */
  12288. minEmitBox: Vector3;
  12289. /**
  12290. * 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.
  12291. */
  12292. maxEmitBox: Vector3;
  12293. /**
  12294. * Creates a new instance BoxParticleEmitter
  12295. */
  12296. constructor();
  12297. /**
  12298. * Called by the particle System when the direction is computed for the created particle.
  12299. * @param worldMatrix is the world matrix of the particle system
  12300. * @param directionToUpdate is the direction vector to update with the result
  12301. * @param particle is the particle we are computed the direction for
  12302. * @param isLocal defines if the direction should be set in local space
  12303. */
  12304. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12305. /**
  12306. * Called by the particle System when the position is computed for the created particle.
  12307. * @param worldMatrix is the world matrix of the particle system
  12308. * @param positionToUpdate is the position vector to update with the result
  12309. * @param particle is the particle we are computed the position for
  12310. * @param isLocal defines if the position should be set in local space
  12311. */
  12312. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12313. /**
  12314. * Clones the current emitter and returns a copy of it
  12315. * @returns the new emitter
  12316. */
  12317. clone(): BoxParticleEmitter;
  12318. /**
  12319. * Called by the GPUParticleSystem to setup the update shader
  12320. * @param effect defines the update shader
  12321. */
  12322. applyToShader(effect: Effect): void;
  12323. /**
  12324. * Returns a string to use to update the GPU particles update shader
  12325. * @returns a string containng the defines string
  12326. */
  12327. getEffectDefines(): string;
  12328. /**
  12329. * Returns the string "BoxParticleEmitter"
  12330. * @returns a string containing the class name
  12331. */
  12332. getClassName(): string;
  12333. /**
  12334. * Serializes the particle system to a JSON object.
  12335. * @returns the JSON object
  12336. */
  12337. serialize(): any;
  12338. /**
  12339. * Parse properties from a JSON object
  12340. * @param serializationObject defines the JSON object
  12341. */
  12342. parse(serializationObject: any): void;
  12343. }
  12344. }
  12345. declare module BABYLON {
  12346. /**
  12347. * Particle emitter emitting particles from the inside of a cone.
  12348. * It emits the particles alongside the cone volume from the base to the particle.
  12349. * The emission direction might be randomized.
  12350. */
  12351. export class ConeParticleEmitter implements IParticleEmitterType {
  12352. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12353. directionRandomizer: number;
  12354. private _radius;
  12355. private _angle;
  12356. private _height;
  12357. /**
  12358. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12359. */
  12360. radiusRange: number;
  12361. /**
  12362. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12363. */
  12364. heightRange: number;
  12365. /**
  12366. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12367. */
  12368. emitFromSpawnPointOnly: boolean;
  12369. /**
  12370. * Gets or sets the radius of the emission cone
  12371. */
  12372. get radius(): number;
  12373. set radius(value: number);
  12374. /**
  12375. * Gets or sets the angle of the emission cone
  12376. */
  12377. get angle(): number;
  12378. set angle(value: number);
  12379. private _buildHeight;
  12380. /**
  12381. * Creates a new instance ConeParticleEmitter
  12382. * @param radius the radius of the emission cone (1 by default)
  12383. * @param angle the cone base angle (PI by default)
  12384. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12385. */
  12386. constructor(radius?: number, angle?: number,
  12387. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12388. directionRandomizer?: number);
  12389. /**
  12390. * Called by the particle System when the direction is computed for the created particle.
  12391. * @param worldMatrix is the world matrix of the particle system
  12392. * @param directionToUpdate is the direction vector to update with the result
  12393. * @param particle is the particle we are computed the direction for
  12394. * @param isLocal defines if the direction should be set in local space
  12395. */
  12396. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12397. /**
  12398. * Called by the particle System when the position is computed for the created particle.
  12399. * @param worldMatrix is the world matrix of the particle system
  12400. * @param positionToUpdate is the position vector to update with the result
  12401. * @param particle is the particle we are computed the position for
  12402. * @param isLocal defines if the position should be set in local space
  12403. */
  12404. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12405. /**
  12406. * Clones the current emitter and returns a copy of it
  12407. * @returns the new emitter
  12408. */
  12409. clone(): ConeParticleEmitter;
  12410. /**
  12411. * Called by the GPUParticleSystem to setup the update shader
  12412. * @param effect defines the update shader
  12413. */
  12414. applyToShader(effect: Effect): void;
  12415. /**
  12416. * Returns a string to use to update the GPU particles update shader
  12417. * @returns a string containng the defines string
  12418. */
  12419. getEffectDefines(): string;
  12420. /**
  12421. * Returns the string "ConeParticleEmitter"
  12422. * @returns a string containing the class name
  12423. */
  12424. getClassName(): string;
  12425. /**
  12426. * Serializes the particle system to a JSON object.
  12427. * @returns the JSON object
  12428. */
  12429. serialize(): any;
  12430. /**
  12431. * Parse properties from a JSON object
  12432. * @param serializationObject defines the JSON object
  12433. */
  12434. parse(serializationObject: any): void;
  12435. }
  12436. }
  12437. declare module BABYLON {
  12438. /**
  12439. * Particle emitter emitting particles from the inside of a cylinder.
  12440. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12441. */
  12442. export class CylinderParticleEmitter implements IParticleEmitterType {
  12443. /**
  12444. * The radius of the emission cylinder.
  12445. */
  12446. radius: number;
  12447. /**
  12448. * The height of the emission cylinder.
  12449. */
  12450. height: number;
  12451. /**
  12452. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12453. */
  12454. radiusRange: number;
  12455. /**
  12456. * How much to randomize the particle direction [0-1].
  12457. */
  12458. directionRandomizer: number;
  12459. /**
  12460. * Creates a new instance CylinderParticleEmitter
  12461. * @param radius the radius of the emission cylinder (1 by default)
  12462. * @param height the height of the emission cylinder (1 by default)
  12463. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12464. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12465. */
  12466. constructor(
  12467. /**
  12468. * The radius of the emission cylinder.
  12469. */
  12470. radius?: number,
  12471. /**
  12472. * The height of the emission cylinder.
  12473. */
  12474. height?: number,
  12475. /**
  12476. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12477. */
  12478. radiusRange?: number,
  12479. /**
  12480. * How much to randomize the particle direction [0-1].
  12481. */
  12482. directionRandomizer?: number);
  12483. /**
  12484. * Called by the particle System when the direction is computed for the created particle.
  12485. * @param worldMatrix is the world matrix of the particle system
  12486. * @param directionToUpdate is the direction vector to update with the result
  12487. * @param particle is the particle we are computed the direction for
  12488. * @param isLocal defines if the direction should be set in local space
  12489. */
  12490. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12491. /**
  12492. * Called by the particle System when the position is computed for the created particle.
  12493. * @param worldMatrix is the world matrix of the particle system
  12494. * @param positionToUpdate is the position vector to update with the result
  12495. * @param particle is the particle we are computed the position for
  12496. * @param isLocal defines if the position should be set in local space
  12497. */
  12498. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12499. /**
  12500. * Clones the current emitter and returns a copy of it
  12501. * @returns the new emitter
  12502. */
  12503. clone(): CylinderParticleEmitter;
  12504. /**
  12505. * Called by the GPUParticleSystem to setup the update shader
  12506. * @param effect defines the update shader
  12507. */
  12508. applyToShader(effect: Effect): void;
  12509. /**
  12510. * Returns a string to use to update the GPU particles update shader
  12511. * @returns a string containng the defines string
  12512. */
  12513. getEffectDefines(): string;
  12514. /**
  12515. * Returns the string "CylinderParticleEmitter"
  12516. * @returns a string containing the class name
  12517. */
  12518. getClassName(): string;
  12519. /**
  12520. * Serializes the particle system to a JSON object.
  12521. * @returns the JSON object
  12522. */
  12523. serialize(): any;
  12524. /**
  12525. * Parse properties from a JSON object
  12526. * @param serializationObject defines the JSON object
  12527. */
  12528. parse(serializationObject: any): void;
  12529. }
  12530. /**
  12531. * Particle emitter emitting particles from the inside of a cylinder.
  12532. * It emits the particles randomly between two vectors.
  12533. */
  12534. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12535. /**
  12536. * The min limit of the emission direction.
  12537. */
  12538. direction1: Vector3;
  12539. /**
  12540. * The max limit of the emission direction.
  12541. */
  12542. direction2: Vector3;
  12543. /**
  12544. * Creates a new instance CylinderDirectedParticleEmitter
  12545. * @param radius the radius of the emission cylinder (1 by default)
  12546. * @param height the height of the emission cylinder (1 by default)
  12547. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12548. * @param direction1 the min limit of the emission direction (up vector by default)
  12549. * @param direction2 the max limit of the emission direction (up vector by default)
  12550. */
  12551. constructor(radius?: number, height?: number, radiusRange?: number,
  12552. /**
  12553. * The min limit of the emission direction.
  12554. */
  12555. direction1?: Vector3,
  12556. /**
  12557. * The max limit of the emission direction.
  12558. */
  12559. direction2?: Vector3);
  12560. /**
  12561. * Called by the particle System when the direction is computed for the created particle.
  12562. * @param worldMatrix is the world matrix of the particle system
  12563. * @param directionToUpdate is the direction vector to update with the result
  12564. * @param particle is the particle we are computed the direction for
  12565. */
  12566. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12567. /**
  12568. * Clones the current emitter and returns a copy of it
  12569. * @returns the new emitter
  12570. */
  12571. clone(): CylinderDirectedParticleEmitter;
  12572. /**
  12573. * Called by the GPUParticleSystem to setup the update shader
  12574. * @param effect defines the update shader
  12575. */
  12576. applyToShader(effect: Effect): void;
  12577. /**
  12578. * Returns a string to use to update the GPU particles update shader
  12579. * @returns a string containng the defines string
  12580. */
  12581. getEffectDefines(): string;
  12582. /**
  12583. * Returns the string "CylinderDirectedParticleEmitter"
  12584. * @returns a string containing the class name
  12585. */
  12586. getClassName(): string;
  12587. /**
  12588. * Serializes the particle system to a JSON object.
  12589. * @returns the JSON object
  12590. */
  12591. serialize(): any;
  12592. /**
  12593. * Parse properties from a JSON object
  12594. * @param serializationObject defines the JSON object
  12595. */
  12596. parse(serializationObject: any): void;
  12597. }
  12598. }
  12599. declare module BABYLON {
  12600. /**
  12601. * Particle emitter emitting particles from the inside of a hemisphere.
  12602. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12603. */
  12604. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12605. /**
  12606. * The radius of the emission hemisphere.
  12607. */
  12608. radius: number;
  12609. /**
  12610. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12611. */
  12612. radiusRange: number;
  12613. /**
  12614. * How much to randomize the particle direction [0-1].
  12615. */
  12616. directionRandomizer: number;
  12617. /**
  12618. * Creates a new instance HemisphericParticleEmitter
  12619. * @param radius the radius of the emission hemisphere (1 by default)
  12620. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12621. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12622. */
  12623. constructor(
  12624. /**
  12625. * The radius of the emission hemisphere.
  12626. */
  12627. radius?: number,
  12628. /**
  12629. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12630. */
  12631. radiusRange?: number,
  12632. /**
  12633. * How much to randomize the particle direction [0-1].
  12634. */
  12635. directionRandomizer?: number);
  12636. /**
  12637. * Called by the particle System when the direction is computed for the created particle.
  12638. * @param worldMatrix is the world matrix of the particle system
  12639. * @param directionToUpdate is the direction vector to update with the result
  12640. * @param particle is the particle we are computed the direction for
  12641. * @param isLocal defines if the direction should be set in local space
  12642. */
  12643. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12644. /**
  12645. * Called by the particle System when the position is computed for the created particle.
  12646. * @param worldMatrix is the world matrix of the particle system
  12647. * @param positionToUpdate is the position vector to update with the result
  12648. * @param particle is the particle we are computed the position for
  12649. * @param isLocal defines if the position should be set in local space
  12650. */
  12651. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12652. /**
  12653. * Clones the current emitter and returns a copy of it
  12654. * @returns the new emitter
  12655. */
  12656. clone(): HemisphericParticleEmitter;
  12657. /**
  12658. * Called by the GPUParticleSystem to setup the update shader
  12659. * @param effect defines the update shader
  12660. */
  12661. applyToShader(effect: Effect): void;
  12662. /**
  12663. * Returns a string to use to update the GPU particles update shader
  12664. * @returns a string containng the defines string
  12665. */
  12666. getEffectDefines(): string;
  12667. /**
  12668. * Returns the string "HemisphericParticleEmitter"
  12669. * @returns a string containing the class name
  12670. */
  12671. getClassName(): string;
  12672. /**
  12673. * Serializes the particle system to a JSON object.
  12674. * @returns the JSON object
  12675. */
  12676. serialize(): any;
  12677. /**
  12678. * Parse properties from a JSON object
  12679. * @param serializationObject defines the JSON object
  12680. */
  12681. parse(serializationObject: any): void;
  12682. }
  12683. }
  12684. declare module BABYLON {
  12685. /**
  12686. * Particle emitter emitting particles from a point.
  12687. * It emits the particles randomly between 2 given directions.
  12688. */
  12689. export class PointParticleEmitter implements IParticleEmitterType {
  12690. /**
  12691. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12692. */
  12693. direction1: Vector3;
  12694. /**
  12695. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12696. */
  12697. direction2: Vector3;
  12698. /**
  12699. * Creates a new instance PointParticleEmitter
  12700. */
  12701. constructor();
  12702. /**
  12703. * Called by the particle System when the direction is computed for the created particle.
  12704. * @param worldMatrix is the world matrix of the particle system
  12705. * @param directionToUpdate is the direction vector to update with the result
  12706. * @param particle is the particle we are computed the direction for
  12707. * @param isLocal defines if the direction should be set in local space
  12708. */
  12709. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12710. /**
  12711. * Called by the particle System when the position is computed for the created particle.
  12712. * @param worldMatrix is the world matrix of the particle system
  12713. * @param positionToUpdate is the position vector to update with the result
  12714. * @param particle is the particle we are computed the position for
  12715. * @param isLocal defines if the position should be set in local space
  12716. */
  12717. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12718. /**
  12719. * Clones the current emitter and returns a copy of it
  12720. * @returns the new emitter
  12721. */
  12722. clone(): PointParticleEmitter;
  12723. /**
  12724. * Called by the GPUParticleSystem to setup the update shader
  12725. * @param effect defines the update shader
  12726. */
  12727. applyToShader(effect: Effect): void;
  12728. /**
  12729. * Returns a string to use to update the GPU particles update shader
  12730. * @returns a string containng the defines string
  12731. */
  12732. getEffectDefines(): string;
  12733. /**
  12734. * Returns the string "PointParticleEmitter"
  12735. * @returns a string containing the class name
  12736. */
  12737. getClassName(): string;
  12738. /**
  12739. * Serializes the particle system to a JSON object.
  12740. * @returns the JSON object
  12741. */
  12742. serialize(): any;
  12743. /**
  12744. * Parse properties from a JSON object
  12745. * @param serializationObject defines the JSON object
  12746. */
  12747. parse(serializationObject: any): void;
  12748. }
  12749. }
  12750. declare module BABYLON {
  12751. /**
  12752. * Particle emitter emitting particles from the inside of a sphere.
  12753. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12754. */
  12755. export class SphereParticleEmitter implements IParticleEmitterType {
  12756. /**
  12757. * The radius of the emission sphere.
  12758. */
  12759. radius: number;
  12760. /**
  12761. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12762. */
  12763. radiusRange: number;
  12764. /**
  12765. * How much to randomize the particle direction [0-1].
  12766. */
  12767. directionRandomizer: number;
  12768. /**
  12769. * Creates a new instance SphereParticleEmitter
  12770. * @param radius the radius of the emission sphere (1 by default)
  12771. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12772. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12773. */
  12774. constructor(
  12775. /**
  12776. * The radius of the emission sphere.
  12777. */
  12778. radius?: number,
  12779. /**
  12780. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12781. */
  12782. radiusRange?: number,
  12783. /**
  12784. * How much to randomize the particle direction [0-1].
  12785. */
  12786. directionRandomizer?: number);
  12787. /**
  12788. * Called by the particle System when the direction is computed for the created particle.
  12789. * @param worldMatrix is the world matrix of the particle system
  12790. * @param directionToUpdate is the direction vector to update with the result
  12791. * @param particle is the particle we are computed the direction for
  12792. * @param isLocal defines if the direction should be set in local space
  12793. */
  12794. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12795. /**
  12796. * Called by the particle System when the position is computed for the created particle.
  12797. * @param worldMatrix is the world matrix of the particle system
  12798. * @param positionToUpdate is the position vector to update with the result
  12799. * @param particle is the particle we are computed the position for
  12800. * @param isLocal defines if the position should be set in local space
  12801. */
  12802. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12803. /**
  12804. * Clones the current emitter and returns a copy of it
  12805. * @returns the new emitter
  12806. */
  12807. clone(): SphereParticleEmitter;
  12808. /**
  12809. * Called by the GPUParticleSystem to setup the update shader
  12810. * @param effect defines the update shader
  12811. */
  12812. applyToShader(effect: Effect): void;
  12813. /**
  12814. * Returns a string to use to update the GPU particles update shader
  12815. * @returns a string containng the defines string
  12816. */
  12817. getEffectDefines(): string;
  12818. /**
  12819. * Returns the string "SphereParticleEmitter"
  12820. * @returns a string containing the class name
  12821. */
  12822. getClassName(): string;
  12823. /**
  12824. * Serializes the particle system to a JSON object.
  12825. * @returns the JSON object
  12826. */
  12827. serialize(): any;
  12828. /**
  12829. * Parse properties from a JSON object
  12830. * @param serializationObject defines the JSON object
  12831. */
  12832. parse(serializationObject: any): void;
  12833. }
  12834. /**
  12835. * Particle emitter emitting particles from the inside of a sphere.
  12836. * It emits the particles randomly between two vectors.
  12837. */
  12838. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12839. /**
  12840. * The min limit of the emission direction.
  12841. */
  12842. direction1: Vector3;
  12843. /**
  12844. * The max limit of the emission direction.
  12845. */
  12846. direction2: Vector3;
  12847. /**
  12848. * Creates a new instance SphereDirectedParticleEmitter
  12849. * @param radius the radius of the emission sphere (1 by default)
  12850. * @param direction1 the min limit of the emission direction (up vector by default)
  12851. * @param direction2 the max limit of the emission direction (up vector by default)
  12852. */
  12853. constructor(radius?: number,
  12854. /**
  12855. * The min limit of the emission direction.
  12856. */
  12857. direction1?: Vector3,
  12858. /**
  12859. * The max limit of the emission direction.
  12860. */
  12861. direction2?: Vector3);
  12862. /**
  12863. * Called by the particle System when the direction is computed for the created particle.
  12864. * @param worldMatrix is the world matrix of the particle system
  12865. * @param directionToUpdate is the direction vector to update with the result
  12866. * @param particle is the particle we are computed the direction for
  12867. */
  12868. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12869. /**
  12870. * Clones the current emitter and returns a copy of it
  12871. * @returns the new emitter
  12872. */
  12873. clone(): SphereDirectedParticleEmitter;
  12874. /**
  12875. * Called by the GPUParticleSystem to setup the update shader
  12876. * @param effect defines the update shader
  12877. */
  12878. applyToShader(effect: Effect): void;
  12879. /**
  12880. * Returns a string to use to update the GPU particles update shader
  12881. * @returns a string containng the defines string
  12882. */
  12883. getEffectDefines(): string;
  12884. /**
  12885. * Returns the string "SphereDirectedParticleEmitter"
  12886. * @returns a string containing the class name
  12887. */
  12888. getClassName(): string;
  12889. /**
  12890. * Serializes the particle system to a JSON object.
  12891. * @returns the JSON object
  12892. */
  12893. serialize(): any;
  12894. /**
  12895. * Parse properties from a JSON object
  12896. * @param serializationObject defines the JSON object
  12897. */
  12898. parse(serializationObject: any): void;
  12899. }
  12900. }
  12901. declare module BABYLON {
  12902. /**
  12903. * Particle emitter emitting particles from a custom list of positions.
  12904. */
  12905. export class CustomParticleEmitter implements IParticleEmitterType {
  12906. /**
  12907. * Gets or sets the position generator that will create the inital position of each particle.
  12908. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12909. */
  12910. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12911. /**
  12912. * Gets or sets the destination generator that will create the final destination of each particle.
  12913. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12914. */
  12915. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12916. /**
  12917. * Creates a new instance CustomParticleEmitter
  12918. */
  12919. constructor();
  12920. /**
  12921. * Called by the particle System when the direction is computed for the created particle.
  12922. * @param worldMatrix is the world matrix of the particle system
  12923. * @param directionToUpdate is the direction vector to update with the result
  12924. * @param particle is the particle we are computed the direction for
  12925. * @param isLocal defines if the direction should be set in local space
  12926. */
  12927. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12928. /**
  12929. * Called by the particle System when the position is computed for the created particle.
  12930. * @param worldMatrix is the world matrix of the particle system
  12931. * @param positionToUpdate is the position vector to update with the result
  12932. * @param particle is the particle we are computed the position for
  12933. * @param isLocal defines if the position should be set in local space
  12934. */
  12935. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12936. /**
  12937. * Clones the current emitter and returns a copy of it
  12938. * @returns the new emitter
  12939. */
  12940. clone(): CustomParticleEmitter;
  12941. /**
  12942. * Called by the GPUParticleSystem to setup the update shader
  12943. * @param effect defines the update shader
  12944. */
  12945. applyToShader(effect: Effect): void;
  12946. /**
  12947. * Returns a string to use to update the GPU particles update shader
  12948. * @returns a string containng the defines string
  12949. */
  12950. getEffectDefines(): string;
  12951. /**
  12952. * Returns the string "PointParticleEmitter"
  12953. * @returns a string containing the class name
  12954. */
  12955. getClassName(): string;
  12956. /**
  12957. * Serializes the particle system to a JSON object.
  12958. * @returns the JSON object
  12959. */
  12960. serialize(): any;
  12961. /**
  12962. * Parse properties from a JSON object
  12963. * @param serializationObject defines the JSON object
  12964. */
  12965. parse(serializationObject: any): void;
  12966. }
  12967. }
  12968. declare module BABYLON {
  12969. /**
  12970. * Particle emitter emitting particles from the inside of a box.
  12971. * It emits the particles randomly between 2 given directions.
  12972. */
  12973. export class MeshParticleEmitter implements IParticleEmitterType {
  12974. private _indices;
  12975. private _positions;
  12976. private _normals;
  12977. private _storedNormal;
  12978. private _mesh;
  12979. /**
  12980. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12981. */
  12982. direction1: Vector3;
  12983. /**
  12984. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12985. */
  12986. direction2: Vector3;
  12987. /**
  12988. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12989. */
  12990. useMeshNormalsForDirection: boolean;
  12991. /** Defines the mesh to use as source */
  12992. get mesh(): Nullable<AbstractMesh>;
  12993. set mesh(value: Nullable<AbstractMesh>);
  12994. /**
  12995. * Creates a new instance MeshParticleEmitter
  12996. * @param mesh defines the mesh to use as source
  12997. */
  12998. constructor(mesh?: Nullable<AbstractMesh>);
  12999. /**
  13000. * Called by the particle System when the direction is computed for the created particle.
  13001. * @param worldMatrix is the world matrix of the particle system
  13002. * @param directionToUpdate is the direction vector to update with the result
  13003. * @param particle is the particle we are computed the direction for
  13004. * @param isLocal defines if the direction should be set in local space
  13005. */
  13006. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13007. /**
  13008. * Called by the particle System when the position is computed for the created particle.
  13009. * @param worldMatrix is the world matrix of the particle system
  13010. * @param positionToUpdate is the position vector to update with the result
  13011. * @param particle is the particle we are computed the position for
  13012. * @param isLocal defines if the position should be set in local space
  13013. */
  13014. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13015. /**
  13016. * Clones the current emitter and returns a copy of it
  13017. * @returns the new emitter
  13018. */
  13019. clone(): MeshParticleEmitter;
  13020. /**
  13021. * Called by the GPUParticleSystem to setup the update shader
  13022. * @param effect defines the update shader
  13023. */
  13024. applyToShader(effect: Effect): void;
  13025. /**
  13026. * Returns a string to use to update the GPU particles update shader
  13027. * @returns a string containng the defines string
  13028. */
  13029. getEffectDefines(): string;
  13030. /**
  13031. * Returns the string "BoxParticleEmitter"
  13032. * @returns a string containing the class name
  13033. */
  13034. getClassName(): string;
  13035. /**
  13036. * Serializes the particle system to a JSON object.
  13037. * @returns the JSON object
  13038. */
  13039. serialize(): any;
  13040. /**
  13041. * Parse properties from a JSON object
  13042. * @param serializationObject defines the JSON object
  13043. * @param scene defines the hosting scene
  13044. */
  13045. parse(serializationObject: any, scene: Scene): void;
  13046. }
  13047. }
  13048. declare module BABYLON {
  13049. /**
  13050. * Interface representing a particle system in Babylon.js.
  13051. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13052. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13053. */
  13054. export interface IParticleSystem {
  13055. /**
  13056. * List of animations used by the particle system.
  13057. */
  13058. animations: Animation[];
  13059. /**
  13060. * The id of the Particle system.
  13061. */
  13062. id: string;
  13063. /**
  13064. * The name of the Particle system.
  13065. */
  13066. name: string;
  13067. /**
  13068. * The emitter represents the Mesh or position we are attaching the particle system to.
  13069. */
  13070. emitter: Nullable<AbstractMesh | Vector3>;
  13071. /**
  13072. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13073. */
  13074. isBillboardBased: boolean;
  13075. /**
  13076. * The rendering group used by the Particle system to chose when to render.
  13077. */
  13078. renderingGroupId: number;
  13079. /**
  13080. * The layer mask we are rendering the particles through.
  13081. */
  13082. layerMask: number;
  13083. /**
  13084. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13085. */
  13086. updateSpeed: number;
  13087. /**
  13088. * The amount of time the particle system is running (depends of the overall update speed).
  13089. */
  13090. targetStopDuration: number;
  13091. /**
  13092. * The texture used to render each particle. (this can be a spritesheet)
  13093. */
  13094. particleTexture: Nullable<Texture>;
  13095. /**
  13096. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13097. */
  13098. blendMode: number;
  13099. /**
  13100. * Minimum life time of emitting particles.
  13101. */
  13102. minLifeTime: number;
  13103. /**
  13104. * Maximum life time of emitting particles.
  13105. */
  13106. maxLifeTime: number;
  13107. /**
  13108. * Minimum Size of emitting particles.
  13109. */
  13110. minSize: number;
  13111. /**
  13112. * Maximum Size of emitting particles.
  13113. */
  13114. maxSize: number;
  13115. /**
  13116. * Minimum scale of emitting particles on X axis.
  13117. */
  13118. minScaleX: number;
  13119. /**
  13120. * Maximum scale of emitting particles on X axis.
  13121. */
  13122. maxScaleX: number;
  13123. /**
  13124. * Minimum scale of emitting particles on Y axis.
  13125. */
  13126. minScaleY: number;
  13127. /**
  13128. * Maximum scale of emitting particles on Y axis.
  13129. */
  13130. maxScaleY: number;
  13131. /**
  13132. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13133. */
  13134. color1: Color4;
  13135. /**
  13136. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13137. */
  13138. color2: Color4;
  13139. /**
  13140. * Color the particle will have at the end of its lifetime.
  13141. */
  13142. colorDead: Color4;
  13143. /**
  13144. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13145. */
  13146. emitRate: number;
  13147. /**
  13148. * You can use gravity if you want to give an orientation to your particles.
  13149. */
  13150. gravity: Vector3;
  13151. /**
  13152. * Minimum power of emitting particles.
  13153. */
  13154. minEmitPower: number;
  13155. /**
  13156. * Maximum power of emitting particles.
  13157. */
  13158. maxEmitPower: number;
  13159. /**
  13160. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13161. */
  13162. minAngularSpeed: number;
  13163. /**
  13164. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13165. */
  13166. maxAngularSpeed: number;
  13167. /**
  13168. * Gets or sets the minimal initial rotation in radians.
  13169. */
  13170. minInitialRotation: number;
  13171. /**
  13172. * Gets or sets the maximal initial rotation in radians.
  13173. */
  13174. maxInitialRotation: number;
  13175. /**
  13176. * The particle emitter type defines the emitter used by the particle system.
  13177. * It can be for example box, sphere, or cone...
  13178. */
  13179. particleEmitterType: Nullable<IParticleEmitterType>;
  13180. /**
  13181. * Defines the delay in milliseconds before starting the system (0 by default)
  13182. */
  13183. startDelay: number;
  13184. /**
  13185. * 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
  13186. */
  13187. preWarmCycles: number;
  13188. /**
  13189. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13190. */
  13191. preWarmStepOffset: number;
  13192. /**
  13193. * 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)
  13194. */
  13195. spriteCellChangeSpeed: number;
  13196. /**
  13197. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13198. */
  13199. startSpriteCellID: number;
  13200. /**
  13201. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13202. */
  13203. endSpriteCellID: number;
  13204. /**
  13205. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13206. */
  13207. spriteCellWidth: number;
  13208. /**
  13209. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13210. */
  13211. spriteCellHeight: number;
  13212. /**
  13213. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13214. */
  13215. spriteRandomStartCell: boolean;
  13216. /**
  13217. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13218. */
  13219. isAnimationSheetEnabled: boolean;
  13220. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13221. translationPivot: Vector2;
  13222. /**
  13223. * Gets or sets a texture used to add random noise to particle positions
  13224. */
  13225. noiseTexture: Nullable<BaseTexture>;
  13226. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13227. noiseStrength: Vector3;
  13228. /**
  13229. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13230. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13231. */
  13232. billboardMode: number;
  13233. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13234. limitVelocityDamping: number;
  13235. /**
  13236. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13237. */
  13238. beginAnimationOnStart: boolean;
  13239. /**
  13240. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13241. */
  13242. beginAnimationFrom: number;
  13243. /**
  13244. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13245. */
  13246. beginAnimationTo: number;
  13247. /**
  13248. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13249. */
  13250. beginAnimationLoop: boolean;
  13251. /**
  13252. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13253. */
  13254. disposeOnStop: boolean;
  13255. /**
  13256. * Specifies if the particles are updated in emitter local space or world space
  13257. */
  13258. isLocal: boolean;
  13259. /** Snippet ID if the particle system was created from the snippet server */
  13260. snippetId: string;
  13261. /**
  13262. * Gets the maximum number of particles active at the same time.
  13263. * @returns The max number of active particles.
  13264. */
  13265. getCapacity(): number;
  13266. /**
  13267. * Gets the number of particles active at the same time.
  13268. * @returns The number of active particles.
  13269. */
  13270. getActiveCount(): number;
  13271. /**
  13272. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13273. * @returns True if it has been started, otherwise false.
  13274. */
  13275. isStarted(): boolean;
  13276. /**
  13277. * Animates the particle system for this frame.
  13278. */
  13279. animate(): void;
  13280. /**
  13281. * Renders the particle system in its current state.
  13282. * @returns the current number of particles
  13283. */
  13284. render(): number;
  13285. /**
  13286. * Dispose the particle system and frees its associated resources.
  13287. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13288. */
  13289. dispose(disposeTexture?: boolean): void;
  13290. /**
  13291. * Clones the particle system.
  13292. * @param name The name of the cloned object
  13293. * @param newEmitter The new emitter to use
  13294. * @returns the cloned particle system
  13295. */
  13296. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13297. /**
  13298. * Serializes the particle system to a JSON object
  13299. * @param serializeTexture defines if the texture must be serialized as well
  13300. * @returns the JSON object
  13301. */
  13302. serialize(serializeTexture: boolean): any;
  13303. /**
  13304. * Rebuild the particle system
  13305. */
  13306. rebuild(): void;
  13307. /** Force the system to rebuild all gradients that need to be resync */
  13308. forceRefreshGradients(): void;
  13309. /**
  13310. * Starts the particle system and begins to emit
  13311. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13312. */
  13313. start(delay?: number): void;
  13314. /**
  13315. * Stops the particle system.
  13316. */
  13317. stop(): void;
  13318. /**
  13319. * Remove all active particles
  13320. */
  13321. reset(): void;
  13322. /**
  13323. * Gets a boolean indicating that the system is stopping
  13324. * @returns true if the system is currently stopping
  13325. */
  13326. isStopping(): boolean;
  13327. /**
  13328. * Is this system ready to be used/rendered
  13329. * @return true if the system is ready
  13330. */
  13331. isReady(): boolean;
  13332. /**
  13333. * Returns the string "ParticleSystem"
  13334. * @returns a string containing the class name
  13335. */
  13336. getClassName(): string;
  13337. /**
  13338. * Adds a new color gradient
  13339. * @param gradient defines the gradient to use (between 0 and 1)
  13340. * @param color1 defines the color to affect to the specified gradient
  13341. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13342. * @returns the current particle system
  13343. */
  13344. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13345. /**
  13346. * Remove a specific color gradient
  13347. * @param gradient defines the gradient to remove
  13348. * @returns the current particle system
  13349. */
  13350. removeColorGradient(gradient: number): IParticleSystem;
  13351. /**
  13352. * Adds a new size gradient
  13353. * @param gradient defines the gradient to use (between 0 and 1)
  13354. * @param factor defines the size factor to affect to the specified gradient
  13355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13356. * @returns the current particle system
  13357. */
  13358. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13359. /**
  13360. * Remove a specific size gradient
  13361. * @param gradient defines the gradient to remove
  13362. * @returns the current particle system
  13363. */
  13364. removeSizeGradient(gradient: number): IParticleSystem;
  13365. /**
  13366. * Gets the current list of color gradients.
  13367. * You must use addColorGradient and removeColorGradient to udpate this list
  13368. * @returns the list of color gradients
  13369. */
  13370. getColorGradients(): Nullable<Array<ColorGradient>>;
  13371. /**
  13372. * Gets the current list of size gradients.
  13373. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13374. * @returns the list of size gradients
  13375. */
  13376. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13377. /**
  13378. * Gets the current list of angular speed gradients.
  13379. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13380. * @returns the list of angular speed gradients
  13381. */
  13382. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13383. /**
  13384. * Adds a new angular speed gradient
  13385. * @param gradient defines the gradient to use (between 0 and 1)
  13386. * @param factor defines the angular speed to affect to the specified gradient
  13387. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13388. * @returns the current particle system
  13389. */
  13390. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13391. /**
  13392. * Remove a specific angular speed gradient
  13393. * @param gradient defines the gradient to remove
  13394. * @returns the current particle system
  13395. */
  13396. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13397. /**
  13398. * Gets the current list of velocity gradients.
  13399. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13400. * @returns the list of velocity gradients
  13401. */
  13402. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13403. /**
  13404. * Adds a new velocity gradient
  13405. * @param gradient defines the gradient to use (between 0 and 1)
  13406. * @param factor defines the velocity to affect to the specified gradient
  13407. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13408. * @returns the current particle system
  13409. */
  13410. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13411. /**
  13412. * Remove a specific velocity gradient
  13413. * @param gradient defines the gradient to remove
  13414. * @returns the current particle system
  13415. */
  13416. removeVelocityGradient(gradient: number): IParticleSystem;
  13417. /**
  13418. * Gets the current list of limit velocity gradients.
  13419. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13420. * @returns the list of limit velocity gradients
  13421. */
  13422. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13423. /**
  13424. * Adds a new limit velocity gradient
  13425. * @param gradient defines the gradient to use (between 0 and 1)
  13426. * @param factor defines the limit velocity to affect to the specified gradient
  13427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13428. * @returns the current particle system
  13429. */
  13430. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13431. /**
  13432. * Remove a specific limit velocity gradient
  13433. * @param gradient defines the gradient to remove
  13434. * @returns the current particle system
  13435. */
  13436. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13437. /**
  13438. * Adds a new drag gradient
  13439. * @param gradient defines the gradient to use (between 0 and 1)
  13440. * @param factor defines the drag to affect to the specified gradient
  13441. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13442. * @returns the current particle system
  13443. */
  13444. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13445. /**
  13446. * Remove a specific drag gradient
  13447. * @param gradient defines the gradient to remove
  13448. * @returns the current particle system
  13449. */
  13450. removeDragGradient(gradient: number): IParticleSystem;
  13451. /**
  13452. * Gets the current list of drag gradients.
  13453. * You must use addDragGradient and removeDragGradient to udpate this list
  13454. * @returns the list of drag gradients
  13455. */
  13456. getDragGradients(): Nullable<Array<FactorGradient>>;
  13457. /**
  13458. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13459. * @param gradient defines the gradient to use (between 0 and 1)
  13460. * @param factor defines the emit rate to affect to the specified gradient
  13461. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13462. * @returns the current particle system
  13463. */
  13464. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13465. /**
  13466. * Remove a specific emit rate gradient
  13467. * @param gradient defines the gradient to remove
  13468. * @returns the current particle system
  13469. */
  13470. removeEmitRateGradient(gradient: number): IParticleSystem;
  13471. /**
  13472. * Gets the current list of emit rate gradients.
  13473. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13474. * @returns the list of emit rate gradients
  13475. */
  13476. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13477. /**
  13478. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13479. * @param gradient defines the gradient to use (between 0 and 1)
  13480. * @param factor defines the start size to affect to the specified gradient
  13481. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13482. * @returns the current particle system
  13483. */
  13484. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13485. /**
  13486. * Remove a specific start size gradient
  13487. * @param gradient defines the gradient to remove
  13488. * @returns the current particle system
  13489. */
  13490. removeStartSizeGradient(gradient: number): IParticleSystem;
  13491. /**
  13492. * Gets the current list of start size gradients.
  13493. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13494. * @returns the list of start size gradients
  13495. */
  13496. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13497. /**
  13498. * Adds a new life time gradient
  13499. * @param gradient defines the gradient to use (between 0 and 1)
  13500. * @param factor defines the life time factor to affect to the specified gradient
  13501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13502. * @returns the current particle system
  13503. */
  13504. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13505. /**
  13506. * Remove a specific life time gradient
  13507. * @param gradient defines the gradient to remove
  13508. * @returns the current particle system
  13509. */
  13510. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13511. /**
  13512. * Gets the current list of life time gradients.
  13513. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13514. * @returns the list of life time gradients
  13515. */
  13516. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13517. /**
  13518. * Gets the current list of color gradients.
  13519. * You must use addColorGradient and removeColorGradient to udpate this list
  13520. * @returns the list of color gradients
  13521. */
  13522. getColorGradients(): Nullable<Array<ColorGradient>>;
  13523. /**
  13524. * Adds a new ramp gradient used to remap particle colors
  13525. * @param gradient defines the gradient to use (between 0 and 1)
  13526. * @param color defines the color to affect to the specified gradient
  13527. * @returns the current particle system
  13528. */
  13529. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13530. /**
  13531. * Gets the current list of ramp gradients.
  13532. * You must use addRampGradient and removeRampGradient to udpate this list
  13533. * @returns the list of ramp gradients
  13534. */
  13535. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13536. /** Gets or sets a boolean indicating that ramp gradients must be used
  13537. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13538. */
  13539. useRampGradients: boolean;
  13540. /**
  13541. * Adds a new color remap gradient
  13542. * @param gradient defines the gradient to use (between 0 and 1)
  13543. * @param min defines the color remap minimal range
  13544. * @param max defines the color remap maximal range
  13545. * @returns the current particle system
  13546. */
  13547. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13548. /**
  13549. * Gets the current list of color remap gradients.
  13550. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13551. * @returns the list of color remap gradients
  13552. */
  13553. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13554. /**
  13555. * Adds a new alpha remap gradient
  13556. * @param gradient defines the gradient to use (between 0 and 1)
  13557. * @param min defines the alpha remap minimal range
  13558. * @param max defines the alpha remap maximal range
  13559. * @returns the current particle system
  13560. */
  13561. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13562. /**
  13563. * Gets the current list of alpha remap gradients.
  13564. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13565. * @returns the list of alpha remap gradients
  13566. */
  13567. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13568. /**
  13569. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13570. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13571. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13572. * @returns the emitter
  13573. */
  13574. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13575. /**
  13576. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13577. * @param radius The radius of the hemisphere to emit from
  13578. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13579. * @returns the emitter
  13580. */
  13581. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13582. /**
  13583. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13584. * @param radius The radius of the sphere to emit from
  13585. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13586. * @returns the emitter
  13587. */
  13588. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13589. /**
  13590. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13591. * @param radius The radius of the sphere to emit from
  13592. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13593. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13594. * @returns the emitter
  13595. */
  13596. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13597. /**
  13598. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13599. * @param radius The radius of the emission cylinder
  13600. * @param height The height of the emission cylinder
  13601. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13602. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13603. * @returns the emitter
  13604. */
  13605. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13606. /**
  13607. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13608. * @param radius The radius of the cylinder to emit from
  13609. * @param height The height of the emission cylinder
  13610. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13611. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13612. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13613. * @returns the emitter
  13614. */
  13615. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13616. /**
  13617. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13618. * @param radius The radius of the cone to emit from
  13619. * @param angle The base angle of the cone
  13620. * @returns the emitter
  13621. */
  13622. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13623. /**
  13624. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13625. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13626. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13627. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13628. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13629. * @returns the emitter
  13630. */
  13631. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13632. /**
  13633. * Get hosting scene
  13634. * @returns the scene
  13635. */
  13636. getScene(): Scene;
  13637. }
  13638. }
  13639. declare module BABYLON {
  13640. /**
  13641. * 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.
  13642. * @see https://doc.babylonjs.com/how_to/transformnode
  13643. */
  13644. export class TransformNode extends Node {
  13645. /**
  13646. * Object will not rotate to face the camera
  13647. */
  13648. static BILLBOARDMODE_NONE: number;
  13649. /**
  13650. * Object will rotate to face the camera but only on the x axis
  13651. */
  13652. static BILLBOARDMODE_X: number;
  13653. /**
  13654. * Object will rotate to face the camera but only on the y axis
  13655. */
  13656. static BILLBOARDMODE_Y: number;
  13657. /**
  13658. * Object will rotate to face the camera but only on the z axis
  13659. */
  13660. static BILLBOARDMODE_Z: number;
  13661. /**
  13662. * Object will rotate to face the camera
  13663. */
  13664. static BILLBOARDMODE_ALL: number;
  13665. /**
  13666. * Object will rotate to face the camera's position instead of orientation
  13667. */
  13668. static BILLBOARDMODE_USE_POSITION: number;
  13669. private _forward;
  13670. private _forwardInverted;
  13671. private _up;
  13672. private _right;
  13673. private _rightInverted;
  13674. private _position;
  13675. private _rotation;
  13676. private _rotationQuaternion;
  13677. protected _scaling: Vector3;
  13678. protected _isDirty: boolean;
  13679. private _transformToBoneReferal;
  13680. private _isAbsoluteSynced;
  13681. private _billboardMode;
  13682. /**
  13683. * Gets or sets the billboard mode. Default is 0.
  13684. *
  13685. * | Value | Type | Description |
  13686. * | --- | --- | --- |
  13687. * | 0 | BILLBOARDMODE_NONE | |
  13688. * | 1 | BILLBOARDMODE_X | |
  13689. * | 2 | BILLBOARDMODE_Y | |
  13690. * | 4 | BILLBOARDMODE_Z | |
  13691. * | 7 | BILLBOARDMODE_ALL | |
  13692. *
  13693. */
  13694. get billboardMode(): number;
  13695. set billboardMode(value: number);
  13696. private _preserveParentRotationForBillboard;
  13697. /**
  13698. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13699. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13700. */
  13701. get preserveParentRotationForBillboard(): boolean;
  13702. set preserveParentRotationForBillboard(value: boolean);
  13703. /**
  13704. * 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
  13705. */
  13706. scalingDeterminant: number;
  13707. private _infiniteDistance;
  13708. /**
  13709. * Gets or sets the distance of the object to max, often used by skybox
  13710. */
  13711. get infiniteDistance(): boolean;
  13712. set infiniteDistance(value: boolean);
  13713. /**
  13714. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13715. * By default the system will update normals to compensate
  13716. */
  13717. ignoreNonUniformScaling: boolean;
  13718. /**
  13719. * 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
  13720. */
  13721. reIntegrateRotationIntoRotationQuaternion: boolean;
  13722. /** @hidden */
  13723. _poseMatrix: Nullable<Matrix>;
  13724. /** @hidden */
  13725. _localMatrix: Matrix;
  13726. private _usePivotMatrix;
  13727. private _absolutePosition;
  13728. private _absoluteScaling;
  13729. private _absoluteRotationQuaternion;
  13730. private _pivotMatrix;
  13731. private _pivotMatrixInverse;
  13732. protected _postMultiplyPivotMatrix: boolean;
  13733. protected _isWorldMatrixFrozen: boolean;
  13734. /** @hidden */
  13735. _indexInSceneTransformNodesArray: number;
  13736. /**
  13737. * An event triggered after the world matrix is updated
  13738. */
  13739. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13740. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13741. /**
  13742. * Gets a string identifying the name of the class
  13743. * @returns "TransformNode" string
  13744. */
  13745. getClassName(): string;
  13746. /**
  13747. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13748. */
  13749. get position(): Vector3;
  13750. set position(newPosition: Vector3);
  13751. /**
  13752. * 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)).
  13753. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13754. */
  13755. get rotation(): Vector3;
  13756. set rotation(newRotation: Vector3);
  13757. /**
  13758. * 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)).
  13759. */
  13760. get scaling(): Vector3;
  13761. set scaling(newScaling: Vector3);
  13762. /**
  13763. * 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).
  13764. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13765. */
  13766. get rotationQuaternion(): Nullable<Quaternion>;
  13767. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13768. /**
  13769. * The forward direction of that transform in world space.
  13770. */
  13771. get forward(): Vector3;
  13772. /**
  13773. * The up direction of that transform in world space.
  13774. */
  13775. get up(): Vector3;
  13776. /**
  13777. * The right direction of that transform in world space.
  13778. */
  13779. get right(): Vector3;
  13780. /**
  13781. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13782. * @param matrix the matrix to copy the pose from
  13783. * @returns this TransformNode.
  13784. */
  13785. updatePoseMatrix(matrix: Matrix): TransformNode;
  13786. /**
  13787. * Returns the mesh Pose matrix.
  13788. * @returns the pose matrix
  13789. */
  13790. getPoseMatrix(): Matrix;
  13791. /** @hidden */
  13792. _isSynchronized(): boolean;
  13793. /** @hidden */
  13794. _initCache(): void;
  13795. /**
  13796. * Flag the transform node as dirty (Forcing it to update everything)
  13797. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13798. * @returns this transform node
  13799. */
  13800. markAsDirty(property: string): TransformNode;
  13801. /**
  13802. * Returns the current mesh absolute position.
  13803. * Returns a Vector3.
  13804. */
  13805. get absolutePosition(): Vector3;
  13806. /**
  13807. * Returns the current mesh absolute scaling.
  13808. * Returns a Vector3.
  13809. */
  13810. get absoluteScaling(): Vector3;
  13811. /**
  13812. * Returns the current mesh absolute rotation.
  13813. * Returns a Quaternion.
  13814. */
  13815. get absoluteRotationQuaternion(): Quaternion;
  13816. /**
  13817. * Sets a new matrix to apply before all other transformation
  13818. * @param matrix defines the transform matrix
  13819. * @returns the current TransformNode
  13820. */
  13821. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13822. /**
  13823. * Sets a new pivot matrix to the current node
  13824. * @param matrix defines the new pivot matrix to use
  13825. * @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
  13826. * @returns the current TransformNode
  13827. */
  13828. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13829. /**
  13830. * Returns the mesh pivot matrix.
  13831. * Default : Identity.
  13832. * @returns the matrix
  13833. */
  13834. getPivotMatrix(): Matrix;
  13835. /**
  13836. * Instantiate (when possible) or clone that node with its hierarchy
  13837. * @param newParent defines the new parent to use for the instance (or clone)
  13838. * @param options defines options to configure how copy is done
  13839. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13840. * @returns an instance (or a clone) of the current node with its hiearchy
  13841. */
  13842. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13843. doNotInstantiate: boolean;
  13844. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13845. /**
  13846. * Prevents the World matrix to be computed any longer
  13847. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13848. * @returns the TransformNode.
  13849. */
  13850. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13851. /**
  13852. * Allows back the World matrix computation.
  13853. * @returns the TransformNode.
  13854. */
  13855. unfreezeWorldMatrix(): this;
  13856. /**
  13857. * True if the World matrix has been frozen.
  13858. */
  13859. get isWorldMatrixFrozen(): boolean;
  13860. /**
  13861. * Retuns the mesh absolute position in the World.
  13862. * @returns a Vector3.
  13863. */
  13864. getAbsolutePosition(): Vector3;
  13865. /**
  13866. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13867. * @param absolutePosition the absolute position to set
  13868. * @returns the TransformNode.
  13869. */
  13870. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13871. /**
  13872. * Sets the mesh position in its local space.
  13873. * @param vector3 the position to set in localspace
  13874. * @returns the TransformNode.
  13875. */
  13876. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13877. /**
  13878. * Returns the mesh position in the local space from the current World matrix values.
  13879. * @returns a new Vector3.
  13880. */
  13881. getPositionExpressedInLocalSpace(): Vector3;
  13882. /**
  13883. * Translates the mesh along the passed Vector3 in its local space.
  13884. * @param vector3 the distance to translate in localspace
  13885. * @returns the TransformNode.
  13886. */
  13887. locallyTranslate(vector3: Vector3): TransformNode;
  13888. private static _lookAtVectorCache;
  13889. /**
  13890. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13891. * @param targetPoint the position (must be in same space as current mesh) to look at
  13892. * @param yawCor optional yaw (y-axis) correction in radians
  13893. * @param pitchCor optional pitch (x-axis) correction in radians
  13894. * @param rollCor optional roll (z-axis) correction in radians
  13895. * @param space the choosen space of the target
  13896. * @returns the TransformNode.
  13897. */
  13898. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13899. /**
  13900. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13901. * This Vector3 is expressed in the World space.
  13902. * @param localAxis axis to rotate
  13903. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13904. */
  13905. getDirection(localAxis: Vector3): Vector3;
  13906. /**
  13907. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13908. * localAxis is expressed in the mesh local space.
  13909. * result is computed in the Wordl space from the mesh World matrix.
  13910. * @param localAxis axis to rotate
  13911. * @param result the resulting transformnode
  13912. * @returns this TransformNode.
  13913. */
  13914. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13915. /**
  13916. * Sets this transform node rotation to the given local axis.
  13917. * @param localAxis the axis in local space
  13918. * @param yawCor optional yaw (y-axis) correction in radians
  13919. * @param pitchCor optional pitch (x-axis) correction in radians
  13920. * @param rollCor optional roll (z-axis) correction in radians
  13921. * @returns this TransformNode
  13922. */
  13923. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13924. /**
  13925. * Sets a new pivot point to the current node
  13926. * @param point defines the new pivot point to use
  13927. * @param space defines if the point is in world or local space (local by default)
  13928. * @returns the current TransformNode
  13929. */
  13930. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13931. /**
  13932. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13933. * @returns the pivot point
  13934. */
  13935. getPivotPoint(): Vector3;
  13936. /**
  13937. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13938. * @param result the vector3 to store the result
  13939. * @returns this TransformNode.
  13940. */
  13941. getPivotPointToRef(result: Vector3): TransformNode;
  13942. /**
  13943. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13944. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13945. */
  13946. getAbsolutePivotPoint(): Vector3;
  13947. /**
  13948. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13949. * @param result vector3 to store the result
  13950. * @returns this TransformNode.
  13951. */
  13952. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13953. /**
  13954. * Defines the passed node as the parent of the current node.
  13955. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13956. * @see https://doc.babylonjs.com/how_to/parenting
  13957. * @param node the node ot set as the parent
  13958. * @returns this TransformNode.
  13959. */
  13960. setParent(node: Nullable<Node>): TransformNode;
  13961. private _nonUniformScaling;
  13962. /**
  13963. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13964. */
  13965. get nonUniformScaling(): boolean;
  13966. /** @hidden */
  13967. _updateNonUniformScalingState(value: boolean): boolean;
  13968. /**
  13969. * Attach the current TransformNode to another TransformNode associated with a bone
  13970. * @param bone Bone affecting the TransformNode
  13971. * @param affectedTransformNode TransformNode associated with the bone
  13972. * @returns this object
  13973. */
  13974. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13975. /**
  13976. * Detach the transform node if its associated with a bone
  13977. * @returns this object
  13978. */
  13979. detachFromBone(): TransformNode;
  13980. private static _rotationAxisCache;
  13981. /**
  13982. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13983. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13984. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13985. * The passed axis is also normalized.
  13986. * @param axis the axis to rotate around
  13987. * @param amount the amount to rotate in radians
  13988. * @param space Space to rotate in (Default: local)
  13989. * @returns the TransformNode.
  13990. */
  13991. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13992. /**
  13993. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13994. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13995. * The passed axis is also normalized. .
  13996. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13997. * @param point the point to rotate around
  13998. * @param axis the axis to rotate around
  13999. * @param amount the amount to rotate in radians
  14000. * @returns the TransformNode
  14001. */
  14002. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14003. /**
  14004. * Translates the mesh along the axis vector for the passed distance in the given space.
  14005. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14006. * @param axis the axis to translate in
  14007. * @param distance the distance to translate
  14008. * @param space Space to rotate in (Default: local)
  14009. * @returns the TransformNode.
  14010. */
  14011. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14012. /**
  14013. * Adds a rotation step to the mesh current rotation.
  14014. * x, y, z are Euler angles expressed in radians.
  14015. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14016. * This means this rotation is made in the mesh local space only.
  14017. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14018. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14019. * ```javascript
  14020. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14021. * ```
  14022. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14023. * 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.
  14024. * @param x Rotation to add
  14025. * @param y Rotation to add
  14026. * @param z Rotation to add
  14027. * @returns the TransformNode.
  14028. */
  14029. addRotation(x: number, y: number, z: number): TransformNode;
  14030. /**
  14031. * @hidden
  14032. */
  14033. protected _getEffectiveParent(): Nullable<Node>;
  14034. /**
  14035. * Computes the world matrix of the node
  14036. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14037. * @returns the world matrix
  14038. */
  14039. computeWorldMatrix(force?: boolean): Matrix;
  14040. /**
  14041. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14042. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14043. */
  14044. resetLocalMatrix(independentOfChildren?: boolean): void;
  14045. protected _afterComputeWorldMatrix(): void;
  14046. /**
  14047. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14048. * @param func callback function to add
  14049. *
  14050. * @returns the TransformNode.
  14051. */
  14052. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14053. /**
  14054. * Removes a registered callback function.
  14055. * @param func callback function to remove
  14056. * @returns the TransformNode.
  14057. */
  14058. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14059. /**
  14060. * Gets the position of the current mesh in camera space
  14061. * @param camera defines the camera to use
  14062. * @returns a position
  14063. */
  14064. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14065. /**
  14066. * Returns the distance from the mesh to the active camera
  14067. * @param camera defines the camera to use
  14068. * @returns the distance
  14069. */
  14070. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14071. /**
  14072. * Clone the current transform node
  14073. * @param name Name of the new clone
  14074. * @param newParent New parent for the clone
  14075. * @param doNotCloneChildren Do not clone children hierarchy
  14076. * @returns the new transform node
  14077. */
  14078. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14079. /**
  14080. * Serializes the objects information.
  14081. * @param currentSerializationObject defines the object to serialize in
  14082. * @returns the serialized object
  14083. */
  14084. serialize(currentSerializationObject?: any): any;
  14085. /**
  14086. * Returns a new TransformNode object parsed from the source provided.
  14087. * @param parsedTransformNode is the source.
  14088. * @param scene the scne the object belongs to
  14089. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14090. * @returns a new TransformNode object parsed from the source provided.
  14091. */
  14092. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14093. /**
  14094. * Get all child-transformNodes of this node
  14095. * @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
  14096. * @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
  14097. * @returns an array of TransformNode
  14098. */
  14099. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14100. /**
  14101. * Releases resources associated with this transform node.
  14102. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14103. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14104. */
  14105. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14106. /**
  14107. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14108. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14109. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14110. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14111. * @returns the current mesh
  14112. */
  14113. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14114. private _syncAbsoluteScalingAndRotation;
  14115. }
  14116. }
  14117. declare module BABYLON {
  14118. /**
  14119. * Class used to override all child animations of a given target
  14120. */
  14121. export class AnimationPropertiesOverride {
  14122. /**
  14123. * Gets or sets a value indicating if animation blending must be used
  14124. */
  14125. enableBlending: boolean;
  14126. /**
  14127. * Gets or sets the blending speed to use when enableBlending is true
  14128. */
  14129. blendingSpeed: number;
  14130. /**
  14131. * Gets or sets the default loop mode to use
  14132. */
  14133. loopMode: number;
  14134. }
  14135. }
  14136. declare module BABYLON {
  14137. /**
  14138. * Class used to store bone information
  14139. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14140. */
  14141. export class Bone extends Node {
  14142. /**
  14143. * defines the bone name
  14144. */
  14145. name: string;
  14146. private static _tmpVecs;
  14147. private static _tmpQuat;
  14148. private static _tmpMats;
  14149. /**
  14150. * Gets the list of child bones
  14151. */
  14152. children: Bone[];
  14153. /** Gets the animations associated with this bone */
  14154. animations: Animation[];
  14155. /**
  14156. * Gets or sets bone length
  14157. */
  14158. length: number;
  14159. /**
  14160. * @hidden Internal only
  14161. * Set this value to map this bone to a different index in the transform matrices
  14162. * Set this value to -1 to exclude the bone from the transform matrices
  14163. */
  14164. _index: Nullable<number>;
  14165. private _skeleton;
  14166. private _localMatrix;
  14167. private _restPose;
  14168. private _baseMatrix;
  14169. private _absoluteTransform;
  14170. private _invertedAbsoluteTransform;
  14171. private _parent;
  14172. private _scalingDeterminant;
  14173. private _worldTransform;
  14174. private _localScaling;
  14175. private _localRotation;
  14176. private _localPosition;
  14177. private _needToDecompose;
  14178. private _needToCompose;
  14179. /** @hidden */
  14180. _linkedTransformNode: Nullable<TransformNode>;
  14181. /** @hidden */
  14182. _waitingTransformNodeId: Nullable<string>;
  14183. /** @hidden */
  14184. get _matrix(): Matrix;
  14185. /** @hidden */
  14186. set _matrix(value: Matrix);
  14187. /**
  14188. * Create a new bone
  14189. * @param name defines the bone name
  14190. * @param skeleton defines the parent skeleton
  14191. * @param parentBone defines the parent (can be null if the bone is the root)
  14192. * @param localMatrix defines the local matrix
  14193. * @param restPose defines the rest pose matrix
  14194. * @param baseMatrix defines the base matrix
  14195. * @param index defines index of the bone in the hiearchy
  14196. */
  14197. constructor(
  14198. /**
  14199. * defines the bone name
  14200. */
  14201. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14202. /**
  14203. * Gets the current object class name.
  14204. * @return the class name
  14205. */
  14206. getClassName(): string;
  14207. /**
  14208. * Gets the parent skeleton
  14209. * @returns a skeleton
  14210. */
  14211. getSkeleton(): Skeleton;
  14212. /**
  14213. * Gets parent bone
  14214. * @returns a bone or null if the bone is the root of the bone hierarchy
  14215. */
  14216. getParent(): Nullable<Bone>;
  14217. /**
  14218. * Returns an array containing the root bones
  14219. * @returns an array containing the root bones
  14220. */
  14221. getChildren(): Array<Bone>;
  14222. /**
  14223. * Gets the node index in matrix array generated for rendering
  14224. * @returns the node index
  14225. */
  14226. getIndex(): number;
  14227. /**
  14228. * Sets the parent bone
  14229. * @param parent defines the parent (can be null if the bone is the root)
  14230. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14231. */
  14232. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14233. /**
  14234. * Gets the local matrix
  14235. * @returns a matrix
  14236. */
  14237. getLocalMatrix(): Matrix;
  14238. /**
  14239. * Gets the base matrix (initial matrix which remains unchanged)
  14240. * @returns a matrix
  14241. */
  14242. getBaseMatrix(): Matrix;
  14243. /**
  14244. * Gets the rest pose matrix
  14245. * @returns a matrix
  14246. */
  14247. getRestPose(): Matrix;
  14248. /**
  14249. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14250. */
  14251. getWorldMatrix(): Matrix;
  14252. /**
  14253. * Sets the local matrix to rest pose matrix
  14254. */
  14255. returnToRest(): void;
  14256. /**
  14257. * Gets the inverse of the absolute transform matrix.
  14258. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14259. * @returns a matrix
  14260. */
  14261. getInvertedAbsoluteTransform(): Matrix;
  14262. /**
  14263. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14264. * @returns a matrix
  14265. */
  14266. getAbsoluteTransform(): Matrix;
  14267. /**
  14268. * Links with the given transform node.
  14269. * The local matrix of this bone is copied from the transform node every frame.
  14270. * @param transformNode defines the transform node to link to
  14271. */
  14272. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14273. /**
  14274. * Gets the node used to drive the bone's transformation
  14275. * @returns a transform node or null
  14276. */
  14277. getTransformNode(): Nullable<TransformNode>;
  14278. /** Gets or sets current position (in local space) */
  14279. get position(): Vector3;
  14280. set position(newPosition: Vector3);
  14281. /** Gets or sets current rotation (in local space) */
  14282. get rotation(): Vector3;
  14283. set rotation(newRotation: Vector3);
  14284. /** Gets or sets current rotation quaternion (in local space) */
  14285. get rotationQuaternion(): Quaternion;
  14286. set rotationQuaternion(newRotation: Quaternion);
  14287. /** Gets or sets current scaling (in local space) */
  14288. get scaling(): Vector3;
  14289. set scaling(newScaling: Vector3);
  14290. /**
  14291. * Gets the animation properties override
  14292. */
  14293. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14294. private _decompose;
  14295. private _compose;
  14296. /**
  14297. * Update the base and local matrices
  14298. * @param matrix defines the new base or local matrix
  14299. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14300. * @param updateLocalMatrix defines if the local matrix should be updated
  14301. */
  14302. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14303. /** @hidden */
  14304. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14305. /**
  14306. * Flag the bone as dirty (Forcing it to update everything)
  14307. */
  14308. markAsDirty(): void;
  14309. /** @hidden */
  14310. _markAsDirtyAndCompose(): void;
  14311. private _markAsDirtyAndDecompose;
  14312. /**
  14313. * Translate the bone in local or world space
  14314. * @param vec The amount to translate the bone
  14315. * @param space The space that the translation is in
  14316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14317. */
  14318. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14319. /**
  14320. * Set the postion of the bone in local or world space
  14321. * @param position The position to set the bone
  14322. * @param space The space that the position is in
  14323. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14324. */
  14325. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14326. /**
  14327. * Set the absolute position of the bone (world space)
  14328. * @param position The position to set the bone
  14329. * @param mesh The mesh that this bone is attached to
  14330. */
  14331. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14332. /**
  14333. * Scale the bone on the x, y and z axes (in local space)
  14334. * @param x The amount to scale the bone on the x axis
  14335. * @param y The amount to scale the bone on the y axis
  14336. * @param z The amount to scale the bone on the z axis
  14337. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14338. */
  14339. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14340. /**
  14341. * Set the bone scaling in local space
  14342. * @param scale defines the scaling vector
  14343. */
  14344. setScale(scale: Vector3): void;
  14345. /**
  14346. * Gets the current scaling in local space
  14347. * @returns the current scaling vector
  14348. */
  14349. getScale(): Vector3;
  14350. /**
  14351. * Gets the current scaling in local space and stores it in a target vector
  14352. * @param result defines the target vector
  14353. */
  14354. getScaleToRef(result: Vector3): void;
  14355. /**
  14356. * Set the yaw, pitch, and roll of the bone in local or world space
  14357. * @param yaw The rotation of the bone on the y axis
  14358. * @param pitch The rotation of the bone on the x axis
  14359. * @param roll The rotation of the bone on the z axis
  14360. * @param space The space that the axes of rotation are in
  14361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14362. */
  14363. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14364. /**
  14365. * Add a rotation to the bone on an axis in local or world space
  14366. * @param axis The axis to rotate the bone on
  14367. * @param amount The amount to rotate the bone
  14368. * @param space The space that the axis is in
  14369. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14370. */
  14371. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14372. /**
  14373. * Set the rotation of the bone to a particular axis angle in local or world space
  14374. * @param axis The axis to rotate the bone on
  14375. * @param angle The angle that the bone should be rotated to
  14376. * @param space The space that the axis is in
  14377. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14378. */
  14379. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14380. /**
  14381. * Set the euler rotation of the bone in local of world space
  14382. * @param rotation The euler rotation that the bone should be set to
  14383. * @param space The space that the rotation is in
  14384. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14385. */
  14386. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14387. /**
  14388. * Set the quaternion rotation of the bone in local of world space
  14389. * @param quat The quaternion rotation that the bone should be set to
  14390. * @param space The space that the rotation is in
  14391. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14392. */
  14393. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14394. /**
  14395. * Set the rotation matrix of the bone in local of world space
  14396. * @param rotMat The rotation matrix that the bone should be set to
  14397. * @param space The space that the rotation is in
  14398. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14399. */
  14400. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14401. private _rotateWithMatrix;
  14402. private _getNegativeRotationToRef;
  14403. /**
  14404. * Get the position of the bone in local or world space
  14405. * @param space The space that the returned position is in
  14406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14407. * @returns The position of the bone
  14408. */
  14409. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14410. /**
  14411. * Copy the position of the bone to a vector3 in local or world space
  14412. * @param space The space that the returned position is in
  14413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14414. * @param result The vector3 to copy the position to
  14415. */
  14416. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14417. /**
  14418. * Get the absolute position of the bone (world space)
  14419. * @param mesh The mesh that this bone is attached to
  14420. * @returns The absolute position of the bone
  14421. */
  14422. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14423. /**
  14424. * Copy the absolute position of the bone (world space) to the result param
  14425. * @param mesh The mesh that this bone is attached to
  14426. * @param result The vector3 to copy the absolute position to
  14427. */
  14428. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14429. /**
  14430. * Compute the absolute transforms of this bone and its children
  14431. */
  14432. computeAbsoluteTransforms(): void;
  14433. /**
  14434. * Get the world direction from an axis that is in the local space of the bone
  14435. * @param localAxis The local direction that is used to compute the world direction
  14436. * @param mesh The mesh that this bone is attached to
  14437. * @returns The world direction
  14438. */
  14439. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14440. /**
  14441. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14442. * @param localAxis The local direction that is used to compute the world direction
  14443. * @param mesh The mesh that this bone is attached to
  14444. * @param result The vector3 that the world direction will be copied to
  14445. */
  14446. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14447. /**
  14448. * Get the euler rotation of the bone in local or world space
  14449. * @param space The space that the rotation should be in
  14450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14451. * @returns The euler rotation
  14452. */
  14453. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14454. /**
  14455. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14456. * @param space The space that the rotation should be in
  14457. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14458. * @param result The vector3 that the rotation should be copied to
  14459. */
  14460. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14461. /**
  14462. * Get the quaternion rotation of the bone in either local or world space
  14463. * @param space The space that the rotation should be in
  14464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14465. * @returns The quaternion rotation
  14466. */
  14467. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14468. /**
  14469. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14470. * @param space The space that the rotation should be in
  14471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14472. * @param result The quaternion that the rotation should be copied to
  14473. */
  14474. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14475. /**
  14476. * Get the rotation matrix of the bone in local or world space
  14477. * @param space The space that the rotation should be in
  14478. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14479. * @returns The rotation matrix
  14480. */
  14481. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14482. /**
  14483. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14484. * @param space The space that the rotation should be in
  14485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14486. * @param result The quaternion that the rotation should be copied to
  14487. */
  14488. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14489. /**
  14490. * Get the world position of a point that is in the local space of the bone
  14491. * @param position The local position
  14492. * @param mesh The mesh that this bone is attached to
  14493. * @returns The world position
  14494. */
  14495. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14496. /**
  14497. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14498. * @param position The local position
  14499. * @param mesh The mesh that this bone is attached to
  14500. * @param result The vector3 that the world position should be copied to
  14501. */
  14502. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14503. /**
  14504. * Get the local position of a point that is in world space
  14505. * @param position The world position
  14506. * @param mesh The mesh that this bone is attached to
  14507. * @returns The local position
  14508. */
  14509. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14510. /**
  14511. * Get the local position of a point that is in world space and copy it to the result param
  14512. * @param position The world position
  14513. * @param mesh The mesh that this bone is attached to
  14514. * @param result The vector3 that the local position should be copied to
  14515. */
  14516. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14517. }
  14518. }
  14519. declare module BABYLON {
  14520. /**
  14521. * Defines a runtime animation
  14522. */
  14523. export class RuntimeAnimation {
  14524. private _events;
  14525. /**
  14526. * The current frame of the runtime animation
  14527. */
  14528. private _currentFrame;
  14529. /**
  14530. * The animation used by the runtime animation
  14531. */
  14532. private _animation;
  14533. /**
  14534. * The target of the runtime animation
  14535. */
  14536. private _target;
  14537. /**
  14538. * The initiating animatable
  14539. */
  14540. private _host;
  14541. /**
  14542. * The original value of the runtime animation
  14543. */
  14544. private _originalValue;
  14545. /**
  14546. * The original blend value of the runtime animation
  14547. */
  14548. private _originalBlendValue;
  14549. /**
  14550. * The offsets cache of the runtime animation
  14551. */
  14552. private _offsetsCache;
  14553. /**
  14554. * The high limits cache of the runtime animation
  14555. */
  14556. private _highLimitsCache;
  14557. /**
  14558. * Specifies if the runtime animation has been stopped
  14559. */
  14560. private _stopped;
  14561. /**
  14562. * The blending factor of the runtime animation
  14563. */
  14564. private _blendingFactor;
  14565. /**
  14566. * The BabylonJS scene
  14567. */
  14568. private _scene;
  14569. /**
  14570. * The current value of the runtime animation
  14571. */
  14572. private _currentValue;
  14573. /** @hidden */
  14574. _animationState: _IAnimationState;
  14575. /**
  14576. * The active target of the runtime animation
  14577. */
  14578. private _activeTargets;
  14579. private _currentActiveTarget;
  14580. private _directTarget;
  14581. /**
  14582. * The target path of the runtime animation
  14583. */
  14584. private _targetPath;
  14585. /**
  14586. * The weight of the runtime animation
  14587. */
  14588. private _weight;
  14589. /**
  14590. * The ratio offset of the runtime animation
  14591. */
  14592. private _ratioOffset;
  14593. /**
  14594. * The previous delay of the runtime animation
  14595. */
  14596. private _previousDelay;
  14597. /**
  14598. * The previous ratio of the runtime animation
  14599. */
  14600. private _previousRatio;
  14601. private _enableBlending;
  14602. private _keys;
  14603. private _minFrame;
  14604. private _maxFrame;
  14605. private _minValue;
  14606. private _maxValue;
  14607. private _targetIsArray;
  14608. /**
  14609. * Gets the current frame of the runtime animation
  14610. */
  14611. get currentFrame(): number;
  14612. /**
  14613. * Gets the weight of the runtime animation
  14614. */
  14615. get weight(): number;
  14616. /**
  14617. * Gets the current value of the runtime animation
  14618. */
  14619. get currentValue(): any;
  14620. /**
  14621. * Gets the target path of the runtime animation
  14622. */
  14623. get targetPath(): string;
  14624. /**
  14625. * Gets the actual target of the runtime animation
  14626. */
  14627. get target(): any;
  14628. /**
  14629. * Gets the additive state of the runtime animation
  14630. */
  14631. get isAdditive(): boolean;
  14632. /** @hidden */
  14633. _onLoop: () => void;
  14634. /**
  14635. * Create a new RuntimeAnimation object
  14636. * @param target defines the target of the animation
  14637. * @param animation defines the source animation object
  14638. * @param scene defines the hosting scene
  14639. * @param host defines the initiating Animatable
  14640. */
  14641. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14642. private _preparePath;
  14643. /**
  14644. * Gets the animation from the runtime animation
  14645. */
  14646. get animation(): Animation;
  14647. /**
  14648. * Resets the runtime animation to the beginning
  14649. * @param restoreOriginal defines whether to restore the target property to the original value
  14650. */
  14651. reset(restoreOriginal?: boolean): void;
  14652. /**
  14653. * Specifies if the runtime animation is stopped
  14654. * @returns Boolean specifying if the runtime animation is stopped
  14655. */
  14656. isStopped(): boolean;
  14657. /**
  14658. * Disposes of the runtime animation
  14659. */
  14660. dispose(): void;
  14661. /**
  14662. * Apply the interpolated value to the target
  14663. * @param currentValue defines the value computed by the animation
  14664. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14665. */
  14666. setValue(currentValue: any, weight: number): void;
  14667. private _getOriginalValues;
  14668. private _setValue;
  14669. /**
  14670. * Gets the loop pmode of the runtime animation
  14671. * @returns Loop Mode
  14672. */
  14673. private _getCorrectLoopMode;
  14674. /**
  14675. * Move the current animation to a given frame
  14676. * @param frame defines the frame to move to
  14677. */
  14678. goToFrame(frame: number): void;
  14679. /**
  14680. * @hidden Internal use only
  14681. */
  14682. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14683. /**
  14684. * Execute the current animation
  14685. * @param delay defines the delay to add to the current frame
  14686. * @param from defines the lower bound of the animation range
  14687. * @param to defines the upper bound of the animation range
  14688. * @param loop defines if the current animation must loop
  14689. * @param speedRatio defines the current speed ratio
  14690. * @param weight defines the weight of the animation (default is -1 so no weight)
  14691. * @param onLoop optional callback called when animation loops
  14692. * @returns a boolean indicating if the animation is running
  14693. */
  14694. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14695. }
  14696. }
  14697. declare module BABYLON {
  14698. /**
  14699. * Class used to store an actual running animation
  14700. */
  14701. export class Animatable {
  14702. /** defines the target object */
  14703. target: any;
  14704. /** defines the starting frame number (default is 0) */
  14705. fromFrame: number;
  14706. /** defines the ending frame number (default is 100) */
  14707. toFrame: number;
  14708. /** defines if the animation must loop (default is false) */
  14709. loopAnimation: boolean;
  14710. /** defines a callback to call when animation ends if it is not looping */
  14711. onAnimationEnd?: (() => void) | null | undefined;
  14712. /** defines a callback to call when animation loops */
  14713. onAnimationLoop?: (() => void) | null | undefined;
  14714. /** defines whether the animation should be evaluated additively */
  14715. isAdditive: boolean;
  14716. private _localDelayOffset;
  14717. private _pausedDelay;
  14718. private _runtimeAnimations;
  14719. private _paused;
  14720. private _scene;
  14721. private _speedRatio;
  14722. private _weight;
  14723. private _syncRoot;
  14724. /**
  14725. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14726. * This will only apply for non looping animation (default is true)
  14727. */
  14728. disposeOnEnd: boolean;
  14729. /**
  14730. * Gets a boolean indicating if the animation has started
  14731. */
  14732. animationStarted: boolean;
  14733. /**
  14734. * Observer raised when the animation ends
  14735. */
  14736. onAnimationEndObservable: Observable<Animatable>;
  14737. /**
  14738. * Observer raised when the animation loops
  14739. */
  14740. onAnimationLoopObservable: Observable<Animatable>;
  14741. /**
  14742. * Gets the root Animatable used to synchronize and normalize animations
  14743. */
  14744. get syncRoot(): Nullable<Animatable>;
  14745. /**
  14746. * Gets the current frame of the first RuntimeAnimation
  14747. * Used to synchronize Animatables
  14748. */
  14749. get masterFrame(): number;
  14750. /**
  14751. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14752. */
  14753. get weight(): number;
  14754. set weight(value: number);
  14755. /**
  14756. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14757. */
  14758. get speedRatio(): number;
  14759. set speedRatio(value: number);
  14760. /**
  14761. * Creates a new Animatable
  14762. * @param scene defines the hosting scene
  14763. * @param target defines the target object
  14764. * @param fromFrame defines the starting frame number (default is 0)
  14765. * @param toFrame defines the ending frame number (default is 100)
  14766. * @param loopAnimation defines if the animation must loop (default is false)
  14767. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14768. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14769. * @param animations defines a group of animation to add to the new Animatable
  14770. * @param onAnimationLoop defines a callback to call when animation loops
  14771. * @param isAdditive defines whether the animation should be evaluated additively
  14772. */
  14773. constructor(scene: Scene,
  14774. /** defines the target object */
  14775. target: any,
  14776. /** defines the starting frame number (default is 0) */
  14777. fromFrame?: number,
  14778. /** defines the ending frame number (default is 100) */
  14779. toFrame?: number,
  14780. /** defines if the animation must loop (default is false) */
  14781. loopAnimation?: boolean, speedRatio?: number,
  14782. /** defines a callback to call when animation ends if it is not looping */
  14783. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14784. /** defines a callback to call when animation loops */
  14785. onAnimationLoop?: (() => void) | null | undefined,
  14786. /** defines whether the animation should be evaluated additively */
  14787. isAdditive?: boolean);
  14788. /**
  14789. * Synchronize and normalize current Animatable with a source Animatable
  14790. * This is useful when using animation weights and when animations are not of the same length
  14791. * @param root defines the root Animatable to synchronize with
  14792. * @returns the current Animatable
  14793. */
  14794. syncWith(root: Animatable): Animatable;
  14795. /**
  14796. * Gets the list of runtime animations
  14797. * @returns an array of RuntimeAnimation
  14798. */
  14799. getAnimations(): RuntimeAnimation[];
  14800. /**
  14801. * Adds more animations to the current animatable
  14802. * @param target defines the target of the animations
  14803. * @param animations defines the new animations to add
  14804. */
  14805. appendAnimations(target: any, animations: Animation[]): void;
  14806. /**
  14807. * Gets the source animation for a specific property
  14808. * @param property defines the propertyu to look for
  14809. * @returns null or the source animation for the given property
  14810. */
  14811. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14812. /**
  14813. * Gets the runtime animation for a specific property
  14814. * @param property defines the propertyu to look for
  14815. * @returns null or the runtime animation for the given property
  14816. */
  14817. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14818. /**
  14819. * Resets the animatable to its original state
  14820. */
  14821. reset(): void;
  14822. /**
  14823. * Allows the animatable to blend with current running animations
  14824. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14825. * @param blendingSpeed defines the blending speed to use
  14826. */
  14827. enableBlending(blendingSpeed: number): void;
  14828. /**
  14829. * Disable animation blending
  14830. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14831. */
  14832. disableBlending(): void;
  14833. /**
  14834. * Jump directly to a given frame
  14835. * @param frame defines the frame to jump to
  14836. */
  14837. goToFrame(frame: number): void;
  14838. /**
  14839. * Pause the animation
  14840. */
  14841. pause(): void;
  14842. /**
  14843. * Restart the animation
  14844. */
  14845. restart(): void;
  14846. private _raiseOnAnimationEnd;
  14847. /**
  14848. * Stop and delete the current animation
  14849. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14850. * @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)
  14851. */
  14852. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14853. /**
  14854. * Wait asynchronously for the animation to end
  14855. * @returns a promise which will be fullfilled when the animation ends
  14856. */
  14857. waitAsync(): Promise<Animatable>;
  14858. /** @hidden */
  14859. _animate(delay: number): boolean;
  14860. }
  14861. interface Scene {
  14862. /** @hidden */
  14863. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14864. /** @hidden */
  14865. _processLateAnimationBindingsForMatrices(holder: {
  14866. totalWeight: number;
  14867. totalAdditiveWeight: number;
  14868. animations: RuntimeAnimation[];
  14869. additiveAnimations: RuntimeAnimation[];
  14870. originalValue: Matrix;
  14871. }): any;
  14872. /** @hidden */
  14873. _processLateAnimationBindingsForQuaternions(holder: {
  14874. totalWeight: number;
  14875. totalAdditiveWeight: number;
  14876. animations: RuntimeAnimation[];
  14877. additiveAnimations: RuntimeAnimation[];
  14878. originalValue: Quaternion;
  14879. }, refQuaternion: Quaternion): Quaternion;
  14880. /** @hidden */
  14881. _processLateAnimationBindings(): void;
  14882. /**
  14883. * Will start the animation sequence of a given target
  14884. * @param target defines the target
  14885. * @param from defines from which frame should animation start
  14886. * @param to defines until which frame should animation run.
  14887. * @param weight defines the weight to apply to the animation (1.0 by default)
  14888. * @param loop defines if the animation loops
  14889. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14890. * @param onAnimationEnd defines the function to be executed when the animation ends
  14891. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14892. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14893. * @param onAnimationLoop defines the callback to call when an animation loops
  14894. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14895. * @returns the animatable object created for this animation
  14896. */
  14897. 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;
  14898. /**
  14899. * Will start the animation sequence of a given target
  14900. * @param target defines the target
  14901. * @param from defines from which frame should animation start
  14902. * @param to defines until which frame should animation run.
  14903. * @param loop defines if the animation loops
  14904. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14905. * @param onAnimationEnd defines the function to be executed when the animation ends
  14906. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14907. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14908. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14909. * @param onAnimationLoop defines the callback to call when an animation loops
  14910. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14911. * @returns the animatable object created for this animation
  14912. */
  14913. 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;
  14914. /**
  14915. * Will start the animation sequence of a given target and its hierarchy
  14916. * @param target defines the target
  14917. * @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.
  14918. * @param from defines from which frame should animation start
  14919. * @param to defines until which frame should animation run.
  14920. * @param loop defines if the animation loops
  14921. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14922. * @param onAnimationEnd defines the function to be executed when the animation ends
  14923. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14924. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14925. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14926. * @param onAnimationLoop defines the callback to call when an animation loops
  14927. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14928. * @returns the list of created animatables
  14929. */
  14930. 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[];
  14931. /**
  14932. * Begin a new animation on a given node
  14933. * @param target defines the target where the animation will take place
  14934. * @param animations defines the list of animations to start
  14935. * @param from defines the initial value
  14936. * @param to defines the final value
  14937. * @param loop defines if you want animation to loop (off by default)
  14938. * @param speedRatio defines the speed ratio to apply to all animations
  14939. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14940. * @param onAnimationLoop defines the callback to call when an animation loops
  14941. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14942. * @returns the list of created animatables
  14943. */
  14944. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14945. /**
  14946. * Begin a new animation on a given node and its hierarchy
  14947. * @param target defines the root node where the animation will take place
  14948. * @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.
  14949. * @param animations defines the list of animations to start
  14950. * @param from defines the initial value
  14951. * @param to defines the final value
  14952. * @param loop defines if you want animation to loop (off by default)
  14953. * @param speedRatio defines the speed ratio to apply to all animations
  14954. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14955. * @param onAnimationLoop defines the callback to call when an animation loops
  14956. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14957. * @returns the list of animatables created for all nodes
  14958. */
  14959. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14960. /**
  14961. * Gets the animatable associated with a specific target
  14962. * @param target defines the target of the animatable
  14963. * @returns the required animatable if found
  14964. */
  14965. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14966. /**
  14967. * Gets all animatables associated with a given target
  14968. * @param target defines the target to look animatables for
  14969. * @returns an array of Animatables
  14970. */
  14971. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14972. /**
  14973. * Stops and removes all animations that have been applied to the scene
  14974. */
  14975. stopAllAnimations(): void;
  14976. /**
  14977. * Gets the current delta time used by animation engine
  14978. */
  14979. deltaTime: number;
  14980. }
  14981. interface Bone {
  14982. /**
  14983. * Copy an animation range from another bone
  14984. * @param source defines the source bone
  14985. * @param rangeName defines the range name to copy
  14986. * @param frameOffset defines the frame offset
  14987. * @param rescaleAsRequired defines if rescaling must be applied if required
  14988. * @param skelDimensionsRatio defines the scaling ratio
  14989. * @returns true if operation was successful
  14990. */
  14991. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14992. }
  14993. }
  14994. declare module BABYLON {
  14995. /**
  14996. * Class used to handle skinning animations
  14997. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14998. */
  14999. export class Skeleton implements IAnimatable {
  15000. /** defines the skeleton name */
  15001. name: string;
  15002. /** defines the skeleton Id */
  15003. id: string;
  15004. /**
  15005. * Defines the list of child bones
  15006. */
  15007. bones: Bone[];
  15008. /**
  15009. * Defines an estimate of the dimension of the skeleton at rest
  15010. */
  15011. dimensionsAtRest: Vector3;
  15012. /**
  15013. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15014. */
  15015. needInitialSkinMatrix: boolean;
  15016. /**
  15017. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15018. */
  15019. overrideMesh: Nullable<AbstractMesh>;
  15020. /**
  15021. * Gets the list of animations attached to this skeleton
  15022. */
  15023. animations: Array<Animation>;
  15024. private _scene;
  15025. private _isDirty;
  15026. private _transformMatrices;
  15027. private _transformMatrixTexture;
  15028. private _meshesWithPoseMatrix;
  15029. private _animatables;
  15030. private _identity;
  15031. private _synchronizedWithMesh;
  15032. private _ranges;
  15033. private _lastAbsoluteTransformsUpdateId;
  15034. private _canUseTextureForBones;
  15035. private _uniqueId;
  15036. /** @hidden */
  15037. _numBonesWithLinkedTransformNode: number;
  15038. /** @hidden */
  15039. _hasWaitingData: Nullable<boolean>;
  15040. /**
  15041. * Specifies if the skeleton should be serialized
  15042. */
  15043. doNotSerialize: boolean;
  15044. private _useTextureToStoreBoneMatrices;
  15045. /**
  15046. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15047. * Please note that this option is not available if the hardware does not support it
  15048. */
  15049. get useTextureToStoreBoneMatrices(): boolean;
  15050. set useTextureToStoreBoneMatrices(value: boolean);
  15051. private _animationPropertiesOverride;
  15052. /**
  15053. * Gets or sets the animation properties override
  15054. */
  15055. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15056. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15057. /**
  15058. * List of inspectable custom properties (used by the Inspector)
  15059. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15060. */
  15061. inspectableCustomProperties: IInspectable[];
  15062. /**
  15063. * An observable triggered before computing the skeleton's matrices
  15064. */
  15065. onBeforeComputeObservable: Observable<Skeleton>;
  15066. /**
  15067. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15068. */
  15069. get isUsingTextureForMatrices(): boolean;
  15070. /**
  15071. * Gets the unique ID of this skeleton
  15072. */
  15073. get uniqueId(): number;
  15074. /**
  15075. * Creates a new skeleton
  15076. * @param name defines the skeleton name
  15077. * @param id defines the skeleton Id
  15078. * @param scene defines the hosting scene
  15079. */
  15080. constructor(
  15081. /** defines the skeleton name */
  15082. name: string,
  15083. /** defines the skeleton Id */
  15084. id: string, scene: Scene);
  15085. /**
  15086. * Gets the current object class name.
  15087. * @return the class name
  15088. */
  15089. getClassName(): string;
  15090. /**
  15091. * Returns an array containing the root bones
  15092. * @returns an array containing the root bones
  15093. */
  15094. getChildren(): Array<Bone>;
  15095. /**
  15096. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15097. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15098. * @returns a Float32Array containing matrices data
  15099. */
  15100. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15101. /**
  15102. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15103. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15104. * @returns a raw texture containing the data
  15105. */
  15106. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15107. /**
  15108. * Gets the current hosting scene
  15109. * @returns a scene object
  15110. */
  15111. getScene(): Scene;
  15112. /**
  15113. * Gets a string representing the current skeleton data
  15114. * @param fullDetails defines a boolean indicating if we want a verbose version
  15115. * @returns a string representing the current skeleton data
  15116. */
  15117. toString(fullDetails?: boolean): string;
  15118. /**
  15119. * Get bone's index searching by name
  15120. * @param name defines bone's name to search for
  15121. * @return the indice of the bone. Returns -1 if not found
  15122. */
  15123. getBoneIndexByName(name: string): number;
  15124. /**
  15125. * Creater a new animation range
  15126. * @param name defines the name of the range
  15127. * @param from defines the start key
  15128. * @param to defines the end key
  15129. */
  15130. createAnimationRange(name: string, from: number, to: number): void;
  15131. /**
  15132. * Delete a specific animation range
  15133. * @param name defines the name of the range
  15134. * @param deleteFrames defines if frames must be removed as well
  15135. */
  15136. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15137. /**
  15138. * Gets a specific animation range
  15139. * @param name defines the name of the range to look for
  15140. * @returns the requested animation range or null if not found
  15141. */
  15142. getAnimationRange(name: string): Nullable<AnimationRange>;
  15143. /**
  15144. * Gets the list of all animation ranges defined on this skeleton
  15145. * @returns an array
  15146. */
  15147. getAnimationRanges(): Nullable<AnimationRange>[];
  15148. /**
  15149. * Copy animation range from a source skeleton.
  15150. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15151. * @param source defines the source skeleton
  15152. * @param name defines the name of the range to copy
  15153. * @param rescaleAsRequired defines if rescaling must be applied if required
  15154. * @returns true if operation was successful
  15155. */
  15156. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15157. /**
  15158. * Forces the skeleton to go to rest pose
  15159. */
  15160. returnToRest(): void;
  15161. private _getHighestAnimationFrame;
  15162. /**
  15163. * Begin a specific animation range
  15164. * @param name defines the name of the range to start
  15165. * @param loop defines if looping must be turned on (false by default)
  15166. * @param speedRatio defines the speed ratio to apply (1 by default)
  15167. * @param onAnimationEnd defines a callback which will be called when animation will end
  15168. * @returns a new animatable
  15169. */
  15170. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15171. /**
  15172. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15173. * @param skeleton defines the Skeleton containing the animation range to convert
  15174. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15175. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15176. * @returns the original skeleton
  15177. */
  15178. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15179. /** @hidden */
  15180. _markAsDirty(): void;
  15181. /** @hidden */
  15182. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15183. /** @hidden */
  15184. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15185. private _computeTransformMatrices;
  15186. /**
  15187. * Build all resources required to render a skeleton
  15188. */
  15189. prepare(): void;
  15190. /**
  15191. * Gets the list of animatables currently running for this skeleton
  15192. * @returns an array of animatables
  15193. */
  15194. getAnimatables(): IAnimatable[];
  15195. /**
  15196. * Clone the current skeleton
  15197. * @param name defines the name of the new skeleton
  15198. * @param id defines the id of the new skeleton
  15199. * @returns the new skeleton
  15200. */
  15201. clone(name: string, id?: string): Skeleton;
  15202. /**
  15203. * Enable animation blending for this skeleton
  15204. * @param blendingSpeed defines the blending speed to apply
  15205. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15206. */
  15207. enableBlending(blendingSpeed?: number): void;
  15208. /**
  15209. * Releases all resources associated with the current skeleton
  15210. */
  15211. dispose(): void;
  15212. /**
  15213. * Serialize the skeleton in a JSON object
  15214. * @returns a JSON object
  15215. */
  15216. serialize(): any;
  15217. /**
  15218. * Creates a new skeleton from serialized data
  15219. * @param parsedSkeleton defines the serialized data
  15220. * @param scene defines the hosting scene
  15221. * @returns a new skeleton
  15222. */
  15223. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15224. /**
  15225. * Compute all node absolute transforms
  15226. * @param forceUpdate defines if computation must be done even if cache is up to date
  15227. */
  15228. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15229. /**
  15230. * Gets the root pose matrix
  15231. * @returns a matrix
  15232. */
  15233. getPoseMatrix(): Nullable<Matrix>;
  15234. /**
  15235. * Sorts bones per internal index
  15236. */
  15237. sortBones(): void;
  15238. private _sortBones;
  15239. }
  15240. }
  15241. declare module BABYLON {
  15242. /**
  15243. * Creates an instance based on a source mesh.
  15244. */
  15245. export class InstancedMesh extends AbstractMesh {
  15246. private _sourceMesh;
  15247. private _currentLOD;
  15248. /** @hidden */
  15249. _indexInSourceMeshInstanceArray: number;
  15250. constructor(name: string, source: Mesh);
  15251. /**
  15252. * Returns the string "InstancedMesh".
  15253. */
  15254. getClassName(): string;
  15255. /** Gets the list of lights affecting that mesh */
  15256. get lightSources(): Light[];
  15257. _resyncLightSources(): void;
  15258. _resyncLightSource(light: Light): void;
  15259. _removeLightSource(light: Light, dispose: boolean): void;
  15260. /**
  15261. * If the source mesh receives shadows
  15262. */
  15263. get receiveShadows(): boolean;
  15264. /**
  15265. * The material of the source mesh
  15266. */
  15267. get material(): Nullable<Material>;
  15268. /**
  15269. * Visibility of the source mesh
  15270. */
  15271. get visibility(): number;
  15272. /**
  15273. * Skeleton of the source mesh
  15274. */
  15275. get skeleton(): Nullable<Skeleton>;
  15276. /**
  15277. * Rendering ground id of the source mesh
  15278. */
  15279. get renderingGroupId(): number;
  15280. set renderingGroupId(value: number);
  15281. /**
  15282. * Returns the total number of vertices (integer).
  15283. */
  15284. getTotalVertices(): number;
  15285. /**
  15286. * Returns a positive integer : the total number of indices in this mesh geometry.
  15287. * @returns the numner of indices or zero if the mesh has no geometry.
  15288. */
  15289. getTotalIndices(): number;
  15290. /**
  15291. * The source mesh of the instance
  15292. */
  15293. get sourceMesh(): Mesh;
  15294. /**
  15295. * Is this node ready to be used/rendered
  15296. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15297. * @return {boolean} is it ready
  15298. */
  15299. isReady(completeCheck?: boolean): boolean;
  15300. /**
  15301. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15302. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15303. * @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.
  15304. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15305. */
  15306. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15307. /**
  15308. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15309. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15310. * The `data` are either a numeric array either a Float32Array.
  15311. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15312. * 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).
  15313. * Note that a new underlying VertexBuffer object is created each call.
  15314. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15315. *
  15316. * Possible `kind` values :
  15317. * - VertexBuffer.PositionKind
  15318. * - VertexBuffer.UVKind
  15319. * - VertexBuffer.UV2Kind
  15320. * - VertexBuffer.UV3Kind
  15321. * - VertexBuffer.UV4Kind
  15322. * - VertexBuffer.UV5Kind
  15323. * - VertexBuffer.UV6Kind
  15324. * - VertexBuffer.ColorKind
  15325. * - VertexBuffer.MatricesIndicesKind
  15326. * - VertexBuffer.MatricesIndicesExtraKind
  15327. * - VertexBuffer.MatricesWeightsKind
  15328. * - VertexBuffer.MatricesWeightsExtraKind
  15329. *
  15330. * Returns the Mesh.
  15331. */
  15332. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15333. /**
  15334. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15335. * If the mesh has no geometry, it is simply returned as it is.
  15336. * The `data` are either a numeric array either a Float32Array.
  15337. * No new underlying VertexBuffer object is created.
  15338. * 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.
  15339. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15340. *
  15341. * Possible `kind` values :
  15342. * - VertexBuffer.PositionKind
  15343. * - VertexBuffer.UVKind
  15344. * - VertexBuffer.UV2Kind
  15345. * - VertexBuffer.UV3Kind
  15346. * - VertexBuffer.UV4Kind
  15347. * - VertexBuffer.UV5Kind
  15348. * - VertexBuffer.UV6Kind
  15349. * - VertexBuffer.ColorKind
  15350. * - VertexBuffer.MatricesIndicesKind
  15351. * - VertexBuffer.MatricesIndicesExtraKind
  15352. * - VertexBuffer.MatricesWeightsKind
  15353. * - VertexBuffer.MatricesWeightsExtraKind
  15354. *
  15355. * Returns the Mesh.
  15356. */
  15357. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15358. /**
  15359. * Sets the mesh indices.
  15360. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15361. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15362. * This method creates a new index buffer each call.
  15363. * Returns the Mesh.
  15364. */
  15365. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15366. /**
  15367. * Boolean : True if the mesh owns the requested kind of data.
  15368. */
  15369. isVerticesDataPresent(kind: string): boolean;
  15370. /**
  15371. * Returns an array of indices (IndicesArray).
  15372. */
  15373. getIndices(): Nullable<IndicesArray>;
  15374. get _positions(): Nullable<Vector3[]>;
  15375. /**
  15376. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15377. * This means the mesh underlying bounding box and sphere are recomputed.
  15378. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15379. * @returns the current mesh
  15380. */
  15381. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15382. /** @hidden */
  15383. _preActivate(): InstancedMesh;
  15384. /** @hidden */
  15385. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15386. /** @hidden */
  15387. _postActivate(): void;
  15388. getWorldMatrix(): Matrix;
  15389. get isAnInstance(): boolean;
  15390. /**
  15391. * Returns the current associated LOD AbstractMesh.
  15392. */
  15393. getLOD(camera: Camera): AbstractMesh;
  15394. /** @hidden */
  15395. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15396. /** @hidden */
  15397. _syncSubMeshes(): InstancedMesh;
  15398. /** @hidden */
  15399. _generatePointsArray(): boolean;
  15400. /**
  15401. * Creates a new InstancedMesh from the current mesh.
  15402. * - name (string) : the cloned mesh name
  15403. * - newParent (optional Node) : the optional Node to parent the clone to.
  15404. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15405. *
  15406. * Returns the clone.
  15407. */
  15408. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15409. /**
  15410. * Disposes the InstancedMesh.
  15411. * Returns nothing.
  15412. */
  15413. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15414. }
  15415. interface Mesh {
  15416. /**
  15417. * Register a custom buffer that will be instanced
  15418. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15419. * @param kind defines the buffer kind
  15420. * @param stride defines the stride in floats
  15421. */
  15422. registerInstancedBuffer(kind: string, stride: number): void;
  15423. /** @hidden */
  15424. _userInstancedBuffersStorage: {
  15425. data: {
  15426. [key: string]: Float32Array;
  15427. };
  15428. sizes: {
  15429. [key: string]: number;
  15430. };
  15431. vertexBuffers: {
  15432. [key: string]: Nullable<VertexBuffer>;
  15433. };
  15434. strides: {
  15435. [key: string]: number;
  15436. };
  15437. };
  15438. }
  15439. interface AbstractMesh {
  15440. /**
  15441. * Object used to store instanced buffers defined by user
  15442. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15443. */
  15444. instancedBuffers: {
  15445. [key: string]: any;
  15446. };
  15447. }
  15448. }
  15449. declare module BABYLON {
  15450. /**
  15451. * Defines the options associated with the creation of a shader material.
  15452. */
  15453. export interface IShaderMaterialOptions {
  15454. /**
  15455. * Does the material work in alpha blend mode
  15456. */
  15457. needAlphaBlending: boolean;
  15458. /**
  15459. * Does the material work in alpha test mode
  15460. */
  15461. needAlphaTesting: boolean;
  15462. /**
  15463. * The list of attribute names used in the shader
  15464. */
  15465. attributes: string[];
  15466. /**
  15467. * The list of unifrom names used in the shader
  15468. */
  15469. uniforms: string[];
  15470. /**
  15471. * The list of UBO names used in the shader
  15472. */
  15473. uniformBuffers: string[];
  15474. /**
  15475. * The list of sampler names used in the shader
  15476. */
  15477. samplers: string[];
  15478. /**
  15479. * The list of defines used in the shader
  15480. */
  15481. defines: string[];
  15482. }
  15483. /**
  15484. * 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.
  15485. *
  15486. * This returned material effects how the mesh will look based on the code in the shaders.
  15487. *
  15488. * @see http://doc.babylonjs.com/how_to/shader_material
  15489. */
  15490. export class ShaderMaterial extends Material {
  15491. private _shaderPath;
  15492. private _options;
  15493. private _textures;
  15494. private _textureArrays;
  15495. private _floats;
  15496. private _ints;
  15497. private _floatsArrays;
  15498. private _colors3;
  15499. private _colors3Arrays;
  15500. private _colors4;
  15501. private _colors4Arrays;
  15502. private _vectors2;
  15503. private _vectors3;
  15504. private _vectors4;
  15505. private _matrices;
  15506. private _matrixArrays;
  15507. private _matrices3x3;
  15508. private _matrices2x2;
  15509. private _vectors2Arrays;
  15510. private _vectors3Arrays;
  15511. private _vectors4Arrays;
  15512. private _cachedWorldViewMatrix;
  15513. private _cachedWorldViewProjectionMatrix;
  15514. private _renderId;
  15515. private _multiview;
  15516. private _cachedDefines;
  15517. /**
  15518. * Instantiate a new shader material.
  15519. * 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.
  15520. * This returned material effects how the mesh will look based on the code in the shaders.
  15521. * @see http://doc.babylonjs.com/how_to/shader_material
  15522. * @param name Define the name of the material in the scene
  15523. * @param scene Define the scene the material belongs to
  15524. * @param shaderPath Defines the route to the shader code in one of three ways:
  15525. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15526. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15527. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15528. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15529. * @param options Define the options used to create the shader
  15530. */
  15531. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15532. /**
  15533. * Gets the shader path used to define the shader code
  15534. * It can be modified to trigger a new compilation
  15535. */
  15536. get shaderPath(): any;
  15537. /**
  15538. * Sets the shader path used to define the shader code
  15539. * It can be modified to trigger a new compilation
  15540. */
  15541. set shaderPath(shaderPath: any);
  15542. /**
  15543. * Gets the options used to compile the shader.
  15544. * They can be modified to trigger a new compilation
  15545. */
  15546. get options(): IShaderMaterialOptions;
  15547. /**
  15548. * Gets the current class name of the material e.g. "ShaderMaterial"
  15549. * Mainly use in serialization.
  15550. * @returns the class name
  15551. */
  15552. getClassName(): string;
  15553. /**
  15554. * Specifies if the material will require alpha blending
  15555. * @returns a boolean specifying if alpha blending is needed
  15556. */
  15557. needAlphaBlending(): boolean;
  15558. /**
  15559. * Specifies if this material should be rendered in alpha test mode
  15560. * @returns a boolean specifying if an alpha test is needed.
  15561. */
  15562. needAlphaTesting(): boolean;
  15563. private _checkUniform;
  15564. /**
  15565. * Set a texture in the shader.
  15566. * @param name Define the name of the uniform samplers as defined in the shader
  15567. * @param texture Define the texture to bind to this sampler
  15568. * @return the material itself allowing "fluent" like uniform updates
  15569. */
  15570. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15571. /**
  15572. * Set a texture array in the shader.
  15573. * @param name Define the name of the uniform sampler array as defined in the shader
  15574. * @param textures Define the list of textures to bind to this sampler
  15575. * @return the material itself allowing "fluent" like uniform updates
  15576. */
  15577. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15578. /**
  15579. * Set a float in the shader.
  15580. * @param name Define the name of the uniform as defined in the shader
  15581. * @param value Define the value to give to the uniform
  15582. * @return the material itself allowing "fluent" like uniform updates
  15583. */
  15584. setFloat(name: string, value: number): ShaderMaterial;
  15585. /**
  15586. * Set a int in the shader.
  15587. * @param name Define the name of the uniform as defined in the shader
  15588. * @param value Define the value to give to the uniform
  15589. * @return the material itself allowing "fluent" like uniform updates
  15590. */
  15591. setInt(name: string, value: number): ShaderMaterial;
  15592. /**
  15593. * Set an array of floats in the shader.
  15594. * @param name Define the name of the uniform as defined in the shader
  15595. * @param value Define the value to give to the uniform
  15596. * @return the material itself allowing "fluent" like uniform updates
  15597. */
  15598. setFloats(name: string, value: number[]): ShaderMaterial;
  15599. /**
  15600. * Set a vec3 in the shader from a Color3.
  15601. * @param name Define the name of the uniform as defined in the shader
  15602. * @param value Define the value to give to the uniform
  15603. * @return the material itself allowing "fluent" like uniform updates
  15604. */
  15605. setColor3(name: string, value: Color3): ShaderMaterial;
  15606. /**
  15607. * Set a vec3 array in the shader from a Color3 array.
  15608. * @param name Define the name of the uniform as defined in the shader
  15609. * @param value Define the value to give to the uniform
  15610. * @return the material itself allowing "fluent" like uniform updates
  15611. */
  15612. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15613. /**
  15614. * Set a vec4 in the shader from a Color4.
  15615. * @param name Define the name of the uniform as defined in the shader
  15616. * @param value Define the value to give to the uniform
  15617. * @return the material itself allowing "fluent" like uniform updates
  15618. */
  15619. setColor4(name: string, value: Color4): ShaderMaterial;
  15620. /**
  15621. * Set a vec4 array in the shader from a Color4 array.
  15622. * @param name Define the name of the uniform as defined in the shader
  15623. * @param value Define the value to give to the uniform
  15624. * @return the material itself allowing "fluent" like uniform updates
  15625. */
  15626. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15627. /**
  15628. * Set a vec2 in the shader from a Vector2.
  15629. * @param name Define the name of the uniform as defined in the shader
  15630. * @param value Define the value to give to the uniform
  15631. * @return the material itself allowing "fluent" like uniform updates
  15632. */
  15633. setVector2(name: string, value: Vector2): ShaderMaterial;
  15634. /**
  15635. * Set a vec3 in the shader from a Vector3.
  15636. * @param name Define the name of the uniform as defined in the shader
  15637. * @param value Define the value to give to the uniform
  15638. * @return the material itself allowing "fluent" like uniform updates
  15639. */
  15640. setVector3(name: string, value: Vector3): ShaderMaterial;
  15641. /**
  15642. * Set a vec4 in the shader from a Vector4.
  15643. * @param name Define the name of the uniform as defined in the shader
  15644. * @param value Define the value to give to the uniform
  15645. * @return the material itself allowing "fluent" like uniform updates
  15646. */
  15647. setVector4(name: string, value: Vector4): ShaderMaterial;
  15648. /**
  15649. * Set a mat4 in the shader from a Matrix.
  15650. * @param name Define the name of the uniform as defined in the shader
  15651. * @param value Define the value to give to the uniform
  15652. * @return the material itself allowing "fluent" like uniform updates
  15653. */
  15654. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15655. /**
  15656. * Set a float32Array in the shader from a matrix array.
  15657. * @param name Define the name of the uniform as defined in the shader
  15658. * @param value Define the value to give to the uniform
  15659. * @return the material itself allowing "fluent" like uniform updates
  15660. */
  15661. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15662. /**
  15663. * Set a mat3 in the shader from a Float32Array.
  15664. * @param name Define the name of the uniform as defined in the shader
  15665. * @param value Define the value to give to the uniform
  15666. * @return the material itself allowing "fluent" like uniform updates
  15667. */
  15668. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15669. /**
  15670. * Set a mat2 in the shader from a Float32Array.
  15671. * @param name Define the name of the uniform as defined in the shader
  15672. * @param value Define the value to give to the uniform
  15673. * @return the material itself allowing "fluent" like uniform updates
  15674. */
  15675. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15676. /**
  15677. * Set a vec2 array in the shader from a number array.
  15678. * @param name Define the name of the uniform as defined in the shader
  15679. * @param value Define the value to give to the uniform
  15680. * @return the material itself allowing "fluent" like uniform updates
  15681. */
  15682. setArray2(name: string, value: number[]): ShaderMaterial;
  15683. /**
  15684. * Set a vec3 array in the shader from a number array.
  15685. * @param name Define the name of the uniform as defined in the shader
  15686. * @param value Define the value to give to the uniform
  15687. * @return the material itself allowing "fluent" like uniform updates
  15688. */
  15689. setArray3(name: string, value: number[]): ShaderMaterial;
  15690. /**
  15691. * Set a vec4 array in the shader from a number array.
  15692. * @param name Define the name of the uniform as defined in the shader
  15693. * @param value Define the value to give to the uniform
  15694. * @return the material itself allowing "fluent" like uniform updates
  15695. */
  15696. setArray4(name: string, value: number[]): ShaderMaterial;
  15697. private _checkCache;
  15698. /**
  15699. * Specifies that the submesh is ready to be used
  15700. * @param mesh defines the mesh to check
  15701. * @param subMesh defines which submesh to check
  15702. * @param useInstances specifies that instances should be used
  15703. * @returns a boolean indicating that the submesh is ready or not
  15704. */
  15705. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15706. /**
  15707. * Checks if the material is ready to render the requested mesh
  15708. * @param mesh Define the mesh to render
  15709. * @param useInstances Define whether or not the material is used with instances
  15710. * @returns true if ready, otherwise false
  15711. */
  15712. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15713. /**
  15714. * Binds the world matrix to the material
  15715. * @param world defines the world transformation matrix
  15716. * @param effectOverride - If provided, use this effect instead of internal effect
  15717. */
  15718. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  15719. /**
  15720. * Binds the submesh to this material by preparing the effect and shader to draw
  15721. * @param world defines the world transformation matrix
  15722. * @param mesh defines the mesh containing the submesh
  15723. * @param subMesh defines the submesh to bind the material to
  15724. */
  15725. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15726. /**
  15727. * Binds the material to the mesh
  15728. * @param world defines the world transformation matrix
  15729. * @param mesh defines the mesh to bind the material to
  15730. * @param effectOverride - If provided, use this effect instead of internal effect
  15731. */
  15732. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  15733. protected _afterBind(mesh?: Mesh): void;
  15734. /**
  15735. * Gets the active textures from the material
  15736. * @returns an array of textures
  15737. */
  15738. getActiveTextures(): BaseTexture[];
  15739. /**
  15740. * Specifies if the material uses a texture
  15741. * @param texture defines the texture to check against the material
  15742. * @returns a boolean specifying if the material uses the texture
  15743. */
  15744. hasTexture(texture: BaseTexture): boolean;
  15745. /**
  15746. * Makes a duplicate of the material, and gives it a new name
  15747. * @param name defines the new name for the duplicated material
  15748. * @returns the cloned material
  15749. */
  15750. clone(name: string): ShaderMaterial;
  15751. /**
  15752. * Disposes the material
  15753. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15754. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15755. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15756. */
  15757. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15758. /**
  15759. * Serializes this material in a JSON representation
  15760. * @returns the serialized material object
  15761. */
  15762. serialize(): any;
  15763. /**
  15764. * Creates a shader material from parsed shader material data
  15765. * @param source defines the JSON represnetation of the material
  15766. * @param scene defines the hosting scene
  15767. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15768. * @returns a new material
  15769. */
  15770. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15771. }
  15772. }
  15773. declare module BABYLON {
  15774. /** @hidden */
  15775. export var colorPixelShader: {
  15776. name: string;
  15777. shader: string;
  15778. };
  15779. }
  15780. declare module BABYLON {
  15781. /** @hidden */
  15782. export var colorVertexShader: {
  15783. name: string;
  15784. shader: string;
  15785. };
  15786. }
  15787. declare module BABYLON {
  15788. /**
  15789. * Line mesh
  15790. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15791. */
  15792. export class LinesMesh extends Mesh {
  15793. /**
  15794. * If vertex color should be applied to the mesh
  15795. */
  15796. readonly useVertexColor?: boolean | undefined;
  15797. /**
  15798. * If vertex alpha should be applied to the mesh
  15799. */
  15800. readonly useVertexAlpha?: boolean | undefined;
  15801. /**
  15802. * Color of the line (Default: White)
  15803. */
  15804. color: Color3;
  15805. /**
  15806. * Alpha of the line (Default: 1)
  15807. */
  15808. alpha: number;
  15809. /**
  15810. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15811. * This margin is expressed in world space coordinates, so its value may vary.
  15812. * Default value is 0.1
  15813. */
  15814. intersectionThreshold: number;
  15815. private _colorShader;
  15816. private color4;
  15817. /**
  15818. * Creates a new LinesMesh
  15819. * @param name defines the name
  15820. * @param scene defines the hosting scene
  15821. * @param parent defines the parent mesh if any
  15822. * @param source defines the optional source LinesMesh used to clone data from
  15823. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15824. * When false, achieved by calling a clone(), also passing False.
  15825. * This will make creation of children, recursive.
  15826. * @param useVertexColor defines if this LinesMesh supports vertex color
  15827. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15828. */
  15829. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15830. /**
  15831. * If vertex color should be applied to the mesh
  15832. */
  15833. useVertexColor?: boolean | undefined,
  15834. /**
  15835. * If vertex alpha should be applied to the mesh
  15836. */
  15837. useVertexAlpha?: boolean | undefined);
  15838. private _addClipPlaneDefine;
  15839. private _removeClipPlaneDefine;
  15840. isReady(): boolean;
  15841. /**
  15842. * Returns the string "LineMesh"
  15843. */
  15844. getClassName(): string;
  15845. /**
  15846. * @hidden
  15847. */
  15848. get material(): Material;
  15849. /**
  15850. * @hidden
  15851. */
  15852. set material(value: Material);
  15853. /**
  15854. * @hidden
  15855. */
  15856. get checkCollisions(): boolean;
  15857. /** @hidden */
  15858. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15859. /** @hidden */
  15860. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15861. /**
  15862. * Disposes of the line mesh
  15863. * @param doNotRecurse If children should be disposed
  15864. */
  15865. dispose(doNotRecurse?: boolean): void;
  15866. /**
  15867. * Returns a new LineMesh object cloned from the current one.
  15868. */
  15869. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15870. /**
  15871. * Creates a new InstancedLinesMesh object from the mesh model.
  15872. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15873. * @param name defines the name of the new instance
  15874. * @returns a new InstancedLinesMesh
  15875. */
  15876. createInstance(name: string): InstancedLinesMesh;
  15877. }
  15878. /**
  15879. * Creates an instance based on a source LinesMesh
  15880. */
  15881. export class InstancedLinesMesh extends InstancedMesh {
  15882. /**
  15883. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15884. * This margin is expressed in world space coordinates, so its value may vary.
  15885. * Initilized with the intersectionThreshold value of the source LinesMesh
  15886. */
  15887. intersectionThreshold: number;
  15888. constructor(name: string, source: LinesMesh);
  15889. /**
  15890. * Returns the string "InstancedLinesMesh".
  15891. */
  15892. getClassName(): string;
  15893. }
  15894. }
  15895. declare module BABYLON {
  15896. /** @hidden */
  15897. export var linePixelShader: {
  15898. name: string;
  15899. shader: string;
  15900. };
  15901. }
  15902. declare module BABYLON {
  15903. /** @hidden */
  15904. export var lineVertexShader: {
  15905. name: string;
  15906. shader: string;
  15907. };
  15908. }
  15909. declare module BABYLON {
  15910. interface AbstractMesh {
  15911. /**
  15912. * Gets the edgesRenderer associated with the mesh
  15913. */
  15914. edgesRenderer: Nullable<EdgesRenderer>;
  15915. }
  15916. interface LinesMesh {
  15917. /**
  15918. * Enables the edge rendering mode on the mesh.
  15919. * This mode makes the mesh edges visible
  15920. * @param epsilon defines the maximal distance between two angles to detect a face
  15921. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15922. * @returns the currentAbstractMesh
  15923. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15924. */
  15925. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15926. }
  15927. interface InstancedLinesMesh {
  15928. /**
  15929. * Enables the edge rendering mode on the mesh.
  15930. * This mode makes the mesh edges visible
  15931. * @param epsilon defines the maximal distance between two angles to detect a face
  15932. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15933. * @returns the current InstancedLinesMesh
  15934. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15935. */
  15936. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15937. }
  15938. /**
  15939. * Defines the minimum contract an Edges renderer should follow.
  15940. */
  15941. export interface IEdgesRenderer extends IDisposable {
  15942. /**
  15943. * Gets or sets a boolean indicating if the edgesRenderer is active
  15944. */
  15945. isEnabled: boolean;
  15946. /**
  15947. * Renders the edges of the attached mesh,
  15948. */
  15949. render(): void;
  15950. /**
  15951. * Checks wether or not the edges renderer is ready to render.
  15952. * @return true if ready, otherwise false.
  15953. */
  15954. isReady(): boolean;
  15955. }
  15956. /**
  15957. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15958. */
  15959. export class EdgesRenderer implements IEdgesRenderer {
  15960. /**
  15961. * Define the size of the edges with an orthographic camera
  15962. */
  15963. edgesWidthScalerForOrthographic: number;
  15964. /**
  15965. * Define the size of the edges with a perspective camera
  15966. */
  15967. edgesWidthScalerForPerspective: number;
  15968. protected _source: AbstractMesh;
  15969. protected _linesPositions: number[];
  15970. protected _linesNormals: number[];
  15971. protected _linesIndices: number[];
  15972. protected _epsilon: number;
  15973. protected _indicesCount: number;
  15974. protected _lineShader: ShaderMaterial;
  15975. protected _ib: DataBuffer;
  15976. protected _buffers: {
  15977. [key: string]: Nullable<VertexBuffer>;
  15978. };
  15979. protected _checkVerticesInsteadOfIndices: boolean;
  15980. private _meshRebuildObserver;
  15981. private _meshDisposeObserver;
  15982. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15983. isEnabled: boolean;
  15984. /**
  15985. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15986. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15987. * @param source Mesh used to create edges
  15988. * @param epsilon sum of angles in adjacency to check for edge
  15989. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15990. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15991. */
  15992. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15993. protected _prepareRessources(): void;
  15994. /** @hidden */
  15995. _rebuild(): void;
  15996. /**
  15997. * Releases the required resources for the edges renderer
  15998. */
  15999. dispose(): void;
  16000. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16001. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16002. /**
  16003. * Checks if the pair of p0 and p1 is en edge
  16004. * @param faceIndex
  16005. * @param edge
  16006. * @param faceNormals
  16007. * @param p0
  16008. * @param p1
  16009. * @private
  16010. */
  16011. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16012. /**
  16013. * push line into the position, normal and index buffer
  16014. * @protected
  16015. */
  16016. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16017. /**
  16018. * Generates lines edges from adjacencjes
  16019. * @private
  16020. */
  16021. _generateEdgesLines(): void;
  16022. /**
  16023. * Checks wether or not the edges renderer is ready to render.
  16024. * @return true if ready, otherwise false.
  16025. */
  16026. isReady(): boolean;
  16027. /**
  16028. * Renders the edges of the attached mesh,
  16029. */
  16030. render(): void;
  16031. }
  16032. /**
  16033. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16034. */
  16035. export class LineEdgesRenderer extends EdgesRenderer {
  16036. /**
  16037. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16038. * @param source LineMesh used to generate edges
  16039. * @param epsilon not important (specified angle for edge detection)
  16040. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16041. */
  16042. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16043. /**
  16044. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16045. */
  16046. _generateEdgesLines(): void;
  16047. }
  16048. }
  16049. declare module BABYLON {
  16050. /**
  16051. * This represents the object necessary to create a rendering group.
  16052. * This is exclusively used and created by the rendering manager.
  16053. * To modify the behavior, you use the available helpers in your scene or meshes.
  16054. * @hidden
  16055. */
  16056. export class RenderingGroup {
  16057. index: number;
  16058. private static _zeroVector;
  16059. private _scene;
  16060. private _opaqueSubMeshes;
  16061. private _transparentSubMeshes;
  16062. private _alphaTestSubMeshes;
  16063. private _depthOnlySubMeshes;
  16064. private _particleSystems;
  16065. private _spriteManagers;
  16066. private _opaqueSortCompareFn;
  16067. private _alphaTestSortCompareFn;
  16068. private _transparentSortCompareFn;
  16069. private _renderOpaque;
  16070. private _renderAlphaTest;
  16071. private _renderTransparent;
  16072. /** @hidden */
  16073. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16074. onBeforeTransparentRendering: () => void;
  16075. /**
  16076. * Set the opaque sort comparison function.
  16077. * If null the sub meshes will be render in the order they were created
  16078. */
  16079. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16080. /**
  16081. * Set the alpha test sort comparison function.
  16082. * If null the sub meshes will be render in the order they were created
  16083. */
  16084. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16085. /**
  16086. * Set the transparent sort comparison function.
  16087. * If null the sub meshes will be render in the order they were created
  16088. */
  16089. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16090. /**
  16091. * Creates a new rendering group.
  16092. * @param index The rendering group index
  16093. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16094. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16095. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16096. */
  16097. 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>);
  16098. /**
  16099. * Render all the sub meshes contained in the group.
  16100. * @param customRenderFunction Used to override the default render behaviour of the group.
  16101. * @returns true if rendered some submeshes.
  16102. */
  16103. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16104. /**
  16105. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16106. * @param subMeshes The submeshes to render
  16107. */
  16108. private renderOpaqueSorted;
  16109. /**
  16110. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16111. * @param subMeshes The submeshes to render
  16112. */
  16113. private renderAlphaTestSorted;
  16114. /**
  16115. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16116. * @param subMeshes The submeshes to render
  16117. */
  16118. private renderTransparentSorted;
  16119. /**
  16120. * Renders the submeshes in a specified order.
  16121. * @param subMeshes The submeshes to sort before render
  16122. * @param sortCompareFn The comparison function use to sort
  16123. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16124. * @param transparent Specifies to activate blending if true
  16125. */
  16126. private static renderSorted;
  16127. /**
  16128. * Renders the submeshes in the order they were dispatched (no sort applied).
  16129. * @param subMeshes The submeshes to render
  16130. */
  16131. private static renderUnsorted;
  16132. /**
  16133. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16134. * are rendered back to front if in the same alpha index.
  16135. *
  16136. * @param a The first submesh
  16137. * @param b The second submesh
  16138. * @returns The result of the comparison
  16139. */
  16140. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16141. /**
  16142. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16143. * are rendered back to front.
  16144. *
  16145. * @param a The first submesh
  16146. * @param b The second submesh
  16147. * @returns The result of the comparison
  16148. */
  16149. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16150. /**
  16151. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16152. * are rendered front to back (prevent overdraw).
  16153. *
  16154. * @param a The first submesh
  16155. * @param b The second submesh
  16156. * @returns The result of the comparison
  16157. */
  16158. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16159. /**
  16160. * Resets the different lists of submeshes to prepare a new frame.
  16161. */
  16162. prepare(): void;
  16163. dispose(): void;
  16164. /**
  16165. * Inserts the submesh in its correct queue depending on its material.
  16166. * @param subMesh The submesh to dispatch
  16167. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16168. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16169. */
  16170. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16171. dispatchSprites(spriteManager: ISpriteManager): void;
  16172. dispatchParticles(particleSystem: IParticleSystem): void;
  16173. private _renderParticles;
  16174. private _renderSprites;
  16175. }
  16176. }
  16177. declare module BABYLON {
  16178. /**
  16179. * Interface describing the different options available in the rendering manager
  16180. * regarding Auto Clear between groups.
  16181. */
  16182. export interface IRenderingManagerAutoClearSetup {
  16183. /**
  16184. * Defines whether or not autoclear is enable.
  16185. */
  16186. autoClear: boolean;
  16187. /**
  16188. * Defines whether or not to autoclear the depth buffer.
  16189. */
  16190. depth: boolean;
  16191. /**
  16192. * Defines whether or not to autoclear the stencil buffer.
  16193. */
  16194. stencil: boolean;
  16195. }
  16196. /**
  16197. * This class is used by the onRenderingGroupObservable
  16198. */
  16199. export class RenderingGroupInfo {
  16200. /**
  16201. * The Scene that being rendered
  16202. */
  16203. scene: Scene;
  16204. /**
  16205. * The camera currently used for the rendering pass
  16206. */
  16207. camera: Nullable<Camera>;
  16208. /**
  16209. * The ID of the renderingGroup being processed
  16210. */
  16211. renderingGroupId: number;
  16212. }
  16213. /**
  16214. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16215. * It is enable to manage the different groups as well as the different necessary sort functions.
  16216. * This should not be used directly aside of the few static configurations
  16217. */
  16218. export class RenderingManager {
  16219. /**
  16220. * The max id used for rendering groups (not included)
  16221. */
  16222. static MAX_RENDERINGGROUPS: number;
  16223. /**
  16224. * The min id used for rendering groups (included)
  16225. */
  16226. static MIN_RENDERINGGROUPS: number;
  16227. /**
  16228. * Used to globally prevent autoclearing scenes.
  16229. */
  16230. static AUTOCLEAR: boolean;
  16231. /**
  16232. * @hidden
  16233. */
  16234. _useSceneAutoClearSetup: boolean;
  16235. private _scene;
  16236. private _renderingGroups;
  16237. private _depthStencilBufferAlreadyCleaned;
  16238. private _autoClearDepthStencil;
  16239. private _customOpaqueSortCompareFn;
  16240. private _customAlphaTestSortCompareFn;
  16241. private _customTransparentSortCompareFn;
  16242. private _renderingGroupInfo;
  16243. /**
  16244. * Instantiates a new rendering group for a particular scene
  16245. * @param scene Defines the scene the groups belongs to
  16246. */
  16247. constructor(scene: Scene);
  16248. private _clearDepthStencilBuffer;
  16249. /**
  16250. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16251. * @hidden
  16252. */
  16253. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16254. /**
  16255. * Resets the different information of the group to prepare a new frame
  16256. * @hidden
  16257. */
  16258. reset(): void;
  16259. /**
  16260. * Dispose and release the group and its associated resources.
  16261. * @hidden
  16262. */
  16263. dispose(): void;
  16264. /**
  16265. * Clear the info related to rendering groups preventing retention points during dispose.
  16266. */
  16267. freeRenderingGroups(): void;
  16268. private _prepareRenderingGroup;
  16269. /**
  16270. * Add a sprite manager to the rendering manager in order to render it this frame.
  16271. * @param spriteManager Define the sprite manager to render
  16272. */
  16273. dispatchSprites(spriteManager: ISpriteManager): void;
  16274. /**
  16275. * Add a particle system to the rendering manager in order to render it this frame.
  16276. * @param particleSystem Define the particle system to render
  16277. */
  16278. dispatchParticles(particleSystem: IParticleSystem): void;
  16279. /**
  16280. * Add a submesh to the manager in order to render it this frame
  16281. * @param subMesh The submesh to dispatch
  16282. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16283. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16284. */
  16285. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16286. /**
  16287. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16288. * This allowed control for front to back rendering or reversly depending of the special needs.
  16289. *
  16290. * @param renderingGroupId The rendering group id corresponding to its index
  16291. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16292. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16293. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16294. */
  16295. 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;
  16296. /**
  16297. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16298. *
  16299. * @param renderingGroupId The rendering group id corresponding to its index
  16300. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16301. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16302. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16303. */
  16304. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16305. /**
  16306. * Gets the current auto clear configuration for one rendering group of the rendering
  16307. * manager.
  16308. * @param index the rendering group index to get the information for
  16309. * @returns The auto clear setup for the requested rendering group
  16310. */
  16311. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16312. }
  16313. }
  16314. declare module BABYLON {
  16315. /**
  16316. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16317. */
  16318. export interface ICustomShaderOptions {
  16319. /**
  16320. * Gets or sets the custom shader name to use
  16321. */
  16322. shaderName: string;
  16323. /**
  16324. * The list of attribute names used in the shader
  16325. */
  16326. attributes?: string[];
  16327. /**
  16328. * The list of unifrom names used in the shader
  16329. */
  16330. uniforms?: string[];
  16331. /**
  16332. * The list of sampler names used in the shader
  16333. */
  16334. samplers?: string[];
  16335. /**
  16336. * The list of defines used in the shader
  16337. */
  16338. defines?: string[];
  16339. }
  16340. /**
  16341. * Interface to implement to create a shadow generator compatible with BJS.
  16342. */
  16343. export interface IShadowGenerator {
  16344. /**
  16345. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16346. * @returns The render target texture if present otherwise, null
  16347. */
  16348. getShadowMap(): Nullable<RenderTargetTexture>;
  16349. /**
  16350. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16351. * @param subMesh The submesh we want to render in the shadow map
  16352. * @param useInstances Defines wether will draw in the map using instances
  16353. * @returns true if ready otherwise, false
  16354. */
  16355. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16356. /**
  16357. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16358. * @param defines Defines of the material we want to update
  16359. * @param lightIndex Index of the light in the enabled light list of the material
  16360. */
  16361. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16362. /**
  16363. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16364. * defined in the generator but impacting the effect).
  16365. * It implies the unifroms available on the materials are the standard BJS ones.
  16366. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16367. * @param effect The effect we are binfing the information for
  16368. */
  16369. bindShadowLight(lightIndex: string, effect: Effect): void;
  16370. /**
  16371. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16372. * (eq to shadow prjection matrix * light transform matrix)
  16373. * @returns The transform matrix used to create the shadow map
  16374. */
  16375. getTransformMatrix(): Matrix;
  16376. /**
  16377. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16378. * Cube and 2D textures for instance.
  16379. */
  16380. recreateShadowMap(): void;
  16381. /**
  16382. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16383. * @param onCompiled Callback triggered at the and of the effects compilation
  16384. * @param options Sets of optional options forcing the compilation with different modes
  16385. */
  16386. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16387. useInstances: boolean;
  16388. }>): void;
  16389. /**
  16390. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16391. * @param options Sets of optional options forcing the compilation with different modes
  16392. * @returns A promise that resolves when the compilation completes
  16393. */
  16394. forceCompilationAsync(options?: Partial<{
  16395. useInstances: boolean;
  16396. }>): Promise<void>;
  16397. /**
  16398. * Serializes the shadow generator setup to a json object.
  16399. * @returns The serialized JSON object
  16400. */
  16401. serialize(): any;
  16402. /**
  16403. * Disposes the Shadow map and related Textures and effects.
  16404. */
  16405. dispose(): void;
  16406. }
  16407. /**
  16408. * Default implementation IShadowGenerator.
  16409. * This is the main object responsible of generating shadows in the framework.
  16410. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16411. */
  16412. export class ShadowGenerator implements IShadowGenerator {
  16413. /**
  16414. * Name of the shadow generator class
  16415. */
  16416. static CLASSNAME: string;
  16417. /**
  16418. * Shadow generator mode None: no filtering applied.
  16419. */
  16420. static readonly FILTER_NONE: number;
  16421. /**
  16422. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16423. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16424. */
  16425. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16426. /**
  16427. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16428. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16429. */
  16430. static readonly FILTER_POISSONSAMPLING: number;
  16431. /**
  16432. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16433. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16434. */
  16435. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16436. /**
  16437. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16438. * edge artifacts on steep falloff.
  16439. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16440. */
  16441. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16442. /**
  16443. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16444. * edge artifacts on steep falloff.
  16445. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16446. */
  16447. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16448. /**
  16449. * Shadow generator mode PCF: Percentage Closer Filtering
  16450. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16451. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16452. */
  16453. static readonly FILTER_PCF: number;
  16454. /**
  16455. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16456. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16457. * Contact Hardening
  16458. */
  16459. static readonly FILTER_PCSS: number;
  16460. /**
  16461. * Reserved for PCF and PCSS
  16462. * Highest Quality.
  16463. *
  16464. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16465. *
  16466. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16467. */
  16468. static readonly QUALITY_HIGH: number;
  16469. /**
  16470. * Reserved for PCF and PCSS
  16471. * Good tradeoff for quality/perf cross devices
  16472. *
  16473. * Execute PCF on a 3*3 kernel.
  16474. *
  16475. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16476. */
  16477. static readonly QUALITY_MEDIUM: number;
  16478. /**
  16479. * Reserved for PCF and PCSS
  16480. * The lowest quality but the fastest.
  16481. *
  16482. * Execute PCF on a 1*1 kernel.
  16483. *
  16484. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16485. */
  16486. static readonly QUALITY_LOW: number;
  16487. /** Gets or sets the custom shader name to use */
  16488. customShaderOptions: ICustomShaderOptions;
  16489. /**
  16490. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16491. */
  16492. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16493. /**
  16494. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16495. */
  16496. onAfterShadowMapRenderObservable: Observable<Effect>;
  16497. /**
  16498. * Observable triggered before a mesh is rendered in the shadow map.
  16499. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16500. */
  16501. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16502. /**
  16503. * Observable triggered after a mesh is rendered in the shadow map.
  16504. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16505. */
  16506. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16507. protected _bias: number;
  16508. /**
  16509. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16510. */
  16511. get bias(): number;
  16512. /**
  16513. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16514. */
  16515. set bias(bias: number);
  16516. protected _normalBias: number;
  16517. /**
  16518. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16519. */
  16520. get normalBias(): number;
  16521. /**
  16522. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16523. */
  16524. set normalBias(normalBias: number);
  16525. protected _blurBoxOffset: number;
  16526. /**
  16527. * Gets the blur box offset: offset applied during the blur pass.
  16528. * Only useful if useKernelBlur = false
  16529. */
  16530. get blurBoxOffset(): number;
  16531. /**
  16532. * Sets the blur box offset: offset applied during the blur pass.
  16533. * Only useful if useKernelBlur = false
  16534. */
  16535. set blurBoxOffset(value: number);
  16536. protected _blurScale: number;
  16537. /**
  16538. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16539. * 2 means half of the size.
  16540. */
  16541. get blurScale(): number;
  16542. /**
  16543. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16544. * 2 means half of the size.
  16545. */
  16546. set blurScale(value: number);
  16547. protected _blurKernel: number;
  16548. /**
  16549. * Gets the blur kernel: kernel size of the blur pass.
  16550. * Only useful if useKernelBlur = true
  16551. */
  16552. get blurKernel(): number;
  16553. /**
  16554. * Sets the blur kernel: kernel size of the blur pass.
  16555. * Only useful if useKernelBlur = true
  16556. */
  16557. set blurKernel(value: number);
  16558. protected _useKernelBlur: boolean;
  16559. /**
  16560. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16561. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16562. */
  16563. get useKernelBlur(): boolean;
  16564. /**
  16565. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16566. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16567. */
  16568. set useKernelBlur(value: boolean);
  16569. protected _depthScale: number;
  16570. /**
  16571. * Gets the depth scale used in ESM mode.
  16572. */
  16573. get depthScale(): number;
  16574. /**
  16575. * Sets the depth scale used in ESM mode.
  16576. * This can override the scale stored on the light.
  16577. */
  16578. set depthScale(value: number);
  16579. protected _validateFilter(filter: number): number;
  16580. protected _filter: number;
  16581. /**
  16582. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16583. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16584. */
  16585. get filter(): number;
  16586. /**
  16587. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16588. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16589. */
  16590. set filter(value: number);
  16591. /**
  16592. * Gets if the current filter is set to Poisson Sampling.
  16593. */
  16594. get usePoissonSampling(): boolean;
  16595. /**
  16596. * Sets the current filter to Poisson Sampling.
  16597. */
  16598. set usePoissonSampling(value: boolean);
  16599. /**
  16600. * Gets if the current filter is set to ESM.
  16601. */
  16602. get useExponentialShadowMap(): boolean;
  16603. /**
  16604. * Sets the current filter is to ESM.
  16605. */
  16606. set useExponentialShadowMap(value: boolean);
  16607. /**
  16608. * Gets if the current filter is set to filtered ESM.
  16609. */
  16610. get useBlurExponentialShadowMap(): boolean;
  16611. /**
  16612. * Gets if the current filter is set to filtered ESM.
  16613. */
  16614. set useBlurExponentialShadowMap(value: boolean);
  16615. /**
  16616. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16617. * exponential to prevent steep falloff artifacts).
  16618. */
  16619. get useCloseExponentialShadowMap(): boolean;
  16620. /**
  16621. * Sets the current filter to "close ESM" (using the inverse of the
  16622. * exponential to prevent steep falloff artifacts).
  16623. */
  16624. set useCloseExponentialShadowMap(value: boolean);
  16625. /**
  16626. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16627. * exponential to prevent steep falloff artifacts).
  16628. */
  16629. get useBlurCloseExponentialShadowMap(): boolean;
  16630. /**
  16631. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16632. * exponential to prevent steep falloff artifacts).
  16633. */
  16634. set useBlurCloseExponentialShadowMap(value: boolean);
  16635. /**
  16636. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16637. */
  16638. get usePercentageCloserFiltering(): boolean;
  16639. /**
  16640. * Sets the current filter to "PCF" (percentage closer filtering).
  16641. */
  16642. set usePercentageCloserFiltering(value: boolean);
  16643. protected _filteringQuality: number;
  16644. /**
  16645. * Gets the PCF or PCSS Quality.
  16646. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16647. */
  16648. get filteringQuality(): number;
  16649. /**
  16650. * Sets the PCF or PCSS Quality.
  16651. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16652. */
  16653. set filteringQuality(filteringQuality: number);
  16654. /**
  16655. * Gets if the current filter is set to "PCSS" (contact hardening).
  16656. */
  16657. get useContactHardeningShadow(): boolean;
  16658. /**
  16659. * Sets the current filter to "PCSS" (contact hardening).
  16660. */
  16661. set useContactHardeningShadow(value: boolean);
  16662. protected _contactHardeningLightSizeUVRatio: number;
  16663. /**
  16664. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16665. * Using a ratio helps keeping shape stability independently of the map size.
  16666. *
  16667. * It does not account for the light projection as it was having too much
  16668. * instability during the light setup or during light position changes.
  16669. *
  16670. * Only valid if useContactHardeningShadow is true.
  16671. */
  16672. get contactHardeningLightSizeUVRatio(): number;
  16673. /**
  16674. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16675. * Using a ratio helps keeping shape stability independently of the map size.
  16676. *
  16677. * It does not account for the light projection as it was having too much
  16678. * instability during the light setup or during light position changes.
  16679. *
  16680. * Only valid if useContactHardeningShadow is true.
  16681. */
  16682. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16683. protected _darkness: number;
  16684. /** Gets or sets the actual darkness of a shadow */
  16685. get darkness(): number;
  16686. set darkness(value: number);
  16687. /**
  16688. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16689. * 0 means strongest and 1 would means no shadow.
  16690. * @returns the darkness.
  16691. */
  16692. getDarkness(): number;
  16693. /**
  16694. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16695. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16696. * @returns the shadow generator allowing fluent coding.
  16697. */
  16698. setDarkness(darkness: number): ShadowGenerator;
  16699. protected _transparencyShadow: boolean;
  16700. /** Gets or sets the ability to have transparent shadow */
  16701. get transparencyShadow(): boolean;
  16702. set transparencyShadow(value: boolean);
  16703. /**
  16704. * Sets the ability to have transparent shadow (boolean).
  16705. * @param transparent True if transparent else False
  16706. * @returns the shadow generator allowing fluent coding
  16707. */
  16708. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16709. protected _shadowMap: Nullable<RenderTargetTexture>;
  16710. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16711. /**
  16712. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16713. * @returns The render target texture if present otherwise, null
  16714. */
  16715. getShadowMap(): Nullable<RenderTargetTexture>;
  16716. /**
  16717. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16718. * @returns The render target texture if the shadow map is present otherwise, null
  16719. */
  16720. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16721. /**
  16722. * Gets the class name of that object
  16723. * @returns "ShadowGenerator"
  16724. */
  16725. getClassName(): string;
  16726. /**
  16727. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16728. * @param mesh Mesh to add
  16729. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16730. * @returns the Shadow Generator itself
  16731. */
  16732. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16733. /**
  16734. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16735. * @param mesh Mesh to remove
  16736. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16737. * @returns the Shadow Generator itself
  16738. */
  16739. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16740. /**
  16741. * Controls the extent to which the shadows fade out at the edge of the frustum
  16742. */
  16743. frustumEdgeFalloff: number;
  16744. protected _light: IShadowLight;
  16745. /**
  16746. * Returns the associated light object.
  16747. * @returns the light generating the shadow
  16748. */
  16749. getLight(): IShadowLight;
  16750. /**
  16751. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16752. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16753. * It might on the other hand introduce peter panning.
  16754. */
  16755. forceBackFacesOnly: boolean;
  16756. protected _scene: Scene;
  16757. protected _lightDirection: Vector3;
  16758. protected _effect: Effect;
  16759. protected _viewMatrix: Matrix;
  16760. protected _projectionMatrix: Matrix;
  16761. protected _transformMatrix: Matrix;
  16762. protected _cachedPosition: Vector3;
  16763. protected _cachedDirection: Vector3;
  16764. protected _cachedDefines: string;
  16765. protected _currentRenderID: number;
  16766. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16767. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16768. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16769. protected _blurPostProcesses: PostProcess[];
  16770. protected _mapSize: number;
  16771. protected _currentFaceIndex: number;
  16772. protected _currentFaceIndexCache: number;
  16773. protected _textureType: number;
  16774. protected _defaultTextureMatrix: Matrix;
  16775. protected _storedUniqueId: Nullable<number>;
  16776. /** @hidden */
  16777. static _SceneComponentInitialization: (scene: Scene) => void;
  16778. /**
  16779. * Creates a ShadowGenerator object.
  16780. * A ShadowGenerator is the required tool to use the shadows.
  16781. * Each light casting shadows needs to use its own ShadowGenerator.
  16782. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16783. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16784. * @param light The light object generating the shadows.
  16785. * @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.
  16786. */
  16787. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16788. protected _initializeGenerator(): void;
  16789. protected _createTargetRenderTexture(): void;
  16790. protected _initializeShadowMap(): void;
  16791. protected _initializeBlurRTTAndPostProcesses(): void;
  16792. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16793. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any): void;
  16794. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16795. protected _applyFilterValues(): void;
  16796. /**
  16797. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16798. * @param onCompiled Callback triggered at the and of the effects compilation
  16799. * @param options Sets of optional options forcing the compilation with different modes
  16800. */
  16801. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16802. useInstances: boolean;
  16803. }>): void;
  16804. /**
  16805. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16806. * @param options Sets of optional options forcing the compilation with different modes
  16807. * @returns A promise that resolves when the compilation completes
  16808. */
  16809. forceCompilationAsync(options?: Partial<{
  16810. useInstances: boolean;
  16811. }>): Promise<void>;
  16812. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16813. private _prepareShadowDefines;
  16814. /**
  16815. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16816. * @param subMesh The submesh we want to render in the shadow map
  16817. * @param useInstances Defines wether will draw in the map using instances
  16818. * @returns true if ready otherwise, false
  16819. */
  16820. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16821. /**
  16822. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16823. * @param defines Defines of the material we want to update
  16824. * @param lightIndex Index of the light in the enabled light list of the material
  16825. */
  16826. prepareDefines(defines: any, lightIndex: number): void;
  16827. /**
  16828. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16829. * defined in the generator but impacting the effect).
  16830. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16831. * @param effect The effect we are binfing the information for
  16832. */
  16833. bindShadowLight(lightIndex: string, effect: Effect): void;
  16834. /**
  16835. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16836. * (eq to shadow prjection matrix * light transform matrix)
  16837. * @returns The transform matrix used to create the shadow map
  16838. */
  16839. getTransformMatrix(): Matrix;
  16840. /**
  16841. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16842. * Cube and 2D textures for instance.
  16843. */
  16844. recreateShadowMap(): void;
  16845. protected _disposeBlurPostProcesses(): void;
  16846. protected _disposeRTTandPostProcesses(): void;
  16847. /**
  16848. * Disposes the ShadowGenerator.
  16849. * Returns nothing.
  16850. */
  16851. dispose(): void;
  16852. /**
  16853. * Serializes the shadow generator setup to a json object.
  16854. * @returns The serialized JSON object
  16855. */
  16856. serialize(): any;
  16857. /**
  16858. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16859. * @param parsedShadowGenerator The JSON object to parse
  16860. * @param scene The scene to create the shadow map for
  16861. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16862. * @returns The parsed shadow generator
  16863. */
  16864. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16865. }
  16866. }
  16867. declare module BABYLON {
  16868. /**
  16869. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16870. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16871. * 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.
  16872. */
  16873. export abstract class Light extends Node {
  16874. /**
  16875. * Falloff Default: light is falling off following the material specification:
  16876. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16877. */
  16878. static readonly FALLOFF_DEFAULT: number;
  16879. /**
  16880. * Falloff Physical: light is falling off following the inverse squared distance law.
  16881. */
  16882. static readonly FALLOFF_PHYSICAL: number;
  16883. /**
  16884. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16885. * to enhance interoperability with other engines.
  16886. */
  16887. static readonly FALLOFF_GLTF: number;
  16888. /**
  16889. * Falloff Standard: light is falling off like in the standard material
  16890. * to enhance interoperability with other materials.
  16891. */
  16892. static readonly FALLOFF_STANDARD: number;
  16893. /**
  16894. * If every light affecting the material is in this lightmapMode,
  16895. * material.lightmapTexture adds or multiplies
  16896. * (depends on material.useLightmapAsShadowmap)
  16897. * after every other light calculations.
  16898. */
  16899. static readonly LIGHTMAP_DEFAULT: number;
  16900. /**
  16901. * material.lightmapTexture as only diffuse lighting from this light
  16902. * adds only specular lighting from this light
  16903. * adds dynamic shadows
  16904. */
  16905. static readonly LIGHTMAP_SPECULAR: number;
  16906. /**
  16907. * material.lightmapTexture as only lighting
  16908. * no light calculation from this light
  16909. * only adds dynamic shadows from this light
  16910. */
  16911. static readonly LIGHTMAP_SHADOWSONLY: number;
  16912. /**
  16913. * Each light type uses the default quantity according to its type:
  16914. * point/spot lights use luminous intensity
  16915. * directional lights use illuminance
  16916. */
  16917. static readonly INTENSITYMODE_AUTOMATIC: number;
  16918. /**
  16919. * lumen (lm)
  16920. */
  16921. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16922. /**
  16923. * candela (lm/sr)
  16924. */
  16925. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16926. /**
  16927. * lux (lm/m^2)
  16928. */
  16929. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16930. /**
  16931. * nit (cd/m^2)
  16932. */
  16933. static readonly INTENSITYMODE_LUMINANCE: number;
  16934. /**
  16935. * Light type const id of the point light.
  16936. */
  16937. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16938. /**
  16939. * Light type const id of the directional light.
  16940. */
  16941. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16942. /**
  16943. * Light type const id of the spot light.
  16944. */
  16945. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16946. /**
  16947. * Light type const id of the hemispheric light.
  16948. */
  16949. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16950. /**
  16951. * Diffuse gives the basic color to an object.
  16952. */
  16953. diffuse: Color3;
  16954. /**
  16955. * Specular produces a highlight color on an object.
  16956. * Note: This is note affecting PBR materials.
  16957. */
  16958. specular: Color3;
  16959. /**
  16960. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16961. * falling off base on range or angle.
  16962. * This can be set to any values in Light.FALLOFF_x.
  16963. *
  16964. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16965. * other types of materials.
  16966. */
  16967. falloffType: number;
  16968. /**
  16969. * Strength of the light.
  16970. * Note: By default it is define in the framework own unit.
  16971. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16972. */
  16973. intensity: number;
  16974. private _range;
  16975. protected _inverseSquaredRange: number;
  16976. /**
  16977. * Defines how far from the source the light is impacting in scene units.
  16978. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16979. */
  16980. get range(): number;
  16981. /**
  16982. * Defines how far from the source the light is impacting in scene units.
  16983. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16984. */
  16985. set range(value: number);
  16986. /**
  16987. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16988. * of light.
  16989. */
  16990. private _photometricScale;
  16991. private _intensityMode;
  16992. /**
  16993. * Gets the photometric scale used to interpret the intensity.
  16994. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16995. */
  16996. get intensityMode(): number;
  16997. /**
  16998. * Sets the photometric scale used to interpret the intensity.
  16999. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17000. */
  17001. set intensityMode(value: number);
  17002. private _radius;
  17003. /**
  17004. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17005. */
  17006. get radius(): number;
  17007. /**
  17008. * sets the light radius used by PBR Materials to simulate soft area lights.
  17009. */
  17010. set radius(value: number);
  17011. private _renderPriority;
  17012. /**
  17013. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17014. * exceeding the number allowed of the materials.
  17015. */
  17016. renderPriority: number;
  17017. private _shadowEnabled;
  17018. /**
  17019. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17020. * the current shadow generator.
  17021. */
  17022. get shadowEnabled(): boolean;
  17023. /**
  17024. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17025. * the current shadow generator.
  17026. */
  17027. set shadowEnabled(value: boolean);
  17028. private _includedOnlyMeshes;
  17029. /**
  17030. * Gets the only meshes impacted by this light.
  17031. */
  17032. get includedOnlyMeshes(): AbstractMesh[];
  17033. /**
  17034. * Sets the only meshes impacted by this light.
  17035. */
  17036. set includedOnlyMeshes(value: AbstractMesh[]);
  17037. private _excludedMeshes;
  17038. /**
  17039. * Gets the meshes not impacted by this light.
  17040. */
  17041. get excludedMeshes(): AbstractMesh[];
  17042. /**
  17043. * Sets the meshes not impacted by this light.
  17044. */
  17045. set excludedMeshes(value: AbstractMesh[]);
  17046. private _excludeWithLayerMask;
  17047. /**
  17048. * Gets the layer id use to find what meshes are not impacted by the light.
  17049. * Inactive if 0
  17050. */
  17051. get excludeWithLayerMask(): number;
  17052. /**
  17053. * Sets the layer id use to find what meshes are not impacted by the light.
  17054. * Inactive if 0
  17055. */
  17056. set excludeWithLayerMask(value: number);
  17057. private _includeOnlyWithLayerMask;
  17058. /**
  17059. * Gets the layer id use to find what meshes are impacted by the light.
  17060. * Inactive if 0
  17061. */
  17062. get includeOnlyWithLayerMask(): number;
  17063. /**
  17064. * Sets the layer id use to find what meshes are impacted by the light.
  17065. * Inactive if 0
  17066. */
  17067. set includeOnlyWithLayerMask(value: number);
  17068. private _lightmapMode;
  17069. /**
  17070. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17071. */
  17072. get lightmapMode(): number;
  17073. /**
  17074. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17075. */
  17076. set lightmapMode(value: number);
  17077. /**
  17078. * Shadow generator associted to the light.
  17079. * @hidden Internal use only.
  17080. */
  17081. _shadowGenerator: Nullable<IShadowGenerator>;
  17082. /**
  17083. * @hidden Internal use only.
  17084. */
  17085. _excludedMeshesIds: string[];
  17086. /**
  17087. * @hidden Internal use only.
  17088. */
  17089. _includedOnlyMeshesIds: string[];
  17090. /**
  17091. * The current light unifom buffer.
  17092. * @hidden Internal use only.
  17093. */
  17094. _uniformBuffer: UniformBuffer;
  17095. /** @hidden */
  17096. _renderId: number;
  17097. /**
  17098. * Creates a Light object in the scene.
  17099. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17100. * @param name The firendly name of the light
  17101. * @param scene The scene the light belongs too
  17102. */
  17103. constructor(name: string, scene: Scene);
  17104. protected abstract _buildUniformLayout(): void;
  17105. /**
  17106. * Sets the passed Effect "effect" with the Light information.
  17107. * @param effect The effect to update
  17108. * @param lightIndex The index of the light in the effect to update
  17109. * @returns The light
  17110. */
  17111. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17112. /**
  17113. * Sets the passed Effect "effect" with the Light textures.
  17114. * @param effect The effect to update
  17115. * @param lightIndex The index of the light in the effect to update
  17116. * @returns The light
  17117. */
  17118. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17119. /**
  17120. * Binds the lights information from the scene to the effect for the given mesh.
  17121. * @param lightIndex Light index
  17122. * @param scene The scene where the light belongs to
  17123. * @param effect The effect we are binding the data to
  17124. * @param useSpecular Defines if specular is supported
  17125. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17126. */
  17127. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17128. /**
  17129. * Sets the passed Effect "effect" with the Light information.
  17130. * @param effect The effect to update
  17131. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17132. * @returns The light
  17133. */
  17134. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17135. /**
  17136. * Returns the string "Light".
  17137. * @returns the class name
  17138. */
  17139. getClassName(): string;
  17140. /** @hidden */
  17141. readonly _isLight: boolean;
  17142. /**
  17143. * Converts the light information to a readable string for debug purpose.
  17144. * @param fullDetails Supports for multiple levels of logging within scene loading
  17145. * @returns the human readable light info
  17146. */
  17147. toString(fullDetails?: boolean): string;
  17148. /** @hidden */
  17149. protected _syncParentEnabledState(): void;
  17150. /**
  17151. * Set the enabled state of this node.
  17152. * @param value - the new enabled state
  17153. */
  17154. setEnabled(value: boolean): void;
  17155. /**
  17156. * Returns the Light associated shadow generator if any.
  17157. * @return the associated shadow generator.
  17158. */
  17159. getShadowGenerator(): Nullable<IShadowGenerator>;
  17160. /**
  17161. * Returns a Vector3, the absolute light position in the World.
  17162. * @returns the world space position of the light
  17163. */
  17164. getAbsolutePosition(): Vector3;
  17165. /**
  17166. * Specifies if the light will affect the passed mesh.
  17167. * @param mesh The mesh to test against the light
  17168. * @return true the mesh is affected otherwise, false.
  17169. */
  17170. canAffectMesh(mesh: AbstractMesh): boolean;
  17171. /**
  17172. * Sort function to order lights for rendering.
  17173. * @param a First Light object to compare to second.
  17174. * @param b Second Light object to compare first.
  17175. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17176. */
  17177. static CompareLightsPriority(a: Light, b: Light): number;
  17178. /**
  17179. * Releases resources associated with this node.
  17180. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17181. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17182. */
  17183. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17184. /**
  17185. * Returns the light type ID (integer).
  17186. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17187. */
  17188. getTypeID(): number;
  17189. /**
  17190. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17191. * @returns the scaled intensity in intensity mode unit
  17192. */
  17193. getScaledIntensity(): number;
  17194. /**
  17195. * Returns a new Light object, named "name", from the current one.
  17196. * @param name The name of the cloned light
  17197. * @returns the new created light
  17198. */
  17199. clone(name: string): Nullable<Light>;
  17200. /**
  17201. * Serializes the current light into a Serialization object.
  17202. * @returns the serialized object.
  17203. */
  17204. serialize(): any;
  17205. /**
  17206. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17207. * This new light is named "name" and added to the passed scene.
  17208. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17209. * @param name The friendly name of the light
  17210. * @param scene The scene the new light will belong to
  17211. * @returns the constructor function
  17212. */
  17213. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17214. /**
  17215. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17216. * @param parsedLight The JSON representation of the light
  17217. * @param scene The scene to create the parsed light in
  17218. * @returns the created light after parsing
  17219. */
  17220. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17221. private _hookArrayForExcluded;
  17222. private _hookArrayForIncludedOnly;
  17223. private _resyncMeshes;
  17224. /**
  17225. * Forces the meshes to update their light related information in their rendering used effects
  17226. * @hidden Internal Use Only
  17227. */
  17228. _markMeshesAsLightDirty(): void;
  17229. /**
  17230. * Recomputes the cached photometric scale if needed.
  17231. */
  17232. private _computePhotometricScale;
  17233. /**
  17234. * Returns the Photometric Scale according to the light type and intensity mode.
  17235. */
  17236. private _getPhotometricScale;
  17237. /**
  17238. * Reorder the light in the scene according to their defined priority.
  17239. * @hidden Internal Use Only
  17240. */
  17241. _reorderLightsInScene(): void;
  17242. /**
  17243. * Prepares the list of defines specific to the light type.
  17244. * @param defines the list of defines
  17245. * @param lightIndex defines the index of the light for the effect
  17246. */
  17247. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17248. }
  17249. }
  17250. declare module BABYLON {
  17251. /**
  17252. * Interface used to define Action
  17253. */
  17254. export interface IAction {
  17255. /**
  17256. * Trigger for the action
  17257. */
  17258. trigger: number;
  17259. /** Options of the trigger */
  17260. triggerOptions: any;
  17261. /**
  17262. * Gets the trigger parameters
  17263. * @returns the trigger parameters
  17264. */
  17265. getTriggerParameter(): any;
  17266. /**
  17267. * Internal only - executes current action event
  17268. * @hidden
  17269. */
  17270. _executeCurrent(evt?: ActionEvent): void;
  17271. /**
  17272. * Serialize placeholder for child classes
  17273. * @param parent of child
  17274. * @returns the serialized object
  17275. */
  17276. serialize(parent: any): any;
  17277. /**
  17278. * Internal only
  17279. * @hidden
  17280. */
  17281. _prepare(): void;
  17282. /**
  17283. * Internal only - manager for action
  17284. * @hidden
  17285. */
  17286. _actionManager: AbstractActionManager;
  17287. /**
  17288. * Adds action to chain of actions, may be a DoNothingAction
  17289. * @param action defines the next action to execute
  17290. * @returns The action passed in
  17291. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17292. */
  17293. then(action: IAction): IAction;
  17294. }
  17295. /**
  17296. * The action to be carried out following a trigger
  17297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17298. */
  17299. export class Action implements IAction {
  17300. /** the trigger, with or without parameters, for the action */
  17301. triggerOptions: any;
  17302. /**
  17303. * Trigger for the action
  17304. */
  17305. trigger: number;
  17306. /**
  17307. * Internal only - manager for action
  17308. * @hidden
  17309. */
  17310. _actionManager: ActionManager;
  17311. private _nextActiveAction;
  17312. private _child;
  17313. private _condition?;
  17314. private _triggerParameter;
  17315. /**
  17316. * An event triggered prior to action being executed.
  17317. */
  17318. onBeforeExecuteObservable: Observable<Action>;
  17319. /**
  17320. * Creates a new Action
  17321. * @param triggerOptions the trigger, with or without parameters, for the action
  17322. * @param condition an optional determinant of action
  17323. */
  17324. constructor(
  17325. /** the trigger, with or without parameters, for the action */
  17326. triggerOptions: any, condition?: Condition);
  17327. /**
  17328. * Internal only
  17329. * @hidden
  17330. */
  17331. _prepare(): void;
  17332. /**
  17333. * Gets the trigger parameters
  17334. * @returns the trigger parameters
  17335. */
  17336. getTriggerParameter(): any;
  17337. /**
  17338. * Internal only - executes current action event
  17339. * @hidden
  17340. */
  17341. _executeCurrent(evt?: ActionEvent): void;
  17342. /**
  17343. * Execute placeholder for child classes
  17344. * @param evt optional action event
  17345. */
  17346. execute(evt?: ActionEvent): void;
  17347. /**
  17348. * Skips to next active action
  17349. */
  17350. skipToNextActiveAction(): void;
  17351. /**
  17352. * Adds action to chain of actions, may be a DoNothingAction
  17353. * @param action defines the next action to execute
  17354. * @returns The action passed in
  17355. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17356. */
  17357. then(action: Action): Action;
  17358. /**
  17359. * Internal only
  17360. * @hidden
  17361. */
  17362. _getProperty(propertyPath: string): string;
  17363. /**
  17364. * Internal only
  17365. * @hidden
  17366. */
  17367. _getEffectiveTarget(target: any, propertyPath: string): any;
  17368. /**
  17369. * Serialize placeholder for child classes
  17370. * @param parent of child
  17371. * @returns the serialized object
  17372. */
  17373. serialize(parent: any): any;
  17374. /**
  17375. * Internal only called by serialize
  17376. * @hidden
  17377. */
  17378. protected _serialize(serializedAction: any, parent?: any): any;
  17379. /**
  17380. * Internal only
  17381. * @hidden
  17382. */
  17383. static _SerializeValueAsString: (value: any) => string;
  17384. /**
  17385. * Internal only
  17386. * @hidden
  17387. */
  17388. static _GetTargetProperty: (target: Node | Scene) => {
  17389. name: string;
  17390. targetType: string;
  17391. value: string;
  17392. };
  17393. }
  17394. }
  17395. declare module BABYLON {
  17396. /**
  17397. * A Condition applied to an Action
  17398. */
  17399. export class Condition {
  17400. /**
  17401. * Internal only - manager for action
  17402. * @hidden
  17403. */
  17404. _actionManager: ActionManager;
  17405. /**
  17406. * Internal only
  17407. * @hidden
  17408. */
  17409. _evaluationId: number;
  17410. /**
  17411. * Internal only
  17412. * @hidden
  17413. */
  17414. _currentResult: boolean;
  17415. /**
  17416. * Creates a new Condition
  17417. * @param actionManager the manager of the action the condition is applied to
  17418. */
  17419. constructor(actionManager: ActionManager);
  17420. /**
  17421. * Check if the current condition is valid
  17422. * @returns a boolean
  17423. */
  17424. isValid(): boolean;
  17425. /**
  17426. * Internal only
  17427. * @hidden
  17428. */
  17429. _getProperty(propertyPath: string): string;
  17430. /**
  17431. * Internal only
  17432. * @hidden
  17433. */
  17434. _getEffectiveTarget(target: any, propertyPath: string): any;
  17435. /**
  17436. * Serialize placeholder for child classes
  17437. * @returns the serialized object
  17438. */
  17439. serialize(): any;
  17440. /**
  17441. * Internal only
  17442. * @hidden
  17443. */
  17444. protected _serialize(serializedCondition: any): any;
  17445. }
  17446. /**
  17447. * Defines specific conditional operators as extensions of Condition
  17448. */
  17449. export class ValueCondition extends Condition {
  17450. /** path to specify the property of the target the conditional operator uses */
  17451. propertyPath: string;
  17452. /** the value compared by the conditional operator against the current value of the property */
  17453. value: any;
  17454. /** the conditional operator, default ValueCondition.IsEqual */
  17455. operator: number;
  17456. /**
  17457. * Internal only
  17458. * @hidden
  17459. */
  17460. private static _IsEqual;
  17461. /**
  17462. * Internal only
  17463. * @hidden
  17464. */
  17465. private static _IsDifferent;
  17466. /**
  17467. * Internal only
  17468. * @hidden
  17469. */
  17470. private static _IsGreater;
  17471. /**
  17472. * Internal only
  17473. * @hidden
  17474. */
  17475. private static _IsLesser;
  17476. /**
  17477. * returns the number for IsEqual
  17478. */
  17479. static get IsEqual(): number;
  17480. /**
  17481. * Returns the number for IsDifferent
  17482. */
  17483. static get IsDifferent(): number;
  17484. /**
  17485. * Returns the number for IsGreater
  17486. */
  17487. static get IsGreater(): number;
  17488. /**
  17489. * Returns the number for IsLesser
  17490. */
  17491. static get IsLesser(): number;
  17492. /**
  17493. * Internal only The action manager for the condition
  17494. * @hidden
  17495. */
  17496. _actionManager: ActionManager;
  17497. /**
  17498. * Internal only
  17499. * @hidden
  17500. */
  17501. private _target;
  17502. /**
  17503. * Internal only
  17504. * @hidden
  17505. */
  17506. private _effectiveTarget;
  17507. /**
  17508. * Internal only
  17509. * @hidden
  17510. */
  17511. private _property;
  17512. /**
  17513. * Creates a new ValueCondition
  17514. * @param actionManager manager for the action the condition applies to
  17515. * @param target for the action
  17516. * @param propertyPath path to specify the property of the target the conditional operator uses
  17517. * @param value the value compared by the conditional operator against the current value of the property
  17518. * @param operator the conditional operator, default ValueCondition.IsEqual
  17519. */
  17520. constructor(actionManager: ActionManager, target: any,
  17521. /** path to specify the property of the target the conditional operator uses */
  17522. propertyPath: string,
  17523. /** the value compared by the conditional operator against the current value of the property */
  17524. value: any,
  17525. /** the conditional operator, default ValueCondition.IsEqual */
  17526. operator?: number);
  17527. /**
  17528. * Compares the given value with the property value for the specified conditional operator
  17529. * @returns the result of the comparison
  17530. */
  17531. isValid(): boolean;
  17532. /**
  17533. * Serialize the ValueCondition into a JSON compatible object
  17534. * @returns serialization object
  17535. */
  17536. serialize(): any;
  17537. /**
  17538. * Gets the name of the conditional operator for the ValueCondition
  17539. * @param operator the conditional operator
  17540. * @returns the name
  17541. */
  17542. static GetOperatorName(operator: number): string;
  17543. }
  17544. /**
  17545. * Defines a predicate condition as an extension of Condition
  17546. */
  17547. export class PredicateCondition extends Condition {
  17548. /** defines the predicate function used to validate the condition */
  17549. predicate: () => boolean;
  17550. /**
  17551. * Internal only - manager for action
  17552. * @hidden
  17553. */
  17554. _actionManager: ActionManager;
  17555. /**
  17556. * Creates a new PredicateCondition
  17557. * @param actionManager manager for the action the condition applies to
  17558. * @param predicate defines the predicate function used to validate the condition
  17559. */
  17560. constructor(actionManager: ActionManager,
  17561. /** defines the predicate function used to validate the condition */
  17562. predicate: () => boolean);
  17563. /**
  17564. * @returns the validity of the predicate condition
  17565. */
  17566. isValid(): boolean;
  17567. }
  17568. /**
  17569. * Defines a state condition as an extension of Condition
  17570. */
  17571. export class StateCondition extends Condition {
  17572. /** Value to compare with target state */
  17573. value: string;
  17574. /**
  17575. * Internal only - manager for action
  17576. * @hidden
  17577. */
  17578. _actionManager: ActionManager;
  17579. /**
  17580. * Internal only
  17581. * @hidden
  17582. */
  17583. private _target;
  17584. /**
  17585. * Creates a new StateCondition
  17586. * @param actionManager manager for the action the condition applies to
  17587. * @param target of the condition
  17588. * @param value to compare with target state
  17589. */
  17590. constructor(actionManager: ActionManager, target: any,
  17591. /** Value to compare with target state */
  17592. value: string);
  17593. /**
  17594. * Gets a boolean indicating if the current condition is met
  17595. * @returns the validity of the state
  17596. */
  17597. isValid(): boolean;
  17598. /**
  17599. * Serialize the StateCondition into a JSON compatible object
  17600. * @returns serialization object
  17601. */
  17602. serialize(): any;
  17603. }
  17604. }
  17605. declare module BABYLON {
  17606. /**
  17607. * This defines an action responsible to toggle a boolean once triggered.
  17608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17609. */
  17610. export class SwitchBooleanAction extends Action {
  17611. /**
  17612. * The path to the boolean property in the target object
  17613. */
  17614. propertyPath: string;
  17615. private _target;
  17616. private _effectiveTarget;
  17617. private _property;
  17618. /**
  17619. * Instantiate the action
  17620. * @param triggerOptions defines the trigger options
  17621. * @param target defines the object containing the boolean
  17622. * @param propertyPath defines the path to the boolean property in the target object
  17623. * @param condition defines the trigger related conditions
  17624. */
  17625. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17626. /** @hidden */
  17627. _prepare(): void;
  17628. /**
  17629. * Execute the action toggle the boolean value.
  17630. */
  17631. execute(): void;
  17632. /**
  17633. * Serializes the actions and its related information.
  17634. * @param parent defines the object to serialize in
  17635. * @returns the serialized object
  17636. */
  17637. serialize(parent: any): any;
  17638. }
  17639. /**
  17640. * This defines an action responsible to set a the state field of the target
  17641. * to a desired value once triggered.
  17642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17643. */
  17644. export class SetStateAction extends Action {
  17645. /**
  17646. * The value to store in the state field.
  17647. */
  17648. value: string;
  17649. private _target;
  17650. /**
  17651. * Instantiate the action
  17652. * @param triggerOptions defines the trigger options
  17653. * @param target defines the object containing the state property
  17654. * @param value defines the value to store in the state field
  17655. * @param condition defines the trigger related conditions
  17656. */
  17657. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17658. /**
  17659. * Execute the action and store the value on the target state property.
  17660. */
  17661. execute(): void;
  17662. /**
  17663. * Serializes the actions and its related information.
  17664. * @param parent defines the object to serialize in
  17665. * @returns the serialized object
  17666. */
  17667. serialize(parent: any): any;
  17668. }
  17669. /**
  17670. * This defines an action responsible to set a property of the target
  17671. * to a desired value once triggered.
  17672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17673. */
  17674. export class SetValueAction extends Action {
  17675. /**
  17676. * The path of the property to set in the target.
  17677. */
  17678. propertyPath: string;
  17679. /**
  17680. * The value to set in the property
  17681. */
  17682. value: any;
  17683. private _target;
  17684. private _effectiveTarget;
  17685. private _property;
  17686. /**
  17687. * Instantiate the action
  17688. * @param triggerOptions defines the trigger options
  17689. * @param target defines the object containing the property
  17690. * @param propertyPath defines the path of the property to set in the target
  17691. * @param value defines the value to set in the property
  17692. * @param condition defines the trigger related conditions
  17693. */
  17694. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17695. /** @hidden */
  17696. _prepare(): void;
  17697. /**
  17698. * Execute the action and set the targetted property to the desired value.
  17699. */
  17700. execute(): void;
  17701. /**
  17702. * Serializes the actions and its related information.
  17703. * @param parent defines the object to serialize in
  17704. * @returns the serialized object
  17705. */
  17706. serialize(parent: any): any;
  17707. }
  17708. /**
  17709. * This defines an action responsible to increment the target value
  17710. * to a desired value once triggered.
  17711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17712. */
  17713. export class IncrementValueAction extends Action {
  17714. /**
  17715. * The path of the property to increment in the target.
  17716. */
  17717. propertyPath: string;
  17718. /**
  17719. * The value we should increment the property by.
  17720. */
  17721. value: any;
  17722. private _target;
  17723. private _effectiveTarget;
  17724. private _property;
  17725. /**
  17726. * Instantiate the action
  17727. * @param triggerOptions defines the trigger options
  17728. * @param target defines the object containing the property
  17729. * @param propertyPath defines the path of the property to increment in the target
  17730. * @param value defines the value value we should increment the property by
  17731. * @param condition defines the trigger related conditions
  17732. */
  17733. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17734. /** @hidden */
  17735. _prepare(): void;
  17736. /**
  17737. * Execute the action and increment the target of the value amount.
  17738. */
  17739. execute(): void;
  17740. /**
  17741. * Serializes the actions and its related information.
  17742. * @param parent defines the object to serialize in
  17743. * @returns the serialized object
  17744. */
  17745. serialize(parent: any): any;
  17746. }
  17747. /**
  17748. * This defines an action responsible to start an animation once triggered.
  17749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17750. */
  17751. export class PlayAnimationAction extends Action {
  17752. /**
  17753. * Where the animation should start (animation frame)
  17754. */
  17755. from: number;
  17756. /**
  17757. * Where the animation should stop (animation frame)
  17758. */
  17759. to: number;
  17760. /**
  17761. * Define if the animation should loop or stop after the first play.
  17762. */
  17763. loop?: boolean;
  17764. private _target;
  17765. /**
  17766. * Instantiate the action
  17767. * @param triggerOptions defines the trigger options
  17768. * @param target defines the target animation or animation name
  17769. * @param from defines from where the animation should start (animation frame)
  17770. * @param end defines where the animation should stop (animation frame)
  17771. * @param loop defines if the animation should loop or stop after the first play
  17772. * @param condition defines the trigger related conditions
  17773. */
  17774. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17775. /** @hidden */
  17776. _prepare(): void;
  17777. /**
  17778. * Execute the action and play the animation.
  17779. */
  17780. execute(): void;
  17781. /**
  17782. * Serializes the actions and its related information.
  17783. * @param parent defines the object to serialize in
  17784. * @returns the serialized object
  17785. */
  17786. serialize(parent: any): any;
  17787. }
  17788. /**
  17789. * This defines an action responsible to stop an animation once triggered.
  17790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17791. */
  17792. export class StopAnimationAction extends Action {
  17793. private _target;
  17794. /**
  17795. * Instantiate the action
  17796. * @param triggerOptions defines the trigger options
  17797. * @param target defines the target animation or animation name
  17798. * @param condition defines the trigger related conditions
  17799. */
  17800. constructor(triggerOptions: any, target: any, condition?: Condition);
  17801. /** @hidden */
  17802. _prepare(): void;
  17803. /**
  17804. * Execute the action and stop the animation.
  17805. */
  17806. execute(): void;
  17807. /**
  17808. * Serializes the actions and its related information.
  17809. * @param parent defines the object to serialize in
  17810. * @returns the serialized object
  17811. */
  17812. serialize(parent: any): any;
  17813. }
  17814. /**
  17815. * This defines an action responsible that does nothing once triggered.
  17816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17817. */
  17818. export class DoNothingAction extends Action {
  17819. /**
  17820. * Instantiate the action
  17821. * @param triggerOptions defines the trigger options
  17822. * @param condition defines the trigger related conditions
  17823. */
  17824. constructor(triggerOptions?: any, condition?: Condition);
  17825. /**
  17826. * Execute the action and do nothing.
  17827. */
  17828. execute(): void;
  17829. /**
  17830. * Serializes the actions and its related information.
  17831. * @param parent defines the object to serialize in
  17832. * @returns the serialized object
  17833. */
  17834. serialize(parent: any): any;
  17835. }
  17836. /**
  17837. * This defines an action responsible to trigger several actions once triggered.
  17838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17839. */
  17840. export class CombineAction extends Action {
  17841. /**
  17842. * The list of aggregated animations to run.
  17843. */
  17844. children: Action[];
  17845. /**
  17846. * Instantiate the action
  17847. * @param triggerOptions defines the trigger options
  17848. * @param children defines the list of aggregated animations to run
  17849. * @param condition defines the trigger related conditions
  17850. */
  17851. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17852. /** @hidden */
  17853. _prepare(): void;
  17854. /**
  17855. * Execute the action and executes all the aggregated actions.
  17856. */
  17857. execute(evt: ActionEvent): void;
  17858. /**
  17859. * Serializes the actions and its related information.
  17860. * @param parent defines the object to serialize in
  17861. * @returns the serialized object
  17862. */
  17863. serialize(parent: any): any;
  17864. }
  17865. /**
  17866. * This defines an action responsible to run code (external event) once triggered.
  17867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17868. */
  17869. export class ExecuteCodeAction extends Action {
  17870. /**
  17871. * The callback function to run.
  17872. */
  17873. func: (evt: ActionEvent) => void;
  17874. /**
  17875. * Instantiate the action
  17876. * @param triggerOptions defines the trigger options
  17877. * @param func defines the callback function to run
  17878. * @param condition defines the trigger related conditions
  17879. */
  17880. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17881. /**
  17882. * Execute the action and run the attached code.
  17883. */
  17884. execute(evt: ActionEvent): void;
  17885. }
  17886. /**
  17887. * This defines an action responsible to set the parent property of the target once triggered.
  17888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17889. */
  17890. export class SetParentAction extends Action {
  17891. private _parent;
  17892. private _target;
  17893. /**
  17894. * Instantiate the action
  17895. * @param triggerOptions defines the trigger options
  17896. * @param target defines the target containing the parent property
  17897. * @param parent defines from where the animation should start (animation frame)
  17898. * @param condition defines the trigger related conditions
  17899. */
  17900. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17901. /** @hidden */
  17902. _prepare(): void;
  17903. /**
  17904. * Execute the action and set the parent property.
  17905. */
  17906. execute(): void;
  17907. /**
  17908. * Serializes the actions and its related information.
  17909. * @param parent defines the object to serialize in
  17910. * @returns the serialized object
  17911. */
  17912. serialize(parent: any): any;
  17913. }
  17914. }
  17915. declare module BABYLON {
  17916. /**
  17917. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17918. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17920. */
  17921. export class ActionManager extends AbstractActionManager {
  17922. /**
  17923. * Nothing
  17924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17925. */
  17926. static readonly NothingTrigger: number;
  17927. /**
  17928. * On pick
  17929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17930. */
  17931. static readonly OnPickTrigger: number;
  17932. /**
  17933. * On left pick
  17934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17935. */
  17936. static readonly OnLeftPickTrigger: number;
  17937. /**
  17938. * On right pick
  17939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17940. */
  17941. static readonly OnRightPickTrigger: number;
  17942. /**
  17943. * On center pick
  17944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17945. */
  17946. static readonly OnCenterPickTrigger: number;
  17947. /**
  17948. * On pick down
  17949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17950. */
  17951. static readonly OnPickDownTrigger: number;
  17952. /**
  17953. * On double pick
  17954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17955. */
  17956. static readonly OnDoublePickTrigger: number;
  17957. /**
  17958. * On pick up
  17959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17960. */
  17961. static readonly OnPickUpTrigger: number;
  17962. /**
  17963. * On pick out.
  17964. * This trigger will only be raised if you also declared a OnPickDown
  17965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17966. */
  17967. static readonly OnPickOutTrigger: number;
  17968. /**
  17969. * On long press
  17970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17971. */
  17972. static readonly OnLongPressTrigger: number;
  17973. /**
  17974. * On pointer over
  17975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17976. */
  17977. static readonly OnPointerOverTrigger: number;
  17978. /**
  17979. * On pointer out
  17980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17981. */
  17982. static readonly OnPointerOutTrigger: number;
  17983. /**
  17984. * On every frame
  17985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17986. */
  17987. static readonly OnEveryFrameTrigger: number;
  17988. /**
  17989. * On intersection enter
  17990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17991. */
  17992. static readonly OnIntersectionEnterTrigger: number;
  17993. /**
  17994. * On intersection exit
  17995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17996. */
  17997. static readonly OnIntersectionExitTrigger: number;
  17998. /**
  17999. * On key down
  18000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18001. */
  18002. static readonly OnKeyDownTrigger: number;
  18003. /**
  18004. * On key up
  18005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18006. */
  18007. static readonly OnKeyUpTrigger: number;
  18008. private _scene;
  18009. /**
  18010. * Creates a new action manager
  18011. * @param scene defines the hosting scene
  18012. */
  18013. constructor(scene: Scene);
  18014. /**
  18015. * Releases all associated resources
  18016. */
  18017. dispose(): void;
  18018. /**
  18019. * Gets hosting scene
  18020. * @returns the hosting scene
  18021. */
  18022. getScene(): Scene;
  18023. /**
  18024. * Does this action manager handles actions of any of the given triggers
  18025. * @param triggers defines the triggers to be tested
  18026. * @return a boolean indicating whether one (or more) of the triggers is handled
  18027. */
  18028. hasSpecificTriggers(triggers: number[]): boolean;
  18029. /**
  18030. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18031. * speed.
  18032. * @param triggerA defines the trigger to be tested
  18033. * @param triggerB defines the trigger to be tested
  18034. * @return a boolean indicating whether one (or more) of the triggers is handled
  18035. */
  18036. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18037. /**
  18038. * Does this action manager handles actions of a given trigger
  18039. * @param trigger defines the trigger to be tested
  18040. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18041. * @return whether the trigger is handled
  18042. */
  18043. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18044. /**
  18045. * Does this action manager has pointer triggers
  18046. */
  18047. get hasPointerTriggers(): boolean;
  18048. /**
  18049. * Does this action manager has pick triggers
  18050. */
  18051. get hasPickTriggers(): boolean;
  18052. /**
  18053. * Registers an action to this action manager
  18054. * @param action defines the action to be registered
  18055. * @return the action amended (prepared) after registration
  18056. */
  18057. registerAction(action: IAction): Nullable<IAction>;
  18058. /**
  18059. * Unregisters an action to this action manager
  18060. * @param action defines the action to be unregistered
  18061. * @return a boolean indicating whether the action has been unregistered
  18062. */
  18063. unregisterAction(action: IAction): Boolean;
  18064. /**
  18065. * Process a specific trigger
  18066. * @param trigger defines the trigger to process
  18067. * @param evt defines the event details to be processed
  18068. */
  18069. processTrigger(trigger: number, evt?: IActionEvent): void;
  18070. /** @hidden */
  18071. _getEffectiveTarget(target: any, propertyPath: string): any;
  18072. /** @hidden */
  18073. _getProperty(propertyPath: string): string;
  18074. /**
  18075. * Serialize this manager to a JSON object
  18076. * @param name defines the property name to store this manager
  18077. * @returns a JSON representation of this manager
  18078. */
  18079. serialize(name: string): any;
  18080. /**
  18081. * Creates a new ActionManager from a JSON data
  18082. * @param parsedActions defines the JSON data to read from
  18083. * @param object defines the hosting mesh
  18084. * @param scene defines the hosting scene
  18085. */
  18086. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18087. /**
  18088. * Get a trigger name by index
  18089. * @param trigger defines the trigger index
  18090. * @returns a trigger name
  18091. */
  18092. static GetTriggerName(trigger: number): string;
  18093. }
  18094. }
  18095. declare module BABYLON {
  18096. /**
  18097. * Class used to represent a sprite
  18098. * @see http://doc.babylonjs.com/babylon101/sprites
  18099. */
  18100. export class Sprite {
  18101. /** defines the name */
  18102. name: string;
  18103. /** Gets or sets the current world position */
  18104. position: Vector3;
  18105. /** Gets or sets the main color */
  18106. color: Color4;
  18107. /** Gets or sets the width */
  18108. width: number;
  18109. /** Gets or sets the height */
  18110. height: number;
  18111. /** Gets or sets rotation angle */
  18112. angle: number;
  18113. /** Gets or sets the cell index in the sprite sheet */
  18114. cellIndex: number;
  18115. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18116. cellRef: string;
  18117. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18118. invertU: number;
  18119. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18120. invertV: number;
  18121. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18122. disposeWhenFinishedAnimating: boolean;
  18123. /** Gets the list of attached animations */
  18124. animations: Animation[];
  18125. /** Gets or sets a boolean indicating if the sprite can be picked */
  18126. isPickable: boolean;
  18127. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18128. useAlphaForPicking: boolean;
  18129. /** @hidden */
  18130. _xOffset: number;
  18131. /** @hidden */
  18132. _yOffset: number;
  18133. /** @hidden */
  18134. _xSize: number;
  18135. /** @hidden */
  18136. _ySize: number;
  18137. /**
  18138. * Gets or sets the associated action manager
  18139. */
  18140. actionManager: Nullable<ActionManager>;
  18141. private _animationStarted;
  18142. private _loopAnimation;
  18143. private _fromIndex;
  18144. private _toIndex;
  18145. private _delay;
  18146. private _direction;
  18147. private _manager;
  18148. private _time;
  18149. private _onAnimationEnd;
  18150. /**
  18151. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18152. */
  18153. isVisible: boolean;
  18154. /**
  18155. * Gets or sets the sprite size
  18156. */
  18157. get size(): number;
  18158. set size(value: number);
  18159. /**
  18160. * Creates a new Sprite
  18161. * @param name defines the name
  18162. * @param manager defines the manager
  18163. */
  18164. constructor(
  18165. /** defines the name */
  18166. name: string, manager: ISpriteManager);
  18167. /**
  18168. * Starts an animation
  18169. * @param from defines the initial key
  18170. * @param to defines the end key
  18171. * @param loop defines if the animation must loop
  18172. * @param delay defines the start delay (in ms)
  18173. * @param onAnimationEnd defines a callback to call when animation ends
  18174. */
  18175. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18176. /** Stops current animation (if any) */
  18177. stopAnimation(): void;
  18178. /** @hidden */
  18179. _animate(deltaTime: number): void;
  18180. /** Release associated resources */
  18181. dispose(): void;
  18182. }
  18183. }
  18184. declare module BABYLON {
  18185. /**
  18186. * Information about the result of picking within a scene
  18187. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18188. */
  18189. export class PickingInfo {
  18190. /** @hidden */
  18191. _pickingUnavailable: boolean;
  18192. /**
  18193. * If the pick collided with an object
  18194. */
  18195. hit: boolean;
  18196. /**
  18197. * Distance away where the pick collided
  18198. */
  18199. distance: number;
  18200. /**
  18201. * The location of pick collision
  18202. */
  18203. pickedPoint: Nullable<Vector3>;
  18204. /**
  18205. * The mesh corresponding the the pick collision
  18206. */
  18207. pickedMesh: Nullable<AbstractMesh>;
  18208. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18209. bu: number;
  18210. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18211. bv: number;
  18212. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18213. faceId: number;
  18214. /** Id of the the submesh that was picked */
  18215. subMeshId: number;
  18216. /** If a sprite was picked, this will be the sprite the pick collided with */
  18217. pickedSprite: Nullable<Sprite>;
  18218. /**
  18219. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18220. */
  18221. originMesh: Nullable<AbstractMesh>;
  18222. /**
  18223. * The ray that was used to perform the picking.
  18224. */
  18225. ray: Nullable<Ray>;
  18226. /**
  18227. * Gets the normal correspodning to the face the pick collided with
  18228. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18229. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18230. * @returns The normal correspodning to the face the pick collided with
  18231. */
  18232. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18233. /**
  18234. * Gets the texture coordinates of where the pick occured
  18235. * @returns the vector containing the coordnates of the texture
  18236. */
  18237. getTextureCoordinates(): Nullable<Vector2>;
  18238. }
  18239. }
  18240. declare module BABYLON {
  18241. /**
  18242. * Gather the list of pointer event types as constants.
  18243. */
  18244. export class PointerEventTypes {
  18245. /**
  18246. * 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.
  18247. */
  18248. static readonly POINTERDOWN: number;
  18249. /**
  18250. * The pointerup event is fired when a pointer is no longer active.
  18251. */
  18252. static readonly POINTERUP: number;
  18253. /**
  18254. * The pointermove event is fired when a pointer changes coordinates.
  18255. */
  18256. static readonly POINTERMOVE: number;
  18257. /**
  18258. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18259. */
  18260. static readonly POINTERWHEEL: number;
  18261. /**
  18262. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18263. */
  18264. static readonly POINTERPICK: number;
  18265. /**
  18266. * The pointertap event is fired when a the object has been touched and released without drag.
  18267. */
  18268. static readonly POINTERTAP: number;
  18269. /**
  18270. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18271. */
  18272. static readonly POINTERDOUBLETAP: number;
  18273. }
  18274. /**
  18275. * Base class of pointer info types.
  18276. */
  18277. export class PointerInfoBase {
  18278. /**
  18279. * Defines the type of event (PointerEventTypes)
  18280. */
  18281. type: number;
  18282. /**
  18283. * Defines the related dom event
  18284. */
  18285. event: PointerEvent | MouseWheelEvent;
  18286. /**
  18287. * Instantiates the base class of pointers info.
  18288. * @param type Defines the type of event (PointerEventTypes)
  18289. * @param event Defines the related dom event
  18290. */
  18291. constructor(
  18292. /**
  18293. * Defines the type of event (PointerEventTypes)
  18294. */
  18295. type: number,
  18296. /**
  18297. * Defines the related dom event
  18298. */
  18299. event: PointerEvent | MouseWheelEvent);
  18300. }
  18301. /**
  18302. * This class is used to store pointer related info for the onPrePointerObservable event.
  18303. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18304. */
  18305. export class PointerInfoPre extends PointerInfoBase {
  18306. /**
  18307. * Ray from a pointer if availible (eg. 6dof controller)
  18308. */
  18309. ray: Nullable<Ray>;
  18310. /**
  18311. * Defines the local position of the pointer on the canvas.
  18312. */
  18313. localPosition: Vector2;
  18314. /**
  18315. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18316. */
  18317. skipOnPointerObservable: boolean;
  18318. /**
  18319. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18320. * @param type Defines the type of event (PointerEventTypes)
  18321. * @param event Defines the related dom event
  18322. * @param localX Defines the local x coordinates of the pointer when the event occured
  18323. * @param localY Defines the local y coordinates of the pointer when the event occured
  18324. */
  18325. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18326. }
  18327. /**
  18328. * This type contains all the data related to a pointer event in Babylon.js.
  18329. * 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.
  18330. */
  18331. export class PointerInfo extends PointerInfoBase {
  18332. /**
  18333. * Defines the picking info associated to the info (if any)\
  18334. */
  18335. pickInfo: Nullable<PickingInfo>;
  18336. /**
  18337. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18338. * @param type Defines the type of event (PointerEventTypes)
  18339. * @param event Defines the related dom event
  18340. * @param pickInfo Defines the picking info associated to the info (if any)\
  18341. */
  18342. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18343. /**
  18344. * Defines the picking info associated to the info (if any)\
  18345. */
  18346. pickInfo: Nullable<PickingInfo>);
  18347. }
  18348. /**
  18349. * Data relating to a touch event on the screen.
  18350. */
  18351. export interface PointerTouch {
  18352. /**
  18353. * X coordinate of touch.
  18354. */
  18355. x: number;
  18356. /**
  18357. * Y coordinate of touch.
  18358. */
  18359. y: number;
  18360. /**
  18361. * Id of touch. Unique for each finger.
  18362. */
  18363. pointerId: number;
  18364. /**
  18365. * Event type passed from DOM.
  18366. */
  18367. type: any;
  18368. }
  18369. }
  18370. declare module BABYLON {
  18371. /**
  18372. * Manage the mouse inputs to control the movement of a free camera.
  18373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18374. */
  18375. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18376. /**
  18377. * Define if touch is enabled in the mouse input
  18378. */
  18379. touchEnabled: boolean;
  18380. /**
  18381. * Defines the camera the input is attached to.
  18382. */
  18383. camera: FreeCamera;
  18384. /**
  18385. * Defines the buttons associated with the input to handle camera move.
  18386. */
  18387. buttons: number[];
  18388. /**
  18389. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18390. */
  18391. angularSensibility: number;
  18392. private _pointerInput;
  18393. private _onMouseMove;
  18394. private _observer;
  18395. private previousPosition;
  18396. /**
  18397. * Observable for when a pointer move event occurs containing the move offset
  18398. */
  18399. onPointerMovedObservable: Observable<{
  18400. offsetX: number;
  18401. offsetY: number;
  18402. }>;
  18403. /**
  18404. * @hidden
  18405. * If the camera should be rotated automatically based on pointer movement
  18406. */
  18407. _allowCameraRotation: boolean;
  18408. /**
  18409. * Manage the mouse inputs to control the movement of a free camera.
  18410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18411. * @param touchEnabled Defines if touch is enabled or not
  18412. */
  18413. constructor(
  18414. /**
  18415. * Define if touch is enabled in the mouse input
  18416. */
  18417. touchEnabled?: boolean);
  18418. /**
  18419. * Attach the input controls to a specific dom element to get the input from.
  18420. * @param element Defines the element the controls should be listened from
  18421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18422. */
  18423. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18424. /**
  18425. * Called on JS contextmenu event.
  18426. * Override this method to provide functionality.
  18427. */
  18428. protected onContextMenu(evt: PointerEvent): void;
  18429. /**
  18430. * Detach the current controls from the specified dom element.
  18431. * @param element Defines the element to stop listening the inputs from
  18432. */
  18433. detachControl(element: Nullable<HTMLElement>): void;
  18434. /**
  18435. * Gets the class name of the current intput.
  18436. * @returns the class name
  18437. */
  18438. getClassName(): string;
  18439. /**
  18440. * Get the friendly name associated with the input class.
  18441. * @returns the input friendly name
  18442. */
  18443. getSimpleName(): string;
  18444. }
  18445. }
  18446. declare module BABYLON {
  18447. /**
  18448. * Manage the touch inputs to control the movement of a free camera.
  18449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18450. */
  18451. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18452. /**
  18453. * Defines the camera the input is attached to.
  18454. */
  18455. camera: FreeCamera;
  18456. /**
  18457. * Defines the touch sensibility for rotation.
  18458. * The higher the faster.
  18459. */
  18460. touchAngularSensibility: number;
  18461. /**
  18462. * Defines the touch sensibility for move.
  18463. * The higher the faster.
  18464. */
  18465. touchMoveSensibility: number;
  18466. private _offsetX;
  18467. private _offsetY;
  18468. private _pointerPressed;
  18469. private _pointerInput;
  18470. private _observer;
  18471. private _onLostFocus;
  18472. /**
  18473. * Attach the input controls to a specific dom element to get the input from.
  18474. * @param element Defines the element the controls should be listened from
  18475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18476. */
  18477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18478. /**
  18479. * Detach the current controls from the specified dom element.
  18480. * @param element Defines the element to stop listening the inputs from
  18481. */
  18482. detachControl(element: Nullable<HTMLElement>): void;
  18483. /**
  18484. * Update the current camera state depending on the inputs that have been used this frame.
  18485. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18486. */
  18487. checkInputs(): void;
  18488. /**
  18489. * Gets the class name of the current intput.
  18490. * @returns the class name
  18491. */
  18492. getClassName(): string;
  18493. /**
  18494. * Get the friendly name associated with the input class.
  18495. * @returns the input friendly name
  18496. */
  18497. getSimpleName(): string;
  18498. }
  18499. }
  18500. declare module BABYLON {
  18501. /**
  18502. * Default Inputs manager for the FreeCamera.
  18503. * It groups all the default supported inputs for ease of use.
  18504. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18505. */
  18506. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18507. /**
  18508. * @hidden
  18509. */
  18510. _mouseInput: Nullable<FreeCameraMouseInput>;
  18511. /**
  18512. * Instantiates a new FreeCameraInputsManager.
  18513. * @param camera Defines the camera the inputs belong to
  18514. */
  18515. constructor(camera: FreeCamera);
  18516. /**
  18517. * Add keyboard input support to the input manager.
  18518. * @returns the current input manager
  18519. */
  18520. addKeyboard(): FreeCameraInputsManager;
  18521. /**
  18522. * Add mouse input support to the input manager.
  18523. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18524. * @returns the current input manager
  18525. */
  18526. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18527. /**
  18528. * Removes the mouse input support from the manager
  18529. * @returns the current input manager
  18530. */
  18531. removeMouse(): FreeCameraInputsManager;
  18532. /**
  18533. * Add touch input support to the input manager.
  18534. * @returns the current input manager
  18535. */
  18536. addTouch(): FreeCameraInputsManager;
  18537. /**
  18538. * Remove all attached input methods from a camera
  18539. */
  18540. clear(): void;
  18541. }
  18542. }
  18543. declare module BABYLON {
  18544. /**
  18545. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18546. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18547. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18548. */
  18549. export class FreeCamera extends TargetCamera {
  18550. /**
  18551. * Define the collision ellipsoid of the camera.
  18552. * This is helpful to simulate a camera body like the player body around the camera
  18553. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18554. */
  18555. ellipsoid: Vector3;
  18556. /**
  18557. * Define an offset for the position of the ellipsoid around the camera.
  18558. * This can be helpful to determine the center of the body near the gravity center of the body
  18559. * instead of its head.
  18560. */
  18561. ellipsoidOffset: Vector3;
  18562. /**
  18563. * Enable or disable collisions of the camera with the rest of the scene objects.
  18564. */
  18565. checkCollisions: boolean;
  18566. /**
  18567. * Enable or disable gravity on the camera.
  18568. */
  18569. applyGravity: boolean;
  18570. /**
  18571. * Define the input manager associated to the camera.
  18572. */
  18573. inputs: FreeCameraInputsManager;
  18574. /**
  18575. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18576. * Higher values reduce sensitivity.
  18577. */
  18578. get angularSensibility(): number;
  18579. /**
  18580. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18581. * Higher values reduce sensitivity.
  18582. */
  18583. set angularSensibility(value: number);
  18584. /**
  18585. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18586. */
  18587. get keysUp(): number[];
  18588. set keysUp(value: number[]);
  18589. /**
  18590. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18591. */
  18592. get keysUpward(): number[];
  18593. set keysUpward(value: number[]);
  18594. /**
  18595. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18596. */
  18597. get keysDown(): number[];
  18598. set keysDown(value: number[]);
  18599. /**
  18600. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18601. */
  18602. get keysDownward(): number[];
  18603. set keysDownward(value: number[]);
  18604. /**
  18605. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18606. */
  18607. get keysLeft(): number[];
  18608. set keysLeft(value: number[]);
  18609. /**
  18610. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18611. */
  18612. get keysRight(): number[];
  18613. set keysRight(value: number[]);
  18614. /**
  18615. * Event raised when the camera collide with a mesh in the scene.
  18616. */
  18617. onCollide: (collidedMesh: AbstractMesh) => void;
  18618. private _collider;
  18619. private _needMoveForGravity;
  18620. private _oldPosition;
  18621. private _diffPosition;
  18622. private _newPosition;
  18623. /** @hidden */
  18624. _localDirection: Vector3;
  18625. /** @hidden */
  18626. _transformedDirection: Vector3;
  18627. /**
  18628. * Instantiates a Free Camera.
  18629. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18630. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18631. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18632. * @param name Define the name of the camera in the scene
  18633. * @param position Define the start position of the camera in the scene
  18634. * @param scene Define the scene the camera belongs to
  18635. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18636. */
  18637. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18638. /**
  18639. * Attached controls to the current camera.
  18640. * @param element Defines the element the controls should be listened from
  18641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18642. */
  18643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18644. /**
  18645. * Detach the current controls from the camera.
  18646. * The camera will stop reacting to inputs.
  18647. * @param element Defines the element to stop listening the inputs from
  18648. */
  18649. detachControl(element: HTMLElement): void;
  18650. private _collisionMask;
  18651. /**
  18652. * Define a collision mask to limit the list of object the camera can collide with
  18653. */
  18654. get collisionMask(): number;
  18655. set collisionMask(mask: number);
  18656. /** @hidden */
  18657. _collideWithWorld(displacement: Vector3): void;
  18658. private _onCollisionPositionChange;
  18659. /** @hidden */
  18660. _checkInputs(): void;
  18661. /** @hidden */
  18662. _decideIfNeedsToMove(): boolean;
  18663. /** @hidden */
  18664. _updatePosition(): void;
  18665. /**
  18666. * Destroy the camera and release the current resources hold by it.
  18667. */
  18668. dispose(): void;
  18669. /**
  18670. * Gets the current object class name.
  18671. * @return the class name
  18672. */
  18673. getClassName(): string;
  18674. }
  18675. }
  18676. declare module BABYLON {
  18677. /**
  18678. * Represents a gamepad control stick position
  18679. */
  18680. export class StickValues {
  18681. /**
  18682. * The x component of the control stick
  18683. */
  18684. x: number;
  18685. /**
  18686. * The y component of the control stick
  18687. */
  18688. y: number;
  18689. /**
  18690. * Initializes the gamepad x and y control stick values
  18691. * @param x The x component of the gamepad control stick value
  18692. * @param y The y component of the gamepad control stick value
  18693. */
  18694. constructor(
  18695. /**
  18696. * The x component of the control stick
  18697. */
  18698. x: number,
  18699. /**
  18700. * The y component of the control stick
  18701. */
  18702. y: number);
  18703. }
  18704. /**
  18705. * An interface which manages callbacks for gamepad button changes
  18706. */
  18707. export interface GamepadButtonChanges {
  18708. /**
  18709. * Called when a gamepad has been changed
  18710. */
  18711. changed: boolean;
  18712. /**
  18713. * Called when a gamepad press event has been triggered
  18714. */
  18715. pressChanged: boolean;
  18716. /**
  18717. * Called when a touch event has been triggered
  18718. */
  18719. touchChanged: boolean;
  18720. /**
  18721. * Called when a value has changed
  18722. */
  18723. valueChanged: boolean;
  18724. }
  18725. /**
  18726. * Represents a gamepad
  18727. */
  18728. export class Gamepad {
  18729. /**
  18730. * The id of the gamepad
  18731. */
  18732. id: string;
  18733. /**
  18734. * The index of the gamepad
  18735. */
  18736. index: number;
  18737. /**
  18738. * The browser gamepad
  18739. */
  18740. browserGamepad: any;
  18741. /**
  18742. * Specifies what type of gamepad this represents
  18743. */
  18744. type: number;
  18745. private _leftStick;
  18746. private _rightStick;
  18747. /** @hidden */
  18748. _isConnected: boolean;
  18749. private _leftStickAxisX;
  18750. private _leftStickAxisY;
  18751. private _rightStickAxisX;
  18752. private _rightStickAxisY;
  18753. /**
  18754. * Triggered when the left control stick has been changed
  18755. */
  18756. private _onleftstickchanged;
  18757. /**
  18758. * Triggered when the right control stick has been changed
  18759. */
  18760. private _onrightstickchanged;
  18761. /**
  18762. * Represents a gamepad controller
  18763. */
  18764. static GAMEPAD: number;
  18765. /**
  18766. * Represents a generic controller
  18767. */
  18768. static GENERIC: number;
  18769. /**
  18770. * Represents an XBox controller
  18771. */
  18772. static XBOX: number;
  18773. /**
  18774. * Represents a pose-enabled controller
  18775. */
  18776. static POSE_ENABLED: number;
  18777. /**
  18778. * Represents an Dual Shock controller
  18779. */
  18780. static DUALSHOCK: number;
  18781. /**
  18782. * Specifies whether the left control stick should be Y-inverted
  18783. */
  18784. protected _invertLeftStickY: boolean;
  18785. /**
  18786. * Specifies if the gamepad has been connected
  18787. */
  18788. get isConnected(): boolean;
  18789. /**
  18790. * Initializes the gamepad
  18791. * @param id The id of the gamepad
  18792. * @param index The index of the gamepad
  18793. * @param browserGamepad The browser gamepad
  18794. * @param leftStickX The x component of the left joystick
  18795. * @param leftStickY The y component of the left joystick
  18796. * @param rightStickX The x component of the right joystick
  18797. * @param rightStickY The y component of the right joystick
  18798. */
  18799. constructor(
  18800. /**
  18801. * The id of the gamepad
  18802. */
  18803. id: string,
  18804. /**
  18805. * The index of the gamepad
  18806. */
  18807. index: number,
  18808. /**
  18809. * The browser gamepad
  18810. */
  18811. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18812. /**
  18813. * Callback triggered when the left joystick has changed
  18814. * @param callback
  18815. */
  18816. onleftstickchanged(callback: (values: StickValues) => void): void;
  18817. /**
  18818. * Callback triggered when the right joystick has changed
  18819. * @param callback
  18820. */
  18821. onrightstickchanged(callback: (values: StickValues) => void): void;
  18822. /**
  18823. * Gets the left joystick
  18824. */
  18825. get leftStick(): StickValues;
  18826. /**
  18827. * Sets the left joystick values
  18828. */
  18829. set leftStick(newValues: StickValues);
  18830. /**
  18831. * Gets the right joystick
  18832. */
  18833. get rightStick(): StickValues;
  18834. /**
  18835. * Sets the right joystick value
  18836. */
  18837. set rightStick(newValues: StickValues);
  18838. /**
  18839. * Updates the gamepad joystick positions
  18840. */
  18841. update(): void;
  18842. /**
  18843. * Disposes the gamepad
  18844. */
  18845. dispose(): void;
  18846. }
  18847. /**
  18848. * Represents a generic gamepad
  18849. */
  18850. export class GenericPad extends Gamepad {
  18851. private _buttons;
  18852. private _onbuttondown;
  18853. private _onbuttonup;
  18854. /**
  18855. * Observable triggered when a button has been pressed
  18856. */
  18857. onButtonDownObservable: Observable<number>;
  18858. /**
  18859. * Observable triggered when a button has been released
  18860. */
  18861. onButtonUpObservable: Observable<number>;
  18862. /**
  18863. * Callback triggered when a button has been pressed
  18864. * @param callback Called when a button has been pressed
  18865. */
  18866. onbuttondown(callback: (buttonPressed: number) => void): void;
  18867. /**
  18868. * Callback triggered when a button has been released
  18869. * @param callback Called when a button has been released
  18870. */
  18871. onbuttonup(callback: (buttonReleased: number) => void): void;
  18872. /**
  18873. * Initializes the generic gamepad
  18874. * @param id The id of the generic gamepad
  18875. * @param index The index of the generic gamepad
  18876. * @param browserGamepad The browser gamepad
  18877. */
  18878. constructor(id: string, index: number, browserGamepad: any);
  18879. private _setButtonValue;
  18880. /**
  18881. * Updates the generic gamepad
  18882. */
  18883. update(): void;
  18884. /**
  18885. * Disposes the generic gamepad
  18886. */
  18887. dispose(): void;
  18888. }
  18889. }
  18890. declare module BABYLON {
  18891. /**
  18892. * Defines the types of pose enabled controllers that are supported
  18893. */
  18894. export enum PoseEnabledControllerType {
  18895. /**
  18896. * HTC Vive
  18897. */
  18898. VIVE = 0,
  18899. /**
  18900. * Oculus Rift
  18901. */
  18902. OCULUS = 1,
  18903. /**
  18904. * Windows mixed reality
  18905. */
  18906. WINDOWS = 2,
  18907. /**
  18908. * Samsung gear VR
  18909. */
  18910. GEAR_VR = 3,
  18911. /**
  18912. * Google Daydream
  18913. */
  18914. DAYDREAM = 4,
  18915. /**
  18916. * Generic
  18917. */
  18918. GENERIC = 5
  18919. }
  18920. /**
  18921. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18922. */
  18923. export interface MutableGamepadButton {
  18924. /**
  18925. * Value of the button/trigger
  18926. */
  18927. value: number;
  18928. /**
  18929. * If the button/trigger is currently touched
  18930. */
  18931. touched: boolean;
  18932. /**
  18933. * If the button/trigger is currently pressed
  18934. */
  18935. pressed: boolean;
  18936. }
  18937. /**
  18938. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18939. * @hidden
  18940. */
  18941. export interface ExtendedGamepadButton extends GamepadButton {
  18942. /**
  18943. * If the button/trigger is currently pressed
  18944. */
  18945. readonly pressed: boolean;
  18946. /**
  18947. * If the button/trigger is currently touched
  18948. */
  18949. readonly touched: boolean;
  18950. /**
  18951. * Value of the button/trigger
  18952. */
  18953. readonly value: number;
  18954. }
  18955. /** @hidden */
  18956. export interface _GamePadFactory {
  18957. /**
  18958. * Returns whether or not the current gamepad can be created for this type of controller.
  18959. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18960. * @returns true if it can be created, otherwise false
  18961. */
  18962. canCreate(gamepadInfo: any): boolean;
  18963. /**
  18964. * Creates a new instance of the Gamepad.
  18965. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18966. * @returns the new gamepad instance
  18967. */
  18968. create(gamepadInfo: any): Gamepad;
  18969. }
  18970. /**
  18971. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18972. */
  18973. export class PoseEnabledControllerHelper {
  18974. /** @hidden */
  18975. static _ControllerFactories: _GamePadFactory[];
  18976. /** @hidden */
  18977. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18978. /**
  18979. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18980. * @param vrGamepad the gamepad to initialized
  18981. * @returns a vr controller of the type the gamepad identified as
  18982. */
  18983. static InitiateController(vrGamepad: any): Gamepad;
  18984. }
  18985. /**
  18986. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18987. */
  18988. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18989. /**
  18990. * If the controller is used in a webXR session
  18991. */
  18992. isXR: boolean;
  18993. private _deviceRoomPosition;
  18994. private _deviceRoomRotationQuaternion;
  18995. /**
  18996. * The device position in babylon space
  18997. */
  18998. devicePosition: Vector3;
  18999. /**
  19000. * The device rotation in babylon space
  19001. */
  19002. deviceRotationQuaternion: Quaternion;
  19003. /**
  19004. * The scale factor of the device in babylon space
  19005. */
  19006. deviceScaleFactor: number;
  19007. /**
  19008. * (Likely devicePosition should be used instead) The device position in its room space
  19009. */
  19010. position: Vector3;
  19011. /**
  19012. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19013. */
  19014. rotationQuaternion: Quaternion;
  19015. /**
  19016. * The type of controller (Eg. Windows mixed reality)
  19017. */
  19018. controllerType: PoseEnabledControllerType;
  19019. protected _calculatedPosition: Vector3;
  19020. private _calculatedRotation;
  19021. /**
  19022. * The raw pose from the device
  19023. */
  19024. rawPose: DevicePose;
  19025. private _trackPosition;
  19026. private _maxRotationDistFromHeadset;
  19027. private _draggedRoomRotation;
  19028. /**
  19029. * @hidden
  19030. */
  19031. _disableTrackPosition(fixedPosition: Vector3): void;
  19032. /**
  19033. * Internal, the mesh attached to the controller
  19034. * @hidden
  19035. */
  19036. _mesh: Nullable<AbstractMesh>;
  19037. private _poseControlledCamera;
  19038. private _leftHandSystemQuaternion;
  19039. /**
  19040. * Internal, matrix used to convert room space to babylon space
  19041. * @hidden
  19042. */
  19043. _deviceToWorld: Matrix;
  19044. /**
  19045. * Node to be used when casting a ray from the controller
  19046. * @hidden
  19047. */
  19048. _pointingPoseNode: Nullable<TransformNode>;
  19049. /**
  19050. * Name of the child mesh that can be used to cast a ray from the controller
  19051. */
  19052. static readonly POINTING_POSE: string;
  19053. /**
  19054. * Creates a new PoseEnabledController from a gamepad
  19055. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19056. */
  19057. constructor(browserGamepad: any);
  19058. private _workingMatrix;
  19059. /**
  19060. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19061. */
  19062. update(): void;
  19063. /**
  19064. * Updates only the pose device and mesh without doing any button event checking
  19065. */
  19066. protected _updatePoseAndMesh(): void;
  19067. /**
  19068. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19069. * @param poseData raw pose fromthe device
  19070. */
  19071. updateFromDevice(poseData: DevicePose): void;
  19072. /**
  19073. * @hidden
  19074. */
  19075. _meshAttachedObservable: Observable<AbstractMesh>;
  19076. /**
  19077. * Attaches a mesh to the controller
  19078. * @param mesh the mesh to be attached
  19079. */
  19080. attachToMesh(mesh: AbstractMesh): void;
  19081. /**
  19082. * Attaches the controllers mesh to a camera
  19083. * @param camera the camera the mesh should be attached to
  19084. */
  19085. attachToPoseControlledCamera(camera: TargetCamera): void;
  19086. /**
  19087. * Disposes of the controller
  19088. */
  19089. dispose(): void;
  19090. /**
  19091. * The mesh that is attached to the controller
  19092. */
  19093. get mesh(): Nullable<AbstractMesh>;
  19094. /**
  19095. * Gets the ray of the controller in the direction the controller is pointing
  19096. * @param length the length the resulting ray should be
  19097. * @returns a ray in the direction the controller is pointing
  19098. */
  19099. getForwardRay(length?: number): Ray;
  19100. }
  19101. }
  19102. declare module BABYLON {
  19103. /**
  19104. * Defines the WebVRController object that represents controllers tracked in 3D space
  19105. */
  19106. export abstract class WebVRController extends PoseEnabledController {
  19107. /**
  19108. * Internal, the default controller model for the controller
  19109. */
  19110. protected _defaultModel: Nullable<AbstractMesh>;
  19111. /**
  19112. * Fired when the trigger state has changed
  19113. */
  19114. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19115. /**
  19116. * Fired when the main button state has changed
  19117. */
  19118. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19119. /**
  19120. * Fired when the secondary button state has changed
  19121. */
  19122. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19123. /**
  19124. * Fired when the pad state has changed
  19125. */
  19126. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19127. /**
  19128. * Fired when controllers stick values have changed
  19129. */
  19130. onPadValuesChangedObservable: Observable<StickValues>;
  19131. /**
  19132. * Array of button availible on the controller
  19133. */
  19134. protected _buttons: Array<MutableGamepadButton>;
  19135. private _onButtonStateChange;
  19136. /**
  19137. * Fired when a controller button's state has changed
  19138. * @param callback the callback containing the button that was modified
  19139. */
  19140. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19141. /**
  19142. * X and Y axis corresponding to the controllers joystick
  19143. */
  19144. pad: StickValues;
  19145. /**
  19146. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19147. */
  19148. hand: string;
  19149. /**
  19150. * The default controller model for the controller
  19151. */
  19152. get defaultModel(): Nullable<AbstractMesh>;
  19153. /**
  19154. * Creates a new WebVRController from a gamepad
  19155. * @param vrGamepad the gamepad that the WebVRController should be created from
  19156. */
  19157. constructor(vrGamepad: any);
  19158. /**
  19159. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19160. */
  19161. update(): void;
  19162. /**
  19163. * Function to be called when a button is modified
  19164. */
  19165. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19166. /**
  19167. * Loads a mesh and attaches it to the controller
  19168. * @param scene the scene the mesh should be added to
  19169. * @param meshLoaded callback for when the mesh has been loaded
  19170. */
  19171. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19172. private _setButtonValue;
  19173. private _changes;
  19174. private _checkChanges;
  19175. /**
  19176. * Disposes of th webVRCOntroller
  19177. */
  19178. dispose(): void;
  19179. }
  19180. }
  19181. declare module BABYLON {
  19182. /**
  19183. * The HemisphericLight simulates the ambient environment light,
  19184. * so the passed direction is the light reflection direction, not the incoming direction.
  19185. */
  19186. export class HemisphericLight extends Light {
  19187. /**
  19188. * The groundColor is the light in the opposite direction to the one specified during creation.
  19189. * 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.
  19190. */
  19191. groundColor: Color3;
  19192. /**
  19193. * The light reflection direction, not the incoming direction.
  19194. */
  19195. direction: Vector3;
  19196. /**
  19197. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19198. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19199. * The HemisphericLight can't cast shadows.
  19200. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19201. * @param name The friendly name of the light
  19202. * @param direction The direction of the light reflection
  19203. * @param scene The scene the light belongs to
  19204. */
  19205. constructor(name: string, direction: Vector3, scene: Scene);
  19206. protected _buildUniformLayout(): void;
  19207. /**
  19208. * Returns the string "HemisphericLight".
  19209. * @return The class name
  19210. */
  19211. getClassName(): string;
  19212. /**
  19213. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19214. * Returns the updated direction.
  19215. * @param target The target the direction should point to
  19216. * @return The computed direction
  19217. */
  19218. setDirectionToTarget(target: Vector3): Vector3;
  19219. /**
  19220. * Returns the shadow generator associated to the light.
  19221. * @returns Always null for hemispheric lights because it does not support shadows.
  19222. */
  19223. getShadowGenerator(): Nullable<IShadowGenerator>;
  19224. /**
  19225. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19226. * @param effect The effect to update
  19227. * @param lightIndex The index of the light in the effect to update
  19228. * @returns The hemispheric light
  19229. */
  19230. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19231. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19232. /**
  19233. * Computes the world matrix of the node
  19234. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19235. * @param useWasUpdatedFlag defines a reserved property
  19236. * @returns the world matrix
  19237. */
  19238. computeWorldMatrix(): Matrix;
  19239. /**
  19240. * Returns the integer 3.
  19241. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19242. */
  19243. getTypeID(): number;
  19244. /**
  19245. * Prepares the list of defines specific to the light type.
  19246. * @param defines the list of defines
  19247. * @param lightIndex defines the index of the light for the effect
  19248. */
  19249. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19250. }
  19251. }
  19252. declare module BABYLON {
  19253. /** @hidden */
  19254. export var vrMultiviewToSingleviewPixelShader: {
  19255. name: string;
  19256. shader: string;
  19257. };
  19258. }
  19259. declare module BABYLON {
  19260. /**
  19261. * Renders to multiple views with a single draw call
  19262. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19263. */
  19264. export class MultiviewRenderTarget extends RenderTargetTexture {
  19265. /**
  19266. * Creates a multiview render target
  19267. * @param scene scene used with the render target
  19268. * @param size the size of the render target (used for each view)
  19269. */
  19270. constructor(scene: Scene, size?: number | {
  19271. width: number;
  19272. height: number;
  19273. } | {
  19274. ratio: number;
  19275. });
  19276. /**
  19277. * @hidden
  19278. * @param faceIndex the face index, if its a cube texture
  19279. */
  19280. _bindFrameBuffer(faceIndex?: number): void;
  19281. /**
  19282. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19283. * @returns the view count
  19284. */
  19285. getViewCount(): number;
  19286. }
  19287. }
  19288. declare module BABYLON {
  19289. /**
  19290. * Represents a camera frustum
  19291. */
  19292. export class Frustum {
  19293. /**
  19294. * Gets the planes representing the frustum
  19295. * @param transform matrix to be applied to the returned planes
  19296. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19297. */
  19298. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19299. /**
  19300. * Gets the near frustum plane transformed by the transform matrix
  19301. * @param transform transformation matrix to be applied to the resulting frustum plane
  19302. * @param frustumPlane the resuling frustum plane
  19303. */
  19304. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19305. /**
  19306. * Gets the far frustum plane transformed by the transform matrix
  19307. * @param transform transformation matrix to be applied to the resulting frustum plane
  19308. * @param frustumPlane the resuling frustum plane
  19309. */
  19310. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19311. /**
  19312. * Gets the left frustum plane transformed by the transform matrix
  19313. * @param transform transformation matrix to be applied to the resulting frustum plane
  19314. * @param frustumPlane the resuling frustum plane
  19315. */
  19316. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19317. /**
  19318. * Gets the right frustum plane transformed by the transform matrix
  19319. * @param transform transformation matrix to be applied to the resulting frustum plane
  19320. * @param frustumPlane the resuling frustum plane
  19321. */
  19322. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19323. /**
  19324. * Gets the top frustum plane transformed by the transform matrix
  19325. * @param transform transformation matrix to be applied to the resulting frustum plane
  19326. * @param frustumPlane the resuling frustum plane
  19327. */
  19328. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19329. /**
  19330. * Gets the bottom frustum plane transformed by the transform matrix
  19331. * @param transform transformation matrix to be applied to the resulting frustum plane
  19332. * @param frustumPlane the resuling frustum plane
  19333. */
  19334. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19335. /**
  19336. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19337. * @param transform transformation matrix to be applied to the resulting frustum planes
  19338. * @param frustumPlanes the resuling frustum planes
  19339. */
  19340. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19341. }
  19342. }
  19343. declare module BABYLON {
  19344. interface Engine {
  19345. /**
  19346. * Creates a new multiview render target
  19347. * @param width defines the width of the texture
  19348. * @param height defines the height of the texture
  19349. * @returns the created multiview texture
  19350. */
  19351. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19352. /**
  19353. * Binds a multiview framebuffer to be drawn to
  19354. * @param multiviewTexture texture to bind
  19355. */
  19356. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19357. }
  19358. interface Camera {
  19359. /**
  19360. * @hidden
  19361. * 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)
  19362. */
  19363. _useMultiviewToSingleView: boolean;
  19364. /**
  19365. * @hidden
  19366. * 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)
  19367. */
  19368. _multiviewTexture: Nullable<RenderTargetTexture>;
  19369. /**
  19370. * @hidden
  19371. * ensures the multiview texture of the camera exists and has the specified width/height
  19372. * @param width height to set on the multiview texture
  19373. * @param height width to set on the multiview texture
  19374. */
  19375. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19376. }
  19377. interface Scene {
  19378. /** @hidden */
  19379. _transformMatrixR: Matrix;
  19380. /** @hidden */
  19381. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19382. /** @hidden */
  19383. _createMultiviewUbo(): void;
  19384. /** @hidden */
  19385. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19386. /** @hidden */
  19387. _renderMultiviewToSingleView(camera: Camera): void;
  19388. }
  19389. }
  19390. declare module BABYLON {
  19391. /**
  19392. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19393. * This will not be used for webXR as it supports displaying texture arrays directly
  19394. */
  19395. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19396. /**
  19397. * Initializes a VRMultiviewToSingleview
  19398. * @param name name of the post process
  19399. * @param camera camera to be applied to
  19400. * @param scaleFactor scaling factor to the size of the output texture
  19401. */
  19402. constructor(name: string, camera: Camera, scaleFactor: number);
  19403. }
  19404. }
  19405. declare module BABYLON {
  19406. /**
  19407. * Interface used to define additional presentation attributes
  19408. */
  19409. export interface IVRPresentationAttributes {
  19410. /**
  19411. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19412. */
  19413. highRefreshRate: boolean;
  19414. /**
  19415. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19416. */
  19417. foveationLevel: number;
  19418. }
  19419. interface Engine {
  19420. /** @hidden */
  19421. _vrDisplay: any;
  19422. /** @hidden */
  19423. _vrSupported: boolean;
  19424. /** @hidden */
  19425. _oldSize: Size;
  19426. /** @hidden */
  19427. _oldHardwareScaleFactor: number;
  19428. /** @hidden */
  19429. _vrExclusivePointerMode: boolean;
  19430. /** @hidden */
  19431. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19432. /** @hidden */
  19433. _onVRDisplayPointerRestricted: () => void;
  19434. /** @hidden */
  19435. _onVRDisplayPointerUnrestricted: () => void;
  19436. /** @hidden */
  19437. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19438. /** @hidden */
  19439. _onVrDisplayDisconnect: Nullable<() => void>;
  19440. /** @hidden */
  19441. _onVrDisplayPresentChange: Nullable<() => void>;
  19442. /**
  19443. * Observable signaled when VR display mode changes
  19444. */
  19445. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19446. /**
  19447. * Observable signaled when VR request present is complete
  19448. */
  19449. onVRRequestPresentComplete: Observable<boolean>;
  19450. /**
  19451. * Observable signaled when VR request present starts
  19452. */
  19453. onVRRequestPresentStart: Observable<Engine>;
  19454. /**
  19455. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19456. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19457. */
  19458. isInVRExclusivePointerMode: boolean;
  19459. /**
  19460. * Gets a boolean indicating if a webVR device was detected
  19461. * @returns true if a webVR device was detected
  19462. */
  19463. isVRDevicePresent(): boolean;
  19464. /**
  19465. * Gets the current webVR device
  19466. * @returns the current webVR device (or null)
  19467. */
  19468. getVRDevice(): any;
  19469. /**
  19470. * Initializes a webVR display and starts listening to display change events
  19471. * The onVRDisplayChangedObservable will be notified upon these changes
  19472. * @returns A promise containing a VRDisplay and if vr is supported
  19473. */
  19474. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19475. /** @hidden */
  19476. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19477. /**
  19478. * Gets or sets the presentation attributes used to configure VR rendering
  19479. */
  19480. vrPresentationAttributes?: IVRPresentationAttributes;
  19481. /**
  19482. * Call this function to switch to webVR mode
  19483. * Will do nothing if webVR is not supported or if there is no webVR device
  19484. * @param options the webvr options provided to the camera. mainly used for multiview
  19485. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19486. */
  19487. enableVR(options: WebVROptions): void;
  19488. /** @hidden */
  19489. _onVRFullScreenTriggered(): void;
  19490. }
  19491. }
  19492. declare module BABYLON {
  19493. /**
  19494. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19495. * IMPORTANT!! The data is right-hand data.
  19496. * @export
  19497. * @interface DevicePose
  19498. */
  19499. export interface DevicePose {
  19500. /**
  19501. * The position of the device, values in array are [x,y,z].
  19502. */
  19503. readonly position: Nullable<Float32Array>;
  19504. /**
  19505. * The linearVelocity of the device, values in array are [x,y,z].
  19506. */
  19507. readonly linearVelocity: Nullable<Float32Array>;
  19508. /**
  19509. * The linearAcceleration of the device, values in array are [x,y,z].
  19510. */
  19511. readonly linearAcceleration: Nullable<Float32Array>;
  19512. /**
  19513. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19514. */
  19515. readonly orientation: Nullable<Float32Array>;
  19516. /**
  19517. * The angularVelocity of the device, values in array are [x,y,z].
  19518. */
  19519. readonly angularVelocity: Nullable<Float32Array>;
  19520. /**
  19521. * The angularAcceleration of the device, values in array are [x,y,z].
  19522. */
  19523. readonly angularAcceleration: Nullable<Float32Array>;
  19524. }
  19525. /**
  19526. * Interface representing a pose controlled object in Babylon.
  19527. * A pose controlled object has both regular pose values as well as pose values
  19528. * from an external device such as a VR head mounted display
  19529. */
  19530. export interface PoseControlled {
  19531. /**
  19532. * The position of the object in babylon space.
  19533. */
  19534. position: Vector3;
  19535. /**
  19536. * The rotation quaternion of the object in babylon space.
  19537. */
  19538. rotationQuaternion: Quaternion;
  19539. /**
  19540. * The position of the device in babylon space.
  19541. */
  19542. devicePosition?: Vector3;
  19543. /**
  19544. * The rotation quaternion of the device in babylon space.
  19545. */
  19546. deviceRotationQuaternion: Quaternion;
  19547. /**
  19548. * The raw pose coming from the device.
  19549. */
  19550. rawPose: Nullable<DevicePose>;
  19551. /**
  19552. * The scale of the device to be used when translating from device space to babylon space.
  19553. */
  19554. deviceScaleFactor: number;
  19555. /**
  19556. * Updates the poseControlled values based on the input device pose.
  19557. * @param poseData the pose data to update the object with
  19558. */
  19559. updateFromDevice(poseData: DevicePose): void;
  19560. }
  19561. /**
  19562. * Set of options to customize the webVRCamera
  19563. */
  19564. export interface WebVROptions {
  19565. /**
  19566. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19567. */
  19568. trackPosition?: boolean;
  19569. /**
  19570. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19571. */
  19572. positionScale?: number;
  19573. /**
  19574. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19575. */
  19576. displayName?: string;
  19577. /**
  19578. * Should the native controller meshes be initialized. (default: true)
  19579. */
  19580. controllerMeshes?: boolean;
  19581. /**
  19582. * Creating a default HemiLight only on controllers. (default: true)
  19583. */
  19584. defaultLightingOnControllers?: boolean;
  19585. /**
  19586. * If you don't want to use the default VR button of the helper. (default: false)
  19587. */
  19588. useCustomVRButton?: boolean;
  19589. /**
  19590. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19591. */
  19592. customVRButton?: HTMLButtonElement;
  19593. /**
  19594. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19595. */
  19596. rayLength?: number;
  19597. /**
  19598. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19599. */
  19600. defaultHeight?: number;
  19601. /**
  19602. * If multiview should be used if availible (default: false)
  19603. */
  19604. useMultiview?: boolean;
  19605. }
  19606. /**
  19607. * This represents a WebVR camera.
  19608. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19609. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19610. */
  19611. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19612. private webVROptions;
  19613. /**
  19614. * @hidden
  19615. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19616. */
  19617. _vrDevice: any;
  19618. /**
  19619. * The rawPose of the vrDevice.
  19620. */
  19621. rawPose: Nullable<DevicePose>;
  19622. private _onVREnabled;
  19623. private _specsVersion;
  19624. private _attached;
  19625. private _frameData;
  19626. protected _descendants: Array<Node>;
  19627. private _deviceRoomPosition;
  19628. /** @hidden */
  19629. _deviceRoomRotationQuaternion: Quaternion;
  19630. private _standingMatrix;
  19631. /**
  19632. * Represents device position in babylon space.
  19633. */
  19634. devicePosition: Vector3;
  19635. /**
  19636. * Represents device rotation in babylon space.
  19637. */
  19638. deviceRotationQuaternion: Quaternion;
  19639. /**
  19640. * The scale of the device to be used when translating from device space to babylon space.
  19641. */
  19642. deviceScaleFactor: number;
  19643. private _deviceToWorld;
  19644. private _worldToDevice;
  19645. /**
  19646. * References to the webVR controllers for the vrDevice.
  19647. */
  19648. controllers: Array<WebVRController>;
  19649. /**
  19650. * Emits an event when a controller is attached.
  19651. */
  19652. onControllersAttachedObservable: Observable<WebVRController[]>;
  19653. /**
  19654. * Emits an event when a controller's mesh has been loaded;
  19655. */
  19656. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19657. /**
  19658. * Emits an event when the HMD's pose has been updated.
  19659. */
  19660. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19661. private _poseSet;
  19662. /**
  19663. * If the rig cameras be used as parent instead of this camera.
  19664. */
  19665. rigParenting: boolean;
  19666. private _lightOnControllers;
  19667. private _defaultHeight?;
  19668. /**
  19669. * Instantiates a WebVRFreeCamera.
  19670. * @param name The name of the WebVRFreeCamera
  19671. * @param position The starting anchor position for the camera
  19672. * @param scene The scene the camera belongs to
  19673. * @param webVROptions a set of customizable options for the webVRCamera
  19674. */
  19675. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19676. /**
  19677. * Gets the device distance from the ground in meters.
  19678. * @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.
  19679. */
  19680. deviceDistanceToRoomGround(): number;
  19681. /**
  19682. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19683. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19684. */
  19685. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19686. /**
  19687. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19688. * @returns A promise with a boolean set to if the standing matrix is supported.
  19689. */
  19690. useStandingMatrixAsync(): Promise<boolean>;
  19691. /**
  19692. * Disposes the camera
  19693. */
  19694. dispose(): void;
  19695. /**
  19696. * Gets a vrController by name.
  19697. * @param name The name of the controller to retreive
  19698. * @returns the controller matching the name specified or null if not found
  19699. */
  19700. getControllerByName(name: string): Nullable<WebVRController>;
  19701. private _leftController;
  19702. /**
  19703. * The controller corresponding to the users left hand.
  19704. */
  19705. get leftController(): Nullable<WebVRController>;
  19706. private _rightController;
  19707. /**
  19708. * The controller corresponding to the users right hand.
  19709. */
  19710. get rightController(): Nullable<WebVRController>;
  19711. /**
  19712. * Casts a ray forward from the vrCamera's gaze.
  19713. * @param length Length of the ray (default: 100)
  19714. * @returns the ray corresponding to the gaze
  19715. */
  19716. getForwardRay(length?: number): Ray;
  19717. /**
  19718. * @hidden
  19719. * Updates the camera based on device's frame data
  19720. */
  19721. _checkInputs(): void;
  19722. /**
  19723. * Updates the poseControlled values based on the input device pose.
  19724. * @param poseData Pose coming from the device
  19725. */
  19726. updateFromDevice(poseData: DevicePose): void;
  19727. private _htmlElementAttached;
  19728. private _detachIfAttached;
  19729. /**
  19730. * WebVR's attach control will start broadcasting frames to the device.
  19731. * Note that in certain browsers (chrome for example) this function must be called
  19732. * within a user-interaction callback. Example:
  19733. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19734. *
  19735. * @param element html element to attach the vrDevice to
  19736. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19737. */
  19738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19739. /**
  19740. * Detaches the camera from the html element and disables VR
  19741. *
  19742. * @param element html element to detach from
  19743. */
  19744. detachControl(element: HTMLElement): void;
  19745. /**
  19746. * @returns the name of this class
  19747. */
  19748. getClassName(): string;
  19749. /**
  19750. * Calls resetPose on the vrDisplay
  19751. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19752. */
  19753. resetToCurrentRotation(): void;
  19754. /**
  19755. * @hidden
  19756. * Updates the rig cameras (left and right eye)
  19757. */
  19758. _updateRigCameras(): void;
  19759. private _workingVector;
  19760. private _oneVector;
  19761. private _workingMatrix;
  19762. private updateCacheCalled;
  19763. private _correctPositionIfNotTrackPosition;
  19764. /**
  19765. * @hidden
  19766. * Updates the cached values of the camera
  19767. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19768. */
  19769. _updateCache(ignoreParentClass?: boolean): void;
  19770. /**
  19771. * @hidden
  19772. * Get current device position in babylon world
  19773. */
  19774. _computeDevicePosition(): void;
  19775. /**
  19776. * Updates the current device position and rotation in the babylon world
  19777. */
  19778. update(): void;
  19779. /**
  19780. * @hidden
  19781. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19782. * @returns an identity matrix
  19783. */
  19784. _getViewMatrix(): Matrix;
  19785. private _tmpMatrix;
  19786. /**
  19787. * This function is called by the two RIG cameras.
  19788. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19789. * @hidden
  19790. */
  19791. _getWebVRViewMatrix(): Matrix;
  19792. /** @hidden */
  19793. _getWebVRProjectionMatrix(): Matrix;
  19794. private _onGamepadConnectedObserver;
  19795. private _onGamepadDisconnectedObserver;
  19796. private _updateCacheWhenTrackingDisabledObserver;
  19797. /**
  19798. * Initializes the controllers and their meshes
  19799. */
  19800. initControllers(): void;
  19801. }
  19802. }
  19803. declare module BABYLON {
  19804. /**
  19805. * Size options for a post process
  19806. */
  19807. export type PostProcessOptions = {
  19808. width: number;
  19809. height: number;
  19810. };
  19811. /**
  19812. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19813. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19814. */
  19815. export class PostProcess {
  19816. /** Name of the PostProcess. */
  19817. name: string;
  19818. /**
  19819. * Gets or sets the unique id of the post process
  19820. */
  19821. uniqueId: number;
  19822. /**
  19823. * Width of the texture to apply the post process on
  19824. */
  19825. width: number;
  19826. /**
  19827. * Height of the texture to apply the post process on
  19828. */
  19829. height: number;
  19830. /**
  19831. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19832. * @hidden
  19833. */
  19834. _outputTexture: Nullable<InternalTexture>;
  19835. /**
  19836. * Sampling mode used by the shader
  19837. * See https://doc.babylonjs.com/classes/3.1/texture
  19838. */
  19839. renderTargetSamplingMode: number;
  19840. /**
  19841. * Clear color to use when screen clearing
  19842. */
  19843. clearColor: Color4;
  19844. /**
  19845. * If the buffer needs to be cleared before applying the post process. (default: true)
  19846. * Should be set to false if shader will overwrite all previous pixels.
  19847. */
  19848. autoClear: boolean;
  19849. /**
  19850. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19851. */
  19852. alphaMode: number;
  19853. /**
  19854. * Sets the setAlphaBlendConstants of the babylon engine
  19855. */
  19856. alphaConstants: Color4;
  19857. /**
  19858. * Animations to be used for the post processing
  19859. */
  19860. animations: Animation[];
  19861. /**
  19862. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19863. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19864. */
  19865. enablePixelPerfectMode: boolean;
  19866. /**
  19867. * Force the postprocess to be applied without taking in account viewport
  19868. */
  19869. forceFullscreenViewport: boolean;
  19870. /**
  19871. * List of inspectable custom properties (used by the Inspector)
  19872. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19873. */
  19874. inspectableCustomProperties: IInspectable[];
  19875. /**
  19876. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19877. *
  19878. * | Value | Type | Description |
  19879. * | ----- | ----------------------------------- | ----------- |
  19880. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19881. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19882. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19883. *
  19884. */
  19885. scaleMode: number;
  19886. /**
  19887. * Force textures to be a power of two (default: false)
  19888. */
  19889. alwaysForcePOT: boolean;
  19890. private _samples;
  19891. /**
  19892. * Number of sample textures (default: 1)
  19893. */
  19894. get samples(): number;
  19895. set samples(n: number);
  19896. /**
  19897. * Modify the scale of the post process to be the same as the viewport (default: false)
  19898. */
  19899. adaptScaleToCurrentViewport: boolean;
  19900. private _camera;
  19901. private _scene;
  19902. private _engine;
  19903. private _options;
  19904. private _reusable;
  19905. private _textureType;
  19906. private _textureFormat;
  19907. /**
  19908. * Smart array of input and output textures for the post process.
  19909. * @hidden
  19910. */
  19911. _textures: SmartArray<InternalTexture>;
  19912. /**
  19913. * The index in _textures that corresponds to the output texture.
  19914. * @hidden
  19915. */
  19916. _currentRenderTextureInd: number;
  19917. private _effect;
  19918. private _samplers;
  19919. private _fragmentUrl;
  19920. private _vertexUrl;
  19921. private _parameters;
  19922. private _scaleRatio;
  19923. protected _indexParameters: any;
  19924. private _shareOutputWithPostProcess;
  19925. private _texelSize;
  19926. private _forcedOutputTexture;
  19927. /**
  19928. * Returns the fragment url or shader name used in the post process.
  19929. * @returns the fragment url or name in the shader store.
  19930. */
  19931. getEffectName(): string;
  19932. /**
  19933. * An event triggered when the postprocess is activated.
  19934. */
  19935. onActivateObservable: Observable<Camera>;
  19936. private _onActivateObserver;
  19937. /**
  19938. * A function that is added to the onActivateObservable
  19939. */
  19940. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19941. /**
  19942. * An event triggered when the postprocess changes its size.
  19943. */
  19944. onSizeChangedObservable: Observable<PostProcess>;
  19945. private _onSizeChangedObserver;
  19946. /**
  19947. * A function that is added to the onSizeChangedObservable
  19948. */
  19949. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19950. /**
  19951. * An event triggered when the postprocess applies its effect.
  19952. */
  19953. onApplyObservable: Observable<Effect>;
  19954. private _onApplyObserver;
  19955. /**
  19956. * A function that is added to the onApplyObservable
  19957. */
  19958. set onApply(callback: (effect: Effect) => void);
  19959. /**
  19960. * An event triggered before rendering the postprocess
  19961. */
  19962. onBeforeRenderObservable: Observable<Effect>;
  19963. private _onBeforeRenderObserver;
  19964. /**
  19965. * A function that is added to the onBeforeRenderObservable
  19966. */
  19967. set onBeforeRender(callback: (effect: Effect) => void);
  19968. /**
  19969. * An event triggered after rendering the postprocess
  19970. */
  19971. onAfterRenderObservable: Observable<Effect>;
  19972. private _onAfterRenderObserver;
  19973. /**
  19974. * A function that is added to the onAfterRenderObservable
  19975. */
  19976. set onAfterRender(callback: (efect: Effect) => void);
  19977. /**
  19978. * 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
  19979. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19980. */
  19981. get inputTexture(): InternalTexture;
  19982. set inputTexture(value: InternalTexture);
  19983. /**
  19984. * Gets the camera which post process is applied to.
  19985. * @returns The camera the post process is applied to.
  19986. */
  19987. getCamera(): Camera;
  19988. /**
  19989. * Gets the texel size of the postprocess.
  19990. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19991. */
  19992. get texelSize(): Vector2;
  19993. /**
  19994. * Creates a new instance PostProcess
  19995. * @param name The name of the PostProcess.
  19996. * @param fragmentUrl The url of the fragment shader to be used.
  19997. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19998. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19999. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20000. * @param camera The camera to apply the render pass to.
  20001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20002. * @param engine The engine which the post process will be applied. (default: current engine)
  20003. * @param reusable If the post process can be reused on the same frame. (default: false)
  20004. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20005. * @param textureType Type of textures used when performing the post process. (default: 0)
  20006. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20007. * @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
  20008. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20009. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20010. */
  20011. constructor(
  20012. /** Name of the PostProcess. */
  20013. 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);
  20014. /**
  20015. * Gets a string idenfifying the name of the class
  20016. * @returns "PostProcess" string
  20017. */
  20018. getClassName(): string;
  20019. /**
  20020. * Gets the engine which this post process belongs to.
  20021. * @returns The engine the post process was enabled with.
  20022. */
  20023. getEngine(): Engine;
  20024. /**
  20025. * The effect that is created when initializing the post process.
  20026. * @returns The created effect corresponding the the postprocess.
  20027. */
  20028. getEffect(): Effect;
  20029. /**
  20030. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20031. * @param postProcess The post process to share the output with.
  20032. * @returns This post process.
  20033. */
  20034. shareOutputWith(postProcess: PostProcess): PostProcess;
  20035. /**
  20036. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20037. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20038. */
  20039. useOwnOutput(): void;
  20040. /**
  20041. * Updates the effect with the current post process compile time values and recompiles the shader.
  20042. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20043. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20044. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20045. * @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
  20046. * @param onCompiled Called when the shader has been compiled.
  20047. * @param onError Called if there is an error when compiling a shader.
  20048. */
  20049. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20050. /**
  20051. * The post process is reusable if it can be used multiple times within one frame.
  20052. * @returns If the post process is reusable
  20053. */
  20054. isReusable(): boolean;
  20055. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20056. markTextureDirty(): void;
  20057. /**
  20058. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20059. * 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.
  20060. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20061. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20062. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20063. * @returns The target texture that was bound to be written to.
  20064. */
  20065. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20066. /**
  20067. * If the post process is supported.
  20068. */
  20069. get isSupported(): boolean;
  20070. /**
  20071. * The aspect ratio of the output texture.
  20072. */
  20073. get aspectRatio(): number;
  20074. /**
  20075. * Get a value indicating if the post-process is ready to be used
  20076. * @returns true if the post-process is ready (shader is compiled)
  20077. */
  20078. isReady(): boolean;
  20079. /**
  20080. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20081. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20082. */
  20083. apply(): Nullable<Effect>;
  20084. private _disposeTextures;
  20085. /**
  20086. * Disposes the post process.
  20087. * @param camera The camera to dispose the post process on.
  20088. */
  20089. dispose(camera?: Camera): void;
  20090. }
  20091. }
  20092. declare module BABYLON {
  20093. /** @hidden */
  20094. export var kernelBlurVaryingDeclaration: {
  20095. name: string;
  20096. shader: string;
  20097. };
  20098. }
  20099. declare module BABYLON {
  20100. /** @hidden */
  20101. export var kernelBlurFragment: {
  20102. name: string;
  20103. shader: string;
  20104. };
  20105. }
  20106. declare module BABYLON {
  20107. /** @hidden */
  20108. export var kernelBlurFragment2: {
  20109. name: string;
  20110. shader: string;
  20111. };
  20112. }
  20113. declare module BABYLON {
  20114. /** @hidden */
  20115. export var kernelBlurPixelShader: {
  20116. name: string;
  20117. shader: string;
  20118. };
  20119. }
  20120. declare module BABYLON {
  20121. /** @hidden */
  20122. export var kernelBlurVertex: {
  20123. name: string;
  20124. shader: string;
  20125. };
  20126. }
  20127. declare module BABYLON {
  20128. /** @hidden */
  20129. export var kernelBlurVertexShader: {
  20130. name: string;
  20131. shader: string;
  20132. };
  20133. }
  20134. declare module BABYLON {
  20135. /**
  20136. * The Blur Post Process which blurs an image based on a kernel and direction.
  20137. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20138. */
  20139. export class BlurPostProcess extends PostProcess {
  20140. /** The direction in which to blur the image. */
  20141. direction: Vector2;
  20142. private blockCompilation;
  20143. protected _kernel: number;
  20144. protected _idealKernel: number;
  20145. protected _packedFloat: boolean;
  20146. private _staticDefines;
  20147. /**
  20148. * Sets the length in pixels of the blur sample region
  20149. */
  20150. set kernel(v: number);
  20151. /**
  20152. * Gets the length in pixels of the blur sample region
  20153. */
  20154. get kernel(): number;
  20155. /**
  20156. * Sets wether or not the blur needs to unpack/repack floats
  20157. */
  20158. set packedFloat(v: boolean);
  20159. /**
  20160. * Gets wether or not the blur is unpacking/repacking floats
  20161. */
  20162. get packedFloat(): boolean;
  20163. /**
  20164. * Creates a new instance BlurPostProcess
  20165. * @param name The name of the effect.
  20166. * @param direction The direction in which to blur the image.
  20167. * @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.
  20168. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20169. * @param camera The camera to apply the render pass to.
  20170. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20171. * @param engine The engine which the post process will be applied. (default: current engine)
  20172. * @param reusable If the post process can be reused on the same frame. (default: false)
  20173. * @param textureType Type of textures used when performing the post process. (default: 0)
  20174. * @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)
  20175. */
  20176. constructor(name: string,
  20177. /** The direction in which to blur the image. */
  20178. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20179. /**
  20180. * Updates the effect with the current post process compile time values and recompiles the shader.
  20181. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20182. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20183. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20184. * @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
  20185. * @param onCompiled Called when the shader has been compiled.
  20186. * @param onError Called if there is an error when compiling a shader.
  20187. */
  20188. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20189. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20190. /**
  20191. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20192. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20193. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20194. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20195. * The gaps between physical kernels are compensated for in the weighting of the samples
  20196. * @param idealKernel Ideal blur kernel.
  20197. * @return Nearest best kernel.
  20198. */
  20199. protected _nearestBestKernel(idealKernel: number): number;
  20200. /**
  20201. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20202. * @param x The point on the Gaussian distribution to sample.
  20203. * @return the value of the Gaussian function at x.
  20204. */
  20205. protected _gaussianWeight(x: number): number;
  20206. /**
  20207. * Generates a string that can be used as a floating point number in GLSL.
  20208. * @param x Value to print.
  20209. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20210. * @return GLSL float string.
  20211. */
  20212. protected _glslFloat(x: number, decimalFigures?: number): string;
  20213. }
  20214. }
  20215. declare module BABYLON {
  20216. /**
  20217. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20218. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20219. * You can then easily use it as a reflectionTexture on a flat surface.
  20220. * In case the surface is not a plane, please consider relying on reflection probes.
  20221. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20222. */
  20223. export class MirrorTexture extends RenderTargetTexture {
  20224. private scene;
  20225. /**
  20226. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20227. * 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.
  20228. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20229. */
  20230. mirrorPlane: Plane;
  20231. /**
  20232. * Define the blur ratio used to blur the reflection if needed.
  20233. */
  20234. set blurRatio(value: number);
  20235. get blurRatio(): number;
  20236. /**
  20237. * Define the adaptive blur kernel used to blur the reflection if needed.
  20238. * This will autocompute the closest best match for the `blurKernel`
  20239. */
  20240. set adaptiveBlurKernel(value: number);
  20241. /**
  20242. * Define the blur kernel used to blur the reflection if needed.
  20243. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20244. */
  20245. set blurKernel(value: number);
  20246. /**
  20247. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20248. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20249. */
  20250. set blurKernelX(value: number);
  20251. get blurKernelX(): number;
  20252. /**
  20253. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20254. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20255. */
  20256. set blurKernelY(value: number);
  20257. get blurKernelY(): number;
  20258. private _autoComputeBlurKernel;
  20259. protected _onRatioRescale(): void;
  20260. private _updateGammaSpace;
  20261. private _imageProcessingConfigChangeObserver;
  20262. private _transformMatrix;
  20263. private _mirrorMatrix;
  20264. private _savedViewMatrix;
  20265. private _blurX;
  20266. private _blurY;
  20267. private _adaptiveBlurKernel;
  20268. private _blurKernelX;
  20269. private _blurKernelY;
  20270. private _blurRatio;
  20271. /**
  20272. * Instantiates a Mirror Texture.
  20273. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20274. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20275. * You can then easily use it as a reflectionTexture on a flat surface.
  20276. * In case the surface is not a plane, please consider relying on reflection probes.
  20277. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20278. * @param name
  20279. * @param size
  20280. * @param scene
  20281. * @param generateMipMaps
  20282. * @param type
  20283. * @param samplingMode
  20284. * @param generateDepthBuffer
  20285. */
  20286. constructor(name: string, size: number | {
  20287. width: number;
  20288. height: number;
  20289. } | {
  20290. ratio: number;
  20291. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20292. private _preparePostProcesses;
  20293. /**
  20294. * Clone the mirror texture.
  20295. * @returns the cloned texture
  20296. */
  20297. clone(): MirrorTexture;
  20298. /**
  20299. * Serialize the texture to a JSON representation you could use in Parse later on
  20300. * @returns the serialized JSON representation
  20301. */
  20302. serialize(): any;
  20303. /**
  20304. * Dispose the texture and release its associated resources.
  20305. */
  20306. dispose(): void;
  20307. }
  20308. }
  20309. declare module BABYLON {
  20310. /**
  20311. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20312. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20313. */
  20314. export class Texture extends BaseTexture {
  20315. /**
  20316. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20317. */
  20318. static SerializeBuffers: boolean;
  20319. /** @hidden */
  20320. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20321. /** @hidden */
  20322. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20323. /** @hidden */
  20324. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20325. /** nearest is mag = nearest and min = nearest and mip = linear */
  20326. static readonly NEAREST_SAMPLINGMODE: number;
  20327. /** nearest is mag = nearest and min = nearest and mip = linear */
  20328. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20329. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20330. static readonly BILINEAR_SAMPLINGMODE: number;
  20331. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20332. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20333. /** Trilinear is mag = linear and min = linear and mip = linear */
  20334. static readonly TRILINEAR_SAMPLINGMODE: number;
  20335. /** Trilinear is mag = linear and min = linear and mip = linear */
  20336. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20337. /** mag = nearest and min = nearest and mip = nearest */
  20338. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20339. /** mag = nearest and min = linear and mip = nearest */
  20340. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20341. /** mag = nearest and min = linear and mip = linear */
  20342. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20343. /** mag = nearest and min = linear and mip = none */
  20344. static readonly NEAREST_LINEAR: number;
  20345. /** mag = nearest and min = nearest and mip = none */
  20346. static readonly NEAREST_NEAREST: number;
  20347. /** mag = linear and min = nearest and mip = nearest */
  20348. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20349. /** mag = linear and min = nearest and mip = linear */
  20350. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20351. /** mag = linear and min = linear and mip = none */
  20352. static readonly LINEAR_LINEAR: number;
  20353. /** mag = linear and min = nearest and mip = none */
  20354. static readonly LINEAR_NEAREST: number;
  20355. /** Explicit coordinates mode */
  20356. static readonly EXPLICIT_MODE: number;
  20357. /** Spherical coordinates mode */
  20358. static readonly SPHERICAL_MODE: number;
  20359. /** Planar coordinates mode */
  20360. static readonly PLANAR_MODE: number;
  20361. /** Cubic coordinates mode */
  20362. static readonly CUBIC_MODE: number;
  20363. /** Projection coordinates mode */
  20364. static readonly PROJECTION_MODE: number;
  20365. /** Inverse Cubic coordinates mode */
  20366. static readonly SKYBOX_MODE: number;
  20367. /** Inverse Cubic coordinates mode */
  20368. static readonly INVCUBIC_MODE: number;
  20369. /** Equirectangular coordinates mode */
  20370. static readonly EQUIRECTANGULAR_MODE: number;
  20371. /** Equirectangular Fixed coordinates mode */
  20372. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20373. /** Equirectangular Fixed Mirrored coordinates mode */
  20374. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20375. /** Texture is not repeating outside of 0..1 UVs */
  20376. static readonly CLAMP_ADDRESSMODE: number;
  20377. /** Texture is repeating outside of 0..1 UVs */
  20378. static readonly WRAP_ADDRESSMODE: number;
  20379. /** Texture is repeating and mirrored */
  20380. static readonly MIRROR_ADDRESSMODE: number;
  20381. /**
  20382. * 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
  20383. */
  20384. static UseSerializedUrlIfAny: boolean;
  20385. /**
  20386. * Define the url of the texture.
  20387. */
  20388. url: Nullable<string>;
  20389. /**
  20390. * Define an offset on the texture to offset the u coordinates of the UVs
  20391. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20392. */
  20393. uOffset: number;
  20394. /**
  20395. * Define an offset on the texture to offset the v coordinates of the UVs
  20396. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20397. */
  20398. vOffset: number;
  20399. /**
  20400. * Define an offset on the texture to scale the u coordinates of the UVs
  20401. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20402. */
  20403. uScale: number;
  20404. /**
  20405. * Define an offset on the texture to scale the v coordinates of the UVs
  20406. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20407. */
  20408. vScale: number;
  20409. /**
  20410. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20411. * @see http://doc.babylonjs.com/how_to/more_materials
  20412. */
  20413. uAng: number;
  20414. /**
  20415. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20416. * @see http://doc.babylonjs.com/how_to/more_materials
  20417. */
  20418. vAng: number;
  20419. /**
  20420. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20421. * @see http://doc.babylonjs.com/how_to/more_materials
  20422. */
  20423. wAng: number;
  20424. /**
  20425. * Defines the center of rotation (U)
  20426. */
  20427. uRotationCenter: number;
  20428. /**
  20429. * Defines the center of rotation (V)
  20430. */
  20431. vRotationCenter: number;
  20432. /**
  20433. * Defines the center of rotation (W)
  20434. */
  20435. wRotationCenter: number;
  20436. /**
  20437. * Are mip maps generated for this texture or not.
  20438. */
  20439. get noMipmap(): boolean;
  20440. /**
  20441. * List of inspectable custom properties (used by the Inspector)
  20442. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20443. */
  20444. inspectableCustomProperties: Nullable<IInspectable[]>;
  20445. private _noMipmap;
  20446. /** @hidden */
  20447. _invertY: boolean;
  20448. private _rowGenerationMatrix;
  20449. private _cachedTextureMatrix;
  20450. private _projectionModeMatrix;
  20451. private _t0;
  20452. private _t1;
  20453. private _t2;
  20454. private _cachedUOffset;
  20455. private _cachedVOffset;
  20456. private _cachedUScale;
  20457. private _cachedVScale;
  20458. private _cachedUAng;
  20459. private _cachedVAng;
  20460. private _cachedWAng;
  20461. private _cachedProjectionMatrixId;
  20462. private _cachedCoordinatesMode;
  20463. /** @hidden */
  20464. protected _initialSamplingMode: number;
  20465. /** @hidden */
  20466. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20467. private _deleteBuffer;
  20468. protected _format: Nullable<number>;
  20469. private _delayedOnLoad;
  20470. private _delayedOnError;
  20471. private _mimeType?;
  20472. /**
  20473. * Observable triggered once the texture has been loaded.
  20474. */
  20475. onLoadObservable: Observable<Texture>;
  20476. protected _isBlocking: boolean;
  20477. /**
  20478. * Is the texture preventing material to render while loading.
  20479. * If false, a default texture will be used instead of the loading one during the preparation step.
  20480. */
  20481. set isBlocking(value: boolean);
  20482. get isBlocking(): boolean;
  20483. /**
  20484. * Get the current sampling mode associated with the texture.
  20485. */
  20486. get samplingMode(): number;
  20487. /**
  20488. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20489. */
  20490. get invertY(): boolean;
  20491. /**
  20492. * Instantiates a new texture.
  20493. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20494. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20495. * @param url defines the url of the picture to load as a texture
  20496. * @param scene defines the scene or engine the texture will belong to
  20497. * @param noMipmap defines if the texture will require mip maps or not
  20498. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20499. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20500. * @param onLoad defines a callback triggered when the texture has been loaded
  20501. * @param onError defines a callback triggered when an error occurred during the loading session
  20502. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20503. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20504. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20505. * @param mimeType defines an optional mime type information
  20506. */
  20507. 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);
  20508. /**
  20509. * Update the url (and optional buffer) of this texture if url was null during construction.
  20510. * @param url the url of the texture
  20511. * @param buffer the buffer of the texture (defaults to null)
  20512. * @param onLoad callback called when the texture is loaded (defaults to null)
  20513. */
  20514. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20515. /**
  20516. * Finish the loading sequence of a texture flagged as delayed load.
  20517. * @hidden
  20518. */
  20519. delayLoad(): void;
  20520. private _prepareRowForTextureGeneration;
  20521. /**
  20522. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20523. * @returns the transform matrix of the texture.
  20524. */
  20525. getTextureMatrix(uBase?: number): Matrix;
  20526. /**
  20527. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20528. * @returns The reflection texture transform
  20529. */
  20530. getReflectionTextureMatrix(): Matrix;
  20531. /**
  20532. * Clones the texture.
  20533. * @returns the cloned texture
  20534. */
  20535. clone(): Texture;
  20536. /**
  20537. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20538. * @returns The JSON representation of the texture
  20539. */
  20540. serialize(): any;
  20541. /**
  20542. * Get the current class name of the texture useful for serialization or dynamic coding.
  20543. * @returns "Texture"
  20544. */
  20545. getClassName(): string;
  20546. /**
  20547. * Dispose the texture and release its associated resources.
  20548. */
  20549. dispose(): void;
  20550. /**
  20551. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20552. * @param parsedTexture Define the JSON representation of the texture
  20553. * @param scene Define the scene the parsed texture should be instantiated in
  20554. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20555. * @returns The parsed texture if successful
  20556. */
  20557. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20558. /**
  20559. * Creates a texture from its base 64 representation.
  20560. * @param data Define the base64 payload without the data: prefix
  20561. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20562. * @param scene Define the scene the texture should belong to
  20563. * @param noMipmap Forces the texture to not create mip map information if true
  20564. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20565. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20566. * @param onLoad define a callback triggered when the texture has been loaded
  20567. * @param onError define a callback triggered when an error occurred during the loading session
  20568. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20569. * @returns the created texture
  20570. */
  20571. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20572. /**
  20573. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20574. * @param data Define the base64 payload without the data: prefix
  20575. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20576. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20577. * @param scene Define the scene the texture should belong to
  20578. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20579. * @param noMipmap Forces the texture to not create mip map information if true
  20580. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20581. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20582. * @param onLoad define a callback triggered when the texture has been loaded
  20583. * @param onError define a callback triggered when an error occurred during the loading session
  20584. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20585. * @returns the created texture
  20586. */
  20587. 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;
  20588. }
  20589. }
  20590. declare module BABYLON {
  20591. /**
  20592. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20593. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20594. */
  20595. export class PostProcessManager {
  20596. private _scene;
  20597. private _indexBuffer;
  20598. private _vertexBuffers;
  20599. /**
  20600. * Creates a new instance PostProcess
  20601. * @param scene The scene that the post process is associated with.
  20602. */
  20603. constructor(scene: Scene);
  20604. private _prepareBuffers;
  20605. private _buildIndexBuffer;
  20606. /**
  20607. * Rebuilds the vertex buffers of the manager.
  20608. * @hidden
  20609. */
  20610. _rebuild(): void;
  20611. /**
  20612. * Prepares a frame to be run through a post process.
  20613. * @param sourceTexture The input texture to the post procesess. (default: null)
  20614. * @param postProcesses An array of post processes to be run. (default: null)
  20615. * @returns True if the post processes were able to be run.
  20616. * @hidden
  20617. */
  20618. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20619. /**
  20620. * Manually render a set of post processes to a texture.
  20621. * @param postProcesses An array of post processes to be run.
  20622. * @param targetTexture The target texture to render to.
  20623. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20624. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20625. * @param lodLevel defines which lod of the texture to render to
  20626. */
  20627. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20628. /**
  20629. * Finalize the result of the output of the postprocesses.
  20630. * @param doNotPresent If true the result will not be displayed to the screen.
  20631. * @param targetTexture The target texture to render to.
  20632. * @param faceIndex The index of the face to bind the target texture to.
  20633. * @param postProcesses The array of post processes to render.
  20634. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20635. * @hidden
  20636. */
  20637. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20638. /**
  20639. * Disposes of the post process manager.
  20640. */
  20641. dispose(): void;
  20642. }
  20643. }
  20644. declare module BABYLON {
  20645. /**
  20646. * This Helps creating a texture that will be created from a camera in your scene.
  20647. * It is basically a dynamic texture that could be used to create special effects for instance.
  20648. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20649. */
  20650. export class RenderTargetTexture extends Texture {
  20651. isCube: boolean;
  20652. /**
  20653. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20654. */
  20655. static readonly REFRESHRATE_RENDER_ONCE: number;
  20656. /**
  20657. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20658. */
  20659. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20660. /**
  20661. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20662. * the central point of your effect and can save a lot of performances.
  20663. */
  20664. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20665. /**
  20666. * Use this predicate to dynamically define the list of mesh you want to render.
  20667. * If set, the renderList property will be overwritten.
  20668. */
  20669. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20670. private _renderList;
  20671. /**
  20672. * Use this list to define the list of mesh you want to render.
  20673. */
  20674. get renderList(): Nullable<Array<AbstractMesh>>;
  20675. set renderList(value: Nullable<Array<AbstractMesh>>);
  20676. /**
  20677. * Use this function to overload the renderList array at rendering time.
  20678. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20679. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20680. * the cube (if the RTT is a cube, else layerOrFace=0).
  20681. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20682. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20683. * hold dummy elements!
  20684. */
  20685. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20686. private _hookArray;
  20687. /**
  20688. * Define if particles should be rendered in your texture.
  20689. */
  20690. renderParticles: boolean;
  20691. /**
  20692. * Define if sprites should be rendered in your texture.
  20693. */
  20694. renderSprites: boolean;
  20695. /**
  20696. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20697. */
  20698. coordinatesMode: number;
  20699. /**
  20700. * Define the camera used to render the texture.
  20701. */
  20702. activeCamera: Nullable<Camera>;
  20703. /**
  20704. * Override the mesh isReady function with your own one.
  20705. */
  20706. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20707. /**
  20708. * Override the render function of the texture with your own one.
  20709. */
  20710. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20711. /**
  20712. * Define if camera post processes should be use while rendering the texture.
  20713. */
  20714. useCameraPostProcesses: boolean;
  20715. /**
  20716. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20717. */
  20718. ignoreCameraViewport: boolean;
  20719. private _postProcessManager;
  20720. private _postProcesses;
  20721. private _resizeObserver;
  20722. /**
  20723. * An event triggered when the texture is unbind.
  20724. */
  20725. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20726. /**
  20727. * An event triggered when the texture is unbind.
  20728. */
  20729. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20730. private _onAfterUnbindObserver;
  20731. /**
  20732. * Set a after unbind callback in the texture.
  20733. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20734. */
  20735. set onAfterUnbind(callback: () => void);
  20736. /**
  20737. * An event triggered before rendering the texture
  20738. */
  20739. onBeforeRenderObservable: Observable<number>;
  20740. private _onBeforeRenderObserver;
  20741. /**
  20742. * Set a before render callback in the texture.
  20743. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20744. */
  20745. set onBeforeRender(callback: (faceIndex: number) => void);
  20746. /**
  20747. * An event triggered after rendering the texture
  20748. */
  20749. onAfterRenderObservable: Observable<number>;
  20750. private _onAfterRenderObserver;
  20751. /**
  20752. * Set a after render callback in the texture.
  20753. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20754. */
  20755. set onAfterRender(callback: (faceIndex: number) => void);
  20756. /**
  20757. * An event triggered after the texture clear
  20758. */
  20759. onClearObservable: Observable<Engine>;
  20760. private _onClearObserver;
  20761. /**
  20762. * Set a clear callback in the texture.
  20763. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20764. */
  20765. set onClear(callback: (Engine: Engine) => void);
  20766. /**
  20767. * An event triggered when the texture is resized.
  20768. */
  20769. onResizeObservable: Observable<RenderTargetTexture>;
  20770. /**
  20771. * Define the clear color of the Render Target if it should be different from the scene.
  20772. */
  20773. clearColor: Color4;
  20774. protected _size: number | {
  20775. width: number;
  20776. height: number;
  20777. layers?: number;
  20778. };
  20779. protected _initialSizeParameter: number | {
  20780. width: number;
  20781. height: number;
  20782. } | {
  20783. ratio: number;
  20784. };
  20785. protected _sizeRatio: Nullable<number>;
  20786. /** @hidden */
  20787. _generateMipMaps: boolean;
  20788. protected _renderingManager: RenderingManager;
  20789. /** @hidden */
  20790. _waitingRenderList: string[];
  20791. protected _doNotChangeAspectRatio: boolean;
  20792. protected _currentRefreshId: number;
  20793. protected _refreshRate: number;
  20794. protected _textureMatrix: Matrix;
  20795. protected _samples: number;
  20796. protected _renderTargetOptions: RenderTargetCreationOptions;
  20797. /**
  20798. * Gets render target creation options that were used.
  20799. */
  20800. get renderTargetOptions(): RenderTargetCreationOptions;
  20801. protected _engine: Engine;
  20802. protected _onRatioRescale(): void;
  20803. /**
  20804. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20805. * It must define where the camera used to render the texture is set
  20806. */
  20807. boundingBoxPosition: Vector3;
  20808. private _boundingBoxSize;
  20809. /**
  20810. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20811. * When defined, the cubemap will switch to local mode
  20812. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20813. * @example https://www.babylonjs-playground.com/#RNASML
  20814. */
  20815. set boundingBoxSize(value: Vector3);
  20816. get boundingBoxSize(): Vector3;
  20817. /**
  20818. * In case the RTT has been created with a depth texture, get the associated
  20819. * depth texture.
  20820. * Otherwise, return null.
  20821. */
  20822. get depthStencilTexture(): Nullable<InternalTexture>;
  20823. /**
  20824. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20825. * or used a shadow, depth texture...
  20826. * @param name The friendly name of the texture
  20827. * @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)
  20828. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20829. * @param generateMipMaps True if mip maps need to be generated after render.
  20830. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20831. * @param type The type of the buffer in the RTT (int, half float, float...)
  20832. * @param isCube True if a cube texture needs to be created
  20833. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20834. * @param generateDepthBuffer True to generate a depth buffer
  20835. * @param generateStencilBuffer True to generate a stencil buffer
  20836. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20837. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20838. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20839. */
  20840. constructor(name: string, size: number | {
  20841. width: number;
  20842. height: number;
  20843. layers?: number;
  20844. } | {
  20845. ratio: number;
  20846. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20847. /**
  20848. * Creates a depth stencil texture.
  20849. * This is only available in WebGL 2 or with the depth texture extension available.
  20850. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20851. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20852. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20853. */
  20854. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20855. private _processSizeParameter;
  20856. /**
  20857. * Define the number of samples to use in case of MSAA.
  20858. * It defaults to one meaning no MSAA has been enabled.
  20859. */
  20860. get samples(): number;
  20861. set samples(value: number);
  20862. /**
  20863. * Resets the refresh counter of the texture and start bak from scratch.
  20864. * Could be useful to regenerate the texture if it is setup to render only once.
  20865. */
  20866. resetRefreshCounter(): void;
  20867. /**
  20868. * Define the refresh rate of the texture or the rendering frequency.
  20869. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20870. */
  20871. get refreshRate(): number;
  20872. set refreshRate(value: number);
  20873. /**
  20874. * Adds a post process to the render target rendering passes.
  20875. * @param postProcess define the post process to add
  20876. */
  20877. addPostProcess(postProcess: PostProcess): void;
  20878. /**
  20879. * Clear all the post processes attached to the render target
  20880. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20881. */
  20882. clearPostProcesses(dispose?: boolean): void;
  20883. /**
  20884. * Remove one of the post process from the list of attached post processes to the texture
  20885. * @param postProcess define the post process to remove from the list
  20886. */
  20887. removePostProcess(postProcess: PostProcess): void;
  20888. /** @hidden */
  20889. _shouldRender(): boolean;
  20890. /**
  20891. * Gets the actual render size of the texture.
  20892. * @returns the width of the render size
  20893. */
  20894. getRenderSize(): number;
  20895. /**
  20896. * Gets the actual render width of the texture.
  20897. * @returns the width of the render size
  20898. */
  20899. getRenderWidth(): number;
  20900. /**
  20901. * Gets the actual render height of the texture.
  20902. * @returns the height of the render size
  20903. */
  20904. getRenderHeight(): number;
  20905. /**
  20906. * Gets the actual number of layers of the texture.
  20907. * @returns the number of layers
  20908. */
  20909. getRenderLayers(): number;
  20910. /**
  20911. * Get if the texture can be rescaled or not.
  20912. */
  20913. get canRescale(): boolean;
  20914. /**
  20915. * Resize the texture using a ratio.
  20916. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20917. */
  20918. scale(ratio: number): void;
  20919. /**
  20920. * Get the texture reflection matrix used to rotate/transform the reflection.
  20921. * @returns the reflection matrix
  20922. */
  20923. getReflectionTextureMatrix(): Matrix;
  20924. /**
  20925. * Resize the texture to a new desired size.
  20926. * Be carrefull as it will recreate all the data in the new texture.
  20927. * @param size Define the new size. It can be:
  20928. * - a number for squared texture,
  20929. * - an object containing { width: number, height: number }
  20930. * - or an object containing a ratio { ratio: number }
  20931. */
  20932. resize(size: number | {
  20933. width: number;
  20934. height: number;
  20935. } | {
  20936. ratio: number;
  20937. }): void;
  20938. private _defaultRenderListPrepared;
  20939. /**
  20940. * Renders all the objects from the render list into the texture.
  20941. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20942. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20943. */
  20944. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20945. private _bestReflectionRenderTargetDimension;
  20946. private _prepareRenderingManager;
  20947. /**
  20948. * @hidden
  20949. * @param faceIndex face index to bind to if this is a cubetexture
  20950. * @param layer defines the index of the texture to bind in the array
  20951. */
  20952. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20953. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20954. private renderToTarget;
  20955. /**
  20956. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20957. * This allowed control for front to back rendering or reversly depending of the special needs.
  20958. *
  20959. * @param renderingGroupId The rendering group id corresponding to its index
  20960. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20961. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20962. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20963. */
  20964. 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;
  20965. /**
  20966. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20967. *
  20968. * @param renderingGroupId The rendering group id corresponding to its index
  20969. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20970. */
  20971. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20972. /**
  20973. * Clones the texture.
  20974. * @returns the cloned texture
  20975. */
  20976. clone(): RenderTargetTexture;
  20977. /**
  20978. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20979. * @returns The JSON representation of the texture
  20980. */
  20981. serialize(): any;
  20982. /**
  20983. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20984. */
  20985. disposeFramebufferObjects(): void;
  20986. /**
  20987. * Dispose the texture and release its associated resources.
  20988. */
  20989. dispose(): void;
  20990. /** @hidden */
  20991. _rebuild(): void;
  20992. /**
  20993. * Clear the info related to rendering groups preventing retention point in material dispose.
  20994. */
  20995. freeRenderingGroups(): void;
  20996. /**
  20997. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20998. * @returns the view count
  20999. */
  21000. getViewCount(): number;
  21001. }
  21002. }
  21003. declare module BABYLON {
  21004. /**
  21005. * Class used to manipulate GUIDs
  21006. */
  21007. export class GUID {
  21008. /**
  21009. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21010. * Be aware Math.random() could cause collisions, but:
  21011. * "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"
  21012. * @returns a pseudo random id
  21013. */
  21014. static RandomId(): string;
  21015. }
  21016. }
  21017. declare module BABYLON {
  21018. /**
  21019. * Options to be used when creating a shadow depth material
  21020. */
  21021. export interface IIOptionShadowDepthMaterial {
  21022. /** Variables in the vertex shader code that need to have their names remapped.
  21023. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21024. * "var_name" should be either: worldPos or vNormalW
  21025. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21026. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21027. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21028. */
  21029. remappedVariables?: string[];
  21030. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21031. standalone?: boolean;
  21032. }
  21033. /**
  21034. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21035. */
  21036. export class ShadowDepthWrapper {
  21037. private _scene;
  21038. private _options?;
  21039. private _baseMaterial;
  21040. private _onEffectCreatedObserver;
  21041. private _subMeshToEffect;
  21042. private _subMeshToDepthEffect;
  21043. private _meshes;
  21044. /** @hidden */
  21045. _matriceNames: any;
  21046. /**
  21047. * Instantiate a new shadow depth wrapper.
  21048. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21049. * generate the shadow depth map. For more information, please refer to the documentation:
  21050. * https://doc.babylonjs.com/babylon101/shadows
  21051. * @param baseMaterial Material to wrap
  21052. * @param scene Define the scene the material belongs to
  21053. * @param options Options used to create the wrapper
  21054. */
  21055. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21056. /**
  21057. * Gets the effect to use to generate the depth map
  21058. * @param subMesh subMesh to get the effect for
  21059. * @param shadowGenerator shadow generator to get the effect for
  21060. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21061. */
  21062. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21063. /**
  21064. * Specifies that the submesh is ready to be used for depth rendering
  21065. * @param subMesh submesh to check
  21066. * @param defines the list of defines to take into account when checking the effect
  21067. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21068. * @param useInstances specifies that instances should be used
  21069. * @returns a boolean indicating that the submesh is ready or not
  21070. */
  21071. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21072. /**
  21073. * Disposes the resources
  21074. */
  21075. dispose(): void;
  21076. private _makeEffect;
  21077. }
  21078. }
  21079. declare module BABYLON {
  21080. /**
  21081. * Options for compiling materials.
  21082. */
  21083. export interface IMaterialCompilationOptions {
  21084. /**
  21085. * Defines whether clip planes are enabled.
  21086. */
  21087. clipPlane: boolean;
  21088. /**
  21089. * Defines whether instances are enabled.
  21090. */
  21091. useInstances: boolean;
  21092. }
  21093. /**
  21094. * Base class for the main features of a material in Babylon.js
  21095. */
  21096. export class Material implements IAnimatable {
  21097. /**
  21098. * Returns the triangle fill mode
  21099. */
  21100. static readonly TriangleFillMode: number;
  21101. /**
  21102. * Returns the wireframe mode
  21103. */
  21104. static readonly WireFrameFillMode: number;
  21105. /**
  21106. * Returns the point fill mode
  21107. */
  21108. static readonly PointFillMode: number;
  21109. /**
  21110. * Returns the point list draw mode
  21111. */
  21112. static readonly PointListDrawMode: number;
  21113. /**
  21114. * Returns the line list draw mode
  21115. */
  21116. static readonly LineListDrawMode: number;
  21117. /**
  21118. * Returns the line loop draw mode
  21119. */
  21120. static readonly LineLoopDrawMode: number;
  21121. /**
  21122. * Returns the line strip draw mode
  21123. */
  21124. static readonly LineStripDrawMode: number;
  21125. /**
  21126. * Returns the triangle strip draw mode
  21127. */
  21128. static readonly TriangleStripDrawMode: number;
  21129. /**
  21130. * Returns the triangle fan draw mode
  21131. */
  21132. static readonly TriangleFanDrawMode: number;
  21133. /**
  21134. * Stores the clock-wise side orientation
  21135. */
  21136. static readonly ClockWiseSideOrientation: number;
  21137. /**
  21138. * Stores the counter clock-wise side orientation
  21139. */
  21140. static readonly CounterClockWiseSideOrientation: number;
  21141. /**
  21142. * The dirty texture flag value
  21143. */
  21144. static readonly TextureDirtyFlag: number;
  21145. /**
  21146. * The dirty light flag value
  21147. */
  21148. static readonly LightDirtyFlag: number;
  21149. /**
  21150. * The dirty fresnel flag value
  21151. */
  21152. static readonly FresnelDirtyFlag: number;
  21153. /**
  21154. * The dirty attribute flag value
  21155. */
  21156. static readonly AttributesDirtyFlag: number;
  21157. /**
  21158. * The dirty misc flag value
  21159. */
  21160. static readonly MiscDirtyFlag: number;
  21161. /**
  21162. * The all dirty flag value
  21163. */
  21164. static readonly AllDirtyFlag: number;
  21165. /**
  21166. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21167. */
  21168. static readonly MATERIAL_OPAQUE: number;
  21169. /**
  21170. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21171. */
  21172. static readonly MATERIAL_ALPHATEST: number;
  21173. /**
  21174. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21175. */
  21176. static readonly MATERIAL_ALPHABLEND: number;
  21177. /**
  21178. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21179. * They are also discarded below the alpha cutoff threshold to improve performances.
  21180. */
  21181. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21182. /**
  21183. * Custom callback helping to override the default shader used in the material.
  21184. */
  21185. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21186. /**
  21187. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21188. */
  21189. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21190. /**
  21191. * The ID of the material
  21192. */
  21193. id: string;
  21194. /**
  21195. * Gets or sets the unique id of the material
  21196. */
  21197. uniqueId: number;
  21198. /**
  21199. * The name of the material
  21200. */
  21201. name: string;
  21202. /**
  21203. * Gets or sets user defined metadata
  21204. */
  21205. metadata: any;
  21206. /**
  21207. * For internal use only. Please do not use.
  21208. */
  21209. reservedDataStore: any;
  21210. /**
  21211. * Specifies if the ready state should be checked on each call
  21212. */
  21213. checkReadyOnEveryCall: boolean;
  21214. /**
  21215. * Specifies if the ready state should be checked once
  21216. */
  21217. checkReadyOnlyOnce: boolean;
  21218. /**
  21219. * The state of the material
  21220. */
  21221. state: string;
  21222. /**
  21223. * The alpha value of the material
  21224. */
  21225. protected _alpha: number;
  21226. /**
  21227. * List of inspectable custom properties (used by the Inspector)
  21228. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21229. */
  21230. inspectableCustomProperties: IInspectable[];
  21231. /**
  21232. * Sets the alpha value of the material
  21233. */
  21234. set alpha(value: number);
  21235. /**
  21236. * Gets the alpha value of the material
  21237. */
  21238. get alpha(): number;
  21239. /**
  21240. * Specifies if back face culling is enabled
  21241. */
  21242. protected _backFaceCulling: boolean;
  21243. /**
  21244. * Sets the back-face culling state
  21245. */
  21246. set backFaceCulling(value: boolean);
  21247. /**
  21248. * Gets the back-face culling state
  21249. */
  21250. get backFaceCulling(): boolean;
  21251. /**
  21252. * Stores the value for side orientation
  21253. */
  21254. sideOrientation: number;
  21255. /**
  21256. * Callback triggered when the material is compiled
  21257. */
  21258. onCompiled: Nullable<(effect: Effect) => void>;
  21259. /**
  21260. * Callback triggered when an error occurs
  21261. */
  21262. onError: Nullable<(effect: Effect, errors: string) => void>;
  21263. /**
  21264. * Callback triggered to get the render target textures
  21265. */
  21266. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21267. /**
  21268. * Gets a boolean indicating that current material needs to register RTT
  21269. */
  21270. get hasRenderTargetTextures(): boolean;
  21271. /**
  21272. * Specifies if the material should be serialized
  21273. */
  21274. doNotSerialize: boolean;
  21275. /**
  21276. * @hidden
  21277. */
  21278. _storeEffectOnSubMeshes: boolean;
  21279. /**
  21280. * Stores the animations for the material
  21281. */
  21282. animations: Nullable<Array<Animation>>;
  21283. /**
  21284. * An event triggered when the material is disposed
  21285. */
  21286. onDisposeObservable: Observable<Material>;
  21287. /**
  21288. * An observer which watches for dispose events
  21289. */
  21290. private _onDisposeObserver;
  21291. private _onUnBindObservable;
  21292. /**
  21293. * Called during a dispose event
  21294. */
  21295. set onDispose(callback: () => void);
  21296. private _onBindObservable;
  21297. /**
  21298. * An event triggered when the material is bound
  21299. */
  21300. get onBindObservable(): Observable<AbstractMesh>;
  21301. /**
  21302. * An observer which watches for bind events
  21303. */
  21304. private _onBindObserver;
  21305. /**
  21306. * Called during a bind event
  21307. */
  21308. set onBind(callback: (Mesh: AbstractMesh) => void);
  21309. /**
  21310. * An event triggered when the material is unbound
  21311. */
  21312. get onUnBindObservable(): Observable<Material>;
  21313. protected _onEffectCreatedObservable: Nullable<Observable<{
  21314. effect: Effect;
  21315. subMesh: Nullable<SubMesh>;
  21316. }>>;
  21317. /**
  21318. * An event triggered when the effect is (re)created
  21319. */
  21320. get onEffectCreatedObservable(): Observable<{
  21321. effect: Effect;
  21322. subMesh: Nullable<SubMesh>;
  21323. }>;
  21324. /**
  21325. * Stores the value of the alpha mode
  21326. */
  21327. private _alphaMode;
  21328. /**
  21329. * Sets the value of the alpha mode.
  21330. *
  21331. * | Value | Type | Description |
  21332. * | --- | --- | --- |
  21333. * | 0 | ALPHA_DISABLE | |
  21334. * | 1 | ALPHA_ADD | |
  21335. * | 2 | ALPHA_COMBINE | |
  21336. * | 3 | ALPHA_SUBTRACT | |
  21337. * | 4 | ALPHA_MULTIPLY | |
  21338. * | 5 | ALPHA_MAXIMIZED | |
  21339. * | 6 | ALPHA_ONEONE | |
  21340. * | 7 | ALPHA_PREMULTIPLIED | |
  21341. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21342. * | 9 | ALPHA_INTERPOLATE | |
  21343. * | 10 | ALPHA_SCREENMODE | |
  21344. *
  21345. */
  21346. set alphaMode(value: number);
  21347. /**
  21348. * Gets the value of the alpha mode
  21349. */
  21350. get alphaMode(): number;
  21351. /**
  21352. * Stores the state of the need depth pre-pass value
  21353. */
  21354. private _needDepthPrePass;
  21355. /**
  21356. * Sets the need depth pre-pass value
  21357. */
  21358. set needDepthPrePass(value: boolean);
  21359. /**
  21360. * Gets the depth pre-pass value
  21361. */
  21362. get needDepthPrePass(): boolean;
  21363. /**
  21364. * Specifies if depth writing should be disabled
  21365. */
  21366. disableDepthWrite: boolean;
  21367. /**
  21368. * Specifies if depth writing should be forced
  21369. */
  21370. forceDepthWrite: boolean;
  21371. /**
  21372. * Specifies the depth function that should be used. 0 means the default engine function
  21373. */
  21374. depthFunction: number;
  21375. /**
  21376. * Specifies if there should be a separate pass for culling
  21377. */
  21378. separateCullingPass: boolean;
  21379. /**
  21380. * Stores the state specifing if fog should be enabled
  21381. */
  21382. private _fogEnabled;
  21383. /**
  21384. * Sets the state for enabling fog
  21385. */
  21386. set fogEnabled(value: boolean);
  21387. /**
  21388. * Gets the value of the fog enabled state
  21389. */
  21390. get fogEnabled(): boolean;
  21391. /**
  21392. * Stores the size of points
  21393. */
  21394. pointSize: number;
  21395. /**
  21396. * Stores the z offset value
  21397. */
  21398. zOffset: number;
  21399. /**
  21400. * Gets a value specifying if wireframe mode is enabled
  21401. */
  21402. get wireframe(): boolean;
  21403. /**
  21404. * Sets the state of wireframe mode
  21405. */
  21406. set wireframe(value: boolean);
  21407. /**
  21408. * Gets the value specifying if point clouds are enabled
  21409. */
  21410. get pointsCloud(): boolean;
  21411. /**
  21412. * Sets the state of point cloud mode
  21413. */
  21414. set pointsCloud(value: boolean);
  21415. /**
  21416. * Gets the material fill mode
  21417. */
  21418. get fillMode(): number;
  21419. /**
  21420. * Sets the material fill mode
  21421. */
  21422. set fillMode(value: number);
  21423. /**
  21424. * @hidden
  21425. * Stores the effects for the material
  21426. */
  21427. _effect: Nullable<Effect>;
  21428. /**
  21429. * Specifies if uniform buffers should be used
  21430. */
  21431. private _useUBO;
  21432. /**
  21433. * Stores a reference to the scene
  21434. */
  21435. private _scene;
  21436. /**
  21437. * Stores the fill mode state
  21438. */
  21439. private _fillMode;
  21440. /**
  21441. * Specifies if the depth write state should be cached
  21442. */
  21443. private _cachedDepthWriteState;
  21444. /**
  21445. * Specifies if the depth function state should be cached
  21446. */
  21447. private _cachedDepthFunctionState;
  21448. /**
  21449. * Stores the uniform buffer
  21450. */
  21451. protected _uniformBuffer: UniformBuffer;
  21452. /** @hidden */
  21453. _indexInSceneMaterialArray: number;
  21454. /** @hidden */
  21455. meshMap: Nullable<{
  21456. [id: string]: AbstractMesh | undefined;
  21457. }>;
  21458. /**
  21459. * Creates a material instance
  21460. * @param name defines the name of the material
  21461. * @param scene defines the scene to reference
  21462. * @param doNotAdd specifies if the material should be added to the scene
  21463. */
  21464. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21465. /**
  21466. * Returns a string representation of the current material
  21467. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21468. * @returns a string with material information
  21469. */
  21470. toString(fullDetails?: boolean): string;
  21471. /**
  21472. * Gets the class name of the material
  21473. * @returns a string with the class name of the material
  21474. */
  21475. getClassName(): string;
  21476. /**
  21477. * Specifies if updates for the material been locked
  21478. */
  21479. get isFrozen(): boolean;
  21480. /**
  21481. * Locks updates for the material
  21482. */
  21483. freeze(): void;
  21484. /**
  21485. * Unlocks updates for the material
  21486. */
  21487. unfreeze(): void;
  21488. /**
  21489. * Specifies if the material is ready to be used
  21490. * @param mesh defines the mesh to check
  21491. * @param useInstances specifies if instances should be used
  21492. * @returns a boolean indicating if the material is ready to be used
  21493. */
  21494. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21495. /**
  21496. * Specifies that the submesh is ready to be used
  21497. * @param mesh defines the mesh to check
  21498. * @param subMesh defines which submesh to check
  21499. * @param useInstances specifies that instances should be used
  21500. * @returns a boolean indicating that the submesh is ready or not
  21501. */
  21502. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21503. /**
  21504. * Returns the material effect
  21505. * @returns the effect associated with the material
  21506. */
  21507. getEffect(): Nullable<Effect>;
  21508. /**
  21509. * Returns the current scene
  21510. * @returns a Scene
  21511. */
  21512. getScene(): Scene;
  21513. /**
  21514. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21515. */
  21516. protected _forceAlphaTest: boolean;
  21517. /**
  21518. * The transparency mode of the material.
  21519. */
  21520. protected _transparencyMode: Nullable<number>;
  21521. /**
  21522. * Gets the current transparency mode.
  21523. */
  21524. get transparencyMode(): Nullable<number>;
  21525. /**
  21526. * Sets the transparency mode of the material.
  21527. *
  21528. * | Value | Type | Description |
  21529. * | ----- | ----------------------------------- | ----------- |
  21530. * | 0 | OPAQUE | |
  21531. * | 1 | ALPHATEST | |
  21532. * | 2 | ALPHABLEND | |
  21533. * | 3 | ALPHATESTANDBLEND | |
  21534. *
  21535. */
  21536. set transparencyMode(value: Nullable<number>);
  21537. /**
  21538. * Returns true if alpha blending should be disabled.
  21539. */
  21540. protected get _disableAlphaBlending(): boolean;
  21541. /**
  21542. * Specifies whether or not this material should be rendered in alpha blend mode.
  21543. * @returns a boolean specifying if alpha blending is needed
  21544. */
  21545. needAlphaBlending(): boolean;
  21546. /**
  21547. * Specifies if the mesh will require alpha blending
  21548. * @param mesh defines the mesh to check
  21549. * @returns a boolean specifying if alpha blending is needed for the mesh
  21550. */
  21551. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21552. /**
  21553. * Specifies whether or not this material should be rendered in alpha test mode.
  21554. * @returns a boolean specifying if an alpha test is needed.
  21555. */
  21556. needAlphaTesting(): boolean;
  21557. /**
  21558. * Specifies if material alpha testing should be turned on for the mesh
  21559. * @param mesh defines the mesh to check
  21560. */
  21561. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21562. /**
  21563. * Gets the texture used for the alpha test
  21564. * @returns the texture to use for alpha testing
  21565. */
  21566. getAlphaTestTexture(): Nullable<BaseTexture>;
  21567. /**
  21568. * Marks the material to indicate that it needs to be re-calculated
  21569. */
  21570. markDirty(): void;
  21571. /** @hidden */
  21572. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21573. /**
  21574. * Binds the material to the mesh
  21575. * @param world defines the world transformation matrix
  21576. * @param mesh defines the mesh to bind the material to
  21577. */
  21578. bind(world: Matrix, mesh?: Mesh): void;
  21579. /**
  21580. * Binds the submesh to the material
  21581. * @param world defines the world transformation matrix
  21582. * @param mesh defines the mesh containing the submesh
  21583. * @param subMesh defines the submesh to bind the material to
  21584. */
  21585. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21586. /**
  21587. * Binds the world matrix to the material
  21588. * @param world defines the world transformation matrix
  21589. */
  21590. bindOnlyWorldMatrix(world: Matrix): void;
  21591. /**
  21592. * Binds the scene's uniform buffer to the effect.
  21593. * @param effect defines the effect to bind to the scene uniform buffer
  21594. * @param sceneUbo defines the uniform buffer storing scene data
  21595. */
  21596. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21597. /**
  21598. * Binds the view matrix to the effect
  21599. * @param effect defines the effect to bind the view matrix to
  21600. */
  21601. bindView(effect: Effect): void;
  21602. /**
  21603. * Binds the view projection matrix to the effect
  21604. * @param effect defines the effect to bind the view projection matrix to
  21605. */
  21606. bindViewProjection(effect: Effect): void;
  21607. /**
  21608. * Processes to execute after binding the material to a mesh
  21609. * @param mesh defines the rendered mesh
  21610. */
  21611. protected _afterBind(mesh?: Mesh): void;
  21612. /**
  21613. * Unbinds the material from the mesh
  21614. */
  21615. unbind(): void;
  21616. /**
  21617. * Gets the active textures from the material
  21618. * @returns an array of textures
  21619. */
  21620. getActiveTextures(): BaseTexture[];
  21621. /**
  21622. * Specifies if the material uses a texture
  21623. * @param texture defines the texture to check against the material
  21624. * @returns a boolean specifying if the material uses the texture
  21625. */
  21626. hasTexture(texture: BaseTexture): boolean;
  21627. /**
  21628. * Makes a duplicate of the material, and gives it a new name
  21629. * @param name defines the new name for the duplicated material
  21630. * @returns the cloned material
  21631. */
  21632. clone(name: string): Nullable<Material>;
  21633. /**
  21634. * Gets the meshes bound to the material
  21635. * @returns an array of meshes bound to the material
  21636. */
  21637. getBindedMeshes(): AbstractMesh[];
  21638. /**
  21639. * Force shader compilation
  21640. * @param mesh defines the mesh associated with this material
  21641. * @param onCompiled defines a function to execute once the material is compiled
  21642. * @param options defines the options to configure the compilation
  21643. * @param onError defines a function to execute if the material fails compiling
  21644. */
  21645. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21646. /**
  21647. * Force shader compilation
  21648. * @param mesh defines the mesh that will use this material
  21649. * @param options defines additional options for compiling the shaders
  21650. * @returns a promise that resolves when the compilation completes
  21651. */
  21652. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21653. private static readonly _AllDirtyCallBack;
  21654. private static readonly _ImageProcessingDirtyCallBack;
  21655. private static readonly _TextureDirtyCallBack;
  21656. private static readonly _FresnelDirtyCallBack;
  21657. private static readonly _MiscDirtyCallBack;
  21658. private static readonly _LightsDirtyCallBack;
  21659. private static readonly _AttributeDirtyCallBack;
  21660. private static _FresnelAndMiscDirtyCallBack;
  21661. private static _TextureAndMiscDirtyCallBack;
  21662. private static readonly _DirtyCallbackArray;
  21663. private static readonly _RunDirtyCallBacks;
  21664. /**
  21665. * Marks a define in the material to indicate that it needs to be re-computed
  21666. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21667. */
  21668. markAsDirty(flag: number): void;
  21669. /**
  21670. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21671. * @param func defines a function which checks material defines against the submeshes
  21672. */
  21673. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21674. /**
  21675. * Indicates that we need to re-calculated for all submeshes
  21676. */
  21677. protected _markAllSubMeshesAsAllDirty(): void;
  21678. /**
  21679. * Indicates that image processing needs to be re-calculated for all submeshes
  21680. */
  21681. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21682. /**
  21683. * Indicates that textures need to be re-calculated for all submeshes
  21684. */
  21685. protected _markAllSubMeshesAsTexturesDirty(): void;
  21686. /**
  21687. * Indicates that fresnel needs to be re-calculated for all submeshes
  21688. */
  21689. protected _markAllSubMeshesAsFresnelDirty(): void;
  21690. /**
  21691. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21692. */
  21693. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21694. /**
  21695. * Indicates that lights need to be re-calculated for all submeshes
  21696. */
  21697. protected _markAllSubMeshesAsLightsDirty(): void;
  21698. /**
  21699. * Indicates that attributes need to be re-calculated for all submeshes
  21700. */
  21701. protected _markAllSubMeshesAsAttributesDirty(): void;
  21702. /**
  21703. * Indicates that misc needs to be re-calculated for all submeshes
  21704. */
  21705. protected _markAllSubMeshesAsMiscDirty(): void;
  21706. /**
  21707. * Indicates that textures and misc need to be re-calculated for all submeshes
  21708. */
  21709. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21710. /**
  21711. * Disposes the material
  21712. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21713. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21714. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21715. */
  21716. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21717. /** @hidden */
  21718. private releaseVertexArrayObject;
  21719. /**
  21720. * Serializes this material
  21721. * @returns the serialized material object
  21722. */
  21723. serialize(): any;
  21724. /**
  21725. * Creates a material from parsed material data
  21726. * @param parsedMaterial defines parsed material data
  21727. * @param scene defines the hosting scene
  21728. * @param rootUrl defines the root URL to use to load textures
  21729. * @returns a new material
  21730. */
  21731. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21732. }
  21733. }
  21734. declare module BABYLON {
  21735. /**
  21736. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21737. * separate meshes. This can be use to improve performances.
  21738. * @see http://doc.babylonjs.com/how_to/multi_materials
  21739. */
  21740. export class MultiMaterial extends Material {
  21741. private _subMaterials;
  21742. /**
  21743. * Gets or Sets the list of Materials used within the multi material.
  21744. * They need to be ordered according to the submeshes order in the associated mesh
  21745. */
  21746. get subMaterials(): Nullable<Material>[];
  21747. set subMaterials(value: Nullable<Material>[]);
  21748. /**
  21749. * Function used to align with Node.getChildren()
  21750. * @returns the list of Materials used within the multi material
  21751. */
  21752. getChildren(): Nullable<Material>[];
  21753. /**
  21754. * Instantiates a new Multi Material
  21755. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21756. * separate meshes. This can be use to improve performances.
  21757. * @see http://doc.babylonjs.com/how_to/multi_materials
  21758. * @param name Define the name in the scene
  21759. * @param scene Define the scene the material belongs to
  21760. */
  21761. constructor(name: string, scene: Scene);
  21762. private _hookArray;
  21763. /**
  21764. * Get one of the submaterial by its index in the submaterials array
  21765. * @param index The index to look the sub material at
  21766. * @returns The Material if the index has been defined
  21767. */
  21768. getSubMaterial(index: number): Nullable<Material>;
  21769. /**
  21770. * Get the list of active textures for the whole sub materials list.
  21771. * @returns All the textures that will be used during the rendering
  21772. */
  21773. getActiveTextures(): BaseTexture[];
  21774. /**
  21775. * Gets the current class name of the material e.g. "MultiMaterial"
  21776. * Mainly use in serialization.
  21777. * @returns the class name
  21778. */
  21779. getClassName(): string;
  21780. /**
  21781. * Checks if the material is ready to render the requested sub mesh
  21782. * @param mesh Define the mesh the submesh belongs to
  21783. * @param subMesh Define the sub mesh to look readyness for
  21784. * @param useInstances Define whether or not the material is used with instances
  21785. * @returns true if ready, otherwise false
  21786. */
  21787. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21788. /**
  21789. * Clones the current material and its related sub materials
  21790. * @param name Define the name of the newly cloned material
  21791. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21792. * @returns the cloned material
  21793. */
  21794. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21795. /**
  21796. * Serializes the materials into a JSON representation.
  21797. * @returns the JSON representation
  21798. */
  21799. serialize(): any;
  21800. /**
  21801. * Dispose the material and release its associated resources
  21802. * @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)
  21803. * @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)
  21804. * @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)
  21805. */
  21806. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21807. /**
  21808. * Creates a MultiMaterial from parsed MultiMaterial data.
  21809. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21810. * @param scene defines the hosting scene
  21811. * @returns a new MultiMaterial
  21812. */
  21813. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21814. }
  21815. }
  21816. declare module BABYLON {
  21817. /**
  21818. * Base class for submeshes
  21819. */
  21820. export class BaseSubMesh {
  21821. /** @hidden */
  21822. _materialDefines: Nullable<MaterialDefines>;
  21823. /** @hidden */
  21824. _materialEffect: Nullable<Effect>;
  21825. /** @hidden */
  21826. _effectOverride: Nullable<Effect>;
  21827. /**
  21828. * Gets material defines used by the effect associated to the sub mesh
  21829. */
  21830. get materialDefines(): Nullable<MaterialDefines>;
  21831. /**
  21832. * Sets material defines used by the effect associated to the sub mesh
  21833. */
  21834. set materialDefines(defines: Nullable<MaterialDefines>);
  21835. /**
  21836. * Gets associated effect
  21837. */
  21838. get effect(): Nullable<Effect>;
  21839. /**
  21840. * Sets associated effect (effect used to render this submesh)
  21841. * @param effect defines the effect to associate with
  21842. * @param defines defines the set of defines used to compile this effect
  21843. */
  21844. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21845. }
  21846. /**
  21847. * Defines a subdivision inside a mesh
  21848. */
  21849. export class SubMesh extends BaseSubMesh implements ICullable {
  21850. /** the material index to use */
  21851. materialIndex: number;
  21852. /** vertex index start */
  21853. verticesStart: number;
  21854. /** vertices count */
  21855. verticesCount: number;
  21856. /** index start */
  21857. indexStart: number;
  21858. /** indices count */
  21859. indexCount: number;
  21860. /** @hidden */
  21861. _linesIndexCount: number;
  21862. private _mesh;
  21863. private _renderingMesh;
  21864. private _boundingInfo;
  21865. private _linesIndexBuffer;
  21866. /** @hidden */
  21867. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21868. /** @hidden */
  21869. _trianglePlanes: Plane[];
  21870. /** @hidden */
  21871. _lastColliderTransformMatrix: Nullable<Matrix>;
  21872. /** @hidden */
  21873. _renderId: number;
  21874. /** @hidden */
  21875. _alphaIndex: number;
  21876. /** @hidden */
  21877. _distanceToCamera: number;
  21878. /** @hidden */
  21879. _id: number;
  21880. private _currentMaterial;
  21881. /**
  21882. * Add a new submesh to a mesh
  21883. * @param materialIndex defines the material index to use
  21884. * @param verticesStart defines vertex index start
  21885. * @param verticesCount defines vertices count
  21886. * @param indexStart defines index start
  21887. * @param indexCount defines indices count
  21888. * @param mesh defines the parent mesh
  21889. * @param renderingMesh defines an optional rendering mesh
  21890. * @param createBoundingBox defines if bounding box should be created for this submesh
  21891. * @returns the new submesh
  21892. */
  21893. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21894. /**
  21895. * Creates a new submesh
  21896. * @param materialIndex defines the material index to use
  21897. * @param verticesStart defines vertex index start
  21898. * @param verticesCount defines vertices count
  21899. * @param indexStart defines index start
  21900. * @param indexCount defines indices count
  21901. * @param mesh defines the parent mesh
  21902. * @param renderingMesh defines an optional rendering mesh
  21903. * @param createBoundingBox defines if bounding box should be created for this submesh
  21904. */
  21905. constructor(
  21906. /** the material index to use */
  21907. materialIndex: number,
  21908. /** vertex index start */
  21909. verticesStart: number,
  21910. /** vertices count */
  21911. verticesCount: number,
  21912. /** index start */
  21913. indexStart: number,
  21914. /** indices count */
  21915. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21916. /**
  21917. * Returns true if this submesh covers the entire parent mesh
  21918. * @ignorenaming
  21919. */
  21920. get IsGlobal(): boolean;
  21921. /**
  21922. * Returns the submesh BoudingInfo object
  21923. * @returns current bounding info (or mesh's one if the submesh is global)
  21924. */
  21925. getBoundingInfo(): BoundingInfo;
  21926. /**
  21927. * Sets the submesh BoundingInfo
  21928. * @param boundingInfo defines the new bounding info to use
  21929. * @returns the SubMesh
  21930. */
  21931. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21932. /**
  21933. * Returns the mesh of the current submesh
  21934. * @return the parent mesh
  21935. */
  21936. getMesh(): AbstractMesh;
  21937. /**
  21938. * Returns the rendering mesh of the submesh
  21939. * @returns the rendering mesh (could be different from parent mesh)
  21940. */
  21941. getRenderingMesh(): Mesh;
  21942. /**
  21943. * Returns the submesh material
  21944. * @returns null or the current material
  21945. */
  21946. getMaterial(): Nullable<Material>;
  21947. /**
  21948. * Sets a new updated BoundingInfo object to the submesh
  21949. * @param data defines an optional position array to use to determine the bounding info
  21950. * @returns the SubMesh
  21951. */
  21952. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21953. /** @hidden */
  21954. _checkCollision(collider: Collider): boolean;
  21955. /**
  21956. * Updates the submesh BoundingInfo
  21957. * @param world defines the world matrix to use to update the bounding info
  21958. * @returns the submesh
  21959. */
  21960. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21961. /**
  21962. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21963. * @param frustumPlanes defines the frustum planes
  21964. * @returns true if the submesh is intersecting with the frustum
  21965. */
  21966. isInFrustum(frustumPlanes: Plane[]): boolean;
  21967. /**
  21968. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21969. * @param frustumPlanes defines the frustum planes
  21970. * @returns true if the submesh is inside the frustum
  21971. */
  21972. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21973. /**
  21974. * Renders the submesh
  21975. * @param enableAlphaMode defines if alpha needs to be used
  21976. * @returns the submesh
  21977. */
  21978. render(enableAlphaMode: boolean): SubMesh;
  21979. /**
  21980. * @hidden
  21981. */
  21982. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21983. /**
  21984. * Checks if the submesh intersects with a ray
  21985. * @param ray defines the ray to test
  21986. * @returns true is the passed ray intersects the submesh bounding box
  21987. */
  21988. canIntersects(ray: Ray): boolean;
  21989. /**
  21990. * Intersects current submesh with a ray
  21991. * @param ray defines the ray to test
  21992. * @param positions defines mesh's positions array
  21993. * @param indices defines mesh's indices array
  21994. * @param fastCheck defines if only bounding info should be used
  21995. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21996. * @returns intersection info or null if no intersection
  21997. */
  21998. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21999. /** @hidden */
  22000. private _intersectLines;
  22001. /** @hidden */
  22002. private _intersectUnIndexedLines;
  22003. /** @hidden */
  22004. private _intersectTriangles;
  22005. /** @hidden */
  22006. private _intersectUnIndexedTriangles;
  22007. /** @hidden */
  22008. _rebuild(): void;
  22009. /**
  22010. * Creates a new submesh from the passed mesh
  22011. * @param newMesh defines the new hosting mesh
  22012. * @param newRenderingMesh defines an optional rendering mesh
  22013. * @returns the new submesh
  22014. */
  22015. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22016. /**
  22017. * Release associated resources
  22018. */
  22019. dispose(): void;
  22020. /**
  22021. * Gets the class name
  22022. * @returns the string "SubMesh".
  22023. */
  22024. getClassName(): string;
  22025. /**
  22026. * Creates a new submesh from indices data
  22027. * @param materialIndex the index of the main mesh material
  22028. * @param startIndex the index where to start the copy in the mesh indices array
  22029. * @param indexCount the number of indices to copy then from the startIndex
  22030. * @param mesh the main mesh to create the submesh from
  22031. * @param renderingMesh the optional rendering mesh
  22032. * @returns a new submesh
  22033. */
  22034. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22035. }
  22036. }
  22037. declare module BABYLON {
  22038. /**
  22039. * Class used to represent data loading progression
  22040. */
  22041. export class SceneLoaderFlags {
  22042. private static _ForceFullSceneLoadingForIncremental;
  22043. private static _ShowLoadingScreen;
  22044. private static _CleanBoneMatrixWeights;
  22045. private static _loggingLevel;
  22046. /**
  22047. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22048. */
  22049. static get ForceFullSceneLoadingForIncremental(): boolean;
  22050. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22051. /**
  22052. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22053. */
  22054. static get ShowLoadingScreen(): boolean;
  22055. static set ShowLoadingScreen(value: boolean);
  22056. /**
  22057. * Defines the current logging level (while loading the scene)
  22058. * @ignorenaming
  22059. */
  22060. static get loggingLevel(): number;
  22061. static set loggingLevel(value: number);
  22062. /**
  22063. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22064. */
  22065. static get CleanBoneMatrixWeights(): boolean;
  22066. static set CleanBoneMatrixWeights(value: boolean);
  22067. }
  22068. }
  22069. declare module BABYLON {
  22070. /**
  22071. * Class used to store geometry data (vertex buffers + index buffer)
  22072. */
  22073. export class Geometry implements IGetSetVerticesData {
  22074. /**
  22075. * Gets or sets the ID of the geometry
  22076. */
  22077. id: string;
  22078. /**
  22079. * Gets or sets the unique ID of the geometry
  22080. */
  22081. uniqueId: number;
  22082. /**
  22083. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22084. */
  22085. delayLoadState: number;
  22086. /**
  22087. * Gets the file containing the data to load when running in delay load state
  22088. */
  22089. delayLoadingFile: Nullable<string>;
  22090. /**
  22091. * Callback called when the geometry is updated
  22092. */
  22093. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22094. private _scene;
  22095. private _engine;
  22096. private _meshes;
  22097. private _totalVertices;
  22098. /** @hidden */
  22099. _indices: IndicesArray;
  22100. /** @hidden */
  22101. _vertexBuffers: {
  22102. [key: string]: VertexBuffer;
  22103. };
  22104. private _isDisposed;
  22105. private _extend;
  22106. private _boundingBias;
  22107. /** @hidden */
  22108. _delayInfo: Array<string>;
  22109. private _indexBuffer;
  22110. private _indexBufferIsUpdatable;
  22111. /** @hidden */
  22112. _boundingInfo: Nullable<BoundingInfo>;
  22113. /** @hidden */
  22114. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22115. /** @hidden */
  22116. _softwareSkinningFrameId: number;
  22117. private _vertexArrayObjects;
  22118. private _updatable;
  22119. /** @hidden */
  22120. _positions: Nullable<Vector3[]>;
  22121. /**
  22122. * 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
  22123. */
  22124. get boundingBias(): Vector2;
  22125. /**
  22126. * 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
  22127. */
  22128. set boundingBias(value: Vector2);
  22129. /**
  22130. * Static function used to attach a new empty geometry to a mesh
  22131. * @param mesh defines the mesh to attach the geometry to
  22132. * @returns the new Geometry
  22133. */
  22134. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22135. /** Get the list of meshes using this geometry */
  22136. get meshes(): Mesh[];
  22137. /**
  22138. * Creates a new geometry
  22139. * @param id defines the unique ID
  22140. * @param scene defines the hosting scene
  22141. * @param vertexData defines the VertexData used to get geometry data
  22142. * @param updatable defines if geometry must be updatable (false by default)
  22143. * @param mesh defines the mesh that will be associated with the geometry
  22144. */
  22145. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22146. /**
  22147. * Gets the current extend of the geometry
  22148. */
  22149. get extend(): {
  22150. minimum: Vector3;
  22151. maximum: Vector3;
  22152. };
  22153. /**
  22154. * Gets the hosting scene
  22155. * @returns the hosting Scene
  22156. */
  22157. getScene(): Scene;
  22158. /**
  22159. * Gets the hosting engine
  22160. * @returns the hosting Engine
  22161. */
  22162. getEngine(): Engine;
  22163. /**
  22164. * Defines if the geometry is ready to use
  22165. * @returns true if the geometry is ready to be used
  22166. */
  22167. isReady(): boolean;
  22168. /**
  22169. * Gets a value indicating that the geometry should not be serialized
  22170. */
  22171. get doNotSerialize(): boolean;
  22172. /** @hidden */
  22173. _rebuild(): void;
  22174. /**
  22175. * Affects all geometry data in one call
  22176. * @param vertexData defines the geometry data
  22177. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22178. */
  22179. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22180. /**
  22181. * Set specific vertex data
  22182. * @param kind defines the data kind (Position, normal, etc...)
  22183. * @param data defines the vertex data to use
  22184. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22185. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22186. */
  22187. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22188. /**
  22189. * Removes a specific vertex data
  22190. * @param kind defines the data kind (Position, normal, etc...)
  22191. */
  22192. removeVerticesData(kind: string): void;
  22193. /**
  22194. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22195. * @param buffer defines the vertex buffer to use
  22196. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22197. */
  22198. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22199. /**
  22200. * Update a specific vertex buffer
  22201. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22202. * It will do nothing if the buffer is not updatable
  22203. * @param kind defines the data kind (Position, normal, etc...)
  22204. * @param data defines the data to use
  22205. * @param offset defines the offset in the target buffer where to store the data
  22206. * @param useBytes set to true if the offset is in bytes
  22207. */
  22208. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22209. /**
  22210. * Update a specific vertex buffer
  22211. * This function will create a new buffer if the current one is not updatable
  22212. * @param kind defines the data kind (Position, normal, etc...)
  22213. * @param data defines the data to use
  22214. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22215. */
  22216. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22217. private _updateBoundingInfo;
  22218. /** @hidden */
  22219. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22220. /**
  22221. * Gets total number of vertices
  22222. * @returns the total number of vertices
  22223. */
  22224. getTotalVertices(): number;
  22225. /**
  22226. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22227. * @param kind defines the data kind (Position, normal, etc...)
  22228. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22229. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22230. * @returns a float array containing vertex data
  22231. */
  22232. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22233. /**
  22234. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22235. * @param kind defines the data kind (Position, normal, etc...)
  22236. * @returns true if the vertex buffer with the specified kind is updatable
  22237. */
  22238. isVertexBufferUpdatable(kind: string): boolean;
  22239. /**
  22240. * Gets a specific vertex buffer
  22241. * @param kind defines the data kind (Position, normal, etc...)
  22242. * @returns a VertexBuffer
  22243. */
  22244. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22245. /**
  22246. * Returns all vertex buffers
  22247. * @return an object holding all vertex buffers indexed by kind
  22248. */
  22249. getVertexBuffers(): Nullable<{
  22250. [key: string]: VertexBuffer;
  22251. }>;
  22252. /**
  22253. * Gets a boolean indicating if specific vertex buffer is present
  22254. * @param kind defines the data kind (Position, normal, etc...)
  22255. * @returns true if data is present
  22256. */
  22257. isVerticesDataPresent(kind: string): boolean;
  22258. /**
  22259. * Gets a list of all attached data kinds (Position, normal, etc...)
  22260. * @returns a list of string containing all kinds
  22261. */
  22262. getVerticesDataKinds(): string[];
  22263. /**
  22264. * Update index buffer
  22265. * @param indices defines the indices to store in the index buffer
  22266. * @param offset defines the offset in the target buffer where to store the data
  22267. * @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)
  22268. */
  22269. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22270. /**
  22271. * Creates a new index buffer
  22272. * @param indices defines the indices to store in the index buffer
  22273. * @param totalVertices defines the total number of vertices (could be null)
  22274. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22275. */
  22276. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22277. /**
  22278. * Return the total number of indices
  22279. * @returns the total number of indices
  22280. */
  22281. getTotalIndices(): number;
  22282. /**
  22283. * Gets the index buffer array
  22284. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22285. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22286. * @returns the index buffer array
  22287. */
  22288. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22289. /**
  22290. * Gets the index buffer
  22291. * @return the index buffer
  22292. */
  22293. getIndexBuffer(): Nullable<DataBuffer>;
  22294. /** @hidden */
  22295. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22296. /**
  22297. * Release the associated resources for a specific mesh
  22298. * @param mesh defines the source mesh
  22299. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22300. */
  22301. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22302. /**
  22303. * Apply current geometry to a given mesh
  22304. * @param mesh defines the mesh to apply geometry to
  22305. */
  22306. applyToMesh(mesh: Mesh): void;
  22307. private _updateExtend;
  22308. private _applyToMesh;
  22309. private notifyUpdate;
  22310. /**
  22311. * Load the geometry if it was flagged as delay loaded
  22312. * @param scene defines the hosting scene
  22313. * @param onLoaded defines a callback called when the geometry is loaded
  22314. */
  22315. load(scene: Scene, onLoaded?: () => void): void;
  22316. private _queueLoad;
  22317. /**
  22318. * Invert the geometry to move from a right handed system to a left handed one.
  22319. */
  22320. toLeftHanded(): void;
  22321. /** @hidden */
  22322. _resetPointsArrayCache(): void;
  22323. /** @hidden */
  22324. _generatePointsArray(): boolean;
  22325. /**
  22326. * Gets a value indicating if the geometry is disposed
  22327. * @returns true if the geometry was disposed
  22328. */
  22329. isDisposed(): boolean;
  22330. private _disposeVertexArrayObjects;
  22331. /**
  22332. * Free all associated resources
  22333. */
  22334. dispose(): void;
  22335. /**
  22336. * Clone the current geometry into a new geometry
  22337. * @param id defines the unique ID of the new geometry
  22338. * @returns a new geometry object
  22339. */
  22340. copy(id: string): Geometry;
  22341. /**
  22342. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22343. * @return a JSON representation of the current geometry data (without the vertices data)
  22344. */
  22345. serialize(): any;
  22346. private toNumberArray;
  22347. /**
  22348. * Serialize all vertices data into a JSON oject
  22349. * @returns a JSON representation of the current geometry data
  22350. */
  22351. serializeVerticeData(): any;
  22352. /**
  22353. * Extracts a clone of a mesh geometry
  22354. * @param mesh defines the source mesh
  22355. * @param id defines the unique ID of the new geometry object
  22356. * @returns the new geometry object
  22357. */
  22358. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22359. /**
  22360. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22361. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22362. * Be aware Math.random() could cause collisions, but:
  22363. * "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"
  22364. * @returns a string containing a new GUID
  22365. */
  22366. static RandomId(): string;
  22367. /** @hidden */
  22368. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22369. private static _CleanMatricesWeights;
  22370. /**
  22371. * Create a new geometry from persisted data (Using .babylon file format)
  22372. * @param parsedVertexData defines the persisted data
  22373. * @param scene defines the hosting scene
  22374. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22375. * @returns the new geometry object
  22376. */
  22377. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22378. }
  22379. }
  22380. declare module BABYLON {
  22381. /**
  22382. * Define an interface for all classes that will get and set the data on vertices
  22383. */
  22384. export interface IGetSetVerticesData {
  22385. /**
  22386. * Gets a boolean indicating if specific vertex data is present
  22387. * @param kind defines the vertex data kind to use
  22388. * @returns true is data kind is present
  22389. */
  22390. isVerticesDataPresent(kind: string): boolean;
  22391. /**
  22392. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22393. * @param kind defines the data kind (Position, normal, etc...)
  22394. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22395. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22396. * @returns a float array containing vertex data
  22397. */
  22398. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22399. /**
  22400. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22401. * @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.
  22402. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22403. * @returns the indices array or an empty array if the mesh has no geometry
  22404. */
  22405. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22406. /**
  22407. * Set specific vertex data
  22408. * @param kind defines the data kind (Position, normal, etc...)
  22409. * @param data defines the vertex data to use
  22410. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22411. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22412. */
  22413. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22414. /**
  22415. * Update a specific associated vertex buffer
  22416. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22417. * - VertexBuffer.PositionKind
  22418. * - VertexBuffer.UVKind
  22419. * - VertexBuffer.UV2Kind
  22420. * - VertexBuffer.UV3Kind
  22421. * - VertexBuffer.UV4Kind
  22422. * - VertexBuffer.UV5Kind
  22423. * - VertexBuffer.UV6Kind
  22424. * - VertexBuffer.ColorKind
  22425. * - VertexBuffer.MatricesIndicesKind
  22426. * - VertexBuffer.MatricesIndicesExtraKind
  22427. * - VertexBuffer.MatricesWeightsKind
  22428. * - VertexBuffer.MatricesWeightsExtraKind
  22429. * @param data defines the data source
  22430. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22431. * @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)
  22432. */
  22433. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22434. /**
  22435. * Creates a new index buffer
  22436. * @param indices defines the indices to store in the index buffer
  22437. * @param totalVertices defines the total number of vertices (could be null)
  22438. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22439. */
  22440. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22441. }
  22442. /**
  22443. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22444. */
  22445. export class VertexData {
  22446. /**
  22447. * Mesh side orientation : usually the external or front surface
  22448. */
  22449. static readonly FRONTSIDE: number;
  22450. /**
  22451. * Mesh side orientation : usually the internal or back surface
  22452. */
  22453. static readonly BACKSIDE: number;
  22454. /**
  22455. * Mesh side orientation : both internal and external or front and back surfaces
  22456. */
  22457. static readonly DOUBLESIDE: number;
  22458. /**
  22459. * Mesh side orientation : by default, `FRONTSIDE`
  22460. */
  22461. static readonly DEFAULTSIDE: number;
  22462. /**
  22463. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22464. */
  22465. positions: Nullable<FloatArray>;
  22466. /**
  22467. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22468. */
  22469. normals: Nullable<FloatArray>;
  22470. /**
  22471. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22472. */
  22473. tangents: Nullable<FloatArray>;
  22474. /**
  22475. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22476. */
  22477. uvs: Nullable<FloatArray>;
  22478. /**
  22479. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22480. */
  22481. uvs2: Nullable<FloatArray>;
  22482. /**
  22483. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22484. */
  22485. uvs3: Nullable<FloatArray>;
  22486. /**
  22487. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22488. */
  22489. uvs4: Nullable<FloatArray>;
  22490. /**
  22491. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22492. */
  22493. uvs5: Nullable<FloatArray>;
  22494. /**
  22495. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22496. */
  22497. uvs6: Nullable<FloatArray>;
  22498. /**
  22499. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22500. */
  22501. colors: Nullable<FloatArray>;
  22502. /**
  22503. * 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).
  22504. */
  22505. matricesIndices: Nullable<FloatArray>;
  22506. /**
  22507. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22508. */
  22509. matricesWeights: Nullable<FloatArray>;
  22510. /**
  22511. * An array extending the number of possible indices
  22512. */
  22513. matricesIndicesExtra: Nullable<FloatArray>;
  22514. /**
  22515. * An array extending the number of possible weights when the number of indices is extended
  22516. */
  22517. matricesWeightsExtra: Nullable<FloatArray>;
  22518. /**
  22519. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22520. */
  22521. indices: Nullable<IndicesArray>;
  22522. /**
  22523. * Uses the passed data array to set the set the values for the specified kind of data
  22524. * @param data a linear array of floating numbers
  22525. * @param kind the type of data that is being set, eg positions, colors etc
  22526. */
  22527. set(data: FloatArray, kind: string): void;
  22528. /**
  22529. * Associates the vertexData to the passed Mesh.
  22530. * Sets it as updatable or not (default `false`)
  22531. * @param mesh the mesh the vertexData is applied to
  22532. * @param updatable when used and having the value true allows new data to update the vertexData
  22533. * @returns the VertexData
  22534. */
  22535. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22536. /**
  22537. * Associates the vertexData to the passed Geometry.
  22538. * Sets it as updatable or not (default `false`)
  22539. * @param geometry the geometry the vertexData is applied to
  22540. * @param updatable when used and having the value true allows new data to update the vertexData
  22541. * @returns VertexData
  22542. */
  22543. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22544. /**
  22545. * Updates the associated mesh
  22546. * @param mesh the mesh to be updated
  22547. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22548. * @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
  22549. * @returns VertexData
  22550. */
  22551. updateMesh(mesh: Mesh): VertexData;
  22552. /**
  22553. * Updates the associated geometry
  22554. * @param geometry the geometry to be updated
  22555. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22556. * @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
  22557. * @returns VertexData.
  22558. */
  22559. updateGeometry(geometry: Geometry): VertexData;
  22560. private _applyTo;
  22561. private _update;
  22562. /**
  22563. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22564. * @param matrix the transforming matrix
  22565. * @returns the VertexData
  22566. */
  22567. transform(matrix: Matrix): VertexData;
  22568. /**
  22569. * Merges the passed VertexData into the current one
  22570. * @param other the VertexData to be merged into the current one
  22571. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22572. * @returns the modified VertexData
  22573. */
  22574. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22575. private _mergeElement;
  22576. private _validate;
  22577. /**
  22578. * Serializes the VertexData
  22579. * @returns a serialized object
  22580. */
  22581. serialize(): any;
  22582. /**
  22583. * Extracts the vertexData from a mesh
  22584. * @param mesh the mesh from which to extract the VertexData
  22585. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22586. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22587. * @returns the object VertexData associated to the passed mesh
  22588. */
  22589. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22590. /**
  22591. * Extracts the vertexData from the geometry
  22592. * @param geometry the geometry from which to extract the VertexData
  22593. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22594. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22595. * @returns the object VertexData associated to the passed mesh
  22596. */
  22597. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22598. private static _ExtractFrom;
  22599. /**
  22600. * Creates the VertexData for a Ribbon
  22601. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22602. * * pathArray array of paths, each of which an array of successive Vector3
  22603. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22604. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22605. * * 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
  22606. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22607. * * 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)
  22608. * * 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)
  22609. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22610. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22611. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22612. * @returns the VertexData of the ribbon
  22613. */
  22614. static CreateRibbon(options: {
  22615. pathArray: Vector3[][];
  22616. closeArray?: boolean;
  22617. closePath?: boolean;
  22618. offset?: number;
  22619. sideOrientation?: number;
  22620. frontUVs?: Vector4;
  22621. backUVs?: Vector4;
  22622. invertUV?: boolean;
  22623. uvs?: Vector2[];
  22624. colors?: Color4[];
  22625. }): VertexData;
  22626. /**
  22627. * Creates the VertexData for a box
  22628. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22629. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22630. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22631. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22632. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22633. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22634. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22635. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22636. * * 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)
  22637. * * 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)
  22638. * @returns the VertexData of the box
  22639. */
  22640. static CreateBox(options: {
  22641. size?: number;
  22642. width?: number;
  22643. height?: number;
  22644. depth?: number;
  22645. faceUV?: Vector4[];
  22646. faceColors?: Color4[];
  22647. sideOrientation?: number;
  22648. frontUVs?: Vector4;
  22649. backUVs?: Vector4;
  22650. }): VertexData;
  22651. /**
  22652. * Creates the VertexData for a tiled box
  22653. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22654. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22655. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22656. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22657. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22658. * @returns the VertexData of the box
  22659. */
  22660. static CreateTiledBox(options: {
  22661. pattern?: number;
  22662. width?: number;
  22663. height?: number;
  22664. depth?: number;
  22665. tileSize?: number;
  22666. tileWidth?: number;
  22667. tileHeight?: number;
  22668. alignHorizontal?: number;
  22669. alignVertical?: number;
  22670. faceUV?: Vector4[];
  22671. faceColors?: Color4[];
  22672. sideOrientation?: number;
  22673. }): VertexData;
  22674. /**
  22675. * Creates the VertexData for a tiled plane
  22676. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22677. * * pattern a limited pattern arrangement depending on the number
  22678. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22679. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22680. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22681. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22682. * * 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)
  22683. * * 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)
  22684. * @returns the VertexData of the tiled plane
  22685. */
  22686. static CreateTiledPlane(options: {
  22687. pattern?: number;
  22688. tileSize?: number;
  22689. tileWidth?: number;
  22690. tileHeight?: number;
  22691. size?: number;
  22692. width?: number;
  22693. height?: number;
  22694. alignHorizontal?: number;
  22695. alignVertical?: number;
  22696. sideOrientation?: number;
  22697. frontUVs?: Vector4;
  22698. backUVs?: Vector4;
  22699. }): VertexData;
  22700. /**
  22701. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22702. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22703. * * segments sets the number of horizontal strips optional, default 32
  22704. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22705. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22706. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22707. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22708. * * 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
  22709. * * 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
  22710. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22711. * * 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)
  22712. * * 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)
  22713. * @returns the VertexData of the ellipsoid
  22714. */
  22715. static CreateSphere(options: {
  22716. segments?: number;
  22717. diameter?: number;
  22718. diameterX?: number;
  22719. diameterY?: number;
  22720. diameterZ?: number;
  22721. arc?: number;
  22722. slice?: number;
  22723. sideOrientation?: number;
  22724. frontUVs?: Vector4;
  22725. backUVs?: Vector4;
  22726. }): VertexData;
  22727. /**
  22728. * Creates the VertexData for a cylinder, cone or prism
  22729. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22730. * * height sets the height (y direction) of the cylinder, optional, default 2
  22731. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22732. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22733. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22734. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22735. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22736. * * 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
  22737. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22738. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22739. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22740. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22741. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22742. * * 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)
  22743. * * 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)
  22744. * @returns the VertexData of the cylinder, cone or prism
  22745. */
  22746. static CreateCylinder(options: {
  22747. height?: number;
  22748. diameterTop?: number;
  22749. diameterBottom?: number;
  22750. diameter?: number;
  22751. tessellation?: number;
  22752. subdivisions?: number;
  22753. arc?: number;
  22754. faceColors?: Color4[];
  22755. faceUV?: Vector4[];
  22756. hasRings?: boolean;
  22757. enclose?: boolean;
  22758. sideOrientation?: number;
  22759. frontUVs?: Vector4;
  22760. backUVs?: Vector4;
  22761. }): VertexData;
  22762. /**
  22763. * Creates the VertexData for a torus
  22764. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22765. * * diameter the diameter of the torus, optional default 1
  22766. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22767. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22768. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22769. * * 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)
  22770. * * 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)
  22771. * @returns the VertexData of the torus
  22772. */
  22773. static CreateTorus(options: {
  22774. diameter?: number;
  22775. thickness?: number;
  22776. tessellation?: number;
  22777. sideOrientation?: number;
  22778. frontUVs?: Vector4;
  22779. backUVs?: Vector4;
  22780. }): VertexData;
  22781. /**
  22782. * Creates the VertexData of the LineSystem
  22783. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22784. * - lines an array of lines, each line being an array of successive Vector3
  22785. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22786. * @returns the VertexData of the LineSystem
  22787. */
  22788. static CreateLineSystem(options: {
  22789. lines: Vector3[][];
  22790. colors?: Nullable<Color4[][]>;
  22791. }): VertexData;
  22792. /**
  22793. * Create the VertexData for a DashedLines
  22794. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22795. * - points an array successive Vector3
  22796. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22797. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22798. * - dashNb the intended total number of dashes, optional, default 200
  22799. * @returns the VertexData for the DashedLines
  22800. */
  22801. static CreateDashedLines(options: {
  22802. points: Vector3[];
  22803. dashSize?: number;
  22804. gapSize?: number;
  22805. dashNb?: number;
  22806. }): VertexData;
  22807. /**
  22808. * Creates the VertexData for a Ground
  22809. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22810. * - width the width (x direction) of the ground, optional, default 1
  22811. * - height the height (z direction) of the ground, optional, default 1
  22812. * - subdivisions the number of subdivisions per side, optional, default 1
  22813. * @returns the VertexData of the Ground
  22814. */
  22815. static CreateGround(options: {
  22816. width?: number;
  22817. height?: number;
  22818. subdivisions?: number;
  22819. subdivisionsX?: number;
  22820. subdivisionsY?: number;
  22821. }): VertexData;
  22822. /**
  22823. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22824. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22825. * * xmin the ground minimum X coordinate, optional, default -1
  22826. * * zmin the ground minimum Z coordinate, optional, default -1
  22827. * * xmax the ground maximum X coordinate, optional, default 1
  22828. * * zmax the ground maximum Z coordinate, optional, default 1
  22829. * * 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}
  22830. * * 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}
  22831. * @returns the VertexData of the TiledGround
  22832. */
  22833. static CreateTiledGround(options: {
  22834. xmin: number;
  22835. zmin: number;
  22836. xmax: number;
  22837. zmax: number;
  22838. subdivisions?: {
  22839. w: number;
  22840. h: number;
  22841. };
  22842. precision?: {
  22843. w: number;
  22844. h: number;
  22845. };
  22846. }): VertexData;
  22847. /**
  22848. * Creates the VertexData of the Ground designed from a heightmap
  22849. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22850. * * width the width (x direction) of the ground
  22851. * * height the height (z direction) of the ground
  22852. * * subdivisions the number of subdivisions per side
  22853. * * minHeight the minimum altitude on the ground, optional, default 0
  22854. * * maxHeight the maximum altitude on the ground, optional default 1
  22855. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22856. * * buffer the array holding the image color data
  22857. * * bufferWidth the width of image
  22858. * * bufferHeight the height of image
  22859. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22860. * @returns the VertexData of the Ground designed from a heightmap
  22861. */
  22862. static CreateGroundFromHeightMap(options: {
  22863. width: number;
  22864. height: number;
  22865. subdivisions: number;
  22866. minHeight: number;
  22867. maxHeight: number;
  22868. colorFilter: Color3;
  22869. buffer: Uint8Array;
  22870. bufferWidth: number;
  22871. bufferHeight: number;
  22872. alphaFilter: number;
  22873. }): VertexData;
  22874. /**
  22875. * Creates the VertexData for a Plane
  22876. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22877. * * size sets the width and height of the plane to the value of size, optional default 1
  22878. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22879. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22880. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22881. * * 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)
  22882. * * 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)
  22883. * @returns the VertexData of the box
  22884. */
  22885. static CreatePlane(options: {
  22886. size?: number;
  22887. width?: number;
  22888. height?: number;
  22889. sideOrientation?: number;
  22890. frontUVs?: Vector4;
  22891. backUVs?: Vector4;
  22892. }): VertexData;
  22893. /**
  22894. * Creates the VertexData of the Disc or regular Polygon
  22895. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22896. * * radius the radius of the disc, optional default 0.5
  22897. * * tessellation the number of polygon sides, optional, default 64
  22898. * * 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
  22899. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22900. * * 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)
  22901. * * 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)
  22902. * @returns the VertexData of the box
  22903. */
  22904. static CreateDisc(options: {
  22905. radius?: number;
  22906. tessellation?: number;
  22907. arc?: number;
  22908. sideOrientation?: number;
  22909. frontUVs?: Vector4;
  22910. backUVs?: Vector4;
  22911. }): VertexData;
  22912. /**
  22913. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22914. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22915. * @param polygon a mesh built from polygonTriangulation.build()
  22916. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22917. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22918. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22919. * @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)
  22920. * @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)
  22921. * @returns the VertexData of the Polygon
  22922. */
  22923. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22924. /**
  22925. * Creates the VertexData of the IcoSphere
  22926. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22927. * * radius the radius of the IcoSphere, optional default 1
  22928. * * radiusX allows stretching in the x direction, optional, default radius
  22929. * * radiusY allows stretching in the y direction, optional, default radius
  22930. * * radiusZ allows stretching in the z direction, optional, default radius
  22931. * * flat when true creates a flat shaded mesh, optional, default true
  22932. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22933. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22934. * * 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)
  22935. * * 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)
  22936. * @returns the VertexData of the IcoSphere
  22937. */
  22938. static CreateIcoSphere(options: {
  22939. radius?: number;
  22940. radiusX?: number;
  22941. radiusY?: number;
  22942. radiusZ?: number;
  22943. flat?: boolean;
  22944. subdivisions?: number;
  22945. sideOrientation?: number;
  22946. frontUVs?: Vector4;
  22947. backUVs?: Vector4;
  22948. }): VertexData;
  22949. /**
  22950. * Creates the VertexData for a Polyhedron
  22951. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22952. * * type provided types are:
  22953. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22954. * * 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)
  22955. * * size the size of the IcoSphere, optional default 1
  22956. * * sizeX allows stretching in the x direction, optional, default size
  22957. * * sizeY allows stretching in the y direction, optional, default size
  22958. * * sizeZ allows stretching in the z direction, optional, default size
  22959. * * 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
  22960. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22961. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22962. * * flat when true creates a flat shaded mesh, optional, default true
  22963. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22964. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22965. * * 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)
  22966. * * 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)
  22967. * @returns the VertexData of the Polyhedron
  22968. */
  22969. static CreatePolyhedron(options: {
  22970. type?: number;
  22971. size?: number;
  22972. sizeX?: number;
  22973. sizeY?: number;
  22974. sizeZ?: number;
  22975. custom?: any;
  22976. faceUV?: Vector4[];
  22977. faceColors?: Color4[];
  22978. flat?: boolean;
  22979. sideOrientation?: number;
  22980. frontUVs?: Vector4;
  22981. backUVs?: Vector4;
  22982. }): VertexData;
  22983. /**
  22984. * Creates the VertexData for a TorusKnot
  22985. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22986. * * radius the radius of the torus knot, optional, default 2
  22987. * * tube the thickness of the tube, optional, default 0.5
  22988. * * radialSegments the number of sides on each tube segments, optional, default 32
  22989. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22990. * * p the number of windings around the z axis, optional, default 2
  22991. * * q the number of windings around the x axis, optional, default 3
  22992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22993. * * 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)
  22994. * * 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)
  22995. * @returns the VertexData of the Torus Knot
  22996. */
  22997. static CreateTorusKnot(options: {
  22998. radius?: number;
  22999. tube?: number;
  23000. radialSegments?: number;
  23001. tubularSegments?: number;
  23002. p?: number;
  23003. q?: number;
  23004. sideOrientation?: number;
  23005. frontUVs?: Vector4;
  23006. backUVs?: Vector4;
  23007. }): VertexData;
  23008. /**
  23009. * Compute normals for given positions and indices
  23010. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23011. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23012. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23013. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23014. * * facetNormals : optional array of facet normals (vector3)
  23015. * * facetPositions : optional array of facet positions (vector3)
  23016. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23017. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23018. * * bInfo : optional bounding info, required for facetPartitioning computation
  23019. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23020. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23021. * * useRightHandedSystem: optional boolean to for right handed system computation
  23022. * * depthSort : optional boolean to enable the facet depth sort computation
  23023. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23024. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23025. */
  23026. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23027. facetNormals?: any;
  23028. facetPositions?: any;
  23029. facetPartitioning?: any;
  23030. ratio?: number;
  23031. bInfo?: any;
  23032. bbSize?: Vector3;
  23033. subDiv?: any;
  23034. useRightHandedSystem?: boolean;
  23035. depthSort?: boolean;
  23036. distanceTo?: Vector3;
  23037. depthSortedFacets?: any;
  23038. }): void;
  23039. /** @hidden */
  23040. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23041. /**
  23042. * Applies VertexData created from the imported parameters to the geometry
  23043. * @param parsedVertexData the parsed data from an imported file
  23044. * @param geometry the geometry to apply the VertexData to
  23045. */
  23046. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23047. }
  23048. }
  23049. declare module BABYLON {
  23050. /**
  23051. * Defines a target to use with MorphTargetManager
  23052. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23053. */
  23054. export class MorphTarget implements IAnimatable {
  23055. /** defines the name of the target */
  23056. name: string;
  23057. /**
  23058. * Gets or sets the list of animations
  23059. */
  23060. animations: Animation[];
  23061. private _scene;
  23062. private _positions;
  23063. private _normals;
  23064. private _tangents;
  23065. private _uvs;
  23066. private _influence;
  23067. private _uniqueId;
  23068. /**
  23069. * Observable raised when the influence changes
  23070. */
  23071. onInfluenceChanged: Observable<boolean>;
  23072. /** @hidden */
  23073. _onDataLayoutChanged: Observable<void>;
  23074. /**
  23075. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23076. */
  23077. get influence(): number;
  23078. set influence(influence: number);
  23079. /**
  23080. * Gets or sets the id of the morph Target
  23081. */
  23082. id: string;
  23083. private _animationPropertiesOverride;
  23084. /**
  23085. * Gets or sets the animation properties override
  23086. */
  23087. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23088. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23089. /**
  23090. * Creates a new MorphTarget
  23091. * @param name defines the name of the target
  23092. * @param influence defines the influence to use
  23093. * @param scene defines the scene the morphtarget belongs to
  23094. */
  23095. constructor(
  23096. /** defines the name of the target */
  23097. name: string, influence?: number, scene?: Nullable<Scene>);
  23098. /**
  23099. * Gets the unique ID of this manager
  23100. */
  23101. get uniqueId(): number;
  23102. /**
  23103. * Gets a boolean defining if the target contains position data
  23104. */
  23105. get hasPositions(): boolean;
  23106. /**
  23107. * Gets a boolean defining if the target contains normal data
  23108. */
  23109. get hasNormals(): boolean;
  23110. /**
  23111. * Gets a boolean defining if the target contains tangent data
  23112. */
  23113. get hasTangents(): boolean;
  23114. /**
  23115. * Gets a boolean defining if the target contains texture coordinates data
  23116. */
  23117. get hasUVs(): boolean;
  23118. /**
  23119. * Affects position data to this target
  23120. * @param data defines the position data to use
  23121. */
  23122. setPositions(data: Nullable<FloatArray>): void;
  23123. /**
  23124. * Gets the position data stored in this target
  23125. * @returns a FloatArray containing the position data (or null if not present)
  23126. */
  23127. getPositions(): Nullable<FloatArray>;
  23128. /**
  23129. * Affects normal data to this target
  23130. * @param data defines the normal data to use
  23131. */
  23132. setNormals(data: Nullable<FloatArray>): void;
  23133. /**
  23134. * Gets the normal data stored in this target
  23135. * @returns a FloatArray containing the normal data (or null if not present)
  23136. */
  23137. getNormals(): Nullable<FloatArray>;
  23138. /**
  23139. * Affects tangent data to this target
  23140. * @param data defines the tangent data to use
  23141. */
  23142. setTangents(data: Nullable<FloatArray>): void;
  23143. /**
  23144. * Gets the tangent data stored in this target
  23145. * @returns a FloatArray containing the tangent data (or null if not present)
  23146. */
  23147. getTangents(): Nullable<FloatArray>;
  23148. /**
  23149. * Affects texture coordinates data to this target
  23150. * @param data defines the texture coordinates data to use
  23151. */
  23152. setUVs(data: Nullable<FloatArray>): void;
  23153. /**
  23154. * Gets the texture coordinates data stored in this target
  23155. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23156. */
  23157. getUVs(): Nullable<FloatArray>;
  23158. /**
  23159. * Clone the current target
  23160. * @returns a new MorphTarget
  23161. */
  23162. clone(): MorphTarget;
  23163. /**
  23164. * Serializes the current target into a Serialization object
  23165. * @returns the serialized object
  23166. */
  23167. serialize(): any;
  23168. /**
  23169. * Returns the string "MorphTarget"
  23170. * @returns "MorphTarget"
  23171. */
  23172. getClassName(): string;
  23173. /**
  23174. * Creates a new target from serialized data
  23175. * @param serializationObject defines the serialized data to use
  23176. * @returns a new MorphTarget
  23177. */
  23178. static Parse(serializationObject: any): MorphTarget;
  23179. /**
  23180. * Creates a MorphTarget from mesh data
  23181. * @param mesh defines the source mesh
  23182. * @param name defines the name to use for the new target
  23183. * @param influence defines the influence to attach to the target
  23184. * @returns a new MorphTarget
  23185. */
  23186. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23187. }
  23188. }
  23189. declare module BABYLON {
  23190. /**
  23191. * This class is used to deform meshes using morphing between different targets
  23192. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23193. */
  23194. export class MorphTargetManager {
  23195. private _targets;
  23196. private _targetInfluenceChangedObservers;
  23197. private _targetDataLayoutChangedObservers;
  23198. private _activeTargets;
  23199. private _scene;
  23200. private _influences;
  23201. private _supportsNormals;
  23202. private _supportsTangents;
  23203. private _supportsUVs;
  23204. private _vertexCount;
  23205. private _uniqueId;
  23206. private _tempInfluences;
  23207. /**
  23208. * Gets or sets a boolean indicating if normals must be morphed
  23209. */
  23210. enableNormalMorphing: boolean;
  23211. /**
  23212. * Gets or sets a boolean indicating if tangents must be morphed
  23213. */
  23214. enableTangentMorphing: boolean;
  23215. /**
  23216. * Gets or sets a boolean indicating if UV must be morphed
  23217. */
  23218. enableUVMorphing: boolean;
  23219. /**
  23220. * Creates a new MorphTargetManager
  23221. * @param scene defines the current scene
  23222. */
  23223. constructor(scene?: Nullable<Scene>);
  23224. /**
  23225. * Gets the unique ID of this manager
  23226. */
  23227. get uniqueId(): number;
  23228. /**
  23229. * Gets the number of vertices handled by this manager
  23230. */
  23231. get vertexCount(): number;
  23232. /**
  23233. * Gets a boolean indicating if this manager supports morphing of normals
  23234. */
  23235. get supportsNormals(): boolean;
  23236. /**
  23237. * Gets a boolean indicating if this manager supports morphing of tangents
  23238. */
  23239. get supportsTangents(): boolean;
  23240. /**
  23241. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23242. */
  23243. get supportsUVs(): boolean;
  23244. /**
  23245. * Gets the number of targets stored in this manager
  23246. */
  23247. get numTargets(): number;
  23248. /**
  23249. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23250. */
  23251. get numInfluencers(): number;
  23252. /**
  23253. * Gets the list of influences (one per target)
  23254. */
  23255. get influences(): Float32Array;
  23256. /**
  23257. * Gets the active target at specified index. An active target is a target with an influence > 0
  23258. * @param index defines the index to check
  23259. * @returns the requested target
  23260. */
  23261. getActiveTarget(index: number): MorphTarget;
  23262. /**
  23263. * Gets the target at specified index
  23264. * @param index defines the index to check
  23265. * @returns the requested target
  23266. */
  23267. getTarget(index: number): MorphTarget;
  23268. /**
  23269. * Add a new target to this manager
  23270. * @param target defines the target to add
  23271. */
  23272. addTarget(target: MorphTarget): void;
  23273. /**
  23274. * Removes a target from the manager
  23275. * @param target defines the target to remove
  23276. */
  23277. removeTarget(target: MorphTarget): void;
  23278. /**
  23279. * Clone the current manager
  23280. * @returns a new MorphTargetManager
  23281. */
  23282. clone(): MorphTargetManager;
  23283. /**
  23284. * Serializes the current manager into a Serialization object
  23285. * @returns the serialized object
  23286. */
  23287. serialize(): any;
  23288. private _syncActiveTargets;
  23289. /**
  23290. * Syncrhonize the targets with all the meshes using this morph target manager
  23291. */
  23292. synchronize(): void;
  23293. /**
  23294. * Creates a new MorphTargetManager from serialized data
  23295. * @param serializationObject defines the serialized data
  23296. * @param scene defines the hosting scene
  23297. * @returns the new MorphTargetManager
  23298. */
  23299. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23300. }
  23301. }
  23302. declare module BABYLON {
  23303. /**
  23304. * Class used to represent a specific level of detail of a mesh
  23305. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23306. */
  23307. export class MeshLODLevel {
  23308. /** Defines the distance where this level should start being displayed */
  23309. distance: number;
  23310. /** Defines the mesh to use to render this level */
  23311. mesh: Nullable<Mesh>;
  23312. /**
  23313. * Creates a new LOD level
  23314. * @param distance defines the distance where this level should star being displayed
  23315. * @param mesh defines the mesh to use to render this level
  23316. */
  23317. constructor(
  23318. /** Defines the distance where this level should start being displayed */
  23319. distance: number,
  23320. /** Defines the mesh to use to render this level */
  23321. mesh: Nullable<Mesh>);
  23322. }
  23323. }
  23324. declare module BABYLON {
  23325. /**
  23326. * Mesh representing the gorund
  23327. */
  23328. export class GroundMesh extends Mesh {
  23329. /** If octree should be generated */
  23330. generateOctree: boolean;
  23331. private _heightQuads;
  23332. /** @hidden */
  23333. _subdivisionsX: number;
  23334. /** @hidden */
  23335. _subdivisionsY: number;
  23336. /** @hidden */
  23337. _width: number;
  23338. /** @hidden */
  23339. _height: number;
  23340. /** @hidden */
  23341. _minX: number;
  23342. /** @hidden */
  23343. _maxX: number;
  23344. /** @hidden */
  23345. _minZ: number;
  23346. /** @hidden */
  23347. _maxZ: number;
  23348. constructor(name: string, scene: Scene);
  23349. /**
  23350. * "GroundMesh"
  23351. * @returns "GroundMesh"
  23352. */
  23353. getClassName(): string;
  23354. /**
  23355. * The minimum of x and y subdivisions
  23356. */
  23357. get subdivisions(): number;
  23358. /**
  23359. * X subdivisions
  23360. */
  23361. get subdivisionsX(): number;
  23362. /**
  23363. * Y subdivisions
  23364. */
  23365. get subdivisionsY(): number;
  23366. /**
  23367. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23368. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23369. * @param chunksCount the number of subdivisions for x and y
  23370. * @param octreeBlocksSize (Default: 32)
  23371. */
  23372. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23373. /**
  23374. * Returns a height (y) value in the Worl system :
  23375. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23376. * @param x x coordinate
  23377. * @param z z coordinate
  23378. * @returns the ground y position if (x, z) are outside the ground surface.
  23379. */
  23380. getHeightAtCoordinates(x: number, z: number): number;
  23381. /**
  23382. * Returns a normalized vector (Vector3) orthogonal to the ground
  23383. * at the ground coordinates (x, z) expressed in the World system.
  23384. * @param x x coordinate
  23385. * @param z z coordinate
  23386. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23387. */
  23388. getNormalAtCoordinates(x: number, z: number): Vector3;
  23389. /**
  23390. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23391. * at the ground coordinates (x, z) expressed in the World system.
  23392. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23393. * @param x x coordinate
  23394. * @param z z coordinate
  23395. * @param ref vector to store the result
  23396. * @returns the GroundMesh.
  23397. */
  23398. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23399. /**
  23400. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23401. * if the ground has been updated.
  23402. * This can be used in the render loop.
  23403. * @returns the GroundMesh.
  23404. */
  23405. updateCoordinateHeights(): GroundMesh;
  23406. private _getFacetAt;
  23407. private _initHeightQuads;
  23408. private _computeHeightQuads;
  23409. /**
  23410. * Serializes this ground mesh
  23411. * @param serializationObject object to write serialization to
  23412. */
  23413. serialize(serializationObject: any): void;
  23414. /**
  23415. * Parses a serialized ground mesh
  23416. * @param parsedMesh the serialized mesh
  23417. * @param scene the scene to create the ground mesh in
  23418. * @returns the created ground mesh
  23419. */
  23420. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23421. }
  23422. }
  23423. declare module BABYLON {
  23424. /**
  23425. * Interface for Physics-Joint data
  23426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23427. */
  23428. export interface PhysicsJointData {
  23429. /**
  23430. * The main pivot of the joint
  23431. */
  23432. mainPivot?: Vector3;
  23433. /**
  23434. * The connected pivot of the joint
  23435. */
  23436. connectedPivot?: Vector3;
  23437. /**
  23438. * The main axis of the joint
  23439. */
  23440. mainAxis?: Vector3;
  23441. /**
  23442. * The connected axis of the joint
  23443. */
  23444. connectedAxis?: Vector3;
  23445. /**
  23446. * The collision of the joint
  23447. */
  23448. collision?: boolean;
  23449. /**
  23450. * Native Oimo/Cannon/Energy data
  23451. */
  23452. nativeParams?: any;
  23453. }
  23454. /**
  23455. * This is a holder class for the physics joint created by the physics plugin
  23456. * It holds a set of functions to control the underlying joint
  23457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23458. */
  23459. export class PhysicsJoint {
  23460. /**
  23461. * The type of the physics joint
  23462. */
  23463. type: number;
  23464. /**
  23465. * The data for the physics joint
  23466. */
  23467. jointData: PhysicsJointData;
  23468. private _physicsJoint;
  23469. protected _physicsPlugin: IPhysicsEnginePlugin;
  23470. /**
  23471. * Initializes the physics joint
  23472. * @param type The type of the physics joint
  23473. * @param jointData The data for the physics joint
  23474. */
  23475. constructor(
  23476. /**
  23477. * The type of the physics joint
  23478. */
  23479. type: number,
  23480. /**
  23481. * The data for the physics joint
  23482. */
  23483. jointData: PhysicsJointData);
  23484. /**
  23485. * Gets the physics joint
  23486. */
  23487. get physicsJoint(): any;
  23488. /**
  23489. * Sets the physics joint
  23490. */
  23491. set physicsJoint(newJoint: any);
  23492. /**
  23493. * Sets the physics plugin
  23494. */
  23495. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23496. /**
  23497. * Execute a function that is physics-plugin specific.
  23498. * @param {Function} func the function that will be executed.
  23499. * It accepts two parameters: the physics world and the physics joint
  23500. */
  23501. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23502. /**
  23503. * Distance-Joint type
  23504. */
  23505. static DistanceJoint: number;
  23506. /**
  23507. * Hinge-Joint type
  23508. */
  23509. static HingeJoint: number;
  23510. /**
  23511. * Ball-and-Socket joint type
  23512. */
  23513. static BallAndSocketJoint: number;
  23514. /**
  23515. * Wheel-Joint type
  23516. */
  23517. static WheelJoint: number;
  23518. /**
  23519. * Slider-Joint type
  23520. */
  23521. static SliderJoint: number;
  23522. /**
  23523. * Prismatic-Joint type
  23524. */
  23525. static PrismaticJoint: number;
  23526. /**
  23527. * Universal-Joint type
  23528. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23529. */
  23530. static UniversalJoint: number;
  23531. /**
  23532. * Hinge-Joint 2 type
  23533. */
  23534. static Hinge2Joint: number;
  23535. /**
  23536. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23537. */
  23538. static PointToPointJoint: number;
  23539. /**
  23540. * Spring-Joint type
  23541. */
  23542. static SpringJoint: number;
  23543. /**
  23544. * Lock-Joint type
  23545. */
  23546. static LockJoint: number;
  23547. }
  23548. /**
  23549. * A class representing a physics distance joint
  23550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23551. */
  23552. export class DistanceJoint extends PhysicsJoint {
  23553. /**
  23554. *
  23555. * @param jointData The data for the Distance-Joint
  23556. */
  23557. constructor(jointData: DistanceJointData);
  23558. /**
  23559. * Update the predefined distance.
  23560. * @param maxDistance The maximum preferred distance
  23561. * @param minDistance The minimum preferred distance
  23562. */
  23563. updateDistance(maxDistance: number, minDistance?: number): void;
  23564. }
  23565. /**
  23566. * Represents a Motor-Enabled Joint
  23567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23568. */
  23569. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23570. /**
  23571. * Initializes the Motor-Enabled Joint
  23572. * @param type The type of the joint
  23573. * @param jointData The physica joint data for the joint
  23574. */
  23575. constructor(type: number, jointData: PhysicsJointData);
  23576. /**
  23577. * Set the motor values.
  23578. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23579. * @param force the force to apply
  23580. * @param maxForce max force for this motor.
  23581. */
  23582. setMotor(force?: number, maxForce?: number): void;
  23583. /**
  23584. * Set the motor's limits.
  23585. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23586. * @param upperLimit The upper limit of the motor
  23587. * @param lowerLimit The lower limit of the motor
  23588. */
  23589. setLimit(upperLimit: number, lowerLimit?: number): void;
  23590. }
  23591. /**
  23592. * This class represents a single physics Hinge-Joint
  23593. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23594. */
  23595. export class HingeJoint extends MotorEnabledJoint {
  23596. /**
  23597. * Initializes the Hinge-Joint
  23598. * @param jointData The joint data for the Hinge-Joint
  23599. */
  23600. constructor(jointData: PhysicsJointData);
  23601. /**
  23602. * Set the motor values.
  23603. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23604. * @param {number} force the force to apply
  23605. * @param {number} maxForce max force for this motor.
  23606. */
  23607. setMotor(force?: number, maxForce?: number): void;
  23608. /**
  23609. * Set the motor's limits.
  23610. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23611. * @param upperLimit The upper limit of the motor
  23612. * @param lowerLimit The lower limit of the motor
  23613. */
  23614. setLimit(upperLimit: number, lowerLimit?: number): void;
  23615. }
  23616. /**
  23617. * This class represents a dual hinge physics joint (same as wheel joint)
  23618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23619. */
  23620. export class Hinge2Joint extends MotorEnabledJoint {
  23621. /**
  23622. * Initializes the Hinge2-Joint
  23623. * @param jointData The joint data for the Hinge2-Joint
  23624. */
  23625. constructor(jointData: PhysicsJointData);
  23626. /**
  23627. * Set the motor values.
  23628. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23629. * @param {number} targetSpeed the speed the motor is to reach
  23630. * @param {number} maxForce max force for this motor.
  23631. * @param {motorIndex} the motor's index, 0 or 1.
  23632. */
  23633. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23634. /**
  23635. * Set the motor limits.
  23636. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23637. * @param {number} upperLimit the upper limit
  23638. * @param {number} lowerLimit lower limit
  23639. * @param {motorIndex} the motor's index, 0 or 1.
  23640. */
  23641. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23642. }
  23643. /**
  23644. * Interface for a motor enabled joint
  23645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23646. */
  23647. export interface IMotorEnabledJoint {
  23648. /**
  23649. * Physics joint
  23650. */
  23651. physicsJoint: any;
  23652. /**
  23653. * Sets the motor of the motor-enabled joint
  23654. * @param force The force of the motor
  23655. * @param maxForce The maximum force of the motor
  23656. * @param motorIndex The index of the motor
  23657. */
  23658. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23659. /**
  23660. * Sets the limit of the motor
  23661. * @param upperLimit The upper limit of the motor
  23662. * @param lowerLimit The lower limit of the motor
  23663. * @param motorIndex The index of the motor
  23664. */
  23665. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23666. }
  23667. /**
  23668. * Joint data for a Distance-Joint
  23669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23670. */
  23671. export interface DistanceJointData extends PhysicsJointData {
  23672. /**
  23673. * Max distance the 2 joint objects can be apart
  23674. */
  23675. maxDistance: number;
  23676. }
  23677. /**
  23678. * Joint data from a spring joint
  23679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23680. */
  23681. export interface SpringJointData extends PhysicsJointData {
  23682. /**
  23683. * Length of the spring
  23684. */
  23685. length: number;
  23686. /**
  23687. * Stiffness of the spring
  23688. */
  23689. stiffness: number;
  23690. /**
  23691. * Damping of the spring
  23692. */
  23693. damping: number;
  23694. /** this callback will be called when applying the force to the impostors. */
  23695. forceApplicationCallback: () => void;
  23696. }
  23697. }
  23698. declare module BABYLON {
  23699. /**
  23700. * Holds the data for the raycast result
  23701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23702. */
  23703. export class PhysicsRaycastResult {
  23704. private _hasHit;
  23705. private _hitDistance;
  23706. private _hitNormalWorld;
  23707. private _hitPointWorld;
  23708. private _rayFromWorld;
  23709. private _rayToWorld;
  23710. /**
  23711. * Gets if there was a hit
  23712. */
  23713. get hasHit(): boolean;
  23714. /**
  23715. * Gets the distance from the hit
  23716. */
  23717. get hitDistance(): number;
  23718. /**
  23719. * Gets the hit normal/direction in the world
  23720. */
  23721. get hitNormalWorld(): Vector3;
  23722. /**
  23723. * Gets the hit point in the world
  23724. */
  23725. get hitPointWorld(): Vector3;
  23726. /**
  23727. * Gets the ray "start point" of the ray in the world
  23728. */
  23729. get rayFromWorld(): Vector3;
  23730. /**
  23731. * Gets the ray "end point" of the ray in the world
  23732. */
  23733. get rayToWorld(): Vector3;
  23734. /**
  23735. * Sets the hit data (normal & point in world space)
  23736. * @param hitNormalWorld defines the normal in world space
  23737. * @param hitPointWorld defines the point in world space
  23738. */
  23739. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23740. /**
  23741. * Sets the distance from the start point to the hit point
  23742. * @param distance
  23743. */
  23744. setHitDistance(distance: number): void;
  23745. /**
  23746. * Calculates the distance manually
  23747. */
  23748. calculateHitDistance(): void;
  23749. /**
  23750. * Resets all the values to default
  23751. * @param from The from point on world space
  23752. * @param to The to point on world space
  23753. */
  23754. reset(from?: Vector3, to?: Vector3): void;
  23755. }
  23756. /**
  23757. * Interface for the size containing width and height
  23758. */
  23759. interface IXYZ {
  23760. /**
  23761. * X
  23762. */
  23763. x: number;
  23764. /**
  23765. * Y
  23766. */
  23767. y: number;
  23768. /**
  23769. * Z
  23770. */
  23771. z: number;
  23772. }
  23773. }
  23774. declare module BABYLON {
  23775. /**
  23776. * Interface used to describe a physics joint
  23777. */
  23778. export interface PhysicsImpostorJoint {
  23779. /** Defines the main impostor to which the joint is linked */
  23780. mainImpostor: PhysicsImpostor;
  23781. /** Defines the impostor that is connected to the main impostor using this joint */
  23782. connectedImpostor: PhysicsImpostor;
  23783. /** Defines the joint itself */
  23784. joint: PhysicsJoint;
  23785. }
  23786. /** @hidden */
  23787. export interface IPhysicsEnginePlugin {
  23788. world: any;
  23789. name: string;
  23790. setGravity(gravity: Vector3): void;
  23791. setTimeStep(timeStep: number): void;
  23792. getTimeStep(): number;
  23793. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23794. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23795. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23796. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23797. removePhysicsBody(impostor: PhysicsImpostor): void;
  23798. generateJoint(joint: PhysicsImpostorJoint): void;
  23799. removeJoint(joint: PhysicsImpostorJoint): void;
  23800. isSupported(): boolean;
  23801. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23802. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23803. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23804. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23805. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23806. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23807. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23808. getBodyMass(impostor: PhysicsImpostor): number;
  23809. getBodyFriction(impostor: PhysicsImpostor): number;
  23810. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23811. getBodyRestitution(impostor: PhysicsImpostor): number;
  23812. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23813. getBodyPressure?(impostor: PhysicsImpostor): number;
  23814. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23815. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23816. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23817. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23818. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23819. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23820. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23821. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23822. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23823. sleepBody(impostor: PhysicsImpostor): void;
  23824. wakeUpBody(impostor: PhysicsImpostor): void;
  23825. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23826. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23827. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23828. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23829. getRadius(impostor: PhysicsImpostor): number;
  23830. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23831. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23832. dispose(): void;
  23833. }
  23834. /**
  23835. * Interface used to define a physics engine
  23836. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23837. */
  23838. export interface IPhysicsEngine {
  23839. /**
  23840. * Gets the gravity vector used by the simulation
  23841. */
  23842. gravity: Vector3;
  23843. /**
  23844. * Sets the gravity vector used by the simulation
  23845. * @param gravity defines the gravity vector to use
  23846. */
  23847. setGravity(gravity: Vector3): void;
  23848. /**
  23849. * Set the time step of the physics engine.
  23850. * Default is 1/60.
  23851. * To slow it down, enter 1/600 for example.
  23852. * To speed it up, 1/30
  23853. * @param newTimeStep the new timestep to apply to this world.
  23854. */
  23855. setTimeStep(newTimeStep: number): void;
  23856. /**
  23857. * Get the time step of the physics engine.
  23858. * @returns the current time step
  23859. */
  23860. getTimeStep(): number;
  23861. /**
  23862. * Set the sub time step of the physics engine.
  23863. * Default is 0 meaning there is no sub steps
  23864. * To increase physics resolution precision, set a small value (like 1 ms)
  23865. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23866. */
  23867. setSubTimeStep(subTimeStep: number): void;
  23868. /**
  23869. * Get the sub time step of the physics engine.
  23870. * @returns the current sub time step
  23871. */
  23872. getSubTimeStep(): number;
  23873. /**
  23874. * Release all resources
  23875. */
  23876. dispose(): void;
  23877. /**
  23878. * Gets the name of the current physics plugin
  23879. * @returns the name of the plugin
  23880. */
  23881. getPhysicsPluginName(): string;
  23882. /**
  23883. * Adding a new impostor for the impostor tracking.
  23884. * This will be done by the impostor itself.
  23885. * @param impostor the impostor to add
  23886. */
  23887. addImpostor(impostor: PhysicsImpostor): void;
  23888. /**
  23889. * Remove an impostor from the engine.
  23890. * This impostor and its mesh will not longer be updated by the physics engine.
  23891. * @param impostor the impostor to remove
  23892. */
  23893. removeImpostor(impostor: PhysicsImpostor): void;
  23894. /**
  23895. * Add a joint to the physics engine
  23896. * @param mainImpostor defines the main impostor to which the joint is added.
  23897. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23898. * @param joint defines the joint that will connect both impostors.
  23899. */
  23900. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23901. /**
  23902. * Removes a joint from the simulation
  23903. * @param mainImpostor defines the impostor used with the joint
  23904. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23905. * @param joint defines the joint to remove
  23906. */
  23907. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23908. /**
  23909. * Gets the current plugin used to run the simulation
  23910. * @returns current plugin
  23911. */
  23912. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23913. /**
  23914. * Gets the list of physic impostors
  23915. * @returns an array of PhysicsImpostor
  23916. */
  23917. getImpostors(): Array<PhysicsImpostor>;
  23918. /**
  23919. * Gets the impostor for a physics enabled object
  23920. * @param object defines the object impersonated by the impostor
  23921. * @returns the PhysicsImpostor or null if not found
  23922. */
  23923. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23924. /**
  23925. * Gets the impostor for a physics body object
  23926. * @param body defines physics body used by the impostor
  23927. * @returns the PhysicsImpostor or null if not found
  23928. */
  23929. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23930. /**
  23931. * Does a raycast in the physics world
  23932. * @param from when should the ray start?
  23933. * @param to when should the ray end?
  23934. * @returns PhysicsRaycastResult
  23935. */
  23936. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23937. /**
  23938. * Called by the scene. No need to call it.
  23939. * @param delta defines the timespam between frames
  23940. */
  23941. _step(delta: number): void;
  23942. }
  23943. }
  23944. declare module BABYLON {
  23945. /**
  23946. * The interface for the physics imposter parameters
  23947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23948. */
  23949. export interface PhysicsImpostorParameters {
  23950. /**
  23951. * The mass of the physics imposter
  23952. */
  23953. mass: number;
  23954. /**
  23955. * The friction of the physics imposter
  23956. */
  23957. friction?: number;
  23958. /**
  23959. * The coefficient of restitution of the physics imposter
  23960. */
  23961. restitution?: number;
  23962. /**
  23963. * The native options of the physics imposter
  23964. */
  23965. nativeOptions?: any;
  23966. /**
  23967. * Specifies if the parent should be ignored
  23968. */
  23969. ignoreParent?: boolean;
  23970. /**
  23971. * Specifies if bi-directional transformations should be disabled
  23972. */
  23973. disableBidirectionalTransformation?: boolean;
  23974. /**
  23975. * The pressure inside the physics imposter, soft object only
  23976. */
  23977. pressure?: number;
  23978. /**
  23979. * The stiffness the physics imposter, soft object only
  23980. */
  23981. stiffness?: number;
  23982. /**
  23983. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23984. */
  23985. velocityIterations?: number;
  23986. /**
  23987. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23988. */
  23989. positionIterations?: number;
  23990. /**
  23991. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23992. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23993. * Add to fix multiple points
  23994. */
  23995. fixedPoints?: number;
  23996. /**
  23997. * The collision margin around a soft object
  23998. */
  23999. margin?: number;
  24000. /**
  24001. * The collision margin around a soft object
  24002. */
  24003. damping?: number;
  24004. /**
  24005. * The path for a rope based on an extrusion
  24006. */
  24007. path?: any;
  24008. /**
  24009. * The shape of an extrusion used for a rope based on an extrusion
  24010. */
  24011. shape?: any;
  24012. }
  24013. /**
  24014. * Interface for a physics-enabled object
  24015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24016. */
  24017. export interface IPhysicsEnabledObject {
  24018. /**
  24019. * The position of the physics-enabled object
  24020. */
  24021. position: Vector3;
  24022. /**
  24023. * The rotation of the physics-enabled object
  24024. */
  24025. rotationQuaternion: Nullable<Quaternion>;
  24026. /**
  24027. * The scale of the physics-enabled object
  24028. */
  24029. scaling: Vector3;
  24030. /**
  24031. * The rotation of the physics-enabled object
  24032. */
  24033. rotation?: Vector3;
  24034. /**
  24035. * The parent of the physics-enabled object
  24036. */
  24037. parent?: any;
  24038. /**
  24039. * The bounding info of the physics-enabled object
  24040. * @returns The bounding info of the physics-enabled object
  24041. */
  24042. getBoundingInfo(): BoundingInfo;
  24043. /**
  24044. * Computes the world matrix
  24045. * @param force Specifies if the world matrix should be computed by force
  24046. * @returns A world matrix
  24047. */
  24048. computeWorldMatrix(force: boolean): Matrix;
  24049. /**
  24050. * Gets the world matrix
  24051. * @returns A world matrix
  24052. */
  24053. getWorldMatrix?(): Matrix;
  24054. /**
  24055. * Gets the child meshes
  24056. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24057. * @returns An array of abstract meshes
  24058. */
  24059. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24060. /**
  24061. * Gets the vertex data
  24062. * @param kind The type of vertex data
  24063. * @returns A nullable array of numbers, or a float32 array
  24064. */
  24065. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24066. /**
  24067. * Gets the indices from the mesh
  24068. * @returns A nullable array of index arrays
  24069. */
  24070. getIndices?(): Nullable<IndicesArray>;
  24071. /**
  24072. * Gets the scene from the mesh
  24073. * @returns the indices array or null
  24074. */
  24075. getScene?(): Scene;
  24076. /**
  24077. * Gets the absolute position from the mesh
  24078. * @returns the absolute position
  24079. */
  24080. getAbsolutePosition(): Vector3;
  24081. /**
  24082. * Gets the absolute pivot point from the mesh
  24083. * @returns the absolute pivot point
  24084. */
  24085. getAbsolutePivotPoint(): Vector3;
  24086. /**
  24087. * Rotates the mesh
  24088. * @param axis The axis of rotation
  24089. * @param amount The amount of rotation
  24090. * @param space The space of the rotation
  24091. * @returns The rotation transform node
  24092. */
  24093. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24094. /**
  24095. * Translates the mesh
  24096. * @param axis The axis of translation
  24097. * @param distance The distance of translation
  24098. * @param space The space of the translation
  24099. * @returns The transform node
  24100. */
  24101. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24102. /**
  24103. * Sets the absolute position of the mesh
  24104. * @param absolutePosition The absolute position of the mesh
  24105. * @returns The transform node
  24106. */
  24107. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24108. /**
  24109. * Gets the class name of the mesh
  24110. * @returns The class name
  24111. */
  24112. getClassName(): string;
  24113. }
  24114. /**
  24115. * Represents a physics imposter
  24116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24117. */
  24118. export class PhysicsImpostor {
  24119. /**
  24120. * The physics-enabled object used as the physics imposter
  24121. */
  24122. object: IPhysicsEnabledObject;
  24123. /**
  24124. * The type of the physics imposter
  24125. */
  24126. type: number;
  24127. private _options;
  24128. private _scene?;
  24129. /**
  24130. * The default object size of the imposter
  24131. */
  24132. static DEFAULT_OBJECT_SIZE: Vector3;
  24133. /**
  24134. * The identity quaternion of the imposter
  24135. */
  24136. static IDENTITY_QUATERNION: Quaternion;
  24137. /** @hidden */
  24138. _pluginData: any;
  24139. private _physicsEngine;
  24140. private _physicsBody;
  24141. private _bodyUpdateRequired;
  24142. private _onBeforePhysicsStepCallbacks;
  24143. private _onAfterPhysicsStepCallbacks;
  24144. /** @hidden */
  24145. _onPhysicsCollideCallbacks: Array<{
  24146. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24147. otherImpostors: Array<PhysicsImpostor>;
  24148. }>;
  24149. private _deltaPosition;
  24150. private _deltaRotation;
  24151. private _deltaRotationConjugated;
  24152. /** @hidden */
  24153. _isFromLine: boolean;
  24154. private _parent;
  24155. private _isDisposed;
  24156. private static _tmpVecs;
  24157. private static _tmpQuat;
  24158. /**
  24159. * Specifies if the physics imposter is disposed
  24160. */
  24161. get isDisposed(): boolean;
  24162. /**
  24163. * Gets the mass of the physics imposter
  24164. */
  24165. get mass(): number;
  24166. set mass(value: number);
  24167. /**
  24168. * Gets the coefficient of friction
  24169. */
  24170. get friction(): number;
  24171. /**
  24172. * Sets the coefficient of friction
  24173. */
  24174. set friction(value: number);
  24175. /**
  24176. * Gets the coefficient of restitution
  24177. */
  24178. get restitution(): number;
  24179. /**
  24180. * Sets the coefficient of restitution
  24181. */
  24182. set restitution(value: number);
  24183. /**
  24184. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24185. */
  24186. get pressure(): number;
  24187. /**
  24188. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24189. */
  24190. set pressure(value: number);
  24191. /**
  24192. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24193. */
  24194. get stiffness(): number;
  24195. /**
  24196. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24197. */
  24198. set stiffness(value: number);
  24199. /**
  24200. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24201. */
  24202. get velocityIterations(): number;
  24203. /**
  24204. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24205. */
  24206. set velocityIterations(value: number);
  24207. /**
  24208. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24209. */
  24210. get positionIterations(): number;
  24211. /**
  24212. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24213. */
  24214. set positionIterations(value: number);
  24215. /**
  24216. * The unique id of the physics imposter
  24217. * set by the physics engine when adding this impostor to the array
  24218. */
  24219. uniqueId: number;
  24220. /**
  24221. * @hidden
  24222. */
  24223. soft: boolean;
  24224. /**
  24225. * @hidden
  24226. */
  24227. segments: number;
  24228. private _joints;
  24229. /**
  24230. * Initializes the physics imposter
  24231. * @param object The physics-enabled object used as the physics imposter
  24232. * @param type The type of the physics imposter
  24233. * @param _options The options for the physics imposter
  24234. * @param _scene The Babylon scene
  24235. */
  24236. constructor(
  24237. /**
  24238. * The physics-enabled object used as the physics imposter
  24239. */
  24240. object: IPhysicsEnabledObject,
  24241. /**
  24242. * The type of the physics imposter
  24243. */
  24244. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24245. /**
  24246. * This function will completly initialize this impostor.
  24247. * It will create a new body - but only if this mesh has no parent.
  24248. * If it has, this impostor will not be used other than to define the impostor
  24249. * of the child mesh.
  24250. * @hidden
  24251. */
  24252. _init(): void;
  24253. private _getPhysicsParent;
  24254. /**
  24255. * Should a new body be generated.
  24256. * @returns boolean specifying if body initialization is required
  24257. */
  24258. isBodyInitRequired(): boolean;
  24259. /**
  24260. * Sets the updated scaling
  24261. * @param updated Specifies if the scaling is updated
  24262. */
  24263. setScalingUpdated(): void;
  24264. /**
  24265. * Force a regeneration of this or the parent's impostor's body.
  24266. * Use under cautious - This will remove all joints already implemented.
  24267. */
  24268. forceUpdate(): void;
  24269. /**
  24270. * Gets the body that holds this impostor. Either its own, or its parent.
  24271. */
  24272. get physicsBody(): any;
  24273. /**
  24274. * Get the parent of the physics imposter
  24275. * @returns Physics imposter or null
  24276. */
  24277. get parent(): Nullable<PhysicsImpostor>;
  24278. /**
  24279. * Sets the parent of the physics imposter
  24280. */
  24281. set parent(value: Nullable<PhysicsImpostor>);
  24282. /**
  24283. * Set the physics body. Used mainly by the physics engine/plugin
  24284. */
  24285. set physicsBody(physicsBody: any);
  24286. /**
  24287. * Resets the update flags
  24288. */
  24289. resetUpdateFlags(): void;
  24290. /**
  24291. * Gets the object extend size
  24292. * @returns the object extend size
  24293. */
  24294. getObjectExtendSize(): Vector3;
  24295. /**
  24296. * Gets the object center
  24297. * @returns The object center
  24298. */
  24299. getObjectCenter(): Vector3;
  24300. /**
  24301. * Get a specific parameter from the options parameters
  24302. * @param paramName The object parameter name
  24303. * @returns The object parameter
  24304. */
  24305. getParam(paramName: string): any;
  24306. /**
  24307. * Sets a specific parameter in the options given to the physics plugin
  24308. * @param paramName The parameter name
  24309. * @param value The value of the parameter
  24310. */
  24311. setParam(paramName: string, value: number): void;
  24312. /**
  24313. * Specifically change the body's mass option. Won't recreate the physics body object
  24314. * @param mass The mass of the physics imposter
  24315. */
  24316. setMass(mass: number): void;
  24317. /**
  24318. * Gets the linear velocity
  24319. * @returns linear velocity or null
  24320. */
  24321. getLinearVelocity(): Nullable<Vector3>;
  24322. /**
  24323. * Sets the linear velocity
  24324. * @param velocity linear velocity or null
  24325. */
  24326. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24327. /**
  24328. * Gets the angular velocity
  24329. * @returns angular velocity or null
  24330. */
  24331. getAngularVelocity(): Nullable<Vector3>;
  24332. /**
  24333. * Sets the angular velocity
  24334. * @param velocity The velocity or null
  24335. */
  24336. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24337. /**
  24338. * Execute a function with the physics plugin native code
  24339. * Provide a function the will have two variables - the world object and the physics body object
  24340. * @param func The function to execute with the physics plugin native code
  24341. */
  24342. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24343. /**
  24344. * Register a function that will be executed before the physics world is stepping forward
  24345. * @param func The function to execute before the physics world is stepped forward
  24346. */
  24347. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24348. /**
  24349. * Unregister a function that will be executed before the physics world is stepping forward
  24350. * @param func The function to execute before the physics world is stepped forward
  24351. */
  24352. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24353. /**
  24354. * Register a function that will be executed after the physics step
  24355. * @param func The function to execute after physics step
  24356. */
  24357. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24358. /**
  24359. * Unregisters a function that will be executed after the physics step
  24360. * @param func The function to execute after physics step
  24361. */
  24362. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24363. /**
  24364. * register a function that will be executed when this impostor collides against a different body
  24365. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24366. * @param func Callback that is executed on collision
  24367. */
  24368. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24369. /**
  24370. * Unregisters the physics imposter on contact
  24371. * @param collideAgainst The physics object to collide against
  24372. * @param func Callback to execute on collision
  24373. */
  24374. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24375. private _tmpQuat;
  24376. private _tmpQuat2;
  24377. /**
  24378. * Get the parent rotation
  24379. * @returns The parent rotation
  24380. */
  24381. getParentsRotation(): Quaternion;
  24382. /**
  24383. * this function is executed by the physics engine.
  24384. */
  24385. beforeStep: () => void;
  24386. /**
  24387. * this function is executed by the physics engine
  24388. */
  24389. afterStep: () => void;
  24390. /**
  24391. * Legacy collision detection event support
  24392. */
  24393. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24394. /**
  24395. * event and body object due to cannon's event-based architecture.
  24396. */
  24397. onCollide: (e: {
  24398. body: any;
  24399. }) => void;
  24400. /**
  24401. * Apply a force
  24402. * @param force The force to apply
  24403. * @param contactPoint The contact point for the force
  24404. * @returns The physics imposter
  24405. */
  24406. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24407. /**
  24408. * Apply an impulse
  24409. * @param force The impulse force
  24410. * @param contactPoint The contact point for the impulse force
  24411. * @returns The physics imposter
  24412. */
  24413. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24414. /**
  24415. * A help function to create a joint
  24416. * @param otherImpostor A physics imposter used to create a joint
  24417. * @param jointType The type of joint
  24418. * @param jointData The data for the joint
  24419. * @returns The physics imposter
  24420. */
  24421. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24422. /**
  24423. * Add a joint to this impostor with a different impostor
  24424. * @param otherImpostor A physics imposter used to add a joint
  24425. * @param joint The joint to add
  24426. * @returns The physics imposter
  24427. */
  24428. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24429. /**
  24430. * Add an anchor to a cloth impostor
  24431. * @param otherImpostor rigid impostor to anchor to
  24432. * @param width ratio across width from 0 to 1
  24433. * @param height ratio up height from 0 to 1
  24434. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24435. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24436. * @returns impostor the soft imposter
  24437. */
  24438. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24439. /**
  24440. * Add a hook to a rope impostor
  24441. * @param otherImpostor rigid impostor to anchor to
  24442. * @param length ratio across rope from 0 to 1
  24443. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24444. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24445. * @returns impostor the rope imposter
  24446. */
  24447. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24448. /**
  24449. * Will keep this body still, in a sleep mode.
  24450. * @returns the physics imposter
  24451. */
  24452. sleep(): PhysicsImpostor;
  24453. /**
  24454. * Wake the body up.
  24455. * @returns The physics imposter
  24456. */
  24457. wakeUp(): PhysicsImpostor;
  24458. /**
  24459. * Clones the physics imposter
  24460. * @param newObject The physics imposter clones to this physics-enabled object
  24461. * @returns A nullable physics imposter
  24462. */
  24463. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24464. /**
  24465. * Disposes the physics imposter
  24466. */
  24467. dispose(): void;
  24468. /**
  24469. * Sets the delta position
  24470. * @param position The delta position amount
  24471. */
  24472. setDeltaPosition(position: Vector3): void;
  24473. /**
  24474. * Sets the delta rotation
  24475. * @param rotation The delta rotation amount
  24476. */
  24477. setDeltaRotation(rotation: Quaternion): void;
  24478. /**
  24479. * Gets the box size of the physics imposter and stores the result in the input parameter
  24480. * @param result Stores the box size
  24481. * @returns The physics imposter
  24482. */
  24483. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24484. /**
  24485. * Gets the radius of the physics imposter
  24486. * @returns Radius of the physics imposter
  24487. */
  24488. getRadius(): number;
  24489. /**
  24490. * Sync a bone with this impostor
  24491. * @param bone The bone to sync to the impostor.
  24492. * @param boneMesh The mesh that the bone is influencing.
  24493. * @param jointPivot The pivot of the joint / bone in local space.
  24494. * @param distToJoint Optional distance from the impostor to the joint.
  24495. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24496. */
  24497. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24498. /**
  24499. * Sync impostor to a bone
  24500. * @param bone The bone that the impostor will be synced to.
  24501. * @param boneMesh The mesh that the bone is influencing.
  24502. * @param jointPivot The pivot of the joint / bone in local space.
  24503. * @param distToJoint Optional distance from the impostor to the joint.
  24504. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24505. * @param boneAxis Optional vector3 axis the bone is aligned with
  24506. */
  24507. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24508. /**
  24509. * No-Imposter type
  24510. */
  24511. static NoImpostor: number;
  24512. /**
  24513. * Sphere-Imposter type
  24514. */
  24515. static SphereImpostor: number;
  24516. /**
  24517. * Box-Imposter type
  24518. */
  24519. static BoxImpostor: number;
  24520. /**
  24521. * Plane-Imposter type
  24522. */
  24523. static PlaneImpostor: number;
  24524. /**
  24525. * Mesh-imposter type
  24526. */
  24527. static MeshImpostor: number;
  24528. /**
  24529. * Capsule-Impostor type (Ammo.js plugin only)
  24530. */
  24531. static CapsuleImpostor: number;
  24532. /**
  24533. * Cylinder-Imposter type
  24534. */
  24535. static CylinderImpostor: number;
  24536. /**
  24537. * Particle-Imposter type
  24538. */
  24539. static ParticleImpostor: number;
  24540. /**
  24541. * Heightmap-Imposter type
  24542. */
  24543. static HeightmapImpostor: number;
  24544. /**
  24545. * ConvexHull-Impostor type (Ammo.js plugin only)
  24546. */
  24547. static ConvexHullImpostor: number;
  24548. /**
  24549. * Custom-Imposter type (Ammo.js plugin only)
  24550. */
  24551. static CustomImpostor: number;
  24552. /**
  24553. * Rope-Imposter type
  24554. */
  24555. static RopeImpostor: number;
  24556. /**
  24557. * Cloth-Imposter type
  24558. */
  24559. static ClothImpostor: number;
  24560. /**
  24561. * Softbody-Imposter type
  24562. */
  24563. static SoftbodyImpostor: number;
  24564. }
  24565. }
  24566. declare module BABYLON {
  24567. /**
  24568. * @hidden
  24569. **/
  24570. export class _CreationDataStorage {
  24571. closePath?: boolean;
  24572. closeArray?: boolean;
  24573. idx: number[];
  24574. dashSize: number;
  24575. gapSize: number;
  24576. path3D: Path3D;
  24577. pathArray: Vector3[][];
  24578. arc: number;
  24579. radius: number;
  24580. cap: number;
  24581. tessellation: number;
  24582. }
  24583. /**
  24584. * @hidden
  24585. **/
  24586. class _InstanceDataStorage {
  24587. visibleInstances: any;
  24588. batchCache: _InstancesBatch;
  24589. instancesBufferSize: number;
  24590. instancesBuffer: Nullable<Buffer>;
  24591. instancesData: Float32Array;
  24592. overridenInstanceCount: number;
  24593. isFrozen: boolean;
  24594. previousBatch: Nullable<_InstancesBatch>;
  24595. hardwareInstancedRendering: boolean;
  24596. sideOrientation: number;
  24597. manualUpdate: boolean;
  24598. }
  24599. /**
  24600. * @hidden
  24601. **/
  24602. export class _InstancesBatch {
  24603. mustReturn: boolean;
  24604. visibleInstances: Nullable<InstancedMesh[]>[];
  24605. renderSelf: boolean[];
  24606. hardwareInstancedRendering: boolean[];
  24607. }
  24608. /**
  24609. * Class used to represent renderable models
  24610. */
  24611. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24612. /**
  24613. * Mesh side orientation : usually the external or front surface
  24614. */
  24615. static readonly FRONTSIDE: number;
  24616. /**
  24617. * Mesh side orientation : usually the internal or back surface
  24618. */
  24619. static readonly BACKSIDE: number;
  24620. /**
  24621. * Mesh side orientation : both internal and external or front and back surfaces
  24622. */
  24623. static readonly DOUBLESIDE: number;
  24624. /**
  24625. * Mesh side orientation : by default, `FRONTSIDE`
  24626. */
  24627. static readonly DEFAULTSIDE: number;
  24628. /**
  24629. * Mesh cap setting : no cap
  24630. */
  24631. static readonly NO_CAP: number;
  24632. /**
  24633. * Mesh cap setting : one cap at the beginning of the mesh
  24634. */
  24635. static readonly CAP_START: number;
  24636. /**
  24637. * Mesh cap setting : one cap at the end of the mesh
  24638. */
  24639. static readonly CAP_END: number;
  24640. /**
  24641. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24642. */
  24643. static readonly CAP_ALL: number;
  24644. /**
  24645. * Mesh pattern setting : no flip or rotate
  24646. */
  24647. static readonly NO_FLIP: number;
  24648. /**
  24649. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24650. */
  24651. static readonly FLIP_TILE: number;
  24652. /**
  24653. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24654. */
  24655. static readonly ROTATE_TILE: number;
  24656. /**
  24657. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24658. */
  24659. static readonly FLIP_ROW: number;
  24660. /**
  24661. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24662. */
  24663. static readonly ROTATE_ROW: number;
  24664. /**
  24665. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24666. */
  24667. static readonly FLIP_N_ROTATE_TILE: number;
  24668. /**
  24669. * Mesh pattern setting : rotate pattern and rotate
  24670. */
  24671. static readonly FLIP_N_ROTATE_ROW: number;
  24672. /**
  24673. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24674. */
  24675. static readonly CENTER: number;
  24676. /**
  24677. * Mesh tile positioning : part tiles on left
  24678. */
  24679. static readonly LEFT: number;
  24680. /**
  24681. * Mesh tile positioning : part tiles on right
  24682. */
  24683. static readonly RIGHT: number;
  24684. /**
  24685. * Mesh tile positioning : part tiles on top
  24686. */
  24687. static readonly TOP: number;
  24688. /**
  24689. * Mesh tile positioning : part tiles on bottom
  24690. */
  24691. static readonly BOTTOM: number;
  24692. /**
  24693. * Gets the default side orientation.
  24694. * @param orientation the orientation to value to attempt to get
  24695. * @returns the default orientation
  24696. * @hidden
  24697. */
  24698. static _GetDefaultSideOrientation(orientation?: number): number;
  24699. private _internalMeshDataInfo;
  24700. /**
  24701. * An event triggered before rendering the mesh
  24702. */
  24703. get onBeforeRenderObservable(): Observable<Mesh>;
  24704. /**
  24705. * An event triggered before binding the mesh
  24706. */
  24707. get onBeforeBindObservable(): Observable<Mesh>;
  24708. /**
  24709. * An event triggered after rendering the mesh
  24710. */
  24711. get onAfterRenderObservable(): Observable<Mesh>;
  24712. /**
  24713. * An event triggered before drawing the mesh
  24714. */
  24715. get onBeforeDrawObservable(): Observable<Mesh>;
  24716. private _onBeforeDrawObserver;
  24717. /**
  24718. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24719. */
  24720. set onBeforeDraw(callback: () => void);
  24721. get hasInstances(): boolean;
  24722. /**
  24723. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24724. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24725. */
  24726. delayLoadState: number;
  24727. /**
  24728. * Gets the list of instances created from this mesh
  24729. * it is not supposed to be modified manually.
  24730. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24731. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24732. */
  24733. instances: InstancedMesh[];
  24734. /**
  24735. * Gets the file containing delay loading data for this mesh
  24736. */
  24737. delayLoadingFile: string;
  24738. /** @hidden */
  24739. _binaryInfo: any;
  24740. /**
  24741. * User defined function used to change how LOD level selection is done
  24742. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24743. */
  24744. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24745. /**
  24746. * Gets or sets the morph target manager
  24747. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24748. */
  24749. get morphTargetManager(): Nullable<MorphTargetManager>;
  24750. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24751. /** @hidden */
  24752. _creationDataStorage: Nullable<_CreationDataStorage>;
  24753. /** @hidden */
  24754. _geometry: Nullable<Geometry>;
  24755. /** @hidden */
  24756. _delayInfo: Array<string>;
  24757. /** @hidden */
  24758. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24759. /** @hidden */
  24760. _instanceDataStorage: _InstanceDataStorage;
  24761. private _effectiveMaterial;
  24762. /** @hidden */
  24763. _shouldGenerateFlatShading: boolean;
  24764. /** @hidden */
  24765. _originalBuilderSideOrientation: number;
  24766. /**
  24767. * Use this property to change the original side orientation defined at construction time
  24768. */
  24769. overrideMaterialSideOrientation: Nullable<number>;
  24770. /**
  24771. * Gets the source mesh (the one used to clone this one from)
  24772. */
  24773. get source(): Nullable<Mesh>;
  24774. /**
  24775. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24776. */
  24777. get isUnIndexed(): boolean;
  24778. set isUnIndexed(value: boolean);
  24779. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24780. get worldMatrixInstancedBuffer(): Float32Array;
  24781. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24782. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24783. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24784. /**
  24785. * @constructor
  24786. * @param name The value used by scene.getMeshByName() to do a lookup.
  24787. * @param scene The scene to add this mesh to.
  24788. * @param parent The parent of this mesh, if it has one
  24789. * @param source An optional Mesh from which geometry is shared, cloned.
  24790. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24791. * When false, achieved by calling a clone(), also passing False.
  24792. * This will make creation of children, recursive.
  24793. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24794. */
  24795. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24796. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24797. doNotInstantiate: boolean;
  24798. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24799. /**
  24800. * Gets the class name
  24801. * @returns the string "Mesh".
  24802. */
  24803. getClassName(): string;
  24804. /** @hidden */
  24805. get _isMesh(): boolean;
  24806. /**
  24807. * Returns a description of this mesh
  24808. * @param fullDetails define if full details about this mesh must be used
  24809. * @returns a descriptive string representing this mesh
  24810. */
  24811. toString(fullDetails?: boolean): string;
  24812. /** @hidden */
  24813. _unBindEffect(): void;
  24814. /**
  24815. * Gets a boolean indicating if this mesh has LOD
  24816. */
  24817. get hasLODLevels(): boolean;
  24818. /**
  24819. * Gets the list of MeshLODLevel associated with the current mesh
  24820. * @returns an array of MeshLODLevel
  24821. */
  24822. getLODLevels(): MeshLODLevel[];
  24823. private _sortLODLevels;
  24824. /**
  24825. * Add a mesh as LOD level triggered at the given distance.
  24826. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24827. * @param distance The distance from the center of the object to show this level
  24828. * @param mesh The mesh to be added as LOD level (can be null)
  24829. * @return This mesh (for chaining)
  24830. */
  24831. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24832. /**
  24833. * Returns the LOD level mesh at the passed distance or null if not found.
  24834. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24835. * @param distance The distance from the center of the object to show this level
  24836. * @returns a Mesh or `null`
  24837. */
  24838. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24839. /**
  24840. * Remove a mesh from the LOD array
  24841. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24842. * @param mesh defines the mesh to be removed
  24843. * @return This mesh (for chaining)
  24844. */
  24845. removeLODLevel(mesh: Mesh): Mesh;
  24846. /**
  24847. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24848. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24849. * @param camera defines the camera to use to compute distance
  24850. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24851. * @return This mesh (for chaining)
  24852. */
  24853. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24854. /**
  24855. * Gets the mesh internal Geometry object
  24856. */
  24857. get geometry(): Nullable<Geometry>;
  24858. /**
  24859. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24860. * @returns the total number of vertices
  24861. */
  24862. getTotalVertices(): number;
  24863. /**
  24864. * Returns the content of an associated vertex buffer
  24865. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24866. * - VertexBuffer.PositionKind
  24867. * - VertexBuffer.UVKind
  24868. * - VertexBuffer.UV2Kind
  24869. * - VertexBuffer.UV3Kind
  24870. * - VertexBuffer.UV4Kind
  24871. * - VertexBuffer.UV5Kind
  24872. * - VertexBuffer.UV6Kind
  24873. * - VertexBuffer.ColorKind
  24874. * - VertexBuffer.MatricesIndicesKind
  24875. * - VertexBuffer.MatricesIndicesExtraKind
  24876. * - VertexBuffer.MatricesWeightsKind
  24877. * - VertexBuffer.MatricesWeightsExtraKind
  24878. * @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
  24879. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24880. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24881. */
  24882. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24883. /**
  24884. * Returns the mesh VertexBuffer object from the requested `kind`
  24885. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24886. * - VertexBuffer.PositionKind
  24887. * - VertexBuffer.NormalKind
  24888. * - VertexBuffer.UVKind
  24889. * - VertexBuffer.UV2Kind
  24890. * - VertexBuffer.UV3Kind
  24891. * - VertexBuffer.UV4Kind
  24892. * - VertexBuffer.UV5Kind
  24893. * - VertexBuffer.UV6Kind
  24894. * - VertexBuffer.ColorKind
  24895. * - VertexBuffer.MatricesIndicesKind
  24896. * - VertexBuffer.MatricesIndicesExtraKind
  24897. * - VertexBuffer.MatricesWeightsKind
  24898. * - VertexBuffer.MatricesWeightsExtraKind
  24899. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24900. */
  24901. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24902. /**
  24903. * Tests if a specific vertex buffer is associated with this mesh
  24904. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24905. * - VertexBuffer.PositionKind
  24906. * - VertexBuffer.NormalKind
  24907. * - VertexBuffer.UVKind
  24908. * - VertexBuffer.UV2Kind
  24909. * - VertexBuffer.UV3Kind
  24910. * - VertexBuffer.UV4Kind
  24911. * - VertexBuffer.UV5Kind
  24912. * - VertexBuffer.UV6Kind
  24913. * - VertexBuffer.ColorKind
  24914. * - VertexBuffer.MatricesIndicesKind
  24915. * - VertexBuffer.MatricesIndicesExtraKind
  24916. * - VertexBuffer.MatricesWeightsKind
  24917. * - VertexBuffer.MatricesWeightsExtraKind
  24918. * @returns a boolean
  24919. */
  24920. isVerticesDataPresent(kind: string): boolean;
  24921. /**
  24922. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24923. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24924. * - VertexBuffer.PositionKind
  24925. * - VertexBuffer.UVKind
  24926. * - VertexBuffer.UV2Kind
  24927. * - VertexBuffer.UV3Kind
  24928. * - VertexBuffer.UV4Kind
  24929. * - VertexBuffer.UV5Kind
  24930. * - VertexBuffer.UV6Kind
  24931. * - VertexBuffer.ColorKind
  24932. * - VertexBuffer.MatricesIndicesKind
  24933. * - VertexBuffer.MatricesIndicesExtraKind
  24934. * - VertexBuffer.MatricesWeightsKind
  24935. * - VertexBuffer.MatricesWeightsExtraKind
  24936. * @returns a boolean
  24937. */
  24938. isVertexBufferUpdatable(kind: string): boolean;
  24939. /**
  24940. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24941. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24942. * - VertexBuffer.PositionKind
  24943. * - VertexBuffer.NormalKind
  24944. * - VertexBuffer.UVKind
  24945. * - VertexBuffer.UV2Kind
  24946. * - VertexBuffer.UV3Kind
  24947. * - VertexBuffer.UV4Kind
  24948. * - VertexBuffer.UV5Kind
  24949. * - VertexBuffer.UV6Kind
  24950. * - VertexBuffer.ColorKind
  24951. * - VertexBuffer.MatricesIndicesKind
  24952. * - VertexBuffer.MatricesIndicesExtraKind
  24953. * - VertexBuffer.MatricesWeightsKind
  24954. * - VertexBuffer.MatricesWeightsExtraKind
  24955. * @returns an array of strings
  24956. */
  24957. getVerticesDataKinds(): string[];
  24958. /**
  24959. * Returns a positive integer : the total number of indices in this mesh geometry.
  24960. * @returns the numner of indices or zero if the mesh has no geometry.
  24961. */
  24962. getTotalIndices(): number;
  24963. /**
  24964. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24965. * @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.
  24966. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24967. * @returns the indices array or an empty array if the mesh has no geometry
  24968. */
  24969. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24970. get isBlocked(): boolean;
  24971. /**
  24972. * Determine if the current mesh is ready to be rendered
  24973. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24974. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24975. * @returns true if all associated assets are ready (material, textures, shaders)
  24976. */
  24977. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24978. /**
  24979. * 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.
  24980. */
  24981. get areNormalsFrozen(): boolean;
  24982. /**
  24983. * 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.
  24984. * @returns the current mesh
  24985. */
  24986. freezeNormals(): Mesh;
  24987. /**
  24988. * 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
  24989. * @returns the current mesh
  24990. */
  24991. unfreezeNormals(): Mesh;
  24992. /**
  24993. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24994. */
  24995. set overridenInstanceCount(count: number);
  24996. /** @hidden */
  24997. _preActivate(): Mesh;
  24998. /** @hidden */
  24999. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25000. /** @hidden */
  25001. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25002. /**
  25003. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25004. * This means the mesh underlying bounding box and sphere are recomputed.
  25005. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25006. * @returns the current mesh
  25007. */
  25008. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25009. /** @hidden */
  25010. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25011. /**
  25012. * This function will subdivide the mesh into multiple submeshes
  25013. * @param count defines the expected number of submeshes
  25014. */
  25015. subdivide(count: number): void;
  25016. /**
  25017. * Copy a FloatArray into a specific associated vertex buffer
  25018. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25019. * - VertexBuffer.PositionKind
  25020. * - VertexBuffer.UVKind
  25021. * - VertexBuffer.UV2Kind
  25022. * - VertexBuffer.UV3Kind
  25023. * - VertexBuffer.UV4Kind
  25024. * - VertexBuffer.UV5Kind
  25025. * - VertexBuffer.UV6Kind
  25026. * - VertexBuffer.ColorKind
  25027. * - VertexBuffer.MatricesIndicesKind
  25028. * - VertexBuffer.MatricesIndicesExtraKind
  25029. * - VertexBuffer.MatricesWeightsKind
  25030. * - VertexBuffer.MatricesWeightsExtraKind
  25031. * @param data defines the data source
  25032. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25033. * @param stride defines the data stride size (can be null)
  25034. * @returns the current mesh
  25035. */
  25036. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25037. /**
  25038. * Delete a vertex buffer associated with this mesh
  25039. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25040. * - VertexBuffer.PositionKind
  25041. * - VertexBuffer.UVKind
  25042. * - VertexBuffer.UV2Kind
  25043. * - VertexBuffer.UV3Kind
  25044. * - VertexBuffer.UV4Kind
  25045. * - VertexBuffer.UV5Kind
  25046. * - VertexBuffer.UV6Kind
  25047. * - VertexBuffer.ColorKind
  25048. * - VertexBuffer.MatricesIndicesKind
  25049. * - VertexBuffer.MatricesIndicesExtraKind
  25050. * - VertexBuffer.MatricesWeightsKind
  25051. * - VertexBuffer.MatricesWeightsExtraKind
  25052. */
  25053. removeVerticesData(kind: string): void;
  25054. /**
  25055. * Flags an associated vertex buffer as updatable
  25056. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25057. * - VertexBuffer.PositionKind
  25058. * - VertexBuffer.UVKind
  25059. * - VertexBuffer.UV2Kind
  25060. * - VertexBuffer.UV3Kind
  25061. * - VertexBuffer.UV4Kind
  25062. * - VertexBuffer.UV5Kind
  25063. * - VertexBuffer.UV6Kind
  25064. * - VertexBuffer.ColorKind
  25065. * - VertexBuffer.MatricesIndicesKind
  25066. * - VertexBuffer.MatricesIndicesExtraKind
  25067. * - VertexBuffer.MatricesWeightsKind
  25068. * - VertexBuffer.MatricesWeightsExtraKind
  25069. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25070. */
  25071. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25072. /**
  25073. * Sets the mesh global Vertex Buffer
  25074. * @param buffer defines the buffer to use
  25075. * @returns the current mesh
  25076. */
  25077. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25078. /**
  25079. * Update a specific associated vertex buffer
  25080. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25081. * - VertexBuffer.PositionKind
  25082. * - VertexBuffer.UVKind
  25083. * - VertexBuffer.UV2Kind
  25084. * - VertexBuffer.UV3Kind
  25085. * - VertexBuffer.UV4Kind
  25086. * - VertexBuffer.UV5Kind
  25087. * - VertexBuffer.UV6Kind
  25088. * - VertexBuffer.ColorKind
  25089. * - VertexBuffer.MatricesIndicesKind
  25090. * - VertexBuffer.MatricesIndicesExtraKind
  25091. * - VertexBuffer.MatricesWeightsKind
  25092. * - VertexBuffer.MatricesWeightsExtraKind
  25093. * @param data defines the data source
  25094. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25095. * @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)
  25096. * @returns the current mesh
  25097. */
  25098. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25099. /**
  25100. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25101. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25102. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25103. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25104. * @returns the current mesh
  25105. */
  25106. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25107. /**
  25108. * Creates a un-shared specific occurence of the geometry for the mesh.
  25109. * @returns the current mesh
  25110. */
  25111. makeGeometryUnique(): Mesh;
  25112. /**
  25113. * Set the index buffer of this mesh
  25114. * @param indices defines the source data
  25115. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25116. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25117. * @returns the current mesh
  25118. */
  25119. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25120. /**
  25121. * Update the current index buffer
  25122. * @param indices defines the source data
  25123. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25124. * @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)
  25125. * @returns the current mesh
  25126. */
  25127. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25128. /**
  25129. * Invert the geometry to move from a right handed system to a left handed one.
  25130. * @returns the current mesh
  25131. */
  25132. toLeftHanded(): Mesh;
  25133. /** @hidden */
  25134. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25135. /** @hidden */
  25136. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25137. /**
  25138. * Registers for this mesh a javascript function called just before the rendering process
  25139. * @param func defines the function to call before rendering this mesh
  25140. * @returns the current mesh
  25141. */
  25142. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25143. /**
  25144. * Disposes a previously registered javascript function called before the rendering
  25145. * @param func defines the function to remove
  25146. * @returns the current mesh
  25147. */
  25148. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25149. /**
  25150. * Registers for this mesh a javascript function called just after the rendering is complete
  25151. * @param func defines the function to call after rendering this mesh
  25152. * @returns the current mesh
  25153. */
  25154. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25155. /**
  25156. * Disposes a previously registered javascript function called after the rendering.
  25157. * @param func defines the function to remove
  25158. * @returns the current mesh
  25159. */
  25160. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25161. /** @hidden */
  25162. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25163. /** @hidden */
  25164. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25165. /** @hidden */
  25166. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25167. /** @hidden */
  25168. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25169. /** @hidden */
  25170. _rebuild(): void;
  25171. /** @hidden */
  25172. _freeze(): void;
  25173. /** @hidden */
  25174. _unFreeze(): void;
  25175. /**
  25176. * 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
  25177. * @param subMesh defines the subMesh to render
  25178. * @param enableAlphaMode defines if alpha mode can be changed
  25179. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25180. * @returns the current mesh
  25181. */
  25182. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25183. private _onBeforeDraw;
  25184. /**
  25185. * Renormalize the mesh and patch it up if there are no weights
  25186. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25187. * However in the case of zero weights then we set just a single influence to 1.
  25188. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25189. */
  25190. cleanMatrixWeights(): void;
  25191. private normalizeSkinFourWeights;
  25192. private normalizeSkinWeightsAndExtra;
  25193. /**
  25194. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25195. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25196. * the user know there was an issue with importing the mesh
  25197. * @returns a validation object with skinned, valid and report string
  25198. */
  25199. validateSkinning(): {
  25200. skinned: boolean;
  25201. valid: boolean;
  25202. report: string;
  25203. };
  25204. /** @hidden */
  25205. _checkDelayState(): Mesh;
  25206. private _queueLoad;
  25207. /**
  25208. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25209. * A mesh is in the frustum if its bounding box intersects the frustum
  25210. * @param frustumPlanes defines the frustum to test
  25211. * @returns true if the mesh is in the frustum planes
  25212. */
  25213. isInFrustum(frustumPlanes: Plane[]): boolean;
  25214. /**
  25215. * Sets the mesh material by the material or multiMaterial `id` property
  25216. * @param id is a string identifying the material or the multiMaterial
  25217. * @returns the current mesh
  25218. */
  25219. setMaterialByID(id: string): Mesh;
  25220. /**
  25221. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25222. * @returns an array of IAnimatable
  25223. */
  25224. getAnimatables(): IAnimatable[];
  25225. /**
  25226. * Modifies the mesh geometry according to the passed transformation matrix.
  25227. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25228. * The mesh normals are modified using the same transformation.
  25229. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25230. * @param transform defines the transform matrix to use
  25231. * @see http://doc.babylonjs.com/resources/baking_transformations
  25232. * @returns the current mesh
  25233. */
  25234. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25235. /**
  25236. * Modifies the mesh geometry according to its own current World Matrix.
  25237. * The mesh World Matrix is then reset.
  25238. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25239. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25240. * @see http://doc.babylonjs.com/resources/baking_transformations
  25241. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25242. * @returns the current mesh
  25243. */
  25244. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25245. /** @hidden */
  25246. get _positions(): Nullable<Vector3[]>;
  25247. /** @hidden */
  25248. _resetPointsArrayCache(): Mesh;
  25249. /** @hidden */
  25250. _generatePointsArray(): boolean;
  25251. /**
  25252. * Returns a new Mesh object generated from the current mesh properties.
  25253. * This method must not get confused with createInstance()
  25254. * @param name is a string, the name given to the new mesh
  25255. * @param newParent can be any Node object (default `null`)
  25256. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25257. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25258. * @returns a new mesh
  25259. */
  25260. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25261. /**
  25262. * Releases resources associated with this mesh.
  25263. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25264. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25265. */
  25266. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25267. /** @hidden */
  25268. _disposeInstanceSpecificData(): void;
  25269. /**
  25270. * Modifies the mesh geometry according to a displacement map.
  25271. * 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.
  25272. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25273. * @param url is a string, the URL from the image file is to be downloaded.
  25274. * @param minHeight is the lower limit of the displacement.
  25275. * @param maxHeight is the upper limit of the displacement.
  25276. * @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.
  25277. * @param uvOffset is an optional vector2 used to offset UV.
  25278. * @param uvScale is an optional vector2 used to scale UV.
  25279. * @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.
  25280. * @returns the Mesh.
  25281. */
  25282. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25283. /**
  25284. * Modifies the mesh geometry according to a displacementMap buffer.
  25285. * 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.
  25286. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25287. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25288. * @param heightMapWidth is the width of the buffer image.
  25289. * @param heightMapHeight is the height of the buffer image.
  25290. * @param minHeight is the lower limit of the displacement.
  25291. * @param maxHeight is the upper limit of the displacement.
  25292. * @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.
  25293. * @param uvOffset is an optional vector2 used to offset UV.
  25294. * @param uvScale is an optional vector2 used to scale UV.
  25295. * @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.
  25296. * @returns the Mesh.
  25297. */
  25298. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25299. /**
  25300. * Modify the mesh to get a flat shading rendering.
  25301. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25302. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25303. * @returns current mesh
  25304. */
  25305. convertToFlatShadedMesh(): Mesh;
  25306. /**
  25307. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25308. * In other words, more vertices, no more indices and a single bigger VBO.
  25309. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25310. * @returns current mesh
  25311. */
  25312. convertToUnIndexedMesh(): Mesh;
  25313. /**
  25314. * Inverses facet orientations.
  25315. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25316. * @param flipNormals will also inverts the normals
  25317. * @returns current mesh
  25318. */
  25319. flipFaces(flipNormals?: boolean): Mesh;
  25320. /**
  25321. * Increase the number of facets and hence vertices in a mesh
  25322. * Vertex normals are interpolated from existing vertex normals
  25323. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25324. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25325. */
  25326. increaseVertices(numberPerEdge: number): void;
  25327. /**
  25328. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25329. * This will undo any application of covertToFlatShadedMesh
  25330. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25331. */
  25332. forceSharedVertices(): void;
  25333. /** @hidden */
  25334. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25335. /** @hidden */
  25336. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25337. /**
  25338. * Creates a new InstancedMesh object from the mesh model.
  25339. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25340. * @param name defines the name of the new instance
  25341. * @returns a new InstancedMesh
  25342. */
  25343. createInstance(name: string): InstancedMesh;
  25344. /**
  25345. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25346. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25347. * @returns the current mesh
  25348. */
  25349. synchronizeInstances(): Mesh;
  25350. /**
  25351. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25352. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25353. * This should be used together with the simplification to avoid disappearing triangles.
  25354. * @param successCallback an optional success callback to be called after the optimization finished.
  25355. * @returns the current mesh
  25356. */
  25357. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25358. /**
  25359. * Serialize current mesh
  25360. * @param serializationObject defines the object which will receive the serialization data
  25361. */
  25362. serialize(serializationObject: any): void;
  25363. /** @hidden */
  25364. _syncGeometryWithMorphTargetManager(): void;
  25365. /** @hidden */
  25366. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25367. /**
  25368. * Returns a new Mesh object parsed from the source provided.
  25369. * @param parsedMesh is the source
  25370. * @param scene defines the hosting scene
  25371. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25372. * @returns a new Mesh
  25373. */
  25374. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25375. /**
  25376. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25377. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25378. * @param name defines the name of the mesh to create
  25379. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25380. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25381. * @param closePath creates a seam between the first and the last points of each path of the path array
  25382. * @param offset is taken in account only if the `pathArray` is containing a single path
  25383. * @param scene defines the hosting scene
  25384. * @param updatable defines if the mesh must be flagged as updatable
  25385. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25386. * @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)
  25387. * @returns a new Mesh
  25388. */
  25389. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25390. /**
  25391. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25392. * @param name defines the name of the mesh to create
  25393. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25394. * @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
  25395. * @param scene defines the hosting scene
  25396. * @param updatable defines if the mesh must be flagged as updatable
  25397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25398. * @returns a new Mesh
  25399. */
  25400. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25401. /**
  25402. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25403. * @param name defines the name of the mesh to create
  25404. * @param size sets the size (float) of each box side (default 1)
  25405. * @param scene defines the hosting scene
  25406. * @param updatable defines if the mesh must be flagged as updatable
  25407. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25408. * @returns a new Mesh
  25409. */
  25410. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25411. /**
  25412. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25413. * @param name defines the name of the mesh to create
  25414. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25415. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25416. * @param scene defines the hosting scene
  25417. * @param updatable defines if the mesh must be flagged as updatable
  25418. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25419. * @returns a new Mesh
  25420. */
  25421. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25422. /**
  25423. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25424. * @param name defines the name of the mesh to create
  25425. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25426. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25427. * @param scene defines the hosting scene
  25428. * @returns a new Mesh
  25429. */
  25430. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25431. /**
  25432. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25433. * @param name defines the name of the mesh to create
  25434. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25435. * @param diameterTop set the top cap diameter (floats, default 1)
  25436. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25437. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25438. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25439. * @param scene defines the hosting scene
  25440. * @param updatable defines if the mesh must be flagged as updatable
  25441. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25442. * @returns a new Mesh
  25443. */
  25444. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25445. /**
  25446. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25447. * @param name defines the name of the mesh to create
  25448. * @param diameter sets the diameter size (float) of the torus (default 1)
  25449. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25450. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25451. * @param scene defines the hosting scene
  25452. * @param updatable defines if the mesh must be flagged as updatable
  25453. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25454. * @returns a new Mesh
  25455. */
  25456. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25457. /**
  25458. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25459. * @param name defines the name of the mesh to create
  25460. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25461. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25462. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25463. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25464. * @param p the number of windings on X axis (positive integers, default 2)
  25465. * @param q the number of windings on Y axis (positive integers, default 3)
  25466. * @param scene defines the hosting scene
  25467. * @param updatable defines if the mesh must be flagged as updatable
  25468. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25469. * @returns a new Mesh
  25470. */
  25471. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25472. /**
  25473. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25474. * @param name defines the name of the mesh to create
  25475. * @param points is an array successive Vector3
  25476. * @param scene defines the hosting scene
  25477. * @param updatable defines if the mesh must be flagged as updatable
  25478. * @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).
  25479. * @returns a new Mesh
  25480. */
  25481. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25482. /**
  25483. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25484. * @param name defines the name of the mesh to create
  25485. * @param points is an array successive Vector3
  25486. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25487. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25488. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25489. * @param scene defines the hosting scene
  25490. * @param updatable defines if the mesh must be flagged as updatable
  25491. * @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)
  25492. * @returns a new Mesh
  25493. */
  25494. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25495. /**
  25496. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25497. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25498. * 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.
  25499. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25500. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25501. * Remember you can only change the shape positions, not their number when updating a polygon.
  25502. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25503. * @param name defines the name of the mesh to create
  25504. * @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
  25505. * @param scene defines the hosting scene
  25506. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25507. * @param updatable defines if the mesh must be flagged as updatable
  25508. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25509. * @param earcutInjection can be used to inject your own earcut reference
  25510. * @returns a new Mesh
  25511. */
  25512. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25513. /**
  25514. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25515. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25516. * @param name defines the name of the mesh to create
  25517. * @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
  25518. * @param depth defines the height of extrusion
  25519. * @param scene defines the hosting scene
  25520. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25521. * @param updatable defines if the mesh must be flagged as updatable
  25522. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25523. * @param earcutInjection can be used to inject your own earcut reference
  25524. * @returns a new Mesh
  25525. */
  25526. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25527. /**
  25528. * Creates an extruded shape mesh.
  25529. * 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
  25530. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25531. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25532. * @param name defines the name of the mesh to create
  25533. * @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
  25534. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25535. * @param scale is the value to scale the shape
  25536. * @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
  25537. * @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
  25538. * @param scene defines the hosting scene
  25539. * @param updatable defines if the mesh must be flagged as updatable
  25540. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25541. * @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)
  25542. * @returns a new Mesh
  25543. */
  25544. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25545. /**
  25546. * Creates an custom extruded shape mesh.
  25547. * The custom extrusion is a parametric shape.
  25548. * It has no predefined shape. Its final shape will depend on the input parameters.
  25549. * Please consider using the same method from the MeshBuilder class instead
  25550. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25551. * @param name defines the name of the mesh to create
  25552. * @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
  25553. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25554. * @param scaleFunction is a custom Javascript function called on each path point
  25555. * @param rotationFunction is a custom Javascript function called on each path point
  25556. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25557. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25558. * @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
  25559. * @param scene defines the hosting scene
  25560. * @param updatable defines if the mesh must be flagged as updatable
  25561. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25562. * @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)
  25563. * @returns a new Mesh
  25564. */
  25565. 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;
  25566. /**
  25567. * Creates lathe mesh.
  25568. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25569. * Please consider using the same method from the MeshBuilder class instead
  25570. * @param name defines the name of the mesh to create
  25571. * @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
  25572. * @param radius is the radius value of the lathe
  25573. * @param tessellation is the side number of the lathe.
  25574. * @param scene defines the hosting scene
  25575. * @param updatable defines if the mesh must be flagged as updatable
  25576. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25577. * @returns a new Mesh
  25578. */
  25579. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25580. /**
  25581. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25582. * @param name defines the name of the mesh to create
  25583. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25584. * @param scene defines the hosting scene
  25585. * @param updatable defines if the mesh must be flagged as updatable
  25586. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25587. * @returns a new Mesh
  25588. */
  25589. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25590. /**
  25591. * Creates a ground mesh.
  25592. * Please consider using the same method from the MeshBuilder class instead
  25593. * @param name defines the name of the mesh to create
  25594. * @param width set the width of the ground
  25595. * @param height set the height of the ground
  25596. * @param subdivisions sets the number of subdivisions per side
  25597. * @param scene defines the hosting scene
  25598. * @param updatable defines if the mesh must be flagged as updatable
  25599. * @returns a new Mesh
  25600. */
  25601. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25602. /**
  25603. * Creates a tiled ground mesh.
  25604. * Please consider using the same method from the MeshBuilder class instead
  25605. * @param name defines the name of the mesh to create
  25606. * @param xmin set the ground minimum X coordinate
  25607. * @param zmin set the ground minimum Y coordinate
  25608. * @param xmax set the ground maximum X coordinate
  25609. * @param zmax set the ground maximum Z coordinate
  25610. * @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
  25611. * @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
  25612. * @param scene defines the hosting scene
  25613. * @param updatable defines if the mesh must be flagged as updatable
  25614. * @returns a new Mesh
  25615. */
  25616. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25617. w: number;
  25618. h: number;
  25619. }, precision: {
  25620. w: number;
  25621. h: number;
  25622. }, scene: Scene, updatable?: boolean): Mesh;
  25623. /**
  25624. * Creates a ground mesh from a height map.
  25625. * Please consider using the same method from the MeshBuilder class instead
  25626. * @see http://doc.babylonjs.com/babylon101/height_map
  25627. * @param name defines the name of the mesh to create
  25628. * @param url sets the URL of the height map image resource
  25629. * @param width set the ground width size
  25630. * @param height set the ground height size
  25631. * @param subdivisions sets the number of subdivision per side
  25632. * @param minHeight is the minimum altitude on the ground
  25633. * @param maxHeight is the maximum altitude on the ground
  25634. * @param scene defines the hosting scene
  25635. * @param updatable defines if the mesh must be flagged as updatable
  25636. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25637. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25638. * @returns a new Mesh
  25639. */
  25640. 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;
  25641. /**
  25642. * Creates a tube mesh.
  25643. * The tube is a parametric shape.
  25644. * It has no predefined shape. Its final shape will depend on the input parameters.
  25645. * Please consider using the same method from the MeshBuilder class instead
  25646. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25647. * @param name defines the name of the mesh to create
  25648. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25649. * @param radius sets the tube radius size
  25650. * @param tessellation is the number of sides on the tubular surface
  25651. * @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
  25652. * @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
  25653. * @param scene defines the hosting scene
  25654. * @param updatable defines if the mesh must be flagged as updatable
  25655. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25656. * @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)
  25657. * @returns a new Mesh
  25658. */
  25659. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25660. (i: number, distance: number): number;
  25661. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25662. /**
  25663. * Creates a polyhedron mesh.
  25664. * Please consider using the same method from the MeshBuilder class instead.
  25665. * * 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
  25666. * * The parameter `size` (positive float, default 1) sets the polygon size
  25667. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25668. * * 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`
  25669. * * 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
  25670. * * 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)`)
  25671. * * 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
  25672. * * 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
  25673. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25674. * * 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
  25675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25676. * @param name defines the name of the mesh to create
  25677. * @param options defines the options used to create the mesh
  25678. * @param scene defines the hosting scene
  25679. * @returns a new Mesh
  25680. */
  25681. static CreatePolyhedron(name: string, options: {
  25682. type?: number;
  25683. size?: number;
  25684. sizeX?: number;
  25685. sizeY?: number;
  25686. sizeZ?: number;
  25687. custom?: any;
  25688. faceUV?: Vector4[];
  25689. faceColors?: Color4[];
  25690. updatable?: boolean;
  25691. sideOrientation?: number;
  25692. }, scene: Scene): Mesh;
  25693. /**
  25694. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25695. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25696. * * 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`)
  25697. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25698. * * 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
  25699. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25700. * * 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
  25701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25702. * @param name defines the name of the mesh
  25703. * @param options defines the options used to create the mesh
  25704. * @param scene defines the hosting scene
  25705. * @returns a new Mesh
  25706. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25707. */
  25708. static CreateIcoSphere(name: string, options: {
  25709. radius?: number;
  25710. flat?: boolean;
  25711. subdivisions?: number;
  25712. sideOrientation?: number;
  25713. updatable?: boolean;
  25714. }, scene: Scene): Mesh;
  25715. /**
  25716. * Creates a decal mesh.
  25717. * Please consider using the same method from the MeshBuilder class instead.
  25718. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25719. * @param name defines the name of the mesh
  25720. * @param sourceMesh defines the mesh receiving the decal
  25721. * @param position sets the position of the decal in world coordinates
  25722. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25723. * @param size sets the decal scaling
  25724. * @param angle sets the angle to rotate the decal
  25725. * @returns a new Mesh
  25726. */
  25727. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25728. /**
  25729. * Prepare internal position array for software CPU skinning
  25730. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25731. */
  25732. setPositionsForCPUSkinning(): Float32Array;
  25733. /**
  25734. * Prepare internal normal array for software CPU skinning
  25735. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25736. */
  25737. setNormalsForCPUSkinning(): Float32Array;
  25738. /**
  25739. * Updates the vertex buffer by applying transformation from the bones
  25740. * @param skeleton defines the skeleton to apply to current mesh
  25741. * @returns the current mesh
  25742. */
  25743. applySkeleton(skeleton: Skeleton): Mesh;
  25744. /**
  25745. * 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
  25746. * @param meshes defines the list of meshes to scan
  25747. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25748. */
  25749. static MinMax(meshes: AbstractMesh[]): {
  25750. min: Vector3;
  25751. max: Vector3;
  25752. };
  25753. /**
  25754. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25755. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25756. * @returns a vector3
  25757. */
  25758. static Center(meshesOrMinMaxVector: {
  25759. min: Vector3;
  25760. max: Vector3;
  25761. } | AbstractMesh[]): Vector3;
  25762. /**
  25763. * Merge the array of meshes into a single mesh for performance reasons.
  25764. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25765. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25766. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25767. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25768. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25769. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25770. * @returns a new mesh
  25771. */
  25772. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25773. /** @hidden */
  25774. addInstance(instance: InstancedMesh): void;
  25775. /** @hidden */
  25776. removeInstance(instance: InstancedMesh): void;
  25777. }
  25778. }
  25779. declare module BABYLON {
  25780. /**
  25781. * This is the base class of all the camera used in the application.
  25782. * @see http://doc.babylonjs.com/features/cameras
  25783. */
  25784. export class Camera extends Node {
  25785. /** @hidden */
  25786. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25787. /**
  25788. * This is the default projection mode used by the cameras.
  25789. * It helps recreating a feeling of perspective and better appreciate depth.
  25790. * This is the best way to simulate real life cameras.
  25791. */
  25792. static readonly PERSPECTIVE_CAMERA: number;
  25793. /**
  25794. * This helps creating camera with an orthographic mode.
  25795. * 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.
  25796. */
  25797. static readonly ORTHOGRAPHIC_CAMERA: number;
  25798. /**
  25799. * This is the default FOV mode for perspective cameras.
  25800. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25801. */
  25802. static readonly FOVMODE_VERTICAL_FIXED: number;
  25803. /**
  25804. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25805. */
  25806. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25807. /**
  25808. * This specifies ther is no need for a camera rig.
  25809. * Basically only one eye is rendered corresponding to the camera.
  25810. */
  25811. static readonly RIG_MODE_NONE: number;
  25812. /**
  25813. * Simulates a camera Rig with one blue eye and one red eye.
  25814. * This can be use with 3d blue and red glasses.
  25815. */
  25816. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25817. /**
  25818. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25819. */
  25820. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25821. /**
  25822. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25823. */
  25824. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25825. /**
  25826. * Defines that both eyes of the camera will be rendered over under each other.
  25827. */
  25828. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25829. /**
  25830. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25831. */
  25832. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25833. /**
  25834. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25835. */
  25836. static readonly RIG_MODE_VR: number;
  25837. /**
  25838. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25839. */
  25840. static readonly RIG_MODE_WEBVR: number;
  25841. /**
  25842. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25843. */
  25844. static readonly RIG_MODE_CUSTOM: number;
  25845. /**
  25846. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25847. */
  25848. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25849. /**
  25850. * Define the input manager associated with the camera.
  25851. */
  25852. inputs: CameraInputsManager<Camera>;
  25853. /** @hidden */
  25854. _position: Vector3;
  25855. /**
  25856. * Define the current local position of the camera in the scene
  25857. */
  25858. get position(): Vector3;
  25859. set position(newPosition: Vector3);
  25860. /**
  25861. * The vector the camera should consider as up.
  25862. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25863. */
  25864. upVector: Vector3;
  25865. /**
  25866. * Define the current limit on the left side for an orthographic camera
  25867. * In scene unit
  25868. */
  25869. orthoLeft: Nullable<number>;
  25870. /**
  25871. * Define the current limit on the right side for an orthographic camera
  25872. * In scene unit
  25873. */
  25874. orthoRight: Nullable<number>;
  25875. /**
  25876. * Define the current limit on the bottom side for an orthographic camera
  25877. * In scene unit
  25878. */
  25879. orthoBottom: Nullable<number>;
  25880. /**
  25881. * Define the current limit on the top side for an orthographic camera
  25882. * In scene unit
  25883. */
  25884. orthoTop: Nullable<number>;
  25885. /**
  25886. * Field Of View is set in Radians. (default is 0.8)
  25887. */
  25888. fov: number;
  25889. /**
  25890. * Define the minimum distance the camera can see from.
  25891. * This is important to note that the depth buffer are not infinite and the closer it starts
  25892. * the more your scene might encounter depth fighting issue.
  25893. */
  25894. minZ: number;
  25895. /**
  25896. * Define the maximum distance the camera can see to.
  25897. * This is important to note that the depth buffer are not infinite and the further it end
  25898. * the more your scene might encounter depth fighting issue.
  25899. */
  25900. maxZ: number;
  25901. /**
  25902. * Define the default inertia of the camera.
  25903. * This helps giving a smooth feeling to the camera movement.
  25904. */
  25905. inertia: number;
  25906. /**
  25907. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25908. */
  25909. mode: number;
  25910. /**
  25911. * Define whether the camera is intermediate.
  25912. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25913. */
  25914. isIntermediate: boolean;
  25915. /**
  25916. * Define the viewport of the camera.
  25917. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25918. */
  25919. viewport: Viewport;
  25920. /**
  25921. * Restricts the camera to viewing objects with the same layerMask.
  25922. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25923. */
  25924. layerMask: number;
  25925. /**
  25926. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25927. */
  25928. fovMode: number;
  25929. /**
  25930. * Rig mode of the camera.
  25931. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25932. * This is normally controlled byt the camera themselves as internal use.
  25933. */
  25934. cameraRigMode: number;
  25935. /**
  25936. * Defines the distance between both "eyes" in case of a RIG
  25937. */
  25938. interaxialDistance: number;
  25939. /**
  25940. * Defines if stereoscopic rendering is done side by side or over under.
  25941. */
  25942. isStereoscopicSideBySide: boolean;
  25943. /**
  25944. * 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
  25945. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25946. * else in the scene. (Eg. security camera)
  25947. *
  25948. * 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)
  25949. */
  25950. customRenderTargets: RenderTargetTexture[];
  25951. /**
  25952. * When set, the camera will render to this render target instead of the default canvas
  25953. *
  25954. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25955. */
  25956. outputRenderTarget: Nullable<RenderTargetTexture>;
  25957. /**
  25958. * Observable triggered when the camera view matrix has changed.
  25959. */
  25960. onViewMatrixChangedObservable: Observable<Camera>;
  25961. /**
  25962. * Observable triggered when the camera Projection matrix has changed.
  25963. */
  25964. onProjectionMatrixChangedObservable: Observable<Camera>;
  25965. /**
  25966. * Observable triggered when the inputs have been processed.
  25967. */
  25968. onAfterCheckInputsObservable: Observable<Camera>;
  25969. /**
  25970. * Observable triggered when reset has been called and applied to the camera.
  25971. */
  25972. onRestoreStateObservable: Observable<Camera>;
  25973. /**
  25974. * Is this camera a part of a rig system?
  25975. */
  25976. isRigCamera: boolean;
  25977. /**
  25978. * If isRigCamera set to true this will be set with the parent camera.
  25979. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25980. */
  25981. rigParent?: Camera;
  25982. /** @hidden */
  25983. _cameraRigParams: any;
  25984. /** @hidden */
  25985. _rigCameras: Camera[];
  25986. /** @hidden */
  25987. _rigPostProcess: Nullable<PostProcess>;
  25988. protected _webvrViewMatrix: Matrix;
  25989. /** @hidden */
  25990. _skipRendering: boolean;
  25991. /** @hidden */
  25992. _projectionMatrix: Matrix;
  25993. /** @hidden */
  25994. _postProcesses: Nullable<PostProcess>[];
  25995. /** @hidden */
  25996. _activeMeshes: SmartArray<AbstractMesh>;
  25997. protected _globalPosition: Vector3;
  25998. /** @hidden */
  25999. _computedViewMatrix: Matrix;
  26000. private _doNotComputeProjectionMatrix;
  26001. private _transformMatrix;
  26002. private _frustumPlanes;
  26003. private _refreshFrustumPlanes;
  26004. private _storedFov;
  26005. private _stateStored;
  26006. /**
  26007. * Instantiates a new camera object.
  26008. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26009. * @see http://doc.babylonjs.com/features/cameras
  26010. * @param name Defines the name of the camera in the scene
  26011. * @param position Defines the position of the camera
  26012. * @param scene Defines the scene the camera belongs too
  26013. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26014. */
  26015. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26016. /**
  26017. * Store current camera state (fov, position, etc..)
  26018. * @returns the camera
  26019. */
  26020. storeState(): Camera;
  26021. /**
  26022. * Restores the camera state values if it has been stored. You must call storeState() first
  26023. */
  26024. protected _restoreStateValues(): boolean;
  26025. /**
  26026. * Restored camera state. You must call storeState() first.
  26027. * @returns true if restored and false otherwise
  26028. */
  26029. restoreState(): boolean;
  26030. /**
  26031. * Gets the class name of the camera.
  26032. * @returns the class name
  26033. */
  26034. getClassName(): string;
  26035. /** @hidden */
  26036. readonly _isCamera: boolean;
  26037. /**
  26038. * Gets a string representation of the camera useful for debug purpose.
  26039. * @param fullDetails Defines that a more verboe level of logging is required
  26040. * @returns the string representation
  26041. */
  26042. toString(fullDetails?: boolean): string;
  26043. /**
  26044. * Gets the current world space position of the camera.
  26045. */
  26046. get globalPosition(): Vector3;
  26047. /**
  26048. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26049. * @returns the active meshe list
  26050. */
  26051. getActiveMeshes(): SmartArray<AbstractMesh>;
  26052. /**
  26053. * Check whether a mesh is part of the current active mesh list of the camera
  26054. * @param mesh Defines the mesh to check
  26055. * @returns true if active, false otherwise
  26056. */
  26057. isActiveMesh(mesh: Mesh): boolean;
  26058. /**
  26059. * Is this camera ready to be used/rendered
  26060. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26061. * @return true if the camera is ready
  26062. */
  26063. isReady(completeCheck?: boolean): boolean;
  26064. /** @hidden */
  26065. _initCache(): void;
  26066. /** @hidden */
  26067. _updateCache(ignoreParentClass?: boolean): void;
  26068. /** @hidden */
  26069. _isSynchronized(): boolean;
  26070. /** @hidden */
  26071. _isSynchronizedViewMatrix(): boolean;
  26072. /** @hidden */
  26073. _isSynchronizedProjectionMatrix(): boolean;
  26074. /**
  26075. * Attach the input controls to a specific dom element to get the input from.
  26076. * @param element Defines the element the controls should be listened from
  26077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26078. */
  26079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26080. /**
  26081. * Detach the current controls from the specified dom element.
  26082. * @param element Defines the element to stop listening the inputs from
  26083. */
  26084. detachControl(element: HTMLElement): void;
  26085. /**
  26086. * Update the camera state according to the different inputs gathered during the frame.
  26087. */
  26088. update(): void;
  26089. /** @hidden */
  26090. _checkInputs(): void;
  26091. /** @hidden */
  26092. get rigCameras(): Camera[];
  26093. /**
  26094. * Gets the post process used by the rig cameras
  26095. */
  26096. get rigPostProcess(): Nullable<PostProcess>;
  26097. /**
  26098. * Internal, gets the first post proces.
  26099. * @returns the first post process to be run on this camera.
  26100. */
  26101. _getFirstPostProcess(): Nullable<PostProcess>;
  26102. private _cascadePostProcessesToRigCams;
  26103. /**
  26104. * Attach a post process to the camera.
  26105. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26106. * @param postProcess The post process to attach to the camera
  26107. * @param insertAt The position of the post process in case several of them are in use in the scene
  26108. * @returns the position the post process has been inserted at
  26109. */
  26110. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26111. /**
  26112. * Detach a post process to the camera.
  26113. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26114. * @param postProcess The post process to detach from the camera
  26115. */
  26116. detachPostProcess(postProcess: PostProcess): void;
  26117. /**
  26118. * Gets the current world matrix of the camera
  26119. */
  26120. getWorldMatrix(): Matrix;
  26121. /** @hidden */
  26122. _getViewMatrix(): Matrix;
  26123. /**
  26124. * Gets the current view matrix of the camera.
  26125. * @param force forces the camera to recompute the matrix without looking at the cached state
  26126. * @returns the view matrix
  26127. */
  26128. getViewMatrix(force?: boolean): Matrix;
  26129. /**
  26130. * Freeze the projection matrix.
  26131. * It will prevent the cache check of the camera projection compute and can speed up perf
  26132. * if no parameter of the camera are meant to change
  26133. * @param projection Defines manually a projection if necessary
  26134. */
  26135. freezeProjectionMatrix(projection?: Matrix): void;
  26136. /**
  26137. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26138. */
  26139. unfreezeProjectionMatrix(): void;
  26140. /**
  26141. * Gets the current projection matrix of the camera.
  26142. * @param force forces the camera to recompute the matrix without looking at the cached state
  26143. * @returns the projection matrix
  26144. */
  26145. getProjectionMatrix(force?: boolean): Matrix;
  26146. /**
  26147. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26148. * @returns a Matrix
  26149. */
  26150. getTransformationMatrix(): Matrix;
  26151. private _updateFrustumPlanes;
  26152. /**
  26153. * Checks if a cullable object (mesh...) is in the camera frustum
  26154. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26155. * @param target The object to check
  26156. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26157. * @returns true if the object is in frustum otherwise false
  26158. */
  26159. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26160. /**
  26161. * Checks if a cullable object (mesh...) is in the camera frustum
  26162. * Unlike isInFrustum this cheks the full bounding box
  26163. * @param target The object to check
  26164. * @returns true if the object is in frustum otherwise false
  26165. */
  26166. isCompletelyInFrustum(target: ICullable): boolean;
  26167. /**
  26168. * Gets a ray in the forward direction from the camera.
  26169. * @param length Defines the length of the ray to create
  26170. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26171. * @param origin Defines the start point of the ray which defaults to the camera position
  26172. * @returns the forward ray
  26173. */
  26174. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26175. /**
  26176. * Releases resources associated with this node.
  26177. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26178. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26179. */
  26180. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26181. /** @hidden */
  26182. _isLeftCamera: boolean;
  26183. /**
  26184. * Gets the left camera of a rig setup in case of Rigged Camera
  26185. */
  26186. get isLeftCamera(): boolean;
  26187. /** @hidden */
  26188. _isRightCamera: boolean;
  26189. /**
  26190. * Gets the right camera of a rig setup in case of Rigged Camera
  26191. */
  26192. get isRightCamera(): boolean;
  26193. /**
  26194. * Gets the left camera of a rig setup in case of Rigged Camera
  26195. */
  26196. get leftCamera(): Nullable<FreeCamera>;
  26197. /**
  26198. * Gets the right camera of a rig setup in case of Rigged Camera
  26199. */
  26200. get rightCamera(): Nullable<FreeCamera>;
  26201. /**
  26202. * Gets the left camera target of a rig setup in case of Rigged Camera
  26203. * @returns the target position
  26204. */
  26205. getLeftTarget(): Nullable<Vector3>;
  26206. /**
  26207. * Gets the right camera target of a rig setup in case of Rigged Camera
  26208. * @returns the target position
  26209. */
  26210. getRightTarget(): Nullable<Vector3>;
  26211. /**
  26212. * @hidden
  26213. */
  26214. setCameraRigMode(mode: number, rigParams: any): void;
  26215. /** @hidden */
  26216. static _setStereoscopicRigMode(camera: Camera): void;
  26217. /** @hidden */
  26218. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26219. /** @hidden */
  26220. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26221. /** @hidden */
  26222. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26223. /** @hidden */
  26224. _getVRProjectionMatrix(): Matrix;
  26225. protected _updateCameraRotationMatrix(): void;
  26226. protected _updateWebVRCameraRotationMatrix(): void;
  26227. /**
  26228. * This function MUST be overwritten by the different WebVR cameras available.
  26229. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26230. * @hidden
  26231. */
  26232. _getWebVRProjectionMatrix(): Matrix;
  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. _getWebVRViewMatrix(): Matrix;
  26239. /** @hidden */
  26240. setCameraRigParameter(name: string, value: any): void;
  26241. /**
  26242. * needs to be overridden by children so sub has required properties to be copied
  26243. * @hidden
  26244. */
  26245. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26246. /**
  26247. * May need to be overridden by children
  26248. * @hidden
  26249. */
  26250. _updateRigCameras(): void;
  26251. /** @hidden */
  26252. _setupInputs(): void;
  26253. /**
  26254. * Serialiaze the camera setup to a json represention
  26255. * @returns the JSON representation
  26256. */
  26257. serialize(): any;
  26258. /**
  26259. * Clones the current camera.
  26260. * @param name The cloned camera name
  26261. * @returns the cloned camera
  26262. */
  26263. clone(name: string): Camera;
  26264. /**
  26265. * Gets the direction of the camera relative to a given local axis.
  26266. * @param localAxis Defines the reference axis to provide a relative direction.
  26267. * @return the direction
  26268. */
  26269. getDirection(localAxis: Vector3): Vector3;
  26270. /**
  26271. * Returns the current camera absolute rotation
  26272. */
  26273. get absoluteRotation(): Quaternion;
  26274. /**
  26275. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26276. * @param localAxis Defines the reference axis to provide a relative direction.
  26277. * @param result Defines the vector to store the result in
  26278. */
  26279. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26280. /**
  26281. * Gets a camera constructor for a given camera type
  26282. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26283. * @param name The name of the camera the result will be able to instantiate
  26284. * @param scene The scene the result will construct the camera in
  26285. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26286. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26287. * @returns a factory method to construc the camera
  26288. */
  26289. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26290. /**
  26291. * Compute the world matrix of the camera.
  26292. * @returns the camera world matrix
  26293. */
  26294. computeWorldMatrix(): Matrix;
  26295. /**
  26296. * Parse a JSON and creates the camera from the parsed information
  26297. * @param parsedCamera The JSON to parse
  26298. * @param scene The scene to instantiate the camera in
  26299. * @returns the newly constructed camera
  26300. */
  26301. static Parse(parsedCamera: any, scene: Scene): Camera;
  26302. }
  26303. }
  26304. declare module BABYLON {
  26305. /**
  26306. * Class containing static functions to help procedurally build meshes
  26307. */
  26308. export class DiscBuilder {
  26309. /**
  26310. * Creates a plane polygonal mesh. By default, this is a disc
  26311. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26312. * * 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
  26313. * * 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
  26314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26315. * * 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
  26316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26317. * @param name defines the name of the mesh
  26318. * @param options defines the options used to create the mesh
  26319. * @param scene defines the hosting scene
  26320. * @returns the plane polygonal mesh
  26321. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26322. */
  26323. static CreateDisc(name: string, options: {
  26324. radius?: number;
  26325. tessellation?: number;
  26326. arc?: number;
  26327. updatable?: boolean;
  26328. sideOrientation?: number;
  26329. frontUVs?: Vector4;
  26330. backUVs?: Vector4;
  26331. }, scene?: Nullable<Scene>): Mesh;
  26332. }
  26333. }
  26334. declare module BABYLON {
  26335. /**
  26336. * Options to be used when creating a FresnelParameters.
  26337. */
  26338. export type IFresnelParametersCreationOptions = {
  26339. /**
  26340. * Define the color used on edges (grazing angle)
  26341. */
  26342. leftColor?: Color3;
  26343. /**
  26344. * Define the color used on center
  26345. */
  26346. rightColor?: Color3;
  26347. /**
  26348. * Define bias applied to computed fresnel term
  26349. */
  26350. bias?: number;
  26351. /**
  26352. * Defined the power exponent applied to fresnel term
  26353. */
  26354. power?: number;
  26355. /**
  26356. * Define if the fresnel effect is enable or not.
  26357. */
  26358. isEnabled?: boolean;
  26359. };
  26360. /**
  26361. * Serialized format for FresnelParameters.
  26362. */
  26363. export type IFresnelParametersSerialized = {
  26364. /**
  26365. * Define the color used on edges (grazing angle) [as an array]
  26366. */
  26367. leftColor: number[];
  26368. /**
  26369. * Define the color used on center [as an array]
  26370. */
  26371. rightColor: number[];
  26372. /**
  26373. * Define bias applied to computed fresnel term
  26374. */
  26375. bias: number;
  26376. /**
  26377. * Defined the power exponent applied to fresnel term
  26378. */
  26379. power?: number;
  26380. /**
  26381. * Define if the fresnel effect is enable or not.
  26382. */
  26383. isEnabled: boolean;
  26384. };
  26385. /**
  26386. * This represents all the required information to add a fresnel effect on a material:
  26387. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26388. */
  26389. export class FresnelParameters {
  26390. private _isEnabled;
  26391. /**
  26392. * Define if the fresnel effect is enable or not.
  26393. */
  26394. get isEnabled(): boolean;
  26395. set isEnabled(value: boolean);
  26396. /**
  26397. * Define the color used on edges (grazing angle)
  26398. */
  26399. leftColor: Color3;
  26400. /**
  26401. * Define the color used on center
  26402. */
  26403. rightColor: Color3;
  26404. /**
  26405. * Define bias applied to computed fresnel term
  26406. */
  26407. bias: number;
  26408. /**
  26409. * Defined the power exponent applied to fresnel term
  26410. */
  26411. power: number;
  26412. /**
  26413. * Creates a new FresnelParameters object.
  26414. *
  26415. * @param options provide your own settings to optionally to override defaults
  26416. */
  26417. constructor(options?: IFresnelParametersCreationOptions);
  26418. /**
  26419. * Clones the current fresnel and its valuues
  26420. * @returns a clone fresnel configuration
  26421. */
  26422. clone(): FresnelParameters;
  26423. /**
  26424. * Determines equality between FresnelParameters objects
  26425. * @param otherFresnelParameters defines the second operand
  26426. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26427. */
  26428. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26429. /**
  26430. * Serializes the current fresnel parameters to a JSON representation.
  26431. * @return the JSON serialization
  26432. */
  26433. serialize(): IFresnelParametersSerialized;
  26434. /**
  26435. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26436. * @param parsedFresnelParameters Define the JSON representation
  26437. * @returns the parsed parameters
  26438. */
  26439. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26440. }
  26441. }
  26442. declare module BABYLON {
  26443. /**
  26444. * Base class of materials working in push mode in babylon JS
  26445. * @hidden
  26446. */
  26447. export class PushMaterial extends Material {
  26448. protected _activeEffect: Effect;
  26449. protected _normalMatrix: Matrix;
  26450. /**
  26451. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26452. * This means that the material can keep using a previous shader while a new one is being compiled.
  26453. * This is mostly used when shader parallel compilation is supported (true by default)
  26454. */
  26455. allowShaderHotSwapping: boolean;
  26456. constructor(name: string, scene: Scene);
  26457. getEffect(): Effect;
  26458. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26459. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26460. /**
  26461. * Binds the given world matrix to the active effect
  26462. *
  26463. * @param world the matrix to bind
  26464. */
  26465. bindOnlyWorldMatrix(world: Matrix): void;
  26466. /**
  26467. * Binds the given normal matrix to the active effect
  26468. *
  26469. * @param normalMatrix the matrix to bind
  26470. */
  26471. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26472. bind(world: Matrix, mesh?: Mesh): void;
  26473. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26474. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26475. }
  26476. }
  26477. declare module BABYLON {
  26478. /**
  26479. * This groups all the flags used to control the materials channel.
  26480. */
  26481. export class MaterialFlags {
  26482. private static _DiffuseTextureEnabled;
  26483. /**
  26484. * Are diffuse textures enabled in the application.
  26485. */
  26486. static get DiffuseTextureEnabled(): boolean;
  26487. static set DiffuseTextureEnabled(value: boolean);
  26488. private static _AmbientTextureEnabled;
  26489. /**
  26490. * Are ambient textures enabled in the application.
  26491. */
  26492. static get AmbientTextureEnabled(): boolean;
  26493. static set AmbientTextureEnabled(value: boolean);
  26494. private static _OpacityTextureEnabled;
  26495. /**
  26496. * Are opacity textures enabled in the application.
  26497. */
  26498. static get OpacityTextureEnabled(): boolean;
  26499. static set OpacityTextureEnabled(value: boolean);
  26500. private static _ReflectionTextureEnabled;
  26501. /**
  26502. * Are reflection textures enabled in the application.
  26503. */
  26504. static get ReflectionTextureEnabled(): boolean;
  26505. static set ReflectionTextureEnabled(value: boolean);
  26506. private static _EmissiveTextureEnabled;
  26507. /**
  26508. * Are emissive textures enabled in the application.
  26509. */
  26510. static get EmissiveTextureEnabled(): boolean;
  26511. static set EmissiveTextureEnabled(value: boolean);
  26512. private static _SpecularTextureEnabled;
  26513. /**
  26514. * Are specular textures enabled in the application.
  26515. */
  26516. static get SpecularTextureEnabled(): boolean;
  26517. static set SpecularTextureEnabled(value: boolean);
  26518. private static _BumpTextureEnabled;
  26519. /**
  26520. * Are bump textures enabled in the application.
  26521. */
  26522. static get BumpTextureEnabled(): boolean;
  26523. static set BumpTextureEnabled(value: boolean);
  26524. private static _LightmapTextureEnabled;
  26525. /**
  26526. * Are lightmap textures enabled in the application.
  26527. */
  26528. static get LightmapTextureEnabled(): boolean;
  26529. static set LightmapTextureEnabled(value: boolean);
  26530. private static _RefractionTextureEnabled;
  26531. /**
  26532. * Are refraction textures enabled in the application.
  26533. */
  26534. static get RefractionTextureEnabled(): boolean;
  26535. static set RefractionTextureEnabled(value: boolean);
  26536. private static _ColorGradingTextureEnabled;
  26537. /**
  26538. * Are color grading textures enabled in the application.
  26539. */
  26540. static get ColorGradingTextureEnabled(): boolean;
  26541. static set ColorGradingTextureEnabled(value: boolean);
  26542. private static _FresnelEnabled;
  26543. /**
  26544. * Are fresnels enabled in the application.
  26545. */
  26546. static get FresnelEnabled(): boolean;
  26547. static set FresnelEnabled(value: boolean);
  26548. private static _ClearCoatTextureEnabled;
  26549. /**
  26550. * Are clear coat textures enabled in the application.
  26551. */
  26552. static get ClearCoatTextureEnabled(): boolean;
  26553. static set ClearCoatTextureEnabled(value: boolean);
  26554. private static _ClearCoatBumpTextureEnabled;
  26555. /**
  26556. * Are clear coat bump textures enabled in the application.
  26557. */
  26558. static get ClearCoatBumpTextureEnabled(): boolean;
  26559. static set ClearCoatBumpTextureEnabled(value: boolean);
  26560. private static _ClearCoatTintTextureEnabled;
  26561. /**
  26562. * Are clear coat tint textures enabled in the application.
  26563. */
  26564. static get ClearCoatTintTextureEnabled(): boolean;
  26565. static set ClearCoatTintTextureEnabled(value: boolean);
  26566. private static _SheenTextureEnabled;
  26567. /**
  26568. * Are sheen textures enabled in the application.
  26569. */
  26570. static get SheenTextureEnabled(): boolean;
  26571. static set SheenTextureEnabled(value: boolean);
  26572. private static _AnisotropicTextureEnabled;
  26573. /**
  26574. * Are anisotropic textures enabled in the application.
  26575. */
  26576. static get AnisotropicTextureEnabled(): boolean;
  26577. static set AnisotropicTextureEnabled(value: boolean);
  26578. private static _ThicknessTextureEnabled;
  26579. /**
  26580. * Are thickness textures enabled in the application.
  26581. */
  26582. static get ThicknessTextureEnabled(): boolean;
  26583. static set ThicknessTextureEnabled(value: boolean);
  26584. }
  26585. }
  26586. declare module BABYLON {
  26587. /** @hidden */
  26588. export var defaultFragmentDeclaration: {
  26589. name: string;
  26590. shader: string;
  26591. };
  26592. }
  26593. declare module BABYLON {
  26594. /** @hidden */
  26595. export var defaultUboDeclaration: {
  26596. name: string;
  26597. shader: string;
  26598. };
  26599. }
  26600. declare module BABYLON {
  26601. /** @hidden */
  26602. export var lightFragmentDeclaration: {
  26603. name: string;
  26604. shader: string;
  26605. };
  26606. }
  26607. declare module BABYLON {
  26608. /** @hidden */
  26609. export var lightUboDeclaration: {
  26610. name: string;
  26611. shader: string;
  26612. };
  26613. }
  26614. declare module BABYLON {
  26615. /** @hidden */
  26616. export var lightsFragmentFunctions: {
  26617. name: string;
  26618. shader: string;
  26619. };
  26620. }
  26621. declare module BABYLON {
  26622. /** @hidden */
  26623. export var shadowsFragmentFunctions: {
  26624. name: string;
  26625. shader: string;
  26626. };
  26627. }
  26628. declare module BABYLON {
  26629. /** @hidden */
  26630. export var fresnelFunction: {
  26631. name: string;
  26632. shader: string;
  26633. };
  26634. }
  26635. declare module BABYLON {
  26636. /** @hidden */
  26637. export var reflectionFunction: {
  26638. name: string;
  26639. shader: string;
  26640. };
  26641. }
  26642. declare module BABYLON {
  26643. /** @hidden */
  26644. export var bumpFragmentFunctions: {
  26645. name: string;
  26646. shader: string;
  26647. };
  26648. }
  26649. declare module BABYLON {
  26650. /** @hidden */
  26651. export var logDepthDeclaration: {
  26652. name: string;
  26653. shader: string;
  26654. };
  26655. }
  26656. declare module BABYLON {
  26657. /** @hidden */
  26658. export var bumpFragment: {
  26659. name: string;
  26660. shader: string;
  26661. };
  26662. }
  26663. declare module BABYLON {
  26664. /** @hidden */
  26665. export var depthPrePass: {
  26666. name: string;
  26667. shader: string;
  26668. };
  26669. }
  26670. declare module BABYLON {
  26671. /** @hidden */
  26672. export var lightFragment: {
  26673. name: string;
  26674. shader: string;
  26675. };
  26676. }
  26677. declare module BABYLON {
  26678. /** @hidden */
  26679. export var logDepthFragment: {
  26680. name: string;
  26681. shader: string;
  26682. };
  26683. }
  26684. declare module BABYLON {
  26685. /** @hidden */
  26686. export var defaultPixelShader: {
  26687. name: string;
  26688. shader: string;
  26689. };
  26690. }
  26691. declare module BABYLON {
  26692. /** @hidden */
  26693. export var defaultVertexDeclaration: {
  26694. name: string;
  26695. shader: string;
  26696. };
  26697. }
  26698. declare module BABYLON {
  26699. /** @hidden */
  26700. export var bumpVertexDeclaration: {
  26701. name: string;
  26702. shader: string;
  26703. };
  26704. }
  26705. declare module BABYLON {
  26706. /** @hidden */
  26707. export var bumpVertex: {
  26708. name: string;
  26709. shader: string;
  26710. };
  26711. }
  26712. declare module BABYLON {
  26713. /** @hidden */
  26714. export var fogVertex: {
  26715. name: string;
  26716. shader: string;
  26717. };
  26718. }
  26719. declare module BABYLON {
  26720. /** @hidden */
  26721. export var shadowsVertex: {
  26722. name: string;
  26723. shader: string;
  26724. };
  26725. }
  26726. declare module BABYLON {
  26727. /** @hidden */
  26728. export var pointCloudVertex: {
  26729. name: string;
  26730. shader: string;
  26731. };
  26732. }
  26733. declare module BABYLON {
  26734. /** @hidden */
  26735. export var logDepthVertex: {
  26736. name: string;
  26737. shader: string;
  26738. };
  26739. }
  26740. declare module BABYLON {
  26741. /** @hidden */
  26742. export var defaultVertexShader: {
  26743. name: string;
  26744. shader: string;
  26745. };
  26746. }
  26747. declare module BABYLON {
  26748. /** @hidden */
  26749. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26750. MAINUV1: boolean;
  26751. MAINUV2: boolean;
  26752. DIFFUSE: boolean;
  26753. DIFFUSEDIRECTUV: number;
  26754. AMBIENT: boolean;
  26755. AMBIENTDIRECTUV: number;
  26756. OPACITY: boolean;
  26757. OPACITYDIRECTUV: number;
  26758. OPACITYRGB: boolean;
  26759. REFLECTION: boolean;
  26760. EMISSIVE: boolean;
  26761. EMISSIVEDIRECTUV: number;
  26762. SPECULAR: boolean;
  26763. SPECULARDIRECTUV: number;
  26764. BUMP: boolean;
  26765. BUMPDIRECTUV: number;
  26766. PARALLAX: boolean;
  26767. PARALLAXOCCLUSION: boolean;
  26768. SPECULAROVERALPHA: boolean;
  26769. CLIPPLANE: boolean;
  26770. CLIPPLANE2: boolean;
  26771. CLIPPLANE3: boolean;
  26772. CLIPPLANE4: boolean;
  26773. CLIPPLANE5: boolean;
  26774. CLIPPLANE6: boolean;
  26775. ALPHATEST: boolean;
  26776. DEPTHPREPASS: boolean;
  26777. ALPHAFROMDIFFUSE: boolean;
  26778. POINTSIZE: boolean;
  26779. FOG: boolean;
  26780. SPECULARTERM: boolean;
  26781. DIFFUSEFRESNEL: boolean;
  26782. OPACITYFRESNEL: boolean;
  26783. REFLECTIONFRESNEL: boolean;
  26784. REFRACTIONFRESNEL: boolean;
  26785. EMISSIVEFRESNEL: boolean;
  26786. FRESNEL: boolean;
  26787. NORMAL: boolean;
  26788. UV1: boolean;
  26789. UV2: boolean;
  26790. VERTEXCOLOR: boolean;
  26791. VERTEXALPHA: boolean;
  26792. NUM_BONE_INFLUENCERS: number;
  26793. BonesPerMesh: number;
  26794. BONETEXTURE: boolean;
  26795. INSTANCES: boolean;
  26796. GLOSSINESS: boolean;
  26797. ROUGHNESS: boolean;
  26798. EMISSIVEASILLUMINATION: boolean;
  26799. LINKEMISSIVEWITHDIFFUSE: boolean;
  26800. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26801. LIGHTMAP: boolean;
  26802. LIGHTMAPDIRECTUV: number;
  26803. OBJECTSPACE_NORMALMAP: boolean;
  26804. USELIGHTMAPASSHADOWMAP: boolean;
  26805. REFLECTIONMAP_3D: boolean;
  26806. REFLECTIONMAP_SPHERICAL: boolean;
  26807. REFLECTIONMAP_PLANAR: boolean;
  26808. REFLECTIONMAP_CUBIC: boolean;
  26809. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26810. REFLECTIONMAP_PROJECTION: boolean;
  26811. REFLECTIONMAP_SKYBOX: boolean;
  26812. REFLECTIONMAP_EXPLICIT: boolean;
  26813. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26814. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26815. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26816. INVERTCUBICMAP: boolean;
  26817. LOGARITHMICDEPTH: boolean;
  26818. REFRACTION: boolean;
  26819. REFRACTIONMAP_3D: boolean;
  26820. REFLECTIONOVERALPHA: boolean;
  26821. TWOSIDEDLIGHTING: boolean;
  26822. SHADOWFLOAT: boolean;
  26823. MORPHTARGETS: boolean;
  26824. MORPHTARGETS_NORMAL: boolean;
  26825. MORPHTARGETS_TANGENT: boolean;
  26826. MORPHTARGETS_UV: boolean;
  26827. NUM_MORPH_INFLUENCERS: number;
  26828. NONUNIFORMSCALING: boolean;
  26829. PREMULTIPLYALPHA: boolean;
  26830. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26831. ALPHABLEND: boolean;
  26832. IMAGEPROCESSING: boolean;
  26833. VIGNETTE: boolean;
  26834. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26835. VIGNETTEBLENDMODEOPAQUE: boolean;
  26836. TONEMAPPING: boolean;
  26837. TONEMAPPING_ACES: boolean;
  26838. CONTRAST: boolean;
  26839. COLORCURVES: boolean;
  26840. COLORGRADING: boolean;
  26841. COLORGRADING3D: boolean;
  26842. SAMPLER3DGREENDEPTH: boolean;
  26843. SAMPLER3DBGRMAP: boolean;
  26844. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26845. MULTIVIEW: boolean;
  26846. /**
  26847. * If the reflection texture on this material is in linear color space
  26848. * @hidden
  26849. */
  26850. IS_REFLECTION_LINEAR: boolean;
  26851. /**
  26852. * If the refraction texture on this material is in linear color space
  26853. * @hidden
  26854. */
  26855. IS_REFRACTION_LINEAR: boolean;
  26856. EXPOSURE: boolean;
  26857. constructor();
  26858. setReflectionMode(modeToEnable: string): void;
  26859. }
  26860. /**
  26861. * This is the default material used in Babylon. It is the best trade off between quality
  26862. * and performances.
  26863. * @see http://doc.babylonjs.com/babylon101/materials
  26864. */
  26865. export class StandardMaterial extends PushMaterial {
  26866. private _diffuseTexture;
  26867. /**
  26868. * The basic texture of the material as viewed under a light.
  26869. */
  26870. diffuseTexture: Nullable<BaseTexture>;
  26871. private _ambientTexture;
  26872. /**
  26873. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26874. */
  26875. ambientTexture: Nullable<BaseTexture>;
  26876. private _opacityTexture;
  26877. /**
  26878. * Define the transparency of the material from a texture.
  26879. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26880. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26881. */
  26882. opacityTexture: Nullable<BaseTexture>;
  26883. private _reflectionTexture;
  26884. /**
  26885. * Define the texture used to display the reflection.
  26886. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26887. */
  26888. reflectionTexture: Nullable<BaseTexture>;
  26889. private _emissiveTexture;
  26890. /**
  26891. * Define texture of the material as if self lit.
  26892. * This will be mixed in the final result even in the absence of light.
  26893. */
  26894. emissiveTexture: Nullable<BaseTexture>;
  26895. private _specularTexture;
  26896. /**
  26897. * Define how the color and intensity of the highlight given by the light in the material.
  26898. */
  26899. specularTexture: Nullable<BaseTexture>;
  26900. private _bumpTexture;
  26901. /**
  26902. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26903. * 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.
  26904. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26905. */
  26906. bumpTexture: Nullable<BaseTexture>;
  26907. private _lightmapTexture;
  26908. /**
  26909. * Complex lighting can be computationally expensive to compute at runtime.
  26910. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26911. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26912. */
  26913. lightmapTexture: Nullable<BaseTexture>;
  26914. private _refractionTexture;
  26915. /**
  26916. * Define the texture used to display the refraction.
  26917. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26918. */
  26919. refractionTexture: Nullable<BaseTexture>;
  26920. /**
  26921. * The color of the material lit by the environmental background lighting.
  26922. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26923. */
  26924. ambientColor: Color3;
  26925. /**
  26926. * The basic color of the material as viewed under a light.
  26927. */
  26928. diffuseColor: Color3;
  26929. /**
  26930. * Define how the color and intensity of the highlight given by the light in the material.
  26931. */
  26932. specularColor: Color3;
  26933. /**
  26934. * Define the color of the material as if self lit.
  26935. * This will be mixed in the final result even in the absence of light.
  26936. */
  26937. emissiveColor: Color3;
  26938. /**
  26939. * Defines how sharp are the highlights in the material.
  26940. * The bigger the value the sharper giving a more glossy feeling to the result.
  26941. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26942. */
  26943. specularPower: number;
  26944. private _useAlphaFromDiffuseTexture;
  26945. /**
  26946. * Does the transparency come from the diffuse texture alpha channel.
  26947. */
  26948. useAlphaFromDiffuseTexture: boolean;
  26949. private _useEmissiveAsIllumination;
  26950. /**
  26951. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26952. */
  26953. useEmissiveAsIllumination: boolean;
  26954. private _linkEmissiveWithDiffuse;
  26955. /**
  26956. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26957. * the emissive level when the final color is close to one.
  26958. */
  26959. linkEmissiveWithDiffuse: boolean;
  26960. private _useSpecularOverAlpha;
  26961. /**
  26962. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26963. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26964. */
  26965. useSpecularOverAlpha: boolean;
  26966. private _useReflectionOverAlpha;
  26967. /**
  26968. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26969. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26970. */
  26971. useReflectionOverAlpha: boolean;
  26972. private _disableLighting;
  26973. /**
  26974. * Does lights from the scene impacts this material.
  26975. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26976. */
  26977. disableLighting: boolean;
  26978. private _useObjectSpaceNormalMap;
  26979. /**
  26980. * Allows using an object space normal map (instead of tangent space).
  26981. */
  26982. useObjectSpaceNormalMap: boolean;
  26983. private _useParallax;
  26984. /**
  26985. * Is parallax enabled or not.
  26986. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26987. */
  26988. useParallax: boolean;
  26989. private _useParallaxOcclusion;
  26990. /**
  26991. * Is parallax occlusion enabled or not.
  26992. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26993. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26994. */
  26995. useParallaxOcclusion: boolean;
  26996. /**
  26997. * 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.
  26998. */
  26999. parallaxScaleBias: number;
  27000. private _roughness;
  27001. /**
  27002. * Helps to define how blurry the reflections should appears in the material.
  27003. */
  27004. roughness: number;
  27005. /**
  27006. * In case of refraction, define the value of the index of refraction.
  27007. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27008. */
  27009. indexOfRefraction: number;
  27010. /**
  27011. * Invert the refraction texture alongside the y axis.
  27012. * It can be useful with procedural textures or probe for instance.
  27013. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27014. */
  27015. invertRefractionY: boolean;
  27016. /**
  27017. * Defines the alpha limits in alpha test mode.
  27018. */
  27019. alphaCutOff: number;
  27020. private _useLightmapAsShadowmap;
  27021. /**
  27022. * In case of light mapping, define whether the map contains light or shadow informations.
  27023. */
  27024. useLightmapAsShadowmap: boolean;
  27025. private _diffuseFresnelParameters;
  27026. /**
  27027. * Define the diffuse fresnel parameters of the material.
  27028. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27029. */
  27030. diffuseFresnelParameters: FresnelParameters;
  27031. private _opacityFresnelParameters;
  27032. /**
  27033. * Define the opacity fresnel parameters of the material.
  27034. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27035. */
  27036. opacityFresnelParameters: FresnelParameters;
  27037. private _reflectionFresnelParameters;
  27038. /**
  27039. * Define the reflection fresnel parameters of the material.
  27040. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27041. */
  27042. reflectionFresnelParameters: FresnelParameters;
  27043. private _refractionFresnelParameters;
  27044. /**
  27045. * Define the refraction fresnel parameters of the material.
  27046. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27047. */
  27048. refractionFresnelParameters: FresnelParameters;
  27049. private _emissiveFresnelParameters;
  27050. /**
  27051. * Define the emissive fresnel parameters of the material.
  27052. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27053. */
  27054. emissiveFresnelParameters: FresnelParameters;
  27055. private _useReflectionFresnelFromSpecular;
  27056. /**
  27057. * If true automatically deducts the fresnels values from the material specularity.
  27058. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27059. */
  27060. useReflectionFresnelFromSpecular: boolean;
  27061. private _useGlossinessFromSpecularMapAlpha;
  27062. /**
  27063. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27064. */
  27065. useGlossinessFromSpecularMapAlpha: boolean;
  27066. private _maxSimultaneousLights;
  27067. /**
  27068. * Defines the maximum number of lights that can be used in the material
  27069. */
  27070. maxSimultaneousLights: number;
  27071. private _invertNormalMapX;
  27072. /**
  27073. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27074. */
  27075. invertNormalMapX: boolean;
  27076. private _invertNormalMapY;
  27077. /**
  27078. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27079. */
  27080. invertNormalMapY: boolean;
  27081. private _twoSidedLighting;
  27082. /**
  27083. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27084. */
  27085. twoSidedLighting: boolean;
  27086. /**
  27087. * Default configuration related to image processing available in the standard Material.
  27088. */
  27089. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27090. /**
  27091. * Gets the image processing configuration used either in this material.
  27092. */
  27093. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27094. /**
  27095. * Sets the Default image processing configuration used either in the this material.
  27096. *
  27097. * If sets to null, the scene one is in use.
  27098. */
  27099. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27100. /**
  27101. * Keep track of the image processing observer to allow dispose and replace.
  27102. */
  27103. private _imageProcessingObserver;
  27104. /**
  27105. * Attaches a new image processing configuration to the Standard Material.
  27106. * @param configuration
  27107. */
  27108. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27109. /**
  27110. * Gets wether the color curves effect is enabled.
  27111. */
  27112. get cameraColorCurvesEnabled(): boolean;
  27113. /**
  27114. * Sets wether the color curves effect is enabled.
  27115. */
  27116. set cameraColorCurvesEnabled(value: boolean);
  27117. /**
  27118. * Gets wether the color grading effect is enabled.
  27119. */
  27120. get cameraColorGradingEnabled(): boolean;
  27121. /**
  27122. * Gets wether the color grading effect is enabled.
  27123. */
  27124. set cameraColorGradingEnabled(value: boolean);
  27125. /**
  27126. * Gets wether tonemapping is enabled or not.
  27127. */
  27128. get cameraToneMappingEnabled(): boolean;
  27129. /**
  27130. * Sets wether tonemapping is enabled or not
  27131. */
  27132. set cameraToneMappingEnabled(value: boolean);
  27133. /**
  27134. * The camera exposure used on this material.
  27135. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27136. * This corresponds to a photographic exposure.
  27137. */
  27138. get cameraExposure(): number;
  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. set cameraExposure(value: number);
  27145. /**
  27146. * Gets The camera contrast used on this material.
  27147. */
  27148. get cameraContrast(): number;
  27149. /**
  27150. * Sets The camera contrast used on this material.
  27151. */
  27152. set cameraContrast(value: number);
  27153. /**
  27154. * Gets the Color Grading 2D Lookup Texture.
  27155. */
  27156. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27157. /**
  27158. * Sets the Color Grading 2D Lookup Texture.
  27159. */
  27160. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27161. /**
  27162. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27163. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27164. * 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;
  27165. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27166. */
  27167. get cameraColorCurves(): Nullable<ColorCurves>;
  27168. /**
  27169. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27170. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27171. * 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;
  27172. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27173. */
  27174. set cameraColorCurves(value: Nullable<ColorCurves>);
  27175. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27176. protected _worldViewProjectionMatrix: Matrix;
  27177. protected _globalAmbientColor: Color3;
  27178. protected _useLogarithmicDepth: boolean;
  27179. protected _rebuildInParallel: boolean;
  27180. /**
  27181. * Instantiates a new standard material.
  27182. * This is the default material used in Babylon. It is the best trade off between quality
  27183. * and performances.
  27184. * @see http://doc.babylonjs.com/babylon101/materials
  27185. * @param name Define the name of the material in the scene
  27186. * @param scene Define the scene the material belong to
  27187. */
  27188. constructor(name: string, scene: Scene);
  27189. /**
  27190. * Gets a boolean indicating that current material needs to register RTT
  27191. */
  27192. get hasRenderTargetTextures(): boolean;
  27193. /**
  27194. * Gets the current class name of the material e.g. "StandardMaterial"
  27195. * Mainly use in serialization.
  27196. * @returns the class name
  27197. */
  27198. getClassName(): string;
  27199. /**
  27200. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27201. * You can try switching to logarithmic depth.
  27202. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27203. */
  27204. get useLogarithmicDepth(): boolean;
  27205. set useLogarithmicDepth(value: boolean);
  27206. /**
  27207. * Specifies if the material will require alpha blending
  27208. * @returns a boolean specifying if alpha blending is needed
  27209. */
  27210. needAlphaBlending(): boolean;
  27211. /**
  27212. * Specifies if this material should be rendered in alpha test mode
  27213. * @returns a boolean specifying if an alpha test is needed.
  27214. */
  27215. needAlphaTesting(): boolean;
  27216. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27217. /**
  27218. * Get the texture used for alpha test purpose.
  27219. * @returns the diffuse texture in case of the standard material.
  27220. */
  27221. getAlphaTestTexture(): Nullable<BaseTexture>;
  27222. /**
  27223. * Get if the submesh is ready to be used and all its information available.
  27224. * Child classes can use it to update shaders
  27225. * @param mesh defines the mesh to check
  27226. * @param subMesh defines which submesh to check
  27227. * @param useInstances specifies that instances should be used
  27228. * @returns a boolean indicating that the submesh is ready or not
  27229. */
  27230. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27231. /**
  27232. * Builds the material UBO layouts.
  27233. * Used internally during the effect preparation.
  27234. */
  27235. buildUniformLayout(): void;
  27236. /**
  27237. * Unbinds the material from the mesh
  27238. */
  27239. unbind(): void;
  27240. /**
  27241. * Binds the submesh to this material by preparing the effect and shader to draw
  27242. * @param world defines the world transformation matrix
  27243. * @param mesh defines the mesh containing the submesh
  27244. * @param subMesh defines the submesh to bind the material to
  27245. */
  27246. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27247. /**
  27248. * Get the list of animatables in the material.
  27249. * @returns the list of animatables object used in the material
  27250. */
  27251. getAnimatables(): IAnimatable[];
  27252. /**
  27253. * Gets the active textures from the material
  27254. * @returns an array of textures
  27255. */
  27256. getActiveTextures(): BaseTexture[];
  27257. /**
  27258. * Specifies if the material uses a texture
  27259. * @param texture defines the texture to check against the material
  27260. * @returns a boolean specifying if the material uses the texture
  27261. */
  27262. hasTexture(texture: BaseTexture): boolean;
  27263. /**
  27264. * Disposes the material
  27265. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27266. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27267. */
  27268. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27269. /**
  27270. * Makes a duplicate of the material, and gives it a new name
  27271. * @param name defines the new name for the duplicated material
  27272. * @returns the cloned material
  27273. */
  27274. clone(name: string): StandardMaterial;
  27275. /**
  27276. * Serializes this material in a JSON representation
  27277. * @returns the serialized material object
  27278. */
  27279. serialize(): any;
  27280. /**
  27281. * Creates a standard material from parsed material data
  27282. * @param source defines the JSON representation of the material
  27283. * @param scene defines the hosting scene
  27284. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27285. * @returns a new standard material
  27286. */
  27287. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27288. /**
  27289. * Are diffuse textures enabled in the application.
  27290. */
  27291. static get DiffuseTextureEnabled(): boolean;
  27292. static set DiffuseTextureEnabled(value: boolean);
  27293. /**
  27294. * Are ambient textures enabled in the application.
  27295. */
  27296. static get AmbientTextureEnabled(): boolean;
  27297. static set AmbientTextureEnabled(value: boolean);
  27298. /**
  27299. * Are opacity textures enabled in the application.
  27300. */
  27301. static get OpacityTextureEnabled(): boolean;
  27302. static set OpacityTextureEnabled(value: boolean);
  27303. /**
  27304. * Are reflection textures enabled in the application.
  27305. */
  27306. static get ReflectionTextureEnabled(): boolean;
  27307. static set ReflectionTextureEnabled(value: boolean);
  27308. /**
  27309. * Are emissive textures enabled in the application.
  27310. */
  27311. static get EmissiveTextureEnabled(): boolean;
  27312. static set EmissiveTextureEnabled(value: boolean);
  27313. /**
  27314. * Are specular textures enabled in the application.
  27315. */
  27316. static get SpecularTextureEnabled(): boolean;
  27317. static set SpecularTextureEnabled(value: boolean);
  27318. /**
  27319. * Are bump textures enabled in the application.
  27320. */
  27321. static get BumpTextureEnabled(): boolean;
  27322. static set BumpTextureEnabled(value: boolean);
  27323. /**
  27324. * Are lightmap textures enabled in the application.
  27325. */
  27326. static get LightmapTextureEnabled(): boolean;
  27327. static set LightmapTextureEnabled(value: boolean);
  27328. /**
  27329. * Are refraction textures enabled in the application.
  27330. */
  27331. static get RefractionTextureEnabled(): boolean;
  27332. static set RefractionTextureEnabled(value: boolean);
  27333. /**
  27334. * Are color grading textures enabled in the application.
  27335. */
  27336. static get ColorGradingTextureEnabled(): boolean;
  27337. static set ColorGradingTextureEnabled(value: boolean);
  27338. /**
  27339. * Are fresnels enabled in the application.
  27340. */
  27341. static get FresnelEnabled(): boolean;
  27342. static set FresnelEnabled(value: boolean);
  27343. }
  27344. }
  27345. declare module BABYLON {
  27346. /**
  27347. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27348. *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.
  27349. * The SPS is also a particle system. It provides some methods to manage the particles.
  27350. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27351. *
  27352. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27353. */
  27354. export class SolidParticleSystem implements IDisposable {
  27355. /**
  27356. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27357. * Example : var p = SPS.particles[i];
  27358. */
  27359. particles: SolidParticle[];
  27360. /**
  27361. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27362. */
  27363. nbParticles: number;
  27364. /**
  27365. * If the particles must ever face the camera (default false). Useful for planar particles.
  27366. */
  27367. billboard: boolean;
  27368. /**
  27369. * Recompute normals when adding a shape
  27370. */
  27371. recomputeNormals: boolean;
  27372. /**
  27373. * This a counter ofr your own usage. It's not set by any SPS functions.
  27374. */
  27375. counter: number;
  27376. /**
  27377. * The SPS name. This name is also given to the underlying mesh.
  27378. */
  27379. name: string;
  27380. /**
  27381. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27382. */
  27383. mesh: Mesh;
  27384. /**
  27385. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27386. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27387. */
  27388. vars: any;
  27389. /**
  27390. * This array is populated when the SPS is set as 'pickable'.
  27391. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27392. * Each element of this array is an object `{idx: int, faceId: int}`.
  27393. * `idx` is the picked particle index in the `SPS.particles` array
  27394. * `faceId` is the picked face index counted within this particle.
  27395. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27396. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27397. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27398. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27399. */
  27400. pickedParticles: {
  27401. idx: number;
  27402. faceId: number;
  27403. }[];
  27404. /**
  27405. * This array is populated when the SPS is set as 'pickable'
  27406. * Each key of this array is a submesh index.
  27407. * Each element of this array is a second array defined like this :
  27408. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27409. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27410. * `idx` is the picked particle index in the `SPS.particles` array
  27411. * `faceId` is the picked face index counted within this particle.
  27412. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27413. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27414. */
  27415. pickedBySubMesh: {
  27416. idx: number;
  27417. faceId: number;
  27418. }[][];
  27419. /**
  27420. * This array is populated when `enableDepthSort` is set to true.
  27421. * Each element of this array is an instance of the class DepthSortedParticle.
  27422. */
  27423. depthSortedParticles: DepthSortedParticle[];
  27424. /**
  27425. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27426. * @hidden
  27427. */
  27428. _bSphereOnly: boolean;
  27429. /**
  27430. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27431. * @hidden
  27432. */
  27433. _bSphereRadiusFactor: number;
  27434. private _scene;
  27435. private _positions;
  27436. private _indices;
  27437. private _normals;
  27438. private _colors;
  27439. private _uvs;
  27440. private _indices32;
  27441. private _positions32;
  27442. private _normals32;
  27443. private _fixedNormal32;
  27444. private _colors32;
  27445. private _uvs32;
  27446. private _index;
  27447. private _updatable;
  27448. private _pickable;
  27449. private _isVisibilityBoxLocked;
  27450. private _alwaysVisible;
  27451. private _depthSort;
  27452. private _expandable;
  27453. private _shapeCounter;
  27454. private _copy;
  27455. private _color;
  27456. private _computeParticleColor;
  27457. private _computeParticleTexture;
  27458. private _computeParticleRotation;
  27459. private _computeParticleVertex;
  27460. private _computeBoundingBox;
  27461. private _depthSortParticles;
  27462. private _camera;
  27463. private _mustUnrotateFixedNormals;
  27464. private _particlesIntersect;
  27465. private _needs32Bits;
  27466. private _isNotBuilt;
  27467. private _lastParticleId;
  27468. private _idxOfId;
  27469. private _multimaterialEnabled;
  27470. private _useModelMaterial;
  27471. private _indicesByMaterial;
  27472. private _materialIndexes;
  27473. private _depthSortFunction;
  27474. private _materialSortFunction;
  27475. private _materials;
  27476. private _multimaterial;
  27477. private _materialIndexesById;
  27478. private _defaultMaterial;
  27479. private _autoUpdateSubMeshes;
  27480. /**
  27481. * Creates a SPS (Solid Particle System) object.
  27482. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27483. * @param scene (Scene) is the scene in which the SPS is added.
  27484. * @param options defines the options of the sps e.g.
  27485. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27486. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27487. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27488. * * 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.
  27489. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27490. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27491. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27492. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27493. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27494. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27495. */
  27496. constructor(name: string, scene: Scene, options?: {
  27497. updatable?: boolean;
  27498. isPickable?: boolean;
  27499. enableDepthSort?: boolean;
  27500. particleIntersection?: boolean;
  27501. boundingSphereOnly?: boolean;
  27502. bSphereRadiusFactor?: number;
  27503. expandable?: boolean;
  27504. useModelMaterial?: boolean;
  27505. enableMultiMaterial?: boolean;
  27506. });
  27507. /**
  27508. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27509. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27510. * @returns the created mesh
  27511. */
  27512. buildMesh(): Mesh;
  27513. /**
  27514. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27515. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27516. * Thus the particles generated from `digest()` have their property `position` set yet.
  27517. * @param mesh ( Mesh ) is the mesh to be digested
  27518. * @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
  27519. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27520. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27521. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27522. * @returns the current SPS
  27523. */
  27524. digest(mesh: Mesh, options?: {
  27525. facetNb?: number;
  27526. number?: number;
  27527. delta?: number;
  27528. storage?: [];
  27529. }): SolidParticleSystem;
  27530. /**
  27531. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27532. * @hidden
  27533. */
  27534. private _unrotateFixedNormals;
  27535. /**
  27536. * Resets the temporary working copy particle
  27537. * @hidden
  27538. */
  27539. private _resetCopy;
  27540. /**
  27541. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27542. * @param p the current index in the positions array to be updated
  27543. * @param ind the current index in the indices array
  27544. * @param shape a Vector3 array, the shape geometry
  27545. * @param positions the positions array to be updated
  27546. * @param meshInd the shape indices array
  27547. * @param indices the indices array to be updated
  27548. * @param meshUV the shape uv array
  27549. * @param uvs the uv array to be updated
  27550. * @param meshCol the shape color array
  27551. * @param colors the color array to be updated
  27552. * @param meshNor the shape normals array
  27553. * @param normals the normals array to be updated
  27554. * @param idx the particle index
  27555. * @param idxInShape the particle index in its shape
  27556. * @param options the addShape() method passed options
  27557. * @model the particle model
  27558. * @hidden
  27559. */
  27560. private _meshBuilder;
  27561. /**
  27562. * Returns a shape Vector3 array from positions float array
  27563. * @param positions float array
  27564. * @returns a vector3 array
  27565. * @hidden
  27566. */
  27567. private _posToShape;
  27568. /**
  27569. * Returns a shapeUV array from a float uvs (array deep copy)
  27570. * @param uvs as a float array
  27571. * @returns a shapeUV array
  27572. * @hidden
  27573. */
  27574. private _uvsToShapeUV;
  27575. /**
  27576. * Adds a new particle object in the particles array
  27577. * @param idx particle index in particles array
  27578. * @param id particle id
  27579. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27580. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27581. * @param model particle ModelShape object
  27582. * @param shapeId model shape identifier
  27583. * @param idxInShape index of the particle in the current model
  27584. * @param bInfo model bounding info object
  27585. * @param storage target storage array, if any
  27586. * @hidden
  27587. */
  27588. private _addParticle;
  27589. /**
  27590. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27591. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27592. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27593. * @param nb (positive integer) the number of particles to be created from this model
  27594. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27595. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27596. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27597. * @returns the number of shapes in the system
  27598. */
  27599. addShape(mesh: Mesh, nb: number, options?: {
  27600. positionFunction?: any;
  27601. vertexFunction?: any;
  27602. storage?: [];
  27603. }): number;
  27604. /**
  27605. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27606. * @hidden
  27607. */
  27608. private _rebuildParticle;
  27609. /**
  27610. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27611. * @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.
  27612. * @returns the SPS.
  27613. */
  27614. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27615. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27616. * Returns an array with the removed particles.
  27617. * 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.
  27618. * The SPS can't be empty so at least one particle needs to remain in place.
  27619. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27620. * @param start index of the first particle to remove
  27621. * @param end index of the last particle to remove (included)
  27622. * @returns an array populated with the removed particles
  27623. */
  27624. removeParticles(start: number, end: number): SolidParticle[];
  27625. /**
  27626. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27627. * @param solidParticleArray an array populated with Solid Particles objects
  27628. * @returns the SPS
  27629. */
  27630. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27631. /**
  27632. * Creates a new particle and modifies the SPS mesh geometry :
  27633. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27634. * - calls _addParticle() to populate the particle array
  27635. * factorized code from addShape() and insertParticlesFromArray()
  27636. * @param idx particle index in the particles array
  27637. * @param i particle index in its shape
  27638. * @param modelShape particle ModelShape object
  27639. * @param shape shape vertex array
  27640. * @param meshInd shape indices array
  27641. * @param meshUV shape uv array
  27642. * @param meshCol shape color array
  27643. * @param meshNor shape normals array
  27644. * @param bbInfo shape bounding info
  27645. * @param storage target particle storage
  27646. * @options addShape() passed options
  27647. * @hidden
  27648. */
  27649. private _insertNewParticle;
  27650. /**
  27651. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27652. * This method calls `updateParticle()` for each particle of the SPS.
  27653. * For an animated SPS, it is usually called within the render loop.
  27654. * 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.
  27655. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27656. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27657. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27658. * @returns the SPS.
  27659. */
  27660. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27661. /**
  27662. * Disposes the SPS.
  27663. */
  27664. dispose(): void;
  27665. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27666. * idx is the particle index in the SPS
  27667. * faceId is the picked face index counted within this particle.
  27668. * Returns null if the pickInfo can't identify a picked particle.
  27669. * @param pickingInfo (PickingInfo object)
  27670. * @returns {idx: number, faceId: number} or null
  27671. */
  27672. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27673. idx: number;
  27674. faceId: number;
  27675. }>;
  27676. /**
  27677. * Returns a SolidParticle object from its identifier : particle.id
  27678. * @param id (integer) the particle Id
  27679. * @returns the searched particle or null if not found in the SPS.
  27680. */
  27681. getParticleById(id: number): Nullable<SolidParticle>;
  27682. /**
  27683. * Returns a new array populated with the particles having the passed shapeId.
  27684. * @param shapeId (integer) the shape identifier
  27685. * @returns a new solid particle array
  27686. */
  27687. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27688. /**
  27689. * Populates the passed array "ref" with the particles having the passed shapeId.
  27690. * @param shapeId the shape identifier
  27691. * @returns the SPS
  27692. * @param ref
  27693. */
  27694. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27695. /**
  27696. * Computes the required SubMeshes according the materials assigned to the particles.
  27697. * @returns the solid particle system.
  27698. * Does nothing if called before the SPS mesh is built.
  27699. */
  27700. computeSubMeshes(): SolidParticleSystem;
  27701. /**
  27702. * Sorts the solid particles by material when MultiMaterial is enabled.
  27703. * Updates the indices32 array.
  27704. * Updates the indicesByMaterial array.
  27705. * Updates the mesh indices array.
  27706. * @returns the SPS
  27707. * @hidden
  27708. */
  27709. private _sortParticlesByMaterial;
  27710. /**
  27711. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27712. * @hidden
  27713. */
  27714. private _setMaterialIndexesById;
  27715. /**
  27716. * Returns an array with unique values of Materials from the passed array
  27717. * @param array the material array to be checked and filtered
  27718. * @hidden
  27719. */
  27720. private _filterUniqueMaterialId;
  27721. /**
  27722. * Sets a new Standard Material as _defaultMaterial if not already set.
  27723. * @hidden
  27724. */
  27725. private _setDefaultMaterial;
  27726. /**
  27727. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27728. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27729. * @returns the SPS.
  27730. */
  27731. refreshVisibleSize(): SolidParticleSystem;
  27732. /**
  27733. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27734. * @param size the size (float) of the visibility box
  27735. * note : this doesn't lock the SPS mesh bounding box.
  27736. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27737. */
  27738. setVisibilityBox(size: number): void;
  27739. /**
  27740. * Gets whether the SPS as always visible or not
  27741. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27742. */
  27743. get isAlwaysVisible(): boolean;
  27744. /**
  27745. * Sets the SPS as always visible or not
  27746. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27747. */
  27748. set isAlwaysVisible(val: boolean);
  27749. /**
  27750. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27751. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27752. */
  27753. set isVisibilityBoxLocked(val: boolean);
  27754. /**
  27755. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27756. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27757. */
  27758. get isVisibilityBoxLocked(): boolean;
  27759. /**
  27760. * Tells to `setParticles()` to compute the particle rotations or not.
  27761. * Default value : true. The SPS is faster when it's set to false.
  27762. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27763. */
  27764. set computeParticleRotation(val: boolean);
  27765. /**
  27766. * Tells to `setParticles()` to compute the particle colors or not.
  27767. * Default value : true. The SPS is faster when it's set to false.
  27768. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27769. */
  27770. set computeParticleColor(val: boolean);
  27771. set computeParticleTexture(val: boolean);
  27772. /**
  27773. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27774. * Default value : false. The SPS is faster when it's set to false.
  27775. * Note : the particle custom vertex positions aren't stored values.
  27776. */
  27777. set computeParticleVertex(val: boolean);
  27778. /**
  27779. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27780. */
  27781. set computeBoundingBox(val: boolean);
  27782. /**
  27783. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27784. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27785. * Default : `true`
  27786. */
  27787. set depthSortParticles(val: boolean);
  27788. /**
  27789. * Gets if `setParticles()` computes the particle rotations or not.
  27790. * Default value : true. The SPS is faster when it's set to false.
  27791. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27792. */
  27793. get computeParticleRotation(): boolean;
  27794. /**
  27795. * Gets if `setParticles()` computes the particle colors or not.
  27796. * Default value : true. The SPS is faster when it's set to false.
  27797. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27798. */
  27799. get computeParticleColor(): boolean;
  27800. /**
  27801. * Gets if `setParticles()` computes the particle textures or not.
  27802. * Default value : true. The SPS is faster when it's set to false.
  27803. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27804. */
  27805. get computeParticleTexture(): boolean;
  27806. /**
  27807. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27808. * Default value : false. The SPS is faster when it's set to false.
  27809. * Note : the particle custom vertex positions aren't stored values.
  27810. */
  27811. get computeParticleVertex(): boolean;
  27812. /**
  27813. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27814. */
  27815. get computeBoundingBox(): boolean;
  27816. /**
  27817. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27818. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27819. * Default : `true`
  27820. */
  27821. get depthSortParticles(): boolean;
  27822. /**
  27823. * Gets if the SPS is created as expandable at construction time.
  27824. * Default : `false`
  27825. */
  27826. get expandable(): boolean;
  27827. /**
  27828. * Gets if the SPS supports the Multi Materials
  27829. */
  27830. get multimaterialEnabled(): boolean;
  27831. /**
  27832. * Gets if the SPS uses the model materials for its own multimaterial.
  27833. */
  27834. get useModelMaterial(): boolean;
  27835. /**
  27836. * The SPS used material array.
  27837. */
  27838. get materials(): Material[];
  27839. /**
  27840. * Sets the SPS MultiMaterial from the passed materials.
  27841. * Note : the passed array is internally copied and not used then by reference.
  27842. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27843. */
  27844. setMultiMaterial(materials: Material[]): void;
  27845. /**
  27846. * The SPS computed multimaterial object
  27847. */
  27848. get multimaterial(): MultiMaterial;
  27849. set multimaterial(mm: MultiMaterial);
  27850. /**
  27851. * If the subMeshes must be updated on the next call to setParticles()
  27852. */
  27853. get autoUpdateSubMeshes(): boolean;
  27854. set autoUpdateSubMeshes(val: boolean);
  27855. /**
  27856. * This function does nothing. It may be overwritten to set all the particle first values.
  27857. * The SPS doesn't call this function, you may have to call it by your own.
  27858. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27859. */
  27860. initParticles(): void;
  27861. /**
  27862. * This function does nothing. It may be overwritten to recycle a particle.
  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. * @param particle The particle to recycle
  27866. * @returns the recycled particle
  27867. */
  27868. recycleParticle(particle: SolidParticle): SolidParticle;
  27869. /**
  27870. * Updates a particle : this function should be overwritten by the user.
  27871. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27872. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27873. * @example : just set a particle position or velocity and recycle conditions
  27874. * @param particle The particle to update
  27875. * @returns the updated particle
  27876. */
  27877. updateParticle(particle: SolidParticle): SolidParticle;
  27878. /**
  27879. * Updates a vertex of a particle : it can be overwritten by the user.
  27880. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27881. * @param particle the current particle
  27882. * @param vertex the current index of the current particle
  27883. * @param pt the index of the current vertex in the particle shape
  27884. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27885. * @example : just set a vertex particle position
  27886. * @returns the updated vertex
  27887. */
  27888. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27889. /**
  27890. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27891. * This does nothing and may be overwritten by the user.
  27892. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27893. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27894. * @param update the boolean update value actually passed to setParticles()
  27895. */
  27896. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27897. /**
  27898. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27899. * This will be passed three parameters.
  27900. * This does nothing and may be overwritten by the user.
  27901. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27902. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27903. * @param update the boolean update value actually passed to setParticles()
  27904. */
  27905. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27906. }
  27907. }
  27908. declare module BABYLON {
  27909. /**
  27910. * Represents one particle of a solid particle system.
  27911. */
  27912. export class SolidParticle {
  27913. /**
  27914. * particle global index
  27915. */
  27916. idx: number;
  27917. /**
  27918. * particle identifier
  27919. */
  27920. id: number;
  27921. /**
  27922. * The color of the particle
  27923. */
  27924. color: Nullable<Color4>;
  27925. /**
  27926. * The world space position of the particle.
  27927. */
  27928. position: Vector3;
  27929. /**
  27930. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27931. */
  27932. rotation: Vector3;
  27933. /**
  27934. * The world space rotation quaternion of the particle.
  27935. */
  27936. rotationQuaternion: Nullable<Quaternion>;
  27937. /**
  27938. * The scaling of the particle.
  27939. */
  27940. scaling: Vector3;
  27941. /**
  27942. * The uvs of the particle.
  27943. */
  27944. uvs: Vector4;
  27945. /**
  27946. * The current speed of the particle.
  27947. */
  27948. velocity: Vector3;
  27949. /**
  27950. * The pivot point in the particle local space.
  27951. */
  27952. pivot: Vector3;
  27953. /**
  27954. * Must the particle be translated from its pivot point in its local space ?
  27955. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27956. * Default : false
  27957. */
  27958. translateFromPivot: boolean;
  27959. /**
  27960. * Is the particle active or not ?
  27961. */
  27962. alive: boolean;
  27963. /**
  27964. * Is the particle visible or not ?
  27965. */
  27966. isVisible: boolean;
  27967. /**
  27968. * Index of this particle in the global "positions" array (Internal use)
  27969. * @hidden
  27970. */
  27971. _pos: number;
  27972. /**
  27973. * @hidden Index of this particle in the global "indices" array (Internal use)
  27974. */
  27975. _ind: number;
  27976. /**
  27977. * @hidden ModelShape of this particle (Internal use)
  27978. */
  27979. _model: ModelShape;
  27980. /**
  27981. * ModelShape id of this particle
  27982. */
  27983. shapeId: number;
  27984. /**
  27985. * Index of the particle in its shape id
  27986. */
  27987. idxInShape: number;
  27988. /**
  27989. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27990. */
  27991. _modelBoundingInfo: BoundingInfo;
  27992. /**
  27993. * @hidden Particle BoundingInfo object (Internal use)
  27994. */
  27995. _boundingInfo: BoundingInfo;
  27996. /**
  27997. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27998. */
  27999. _sps: SolidParticleSystem;
  28000. /**
  28001. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28002. */
  28003. _stillInvisible: boolean;
  28004. /**
  28005. * @hidden Last computed particle rotation matrix
  28006. */
  28007. _rotationMatrix: number[];
  28008. /**
  28009. * Parent particle Id, if any.
  28010. * Default null.
  28011. */
  28012. parentId: Nullable<number>;
  28013. /**
  28014. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28015. */
  28016. materialIndex: Nullable<number>;
  28017. /**
  28018. * Custom object or properties.
  28019. */
  28020. props: Nullable<any>;
  28021. /**
  28022. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28023. * The possible values are :
  28024. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28025. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28026. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28027. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28028. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28029. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28030. * */
  28031. cullingStrategy: number;
  28032. /**
  28033. * @hidden Internal global position in the SPS.
  28034. */
  28035. _globalPosition: Vector3;
  28036. /**
  28037. * Creates a Solid Particle object.
  28038. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28039. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28040. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28041. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28042. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28043. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28044. * @param shapeId (integer) is the model shape identifier in the SPS.
  28045. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28046. * @param sps defines the sps it is associated to
  28047. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28048. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28049. */
  28050. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28051. /**
  28052. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28053. * @param target the particle target
  28054. * @returns the current particle
  28055. */
  28056. copyToRef(target: SolidParticle): SolidParticle;
  28057. /**
  28058. * Legacy support, changed scale to scaling
  28059. */
  28060. get scale(): Vector3;
  28061. /**
  28062. * Legacy support, changed scale to scaling
  28063. */
  28064. set scale(scale: Vector3);
  28065. /**
  28066. * Legacy support, changed quaternion to rotationQuaternion
  28067. */
  28068. get quaternion(): Nullable<Quaternion>;
  28069. /**
  28070. * Legacy support, changed quaternion to rotationQuaternion
  28071. */
  28072. set quaternion(q: Nullable<Quaternion>);
  28073. /**
  28074. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28075. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28076. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28077. * @returns true if it intersects
  28078. */
  28079. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28080. /**
  28081. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28082. * A particle is in the frustum if its bounding box intersects the frustum
  28083. * @param frustumPlanes defines the frustum to test
  28084. * @returns true if the particle is in the frustum planes
  28085. */
  28086. isInFrustum(frustumPlanes: Plane[]): boolean;
  28087. /**
  28088. * get the rotation matrix of the particle
  28089. * @hidden
  28090. */
  28091. getRotationMatrix(m: Matrix): void;
  28092. }
  28093. /**
  28094. * Represents the shape of the model used by one particle of a solid particle system.
  28095. * SPS internal tool, don't use it manually.
  28096. */
  28097. export class ModelShape {
  28098. /**
  28099. * The shape id
  28100. * @hidden
  28101. */
  28102. shapeID: number;
  28103. /**
  28104. * flat array of model positions (internal use)
  28105. * @hidden
  28106. */
  28107. _shape: Vector3[];
  28108. /**
  28109. * flat array of model UVs (internal use)
  28110. * @hidden
  28111. */
  28112. _shapeUV: number[];
  28113. /**
  28114. * color array of the model
  28115. * @hidden
  28116. */
  28117. _shapeColors: number[];
  28118. /**
  28119. * indices array of the model
  28120. * @hidden
  28121. */
  28122. _indices: number[];
  28123. /**
  28124. * normals array of the model
  28125. * @hidden
  28126. */
  28127. _normals: number[];
  28128. /**
  28129. * length of the shape in the model indices array (internal use)
  28130. * @hidden
  28131. */
  28132. _indicesLength: number;
  28133. /**
  28134. * Custom position function (internal use)
  28135. * @hidden
  28136. */
  28137. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28138. /**
  28139. * Custom vertex function (internal use)
  28140. * @hidden
  28141. */
  28142. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28143. /**
  28144. * Model material (internal use)
  28145. * @hidden
  28146. */
  28147. _material: Nullable<Material>;
  28148. /**
  28149. * 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.
  28150. * SPS internal tool, don't use it manually.
  28151. * @hidden
  28152. */
  28153. 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>);
  28154. }
  28155. /**
  28156. * Represents a Depth Sorted Particle in the solid particle system.
  28157. * @hidden
  28158. */
  28159. export class DepthSortedParticle {
  28160. /**
  28161. * Particle index
  28162. */
  28163. idx: number;
  28164. /**
  28165. * Index of the particle in the "indices" array
  28166. */
  28167. ind: number;
  28168. /**
  28169. * Length of the particle shape in the "indices" array
  28170. */
  28171. indicesLength: number;
  28172. /**
  28173. * Squared distance from the particle to the camera
  28174. */
  28175. sqDistance: number;
  28176. /**
  28177. * Material index when used with MultiMaterials
  28178. */
  28179. materialIndex: number;
  28180. /**
  28181. * Creates a new sorted particle
  28182. * @param materialIndex
  28183. */
  28184. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28185. }
  28186. }
  28187. declare module BABYLON {
  28188. /**
  28189. * @hidden
  28190. */
  28191. export class _MeshCollisionData {
  28192. _checkCollisions: boolean;
  28193. _collisionMask: number;
  28194. _collisionGroup: number;
  28195. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28196. _collider: Nullable<Collider>;
  28197. _oldPositionForCollisions: Vector3;
  28198. _diffPositionForCollisions: Vector3;
  28199. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28200. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28201. }
  28202. }
  28203. declare module BABYLON {
  28204. /** @hidden */
  28205. class _FacetDataStorage {
  28206. facetPositions: Vector3[];
  28207. facetNormals: Vector3[];
  28208. facetPartitioning: number[][];
  28209. facetNb: number;
  28210. partitioningSubdivisions: number;
  28211. partitioningBBoxRatio: number;
  28212. facetDataEnabled: boolean;
  28213. facetParameters: any;
  28214. bbSize: Vector3;
  28215. subDiv: {
  28216. max: number;
  28217. X: number;
  28218. Y: number;
  28219. Z: number;
  28220. };
  28221. facetDepthSort: boolean;
  28222. facetDepthSortEnabled: boolean;
  28223. depthSortedIndices: IndicesArray;
  28224. depthSortedFacets: {
  28225. ind: number;
  28226. sqDistance: number;
  28227. }[];
  28228. facetDepthSortFunction: (f1: {
  28229. ind: number;
  28230. sqDistance: number;
  28231. }, f2: {
  28232. ind: number;
  28233. sqDistance: number;
  28234. }) => number;
  28235. facetDepthSortFrom: Vector3;
  28236. facetDepthSortOrigin: Vector3;
  28237. invertedMatrix: Matrix;
  28238. }
  28239. /**
  28240. * @hidden
  28241. **/
  28242. class _InternalAbstractMeshDataInfo {
  28243. _hasVertexAlpha: boolean;
  28244. _useVertexColors: boolean;
  28245. _numBoneInfluencers: number;
  28246. _applyFog: boolean;
  28247. _receiveShadows: boolean;
  28248. _facetData: _FacetDataStorage;
  28249. _visibility: number;
  28250. _skeleton: Nullable<Skeleton>;
  28251. _layerMask: number;
  28252. _computeBonesUsingShaders: boolean;
  28253. _isActive: boolean;
  28254. _onlyForInstances: boolean;
  28255. _isActiveIntermediate: boolean;
  28256. _onlyForInstancesIntermediate: boolean;
  28257. _actAsRegularMesh: boolean;
  28258. }
  28259. /**
  28260. * Class used to store all common mesh properties
  28261. */
  28262. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28263. /** No occlusion */
  28264. static OCCLUSION_TYPE_NONE: number;
  28265. /** Occlusion set to optimisitic */
  28266. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28267. /** Occlusion set to strict */
  28268. static OCCLUSION_TYPE_STRICT: number;
  28269. /** Use an accurante occlusion algorithm */
  28270. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28271. /** Use a conservative occlusion algorithm */
  28272. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28273. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28274. * Test order :
  28275. * Is the bounding sphere outside the frustum ?
  28276. * If not, are the bounding box vertices outside the frustum ?
  28277. * It not, then the cullable object is in the frustum.
  28278. */
  28279. static readonly CULLINGSTRATEGY_STANDARD: number;
  28280. /** Culling strategy : Bounding Sphere Only.
  28281. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28282. * It's also less accurate than the standard because some not visible objects can still be selected.
  28283. * Test : is the bounding sphere outside the frustum ?
  28284. * If not, then the cullable object is in the frustum.
  28285. */
  28286. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28287. /** Culling strategy : Optimistic Inclusion.
  28288. * This in an inclusion test first, then the standard exclusion test.
  28289. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28290. * 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.
  28291. * Anyway, it's as accurate as the standard strategy.
  28292. * Test :
  28293. * Is the cullable object bounding sphere center in the frustum ?
  28294. * If not, apply the default culling strategy.
  28295. */
  28296. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28297. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28298. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28299. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28300. * 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.
  28301. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28302. * Test :
  28303. * Is the cullable object bounding sphere center in the frustum ?
  28304. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28305. */
  28306. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28307. /**
  28308. * No billboard
  28309. */
  28310. static get BILLBOARDMODE_NONE(): number;
  28311. /** Billboard on X axis */
  28312. static get BILLBOARDMODE_X(): number;
  28313. /** Billboard on Y axis */
  28314. static get BILLBOARDMODE_Y(): number;
  28315. /** Billboard on Z axis */
  28316. static get BILLBOARDMODE_Z(): number;
  28317. /** Billboard on all axes */
  28318. static get BILLBOARDMODE_ALL(): number;
  28319. /** Billboard on using position instead of orientation */
  28320. static get BILLBOARDMODE_USE_POSITION(): number;
  28321. /** @hidden */
  28322. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28323. /**
  28324. * The culling strategy to use to check whether the mesh must be rendered or not.
  28325. * This value can be changed at any time and will be used on the next render mesh selection.
  28326. * The possible values are :
  28327. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28328. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28329. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28330. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28331. * Please read each static variable documentation to get details about the culling process.
  28332. * */
  28333. cullingStrategy: number;
  28334. /**
  28335. * Gets the number of facets in the mesh
  28336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28337. */
  28338. get facetNb(): number;
  28339. /**
  28340. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28341. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28342. */
  28343. get partitioningSubdivisions(): number;
  28344. set partitioningSubdivisions(nb: number);
  28345. /**
  28346. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28347. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28348. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28349. */
  28350. get partitioningBBoxRatio(): number;
  28351. set partitioningBBoxRatio(ratio: number);
  28352. /**
  28353. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28354. * Works only for updatable meshes.
  28355. * Doesn't work with multi-materials
  28356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28357. */
  28358. get mustDepthSortFacets(): boolean;
  28359. set mustDepthSortFacets(sort: boolean);
  28360. /**
  28361. * The location (Vector3) where the facet depth sort must be computed from.
  28362. * By default, the active camera position.
  28363. * Used only when facet depth sort is enabled
  28364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28365. */
  28366. get facetDepthSortFrom(): Vector3;
  28367. set facetDepthSortFrom(location: Vector3);
  28368. /**
  28369. * gets a boolean indicating if facetData is enabled
  28370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28371. */
  28372. get isFacetDataEnabled(): boolean;
  28373. /** @hidden */
  28374. _updateNonUniformScalingState(value: boolean): boolean;
  28375. /**
  28376. * An event triggered when this mesh collides with another one
  28377. */
  28378. onCollideObservable: Observable<AbstractMesh>;
  28379. /** Set a function to call when this mesh collides with another one */
  28380. set onCollide(callback: () => void);
  28381. /**
  28382. * An event triggered when the collision's position changes
  28383. */
  28384. onCollisionPositionChangeObservable: Observable<Vector3>;
  28385. /** Set a function to call when the collision's position changes */
  28386. set onCollisionPositionChange(callback: () => void);
  28387. /**
  28388. * An event triggered when material is changed
  28389. */
  28390. onMaterialChangedObservable: Observable<AbstractMesh>;
  28391. /**
  28392. * Gets or sets the orientation for POV movement & rotation
  28393. */
  28394. definedFacingForward: boolean;
  28395. /** @hidden */
  28396. _occlusionQuery: Nullable<WebGLQuery>;
  28397. /** @hidden */
  28398. _renderingGroup: Nullable<RenderingGroup>;
  28399. /**
  28400. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28401. */
  28402. get visibility(): number;
  28403. /**
  28404. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28405. */
  28406. set visibility(value: number);
  28407. /** Gets or sets the alpha index used to sort transparent meshes
  28408. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28409. */
  28410. alphaIndex: number;
  28411. /**
  28412. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28413. */
  28414. isVisible: boolean;
  28415. /**
  28416. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28417. */
  28418. isPickable: boolean;
  28419. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28420. showSubMeshesBoundingBox: boolean;
  28421. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28422. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28423. */
  28424. isBlocker: boolean;
  28425. /**
  28426. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28427. */
  28428. enablePointerMoveEvents: boolean;
  28429. /**
  28430. * Specifies the rendering group id for this mesh (0 by default)
  28431. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28432. */
  28433. renderingGroupId: number;
  28434. private _material;
  28435. /** Gets or sets current material */
  28436. get material(): Nullable<Material>;
  28437. set material(value: Nullable<Material>);
  28438. /**
  28439. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28440. * @see http://doc.babylonjs.com/babylon101/shadows
  28441. */
  28442. get receiveShadows(): boolean;
  28443. set receiveShadows(value: boolean);
  28444. /** Defines color to use when rendering outline */
  28445. outlineColor: Color3;
  28446. /** Define width to use when rendering outline */
  28447. outlineWidth: number;
  28448. /** Defines color to use when rendering overlay */
  28449. overlayColor: Color3;
  28450. /** Defines alpha to use when rendering overlay */
  28451. overlayAlpha: number;
  28452. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28453. get hasVertexAlpha(): boolean;
  28454. set hasVertexAlpha(value: boolean);
  28455. /** 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) */
  28456. get useVertexColors(): boolean;
  28457. set useVertexColors(value: boolean);
  28458. /**
  28459. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28460. */
  28461. get computeBonesUsingShaders(): boolean;
  28462. set computeBonesUsingShaders(value: boolean);
  28463. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28464. get numBoneInfluencers(): number;
  28465. set numBoneInfluencers(value: number);
  28466. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28467. get applyFog(): boolean;
  28468. set applyFog(value: boolean);
  28469. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28470. useOctreeForRenderingSelection: boolean;
  28471. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28472. useOctreeForPicking: boolean;
  28473. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28474. useOctreeForCollisions: boolean;
  28475. /**
  28476. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28477. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28478. */
  28479. get layerMask(): number;
  28480. set layerMask(value: number);
  28481. /**
  28482. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28483. */
  28484. alwaysSelectAsActiveMesh: boolean;
  28485. /**
  28486. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28487. */
  28488. doNotSyncBoundingInfo: boolean;
  28489. /**
  28490. * Gets or sets the current action manager
  28491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28492. */
  28493. actionManager: Nullable<AbstractActionManager>;
  28494. private _meshCollisionData;
  28495. /**
  28496. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28497. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28498. */
  28499. ellipsoid: Vector3;
  28500. /**
  28501. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28502. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28503. */
  28504. ellipsoidOffset: Vector3;
  28505. /**
  28506. * Gets or sets a collision mask used to mask collisions (default is -1).
  28507. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28508. */
  28509. get collisionMask(): number;
  28510. set collisionMask(mask: number);
  28511. /**
  28512. * Gets or sets the current collision group mask (-1 by default).
  28513. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28514. */
  28515. get collisionGroup(): number;
  28516. set collisionGroup(mask: number);
  28517. /**
  28518. * Gets or sets current surrounding meshes (null by default).
  28519. *
  28520. * By default collision detection is tested against every mesh in the scene.
  28521. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28522. * meshes will be tested for the collision.
  28523. *
  28524. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28525. */
  28526. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28527. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28528. /**
  28529. * Defines edge width used when edgesRenderer is enabled
  28530. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28531. */
  28532. edgesWidth: number;
  28533. /**
  28534. * Defines edge color used when edgesRenderer is enabled
  28535. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28536. */
  28537. edgesColor: Color4;
  28538. /** @hidden */
  28539. _edgesRenderer: Nullable<IEdgesRenderer>;
  28540. /** @hidden */
  28541. _masterMesh: Nullable<AbstractMesh>;
  28542. /** @hidden */
  28543. _boundingInfo: Nullable<BoundingInfo>;
  28544. /** @hidden */
  28545. _renderId: number;
  28546. /**
  28547. * Gets or sets the list of subMeshes
  28548. * @see http://doc.babylonjs.com/how_to/multi_materials
  28549. */
  28550. subMeshes: SubMesh[];
  28551. /** @hidden */
  28552. _intersectionsInProgress: AbstractMesh[];
  28553. /** @hidden */
  28554. _unIndexed: boolean;
  28555. /** @hidden */
  28556. _lightSources: Light[];
  28557. /** Gets the list of lights affecting that mesh */
  28558. get lightSources(): Light[];
  28559. /** @hidden */
  28560. get _positions(): Nullable<Vector3[]>;
  28561. /** @hidden */
  28562. _waitingData: {
  28563. lods: Nullable<any>;
  28564. actions: Nullable<any>;
  28565. freezeWorldMatrix: Nullable<boolean>;
  28566. };
  28567. /** @hidden */
  28568. _bonesTransformMatrices: Nullable<Float32Array>;
  28569. /** @hidden */
  28570. _transformMatrixTexture: Nullable<RawTexture>;
  28571. /**
  28572. * Gets or sets a skeleton to apply skining transformations
  28573. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28574. */
  28575. set skeleton(value: Nullable<Skeleton>);
  28576. get skeleton(): Nullable<Skeleton>;
  28577. /**
  28578. * An event triggered when the mesh is rebuilt.
  28579. */
  28580. onRebuildObservable: Observable<AbstractMesh>;
  28581. /**
  28582. * Creates a new AbstractMesh
  28583. * @param name defines the name of the mesh
  28584. * @param scene defines the hosting scene
  28585. */
  28586. constructor(name: string, scene?: Nullable<Scene>);
  28587. /**
  28588. * Returns the string "AbstractMesh"
  28589. * @returns "AbstractMesh"
  28590. */
  28591. getClassName(): string;
  28592. /**
  28593. * Gets a string representation of the current mesh
  28594. * @param fullDetails defines a boolean indicating if full details must be included
  28595. * @returns a string representation of the current mesh
  28596. */
  28597. toString(fullDetails?: boolean): string;
  28598. /**
  28599. * @hidden
  28600. */
  28601. protected _getEffectiveParent(): Nullable<Node>;
  28602. /** @hidden */
  28603. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28604. /** @hidden */
  28605. _rebuild(): void;
  28606. /** @hidden */
  28607. _resyncLightSources(): void;
  28608. /** @hidden */
  28609. _resyncLightSource(light: Light): void;
  28610. /** @hidden */
  28611. _unBindEffect(): void;
  28612. /** @hidden */
  28613. _removeLightSource(light: Light, dispose: boolean): void;
  28614. private _markSubMeshesAsDirty;
  28615. /** @hidden */
  28616. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28617. /** @hidden */
  28618. _markSubMeshesAsAttributesDirty(): void;
  28619. /** @hidden */
  28620. _markSubMeshesAsMiscDirty(): void;
  28621. /**
  28622. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28623. */
  28624. get scaling(): Vector3;
  28625. set scaling(newScaling: Vector3);
  28626. /**
  28627. * Returns true if the mesh is blocked. Implemented by child classes
  28628. */
  28629. get isBlocked(): boolean;
  28630. /**
  28631. * Returns the mesh itself by default. Implemented by child classes
  28632. * @param camera defines the camera to use to pick the right LOD level
  28633. * @returns the currentAbstractMesh
  28634. */
  28635. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28636. /**
  28637. * Returns 0 by default. Implemented by child classes
  28638. * @returns an integer
  28639. */
  28640. getTotalVertices(): number;
  28641. /**
  28642. * Returns a positive integer : the total number of indices in this mesh geometry.
  28643. * @returns the numner of indices or zero if the mesh has no geometry.
  28644. */
  28645. getTotalIndices(): number;
  28646. /**
  28647. * Returns null by default. Implemented by child classes
  28648. * @returns null
  28649. */
  28650. getIndices(): Nullable<IndicesArray>;
  28651. /**
  28652. * Returns the array of the requested vertex data kind. Implemented by child classes
  28653. * @param kind defines the vertex data kind to use
  28654. * @returns null
  28655. */
  28656. getVerticesData(kind: string): Nullable<FloatArray>;
  28657. /**
  28658. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28659. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28660. * Note that a new underlying VertexBuffer object is created each call.
  28661. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28662. * @param kind defines vertex data kind:
  28663. * * VertexBuffer.PositionKind
  28664. * * VertexBuffer.UVKind
  28665. * * VertexBuffer.UV2Kind
  28666. * * VertexBuffer.UV3Kind
  28667. * * VertexBuffer.UV4Kind
  28668. * * VertexBuffer.UV5Kind
  28669. * * VertexBuffer.UV6Kind
  28670. * * VertexBuffer.ColorKind
  28671. * * VertexBuffer.MatricesIndicesKind
  28672. * * VertexBuffer.MatricesIndicesExtraKind
  28673. * * VertexBuffer.MatricesWeightsKind
  28674. * * VertexBuffer.MatricesWeightsExtraKind
  28675. * @param data defines the data source
  28676. * @param updatable defines if the data must be flagged as updatable (or static)
  28677. * @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
  28678. * @returns the current mesh
  28679. */
  28680. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28681. /**
  28682. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28683. * If the mesh has no geometry, it is simply returned as it is.
  28684. * @param kind defines vertex data kind:
  28685. * * VertexBuffer.PositionKind
  28686. * * VertexBuffer.UVKind
  28687. * * VertexBuffer.UV2Kind
  28688. * * VertexBuffer.UV3Kind
  28689. * * VertexBuffer.UV4Kind
  28690. * * VertexBuffer.UV5Kind
  28691. * * VertexBuffer.UV6Kind
  28692. * * VertexBuffer.ColorKind
  28693. * * VertexBuffer.MatricesIndicesKind
  28694. * * VertexBuffer.MatricesIndicesExtraKind
  28695. * * VertexBuffer.MatricesWeightsKind
  28696. * * VertexBuffer.MatricesWeightsExtraKind
  28697. * @param data defines the data source
  28698. * @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
  28699. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28700. * @returns the current mesh
  28701. */
  28702. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28703. /**
  28704. * Sets the mesh indices,
  28705. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28706. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28707. * @param totalVertices Defines the total number of vertices
  28708. * @returns the current mesh
  28709. */
  28710. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28711. /**
  28712. * Gets a boolean indicating if specific vertex data is present
  28713. * @param kind defines the vertex data kind to use
  28714. * @returns true is data kind is present
  28715. */
  28716. isVerticesDataPresent(kind: string): boolean;
  28717. /**
  28718. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28719. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28720. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28721. * @returns a BoundingInfo
  28722. */
  28723. getBoundingInfo(): BoundingInfo;
  28724. /**
  28725. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28726. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28727. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28728. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28729. * @returns the current mesh
  28730. */
  28731. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28732. /**
  28733. * Overwrite the current bounding info
  28734. * @param boundingInfo defines the new bounding info
  28735. * @returns the current mesh
  28736. */
  28737. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28738. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28739. get useBones(): boolean;
  28740. /** @hidden */
  28741. _preActivate(): void;
  28742. /** @hidden */
  28743. _preActivateForIntermediateRendering(renderId: number): void;
  28744. /** @hidden */
  28745. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28746. /** @hidden */
  28747. _postActivate(): void;
  28748. /** @hidden */
  28749. _freeze(): void;
  28750. /** @hidden */
  28751. _unFreeze(): void;
  28752. /**
  28753. * Gets the current world matrix
  28754. * @returns a Matrix
  28755. */
  28756. getWorldMatrix(): Matrix;
  28757. /** @hidden */
  28758. _getWorldMatrixDeterminant(): number;
  28759. /**
  28760. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28761. */
  28762. get isAnInstance(): boolean;
  28763. /**
  28764. * Gets a boolean indicating if this mesh has instances
  28765. */
  28766. get hasInstances(): boolean;
  28767. /**
  28768. * Perform relative position change from the point of view of behind the front of the mesh.
  28769. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28770. * Supports definition of mesh facing forward or backward
  28771. * @param amountRight defines the distance on the right axis
  28772. * @param amountUp defines the distance on the up axis
  28773. * @param amountForward defines the distance on the forward axis
  28774. * @returns the current mesh
  28775. */
  28776. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28777. /**
  28778. * Calculate relative position change from the point of view of behind the front of the mesh.
  28779. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28780. * Supports definition of mesh facing forward or backward
  28781. * @param amountRight defines the distance on the right axis
  28782. * @param amountUp defines the distance on the up axis
  28783. * @param amountForward defines the distance on the forward axis
  28784. * @returns the new displacement vector
  28785. */
  28786. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28787. /**
  28788. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28789. * Supports definition of mesh facing forward or backward
  28790. * @param flipBack defines the flip
  28791. * @param twirlClockwise defines the twirl
  28792. * @param tiltRight defines the tilt
  28793. * @returns the current mesh
  28794. */
  28795. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28796. /**
  28797. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28798. * Supports definition of mesh facing forward or backward.
  28799. * @param flipBack defines the flip
  28800. * @param twirlClockwise defines the twirl
  28801. * @param tiltRight defines the tilt
  28802. * @returns the new rotation vector
  28803. */
  28804. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28805. /**
  28806. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28807. * This means the mesh underlying bounding box and sphere are recomputed.
  28808. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28809. * @returns the current mesh
  28810. */
  28811. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28812. /** @hidden */
  28813. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28814. /** @hidden */
  28815. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28816. /** @hidden */
  28817. _updateBoundingInfo(): AbstractMesh;
  28818. /** @hidden */
  28819. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28820. /** @hidden */
  28821. protected _afterComputeWorldMatrix(): void;
  28822. /** @hidden */
  28823. get _effectiveMesh(): AbstractMesh;
  28824. /**
  28825. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28826. * A mesh is in the frustum if its bounding box intersects the frustum
  28827. * @param frustumPlanes defines the frustum to test
  28828. * @returns true if the mesh is in the frustum planes
  28829. */
  28830. isInFrustum(frustumPlanes: Plane[]): boolean;
  28831. /**
  28832. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28833. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28834. * @param frustumPlanes defines the frustum to test
  28835. * @returns true if the mesh is completely in the frustum planes
  28836. */
  28837. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28838. /**
  28839. * True if the mesh intersects another mesh or a SolidParticle object
  28840. * @param mesh defines a target mesh or SolidParticle to test
  28841. * @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)
  28842. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28843. * @returns true if there is an intersection
  28844. */
  28845. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28846. /**
  28847. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28848. * @param point defines the point to test
  28849. * @returns true if there is an intersection
  28850. */
  28851. intersectsPoint(point: Vector3): boolean;
  28852. /**
  28853. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28854. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28855. */
  28856. get checkCollisions(): boolean;
  28857. set checkCollisions(collisionEnabled: boolean);
  28858. /**
  28859. * Gets Collider object used to compute collisions (not physics)
  28860. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28861. */
  28862. get collider(): Nullable<Collider>;
  28863. /**
  28864. * Move the mesh using collision engine
  28865. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28866. * @param displacement defines the requested displacement vector
  28867. * @returns the current mesh
  28868. */
  28869. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28870. private _onCollisionPositionChange;
  28871. /** @hidden */
  28872. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28873. /** @hidden */
  28874. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28875. /** @hidden */
  28876. _checkCollision(collider: Collider): AbstractMesh;
  28877. /** @hidden */
  28878. _generatePointsArray(): boolean;
  28879. /**
  28880. * Checks if the passed Ray intersects with the mesh
  28881. * @param ray defines the ray to use
  28882. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28883. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28884. * @returns the picking info
  28885. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28886. */
  28887. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28888. /**
  28889. * Clones the current mesh
  28890. * @param name defines the mesh name
  28891. * @param newParent defines the new mesh parent
  28892. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28893. * @returns the new mesh
  28894. */
  28895. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28896. /**
  28897. * Disposes all the submeshes of the current meshnp
  28898. * @returns the current mesh
  28899. */
  28900. releaseSubMeshes(): AbstractMesh;
  28901. /**
  28902. * Releases resources associated with this abstract mesh.
  28903. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28904. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28905. */
  28906. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28907. /**
  28908. * Adds the passed mesh as a child to the current mesh
  28909. * @param mesh defines the child mesh
  28910. * @returns the current mesh
  28911. */
  28912. addChild(mesh: AbstractMesh): AbstractMesh;
  28913. /**
  28914. * Removes the passed mesh from the current mesh children list
  28915. * @param mesh defines the child mesh
  28916. * @returns the current mesh
  28917. */
  28918. removeChild(mesh: AbstractMesh): AbstractMesh;
  28919. /** @hidden */
  28920. private _initFacetData;
  28921. /**
  28922. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28923. * This method can be called within the render loop.
  28924. * 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
  28925. * @returns the current mesh
  28926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28927. */
  28928. updateFacetData(): AbstractMesh;
  28929. /**
  28930. * Returns the facetLocalNormals array.
  28931. * The normals are expressed in the mesh local spac
  28932. * @returns an array of Vector3
  28933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28934. */
  28935. getFacetLocalNormals(): Vector3[];
  28936. /**
  28937. * Returns the facetLocalPositions array.
  28938. * The facet positions are expressed in the mesh local space
  28939. * @returns an array of Vector3
  28940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28941. */
  28942. getFacetLocalPositions(): Vector3[];
  28943. /**
  28944. * Returns the facetLocalPartioning array
  28945. * @returns an array of array of numbers
  28946. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28947. */
  28948. getFacetLocalPartitioning(): number[][];
  28949. /**
  28950. * Returns the i-th facet position in the world system.
  28951. * This method allocates a new Vector3 per call
  28952. * @param i defines the facet index
  28953. * @returns a new Vector3
  28954. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28955. */
  28956. getFacetPosition(i: number): Vector3;
  28957. /**
  28958. * Sets the reference Vector3 with the i-th facet position in the world system
  28959. * @param i defines the facet index
  28960. * @param ref defines the target vector
  28961. * @returns the current mesh
  28962. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28963. */
  28964. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28965. /**
  28966. * Returns the i-th facet normal in the world system.
  28967. * This method allocates a new Vector3 per call
  28968. * @param i defines the facet index
  28969. * @returns a new Vector3
  28970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28971. */
  28972. getFacetNormal(i: number): Vector3;
  28973. /**
  28974. * Sets the reference Vector3 with the i-th facet normal in the world system
  28975. * @param i defines the facet index
  28976. * @param ref defines the target vector
  28977. * @returns the current mesh
  28978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28979. */
  28980. getFacetNormalToRef(i: number, ref: Vector3): this;
  28981. /**
  28982. * 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)
  28983. * @param x defines x coordinate
  28984. * @param y defines y coordinate
  28985. * @param z defines z coordinate
  28986. * @returns the array of facet indexes
  28987. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28988. */
  28989. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28990. /**
  28991. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28992. * @param projected sets as the (x,y,z) world projection on the facet
  28993. * @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
  28994. * @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
  28995. * @param x defines x coordinate
  28996. * @param y defines y coordinate
  28997. * @param z defines z coordinate
  28998. * @returns the face index if found (or null instead)
  28999. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29000. */
  29001. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29002. /**
  29003. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29004. * @param projected sets as the (x,y,z) local projection on the facet
  29005. * @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
  29006. * @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
  29007. * @param x defines x coordinate
  29008. * @param y defines y coordinate
  29009. * @param z defines z coordinate
  29010. * @returns the face index if found (or null instead)
  29011. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29012. */
  29013. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29014. /**
  29015. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29016. * @returns the parameters
  29017. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29018. */
  29019. getFacetDataParameters(): any;
  29020. /**
  29021. * Disables the feature FacetData and frees the related memory
  29022. * @returns the current mesh
  29023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29024. */
  29025. disableFacetData(): AbstractMesh;
  29026. /**
  29027. * Updates the AbstractMesh indices array
  29028. * @param indices defines the data source
  29029. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29030. * @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)
  29031. * @returns the current mesh
  29032. */
  29033. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29034. /**
  29035. * Creates new normals data for the mesh
  29036. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29037. * @returns the current mesh
  29038. */
  29039. createNormals(updatable: boolean): AbstractMesh;
  29040. /**
  29041. * Align the mesh with a normal
  29042. * @param normal defines the normal to use
  29043. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29044. * @returns the current mesh
  29045. */
  29046. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29047. /** @hidden */
  29048. _checkOcclusionQuery(): boolean;
  29049. /**
  29050. * Disables the mesh edge rendering mode
  29051. * @returns the currentAbstractMesh
  29052. */
  29053. disableEdgesRendering(): AbstractMesh;
  29054. /**
  29055. * Enables the edge rendering mode on the mesh.
  29056. * This mode makes the mesh edges visible
  29057. * @param epsilon defines the maximal distance between two angles to detect a face
  29058. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29059. * @returns the currentAbstractMesh
  29060. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29061. */
  29062. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29063. }
  29064. }
  29065. declare module BABYLON {
  29066. /**
  29067. * Interface used to define ActionEvent
  29068. */
  29069. export interface IActionEvent {
  29070. /** The mesh or sprite that triggered the action */
  29071. source: any;
  29072. /** The X mouse cursor position at the time of the event */
  29073. pointerX: number;
  29074. /** The Y mouse cursor position at the time of the event */
  29075. pointerY: number;
  29076. /** The mesh that is currently pointed at (can be null) */
  29077. meshUnderPointer: Nullable<AbstractMesh>;
  29078. /** the original (browser) event that triggered the ActionEvent */
  29079. sourceEvent?: any;
  29080. /** additional data for the event */
  29081. additionalData?: any;
  29082. }
  29083. /**
  29084. * ActionEvent is the event being sent when an action is triggered.
  29085. */
  29086. export class ActionEvent implements IActionEvent {
  29087. /** The mesh or sprite that triggered the action */
  29088. source: any;
  29089. /** The X mouse cursor position at the time of the event */
  29090. pointerX: number;
  29091. /** The Y mouse cursor position at the time of the event */
  29092. pointerY: number;
  29093. /** The mesh that is currently pointed at (can be null) */
  29094. meshUnderPointer: Nullable<AbstractMesh>;
  29095. /** the original (browser) event that triggered the ActionEvent */
  29096. sourceEvent?: any;
  29097. /** additional data for the event */
  29098. additionalData?: any;
  29099. /**
  29100. * Creates a new ActionEvent
  29101. * @param source The mesh or sprite that triggered the action
  29102. * @param pointerX The X mouse cursor position at the time of the event
  29103. * @param pointerY The Y mouse cursor position at the time of the event
  29104. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29105. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29106. * @param additionalData additional data for the event
  29107. */
  29108. constructor(
  29109. /** The mesh or sprite that triggered the action */
  29110. source: any,
  29111. /** The X mouse cursor position at the time of the event */
  29112. pointerX: number,
  29113. /** The Y mouse cursor position at the time of the event */
  29114. pointerY: number,
  29115. /** The mesh that is currently pointed at (can be null) */
  29116. meshUnderPointer: Nullable<AbstractMesh>,
  29117. /** the original (browser) event that triggered the ActionEvent */
  29118. sourceEvent?: any,
  29119. /** additional data for the event */
  29120. additionalData?: any);
  29121. /**
  29122. * Helper function to auto-create an ActionEvent from a source mesh.
  29123. * @param source The source mesh that triggered the event
  29124. * @param evt The original (browser) event
  29125. * @param additionalData additional data for the event
  29126. * @returns the new ActionEvent
  29127. */
  29128. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29129. /**
  29130. * Helper function to auto-create an ActionEvent from a source sprite
  29131. * @param source The source sprite that triggered the event
  29132. * @param scene Scene associated with the sprite
  29133. * @param evt The original (browser) event
  29134. * @param additionalData additional data for the event
  29135. * @returns the new ActionEvent
  29136. */
  29137. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29138. /**
  29139. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29140. * @param scene the scene where the event occurred
  29141. * @param evt The original (browser) event
  29142. * @returns the new ActionEvent
  29143. */
  29144. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29145. /**
  29146. * Helper function to auto-create an ActionEvent from a primitive
  29147. * @param prim defines the target primitive
  29148. * @param pointerPos defines the pointer position
  29149. * @param evt The original (browser) event
  29150. * @param additionalData additional data for the event
  29151. * @returns the new ActionEvent
  29152. */
  29153. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29154. }
  29155. }
  29156. declare module BABYLON {
  29157. /**
  29158. * Abstract class used to decouple action Manager from scene and meshes.
  29159. * Do not instantiate.
  29160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29161. */
  29162. export abstract class AbstractActionManager implements IDisposable {
  29163. /** Gets the list of active triggers */
  29164. static Triggers: {
  29165. [key: string]: number;
  29166. };
  29167. /** Gets the cursor to use when hovering items */
  29168. hoverCursor: string;
  29169. /** Gets the list of actions */
  29170. actions: IAction[];
  29171. /**
  29172. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29173. */
  29174. isRecursive: boolean;
  29175. /**
  29176. * Releases all associated resources
  29177. */
  29178. abstract dispose(): void;
  29179. /**
  29180. * Does this action manager has pointer triggers
  29181. */
  29182. abstract get hasPointerTriggers(): boolean;
  29183. /**
  29184. * Does this action manager has pick triggers
  29185. */
  29186. abstract get hasPickTriggers(): boolean;
  29187. /**
  29188. * Process a specific trigger
  29189. * @param trigger defines the trigger to process
  29190. * @param evt defines the event details to be processed
  29191. */
  29192. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29193. /**
  29194. * Does this action manager handles actions of any of the given triggers
  29195. * @param triggers defines the triggers to be tested
  29196. * @return a boolean indicating whether one (or more) of the triggers is handled
  29197. */
  29198. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29199. /**
  29200. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29201. * speed.
  29202. * @param triggerA defines the trigger to be tested
  29203. * @param triggerB defines the trigger to be tested
  29204. * @return a boolean indicating whether one (or more) of the triggers is handled
  29205. */
  29206. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29207. /**
  29208. * Does this action manager handles actions of a given trigger
  29209. * @param trigger defines the trigger to be tested
  29210. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29211. * @return whether the trigger is handled
  29212. */
  29213. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29214. /**
  29215. * Serialize this manager to a JSON object
  29216. * @param name defines the property name to store this manager
  29217. * @returns a JSON representation of this manager
  29218. */
  29219. abstract serialize(name: string): any;
  29220. /**
  29221. * Registers an action to this action manager
  29222. * @param action defines the action to be registered
  29223. * @return the action amended (prepared) after registration
  29224. */
  29225. abstract registerAction(action: IAction): Nullable<IAction>;
  29226. /**
  29227. * Unregisters an action to this action manager
  29228. * @param action defines the action to be unregistered
  29229. * @return a boolean indicating whether the action has been unregistered
  29230. */
  29231. abstract unregisterAction(action: IAction): Boolean;
  29232. /**
  29233. * Does exist one action manager with at least one trigger
  29234. **/
  29235. static get HasTriggers(): boolean;
  29236. /**
  29237. * Does exist one action manager with at least one pick trigger
  29238. **/
  29239. static get HasPickTriggers(): boolean;
  29240. /**
  29241. * Does exist one action manager that handles actions of a given trigger
  29242. * @param trigger defines the trigger to be tested
  29243. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29244. **/
  29245. static HasSpecificTrigger(trigger: number): boolean;
  29246. }
  29247. }
  29248. declare module BABYLON {
  29249. /**
  29250. * Defines how a node can be built from a string name.
  29251. */
  29252. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29253. /**
  29254. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29255. */
  29256. export class Node implements IBehaviorAware<Node> {
  29257. /** @hidden */
  29258. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29259. private static _NodeConstructors;
  29260. /**
  29261. * Add a new node constructor
  29262. * @param type defines the type name of the node to construct
  29263. * @param constructorFunc defines the constructor function
  29264. */
  29265. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29266. /**
  29267. * Returns a node constructor based on type name
  29268. * @param type defines the type name
  29269. * @param name defines the new node name
  29270. * @param scene defines the hosting scene
  29271. * @param options defines optional options to transmit to constructors
  29272. * @returns the new constructor or null
  29273. */
  29274. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29275. /**
  29276. * Gets or sets the name of the node
  29277. */
  29278. name: string;
  29279. /**
  29280. * Gets or sets the id of the node
  29281. */
  29282. id: string;
  29283. /**
  29284. * Gets or sets the unique id of the node
  29285. */
  29286. uniqueId: number;
  29287. /**
  29288. * Gets or sets a string used to store user defined state for the node
  29289. */
  29290. state: string;
  29291. /**
  29292. * Gets or sets an object used to store user defined information for the node
  29293. */
  29294. metadata: any;
  29295. /**
  29296. * For internal use only. Please do not use.
  29297. */
  29298. reservedDataStore: any;
  29299. /**
  29300. * List of inspectable custom properties (used by the Inspector)
  29301. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29302. */
  29303. inspectableCustomProperties: IInspectable[];
  29304. private _doNotSerialize;
  29305. /**
  29306. * Gets or sets a boolean used to define if the node must be serialized
  29307. */
  29308. get doNotSerialize(): boolean;
  29309. set doNotSerialize(value: boolean);
  29310. /** @hidden */
  29311. _isDisposed: boolean;
  29312. /**
  29313. * Gets a list of Animations associated with the node
  29314. */
  29315. animations: Animation[];
  29316. protected _ranges: {
  29317. [name: string]: Nullable<AnimationRange>;
  29318. };
  29319. /**
  29320. * Callback raised when the node is ready to be used
  29321. */
  29322. onReady: Nullable<(node: Node) => void>;
  29323. private _isEnabled;
  29324. private _isParentEnabled;
  29325. private _isReady;
  29326. /** @hidden */
  29327. _currentRenderId: number;
  29328. private _parentUpdateId;
  29329. /** @hidden */
  29330. _childUpdateId: number;
  29331. /** @hidden */
  29332. _waitingParentId: Nullable<string>;
  29333. /** @hidden */
  29334. _scene: Scene;
  29335. /** @hidden */
  29336. _cache: any;
  29337. private _parentNode;
  29338. private _children;
  29339. /** @hidden */
  29340. _worldMatrix: Matrix;
  29341. /** @hidden */
  29342. _worldMatrixDeterminant: number;
  29343. /** @hidden */
  29344. _worldMatrixDeterminantIsDirty: boolean;
  29345. /** @hidden */
  29346. private _sceneRootNodesIndex;
  29347. /**
  29348. * Gets a boolean indicating if the node has been disposed
  29349. * @returns true if the node was disposed
  29350. */
  29351. isDisposed(): boolean;
  29352. /**
  29353. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29354. * @see https://doc.babylonjs.com/how_to/parenting
  29355. */
  29356. set parent(parent: Nullable<Node>);
  29357. get parent(): Nullable<Node>;
  29358. /** @hidden */
  29359. _addToSceneRootNodes(): void;
  29360. /** @hidden */
  29361. _removeFromSceneRootNodes(): void;
  29362. private _animationPropertiesOverride;
  29363. /**
  29364. * Gets or sets the animation properties override
  29365. */
  29366. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29367. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29368. /**
  29369. * Gets a string idenfifying the name of the class
  29370. * @returns "Node" string
  29371. */
  29372. getClassName(): string;
  29373. /** @hidden */
  29374. readonly _isNode: boolean;
  29375. /**
  29376. * An event triggered when the mesh is disposed
  29377. */
  29378. onDisposeObservable: Observable<Node>;
  29379. private _onDisposeObserver;
  29380. /**
  29381. * Sets a callback that will be raised when the node will be disposed
  29382. */
  29383. set onDispose(callback: () => void);
  29384. /**
  29385. * Creates a new Node
  29386. * @param name the name and id to be given to this node
  29387. * @param scene the scene this node will be added to
  29388. */
  29389. constructor(name: string, scene?: Nullable<Scene>);
  29390. /**
  29391. * Gets the scene of the node
  29392. * @returns a scene
  29393. */
  29394. getScene(): Scene;
  29395. /**
  29396. * Gets the engine of the node
  29397. * @returns a Engine
  29398. */
  29399. getEngine(): Engine;
  29400. private _behaviors;
  29401. /**
  29402. * Attach a behavior to the node
  29403. * @see http://doc.babylonjs.com/features/behaviour
  29404. * @param behavior defines the behavior to attach
  29405. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29406. * @returns the current Node
  29407. */
  29408. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29409. /**
  29410. * Remove an attached behavior
  29411. * @see http://doc.babylonjs.com/features/behaviour
  29412. * @param behavior defines the behavior to attach
  29413. * @returns the current Node
  29414. */
  29415. removeBehavior(behavior: Behavior<Node>): Node;
  29416. /**
  29417. * Gets the list of attached behaviors
  29418. * @see http://doc.babylonjs.com/features/behaviour
  29419. */
  29420. get behaviors(): Behavior<Node>[];
  29421. /**
  29422. * Gets an attached behavior by name
  29423. * @param name defines the name of the behavior to look for
  29424. * @see http://doc.babylonjs.com/features/behaviour
  29425. * @returns null if behavior was not found else the requested behavior
  29426. */
  29427. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29428. /**
  29429. * Returns the latest update of the World matrix
  29430. * @returns a Matrix
  29431. */
  29432. getWorldMatrix(): Matrix;
  29433. /** @hidden */
  29434. _getWorldMatrixDeterminant(): number;
  29435. /**
  29436. * Returns directly the latest state of the mesh World matrix.
  29437. * A Matrix is returned.
  29438. */
  29439. get worldMatrixFromCache(): Matrix;
  29440. /** @hidden */
  29441. _initCache(): void;
  29442. /** @hidden */
  29443. updateCache(force?: boolean): void;
  29444. /** @hidden */
  29445. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29446. /** @hidden */
  29447. _updateCache(ignoreParentClass?: boolean): void;
  29448. /** @hidden */
  29449. _isSynchronized(): boolean;
  29450. /** @hidden */
  29451. _markSyncedWithParent(): void;
  29452. /** @hidden */
  29453. isSynchronizedWithParent(): boolean;
  29454. /** @hidden */
  29455. isSynchronized(): boolean;
  29456. /**
  29457. * Is this node ready to be used/rendered
  29458. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29459. * @return true if the node is ready
  29460. */
  29461. isReady(completeCheck?: boolean): boolean;
  29462. /**
  29463. * Is this node enabled?
  29464. * 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
  29465. * @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
  29466. * @return whether this node (and its parent) is enabled
  29467. */
  29468. isEnabled(checkAncestors?: boolean): boolean;
  29469. /** @hidden */
  29470. protected _syncParentEnabledState(): void;
  29471. /**
  29472. * Set the enabled state of this node
  29473. * @param value defines the new enabled state
  29474. */
  29475. setEnabled(value: boolean): void;
  29476. /**
  29477. * Is this node a descendant of the given node?
  29478. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29479. * @param ancestor defines the parent node to inspect
  29480. * @returns a boolean indicating if this node is a descendant of the given node
  29481. */
  29482. isDescendantOf(ancestor: Node): boolean;
  29483. /** @hidden */
  29484. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29485. /**
  29486. * Will return all nodes that have this node as ascendant
  29487. * @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
  29488. * @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
  29489. * @return all children nodes of all types
  29490. */
  29491. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29492. /**
  29493. * Get all child-meshes of this node
  29494. * @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)
  29495. * @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
  29496. * @returns an array of AbstractMesh
  29497. */
  29498. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29499. /**
  29500. * Get all direct children of this node
  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. * @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)
  29503. * @returns an array of Node
  29504. */
  29505. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29506. /** @hidden */
  29507. _setReady(state: boolean): void;
  29508. /**
  29509. * Get an animation by name
  29510. * @param name defines the name of the animation to look for
  29511. * @returns null if not found else the requested animation
  29512. */
  29513. getAnimationByName(name: string): Nullable<Animation>;
  29514. /**
  29515. * Creates an animation range for this node
  29516. * @param name defines the name of the range
  29517. * @param from defines the starting key
  29518. * @param to defines the end key
  29519. */
  29520. createAnimationRange(name: string, from: number, to: number): void;
  29521. /**
  29522. * Delete a specific animation range
  29523. * @param name defines the name of the range to delete
  29524. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29525. */
  29526. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29527. /**
  29528. * Get an animation range by name
  29529. * @param name defines the name of the animation range to look for
  29530. * @returns null if not found else the requested animation range
  29531. */
  29532. getAnimationRange(name: string): Nullable<AnimationRange>;
  29533. /**
  29534. * Gets the list of all animation ranges defined on this node
  29535. * @returns an array
  29536. */
  29537. getAnimationRanges(): Nullable<AnimationRange>[];
  29538. /**
  29539. * Will start the animation sequence
  29540. * @param name defines the range frames for animation sequence
  29541. * @param loop defines if the animation should loop (false by default)
  29542. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29543. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29544. * @returns the object created for this animation. If range does not exist, it will return null
  29545. */
  29546. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29547. /**
  29548. * Serialize animation ranges into a JSON compatible object
  29549. * @returns serialization object
  29550. */
  29551. serializeAnimationRanges(): any;
  29552. /**
  29553. * Computes the world matrix of the node
  29554. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29555. * @returns the world matrix
  29556. */
  29557. computeWorldMatrix(force?: boolean): Matrix;
  29558. /**
  29559. * Releases resources associated with this node.
  29560. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29561. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29562. */
  29563. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29564. /**
  29565. * Parse animation range data from a serialization object and store them into a given node
  29566. * @param node defines where to store the animation ranges
  29567. * @param parsedNode defines the serialization object to read data from
  29568. * @param scene defines the hosting scene
  29569. */
  29570. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29571. /**
  29572. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29573. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29574. * @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
  29575. * @returns the new bounding vectors
  29576. */
  29577. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29578. min: Vector3;
  29579. max: Vector3;
  29580. };
  29581. }
  29582. }
  29583. declare module BABYLON {
  29584. /**
  29585. * @hidden
  29586. */
  29587. export class _IAnimationState {
  29588. key: number;
  29589. repeatCount: number;
  29590. workValue?: any;
  29591. loopMode?: number;
  29592. offsetValue?: any;
  29593. highLimitValue?: any;
  29594. }
  29595. /**
  29596. * Class used to store any kind of animation
  29597. */
  29598. export class Animation {
  29599. /**Name of the animation */
  29600. name: string;
  29601. /**Property to animate */
  29602. targetProperty: string;
  29603. /**The frames per second of the animation */
  29604. framePerSecond: number;
  29605. /**The data type of the animation */
  29606. dataType: number;
  29607. /**The loop mode of the animation */
  29608. loopMode?: number | undefined;
  29609. /**Specifies if blending should be enabled */
  29610. enableBlending?: boolean | undefined;
  29611. /**
  29612. * Use matrix interpolation instead of using direct key value when animating matrices
  29613. */
  29614. static AllowMatricesInterpolation: boolean;
  29615. /**
  29616. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29617. */
  29618. static AllowMatrixDecomposeForInterpolation: boolean;
  29619. /**
  29620. * Stores the key frames of the animation
  29621. */
  29622. private _keys;
  29623. /**
  29624. * Stores the easing function of the animation
  29625. */
  29626. private _easingFunction;
  29627. /**
  29628. * @hidden Internal use only
  29629. */
  29630. _runtimeAnimations: RuntimeAnimation[];
  29631. /**
  29632. * The set of event that will be linked to this animation
  29633. */
  29634. private _events;
  29635. /**
  29636. * Stores an array of target property paths
  29637. */
  29638. targetPropertyPath: string[];
  29639. /**
  29640. * Stores the blending speed of the animation
  29641. */
  29642. blendingSpeed: number;
  29643. /**
  29644. * Stores the animation ranges for the animation
  29645. */
  29646. private _ranges;
  29647. /**
  29648. * @hidden Internal use
  29649. */
  29650. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29651. /**
  29652. * Sets up an animation
  29653. * @param property The property to animate
  29654. * @param animationType The animation type to apply
  29655. * @param framePerSecond The frames per second of the animation
  29656. * @param easingFunction The easing function used in the animation
  29657. * @returns The created animation
  29658. */
  29659. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29660. /**
  29661. * Create and start an animation on a node
  29662. * @param name defines the name of the global animation that will be run on all nodes
  29663. * @param node defines the root node where the animation will take place
  29664. * @param targetProperty defines property to animate
  29665. * @param framePerSecond defines the number of frame per second yo use
  29666. * @param totalFrame defines the number of frames in total
  29667. * @param from defines the initial value
  29668. * @param to defines the final value
  29669. * @param loopMode defines which loop mode you want to use (off by default)
  29670. * @param easingFunction defines the easing function to use (linear by default)
  29671. * @param onAnimationEnd defines the callback to call when animation end
  29672. * @returns the animatable created for this animation
  29673. */
  29674. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29675. /**
  29676. * Create and start an animation on a node and its descendants
  29677. * @param name defines the name of the global animation that will be run on all nodes
  29678. * @param node defines the root node where the animation will take place
  29679. * @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
  29680. * @param targetProperty defines property to animate
  29681. * @param framePerSecond defines the number of frame per second to use
  29682. * @param totalFrame defines the number of frames in total
  29683. * @param from defines the initial value
  29684. * @param to defines the final value
  29685. * @param loopMode defines which loop mode you want to use (off by default)
  29686. * @param easingFunction defines the easing function to use (linear by default)
  29687. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29688. * @returns the list of animatables created for all nodes
  29689. * @example https://www.babylonjs-playground.com/#MH0VLI
  29690. */
  29691. 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[]>;
  29692. /**
  29693. * Creates a new animation, merges it with the existing animations and starts it
  29694. * @param name Name of the animation
  29695. * @param node Node which contains the scene that begins the animations
  29696. * @param targetProperty Specifies which property to animate
  29697. * @param framePerSecond The frames per second of the animation
  29698. * @param totalFrame The total number of frames
  29699. * @param from The frame at the beginning of the animation
  29700. * @param to The frame at the end of the animation
  29701. * @param loopMode Specifies the loop mode of the animation
  29702. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29703. * @param onAnimationEnd Callback to run once the animation is complete
  29704. * @returns Nullable animation
  29705. */
  29706. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29707. /**
  29708. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29709. * @param sourceAnimation defines the Animation containing keyframes to convert
  29710. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29711. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29712. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29713. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29714. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29715. */
  29716. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29717. /**
  29718. * Transition property of an host to the target Value
  29719. * @param property The property to transition
  29720. * @param targetValue The target Value of the property
  29721. * @param host The object where the property to animate belongs
  29722. * @param scene Scene used to run the animation
  29723. * @param frameRate Framerate (in frame/s) to use
  29724. * @param transition The transition type we want to use
  29725. * @param duration The duration of the animation, in milliseconds
  29726. * @param onAnimationEnd Callback trigger at the end of the animation
  29727. * @returns Nullable animation
  29728. */
  29729. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29730. /**
  29731. * Return the array of runtime animations currently using this animation
  29732. */
  29733. get runtimeAnimations(): RuntimeAnimation[];
  29734. /**
  29735. * Specifies if any of the runtime animations are currently running
  29736. */
  29737. get hasRunningRuntimeAnimations(): boolean;
  29738. /**
  29739. * Initializes the animation
  29740. * @param name Name of the animation
  29741. * @param targetProperty Property to animate
  29742. * @param framePerSecond The frames per second of the animation
  29743. * @param dataType The data type of the animation
  29744. * @param loopMode The loop mode of the animation
  29745. * @param enableBlending Specifies if blending should be enabled
  29746. */
  29747. constructor(
  29748. /**Name of the animation */
  29749. name: string,
  29750. /**Property to animate */
  29751. targetProperty: string,
  29752. /**The frames per second of the animation */
  29753. framePerSecond: number,
  29754. /**The data type of the animation */
  29755. dataType: number,
  29756. /**The loop mode of the animation */
  29757. loopMode?: number | undefined,
  29758. /**Specifies if blending should be enabled */
  29759. enableBlending?: boolean | undefined);
  29760. /**
  29761. * Converts the animation to a string
  29762. * @param fullDetails support for multiple levels of logging within scene loading
  29763. * @returns String form of the animation
  29764. */
  29765. toString(fullDetails?: boolean): string;
  29766. /**
  29767. * Add an event to this animation
  29768. * @param event Event to add
  29769. */
  29770. addEvent(event: AnimationEvent): void;
  29771. /**
  29772. * Remove all events found at the given frame
  29773. * @param frame The frame to remove events from
  29774. */
  29775. removeEvents(frame: number): void;
  29776. /**
  29777. * Retrieves all the events from the animation
  29778. * @returns Events from the animation
  29779. */
  29780. getEvents(): AnimationEvent[];
  29781. /**
  29782. * Creates an animation range
  29783. * @param name Name of the animation range
  29784. * @param from Starting frame of the animation range
  29785. * @param to Ending frame of the animation
  29786. */
  29787. createRange(name: string, from: number, to: number): void;
  29788. /**
  29789. * Deletes an animation range by name
  29790. * @param name Name of the animation range to delete
  29791. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29792. */
  29793. deleteRange(name: string, deleteFrames?: boolean): void;
  29794. /**
  29795. * Gets the animation range by name, or null if not defined
  29796. * @param name Name of the animation range
  29797. * @returns Nullable animation range
  29798. */
  29799. getRange(name: string): Nullable<AnimationRange>;
  29800. /**
  29801. * Gets the key frames from the animation
  29802. * @returns The key frames of the animation
  29803. */
  29804. getKeys(): Array<IAnimationKey>;
  29805. /**
  29806. * Gets the highest frame rate of the animation
  29807. * @returns Highest frame rate of the animation
  29808. */
  29809. getHighestFrame(): number;
  29810. /**
  29811. * Gets the easing function of the animation
  29812. * @returns Easing function of the animation
  29813. */
  29814. getEasingFunction(): IEasingFunction;
  29815. /**
  29816. * Sets the easing function of the animation
  29817. * @param easingFunction A custom mathematical formula for animation
  29818. */
  29819. setEasingFunction(easingFunction: EasingFunction): void;
  29820. /**
  29821. * Interpolates a scalar linearly
  29822. * @param startValue Start value of the animation curve
  29823. * @param endValue End value of the animation curve
  29824. * @param gradient Scalar amount to interpolate
  29825. * @returns Interpolated scalar value
  29826. */
  29827. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29828. /**
  29829. * Interpolates a scalar cubically
  29830. * @param startValue Start value of the animation curve
  29831. * @param outTangent End tangent of the animation
  29832. * @param endValue End value of the animation curve
  29833. * @param inTangent Start tangent of the animation curve
  29834. * @param gradient Scalar amount to interpolate
  29835. * @returns Interpolated scalar value
  29836. */
  29837. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29838. /**
  29839. * Interpolates a quaternion using a spherical linear interpolation
  29840. * @param startValue Start value of the animation curve
  29841. * @param endValue End value of the animation curve
  29842. * @param gradient Scalar amount to interpolate
  29843. * @returns Interpolated quaternion value
  29844. */
  29845. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29846. /**
  29847. * Interpolates a quaternion cubically
  29848. * @param startValue Start value of the animation curve
  29849. * @param outTangent End tangent of the animation curve
  29850. * @param endValue End value of the animation curve
  29851. * @param inTangent Start tangent of the animation curve
  29852. * @param gradient Scalar amount to interpolate
  29853. * @returns Interpolated quaternion value
  29854. */
  29855. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29856. /**
  29857. * Interpolates a Vector3 linearl
  29858. * @param startValue Start value of the animation curve
  29859. * @param endValue End value of the animation curve
  29860. * @param gradient Scalar amount to interpolate
  29861. * @returns Interpolated scalar value
  29862. */
  29863. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29864. /**
  29865. * Interpolates a Vector3 cubically
  29866. * @param startValue Start value of the animation curve
  29867. * @param outTangent End tangent of the animation
  29868. * @param endValue End value of the animation curve
  29869. * @param inTangent Start tangent of the animation curve
  29870. * @param gradient Scalar amount to interpolate
  29871. * @returns InterpolatedVector3 value
  29872. */
  29873. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29874. /**
  29875. * Interpolates a Vector2 linearly
  29876. * @param startValue Start value of the animation curve
  29877. * @param endValue End value of the animation curve
  29878. * @param gradient Scalar amount to interpolate
  29879. * @returns Interpolated Vector2 value
  29880. */
  29881. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29882. /**
  29883. * Interpolates a Vector2 cubically
  29884. * @param startValue Start value of the animation curve
  29885. * @param outTangent End tangent of the animation
  29886. * @param endValue End value of the animation curve
  29887. * @param inTangent Start tangent of the animation curve
  29888. * @param gradient Scalar amount to interpolate
  29889. * @returns Interpolated Vector2 value
  29890. */
  29891. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29892. /**
  29893. * Interpolates a size linearly
  29894. * @param startValue Start value of the animation curve
  29895. * @param endValue End value of the animation curve
  29896. * @param gradient Scalar amount to interpolate
  29897. * @returns Interpolated Size value
  29898. */
  29899. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29900. /**
  29901. * Interpolates a Color3 linearly
  29902. * @param startValue Start value of the animation curve
  29903. * @param endValue End value of the animation curve
  29904. * @param gradient Scalar amount to interpolate
  29905. * @returns Interpolated Color3 value
  29906. */
  29907. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29908. /**
  29909. * Interpolates a Color4 linearly
  29910. * @param startValue Start value of the animation curve
  29911. * @param endValue End value of the animation curve
  29912. * @param gradient Scalar amount to interpolate
  29913. * @returns Interpolated Color3 value
  29914. */
  29915. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29916. /**
  29917. * @hidden Internal use only
  29918. */
  29919. _getKeyValue(value: any): any;
  29920. /**
  29921. * @hidden Internal use only
  29922. */
  29923. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29924. /**
  29925. * Defines the function to use to interpolate matrices
  29926. * @param startValue defines the start matrix
  29927. * @param endValue defines the end matrix
  29928. * @param gradient defines the gradient between both matrices
  29929. * @param result defines an optional target matrix where to store the interpolation
  29930. * @returns the interpolated matrix
  29931. */
  29932. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29933. /**
  29934. * Makes a copy of the animation
  29935. * @returns Cloned animation
  29936. */
  29937. clone(): Animation;
  29938. /**
  29939. * Sets the key frames of the animation
  29940. * @param values The animation key frames to set
  29941. */
  29942. setKeys(values: Array<IAnimationKey>): void;
  29943. /**
  29944. * Serializes the animation to an object
  29945. * @returns Serialized object
  29946. */
  29947. serialize(): any;
  29948. /**
  29949. * Float animation type
  29950. */
  29951. static readonly ANIMATIONTYPE_FLOAT: number;
  29952. /**
  29953. * Vector3 animation type
  29954. */
  29955. static readonly ANIMATIONTYPE_VECTOR3: number;
  29956. /**
  29957. * Quaternion animation type
  29958. */
  29959. static readonly ANIMATIONTYPE_QUATERNION: number;
  29960. /**
  29961. * Matrix animation type
  29962. */
  29963. static readonly ANIMATIONTYPE_MATRIX: number;
  29964. /**
  29965. * Color3 animation type
  29966. */
  29967. static readonly ANIMATIONTYPE_COLOR3: number;
  29968. /**
  29969. * Color3 animation type
  29970. */
  29971. static readonly ANIMATIONTYPE_COLOR4: number;
  29972. /**
  29973. * Vector2 animation type
  29974. */
  29975. static readonly ANIMATIONTYPE_VECTOR2: number;
  29976. /**
  29977. * Size animation type
  29978. */
  29979. static readonly ANIMATIONTYPE_SIZE: number;
  29980. /**
  29981. * Relative Loop Mode
  29982. */
  29983. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29984. /**
  29985. * Cycle Loop Mode
  29986. */
  29987. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29988. /**
  29989. * Constant Loop Mode
  29990. */
  29991. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29992. /** @hidden */
  29993. static _UniversalLerp(left: any, right: any, amount: number): any;
  29994. /**
  29995. * Parses an animation object and creates an animation
  29996. * @param parsedAnimation Parsed animation object
  29997. * @returns Animation object
  29998. */
  29999. static Parse(parsedAnimation: any): Animation;
  30000. /**
  30001. * Appends the serialized animations from the source animations
  30002. * @param source Source containing the animations
  30003. * @param destination Target to store the animations
  30004. */
  30005. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30006. }
  30007. }
  30008. declare module BABYLON {
  30009. /**
  30010. * Interface containing an array of animations
  30011. */
  30012. export interface IAnimatable {
  30013. /**
  30014. * Array of animations
  30015. */
  30016. animations: Nullable<Array<Animation>>;
  30017. }
  30018. }
  30019. declare module BABYLON {
  30020. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30021. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30022. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30023. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30024. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30025. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30026. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30027. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30028. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30029. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30030. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30031. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30032. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30033. /**
  30034. * Decorator used to define property that can be serialized as reference to a camera
  30035. * @param sourceName defines the name of the property to decorate
  30036. */
  30037. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30038. /**
  30039. * Class used to help serialization objects
  30040. */
  30041. export class SerializationHelper {
  30042. /** @hidden */
  30043. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30044. /** @hidden */
  30045. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30046. /** @hidden */
  30047. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30048. /** @hidden */
  30049. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30050. /**
  30051. * Appends the serialized animations from the source animations
  30052. * @param source Source containing the animations
  30053. * @param destination Target to store the animations
  30054. */
  30055. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30056. /**
  30057. * Static function used to serialized a specific entity
  30058. * @param entity defines the entity to serialize
  30059. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30060. * @returns a JSON compatible object representing the serialization of the entity
  30061. */
  30062. static Serialize<T>(entity: T, serializationObject?: any): any;
  30063. /**
  30064. * Creates a new entity from a serialization data object
  30065. * @param creationFunction defines a function used to instanciated the new entity
  30066. * @param source defines the source serialization data
  30067. * @param scene defines the hosting scene
  30068. * @param rootUrl defines the root url for resources
  30069. * @returns a new entity
  30070. */
  30071. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30072. /**
  30073. * Clones an object
  30074. * @param creationFunction defines the function used to instanciate the new object
  30075. * @param source defines the source object
  30076. * @returns the cloned object
  30077. */
  30078. static Clone<T>(creationFunction: () => T, source: T): T;
  30079. /**
  30080. * Instanciates a new object based on a source one (some data will be shared between both object)
  30081. * @param creationFunction defines the function used to instanciate the new object
  30082. * @param source defines the source object
  30083. * @returns the new object
  30084. */
  30085. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30086. }
  30087. }
  30088. declare module BABYLON {
  30089. /**
  30090. * Base class of all the textures in babylon.
  30091. * It groups all the common properties the materials, post process, lights... might need
  30092. * in order to make a correct use of the texture.
  30093. */
  30094. export class BaseTexture implements IAnimatable {
  30095. /**
  30096. * Default anisotropic filtering level for the application.
  30097. * It is set to 4 as a good tradeoff between perf and quality.
  30098. */
  30099. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30100. /**
  30101. * Gets or sets the unique id of the texture
  30102. */
  30103. uniqueId: number;
  30104. /**
  30105. * Define the name of the texture.
  30106. */
  30107. name: string;
  30108. /**
  30109. * Gets or sets an object used to store user defined information.
  30110. */
  30111. metadata: any;
  30112. /**
  30113. * For internal use only. Please do not use.
  30114. */
  30115. reservedDataStore: any;
  30116. private _hasAlpha;
  30117. /**
  30118. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30119. */
  30120. set hasAlpha(value: boolean);
  30121. get hasAlpha(): boolean;
  30122. /**
  30123. * Defines if the alpha value should be determined via the rgb values.
  30124. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30125. */
  30126. getAlphaFromRGB: boolean;
  30127. /**
  30128. * Intensity or strength of the texture.
  30129. * It is commonly used by materials to fine tune the intensity of the texture
  30130. */
  30131. level: number;
  30132. /**
  30133. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30134. * This is part of the texture as textures usually maps to one uv set.
  30135. */
  30136. coordinatesIndex: number;
  30137. private _coordinatesMode;
  30138. /**
  30139. * How a texture is mapped.
  30140. *
  30141. * | Value | Type | Description |
  30142. * | ----- | ----------------------------------- | ----------- |
  30143. * | 0 | EXPLICIT_MODE | |
  30144. * | 1 | SPHERICAL_MODE | |
  30145. * | 2 | PLANAR_MODE | |
  30146. * | 3 | CUBIC_MODE | |
  30147. * | 4 | PROJECTION_MODE | |
  30148. * | 5 | SKYBOX_MODE | |
  30149. * | 6 | INVCUBIC_MODE | |
  30150. * | 7 | EQUIRECTANGULAR_MODE | |
  30151. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30152. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30153. */
  30154. set coordinatesMode(value: number);
  30155. get coordinatesMode(): number;
  30156. /**
  30157. * | Value | Type | Description |
  30158. * | ----- | ------------------ | ----------- |
  30159. * | 0 | CLAMP_ADDRESSMODE | |
  30160. * | 1 | WRAP_ADDRESSMODE | |
  30161. * | 2 | MIRROR_ADDRESSMODE | |
  30162. */
  30163. wrapU: number;
  30164. /**
  30165. * | Value | Type | Description |
  30166. * | ----- | ------------------ | ----------- |
  30167. * | 0 | CLAMP_ADDRESSMODE | |
  30168. * | 1 | WRAP_ADDRESSMODE | |
  30169. * | 2 | MIRROR_ADDRESSMODE | |
  30170. */
  30171. wrapV: number;
  30172. /**
  30173. * | Value | Type | Description |
  30174. * | ----- | ------------------ | ----------- |
  30175. * | 0 | CLAMP_ADDRESSMODE | |
  30176. * | 1 | WRAP_ADDRESSMODE | |
  30177. * | 2 | MIRROR_ADDRESSMODE | |
  30178. */
  30179. wrapR: number;
  30180. /**
  30181. * With compliant hardware and browser (supporting anisotropic filtering)
  30182. * this defines the level of anisotropic filtering in the texture.
  30183. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30184. */
  30185. anisotropicFilteringLevel: number;
  30186. /**
  30187. * Define if the texture is a cube texture or if false a 2d texture.
  30188. */
  30189. get isCube(): boolean;
  30190. set isCube(value: boolean);
  30191. /**
  30192. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30193. */
  30194. get is3D(): boolean;
  30195. set is3D(value: boolean);
  30196. /**
  30197. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30198. */
  30199. get is2DArray(): boolean;
  30200. set is2DArray(value: boolean);
  30201. /**
  30202. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30203. * HDR texture are usually stored in linear space.
  30204. * This only impacts the PBR and Background materials
  30205. */
  30206. gammaSpace: boolean;
  30207. /**
  30208. * Gets or sets whether or not the texture contains RGBD data.
  30209. */
  30210. get isRGBD(): boolean;
  30211. set isRGBD(value: boolean);
  30212. /**
  30213. * Is Z inverted in the texture (useful in a cube texture).
  30214. */
  30215. invertZ: boolean;
  30216. /**
  30217. * Are mip maps generated for this texture or not.
  30218. */
  30219. get noMipmap(): boolean;
  30220. /**
  30221. * @hidden
  30222. */
  30223. lodLevelInAlpha: boolean;
  30224. /**
  30225. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30226. */
  30227. get lodGenerationOffset(): number;
  30228. set lodGenerationOffset(value: number);
  30229. /**
  30230. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30231. */
  30232. get lodGenerationScale(): number;
  30233. set lodGenerationScale(value: number);
  30234. /**
  30235. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30236. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30237. * average roughness values.
  30238. */
  30239. get linearSpecularLOD(): boolean;
  30240. set linearSpecularLOD(value: boolean);
  30241. /**
  30242. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30243. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30244. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30245. */
  30246. get irradianceTexture(): Nullable<BaseTexture>;
  30247. set irradianceTexture(value: Nullable<BaseTexture>);
  30248. /**
  30249. * Define if the texture is a render target.
  30250. */
  30251. isRenderTarget: boolean;
  30252. /**
  30253. * Define the unique id of the texture in the scene.
  30254. */
  30255. get uid(): string;
  30256. /**
  30257. * Return a string representation of the texture.
  30258. * @returns the texture as a string
  30259. */
  30260. toString(): string;
  30261. /**
  30262. * Get the class name of the texture.
  30263. * @returns "BaseTexture"
  30264. */
  30265. getClassName(): string;
  30266. /**
  30267. * Define the list of animation attached to the texture.
  30268. */
  30269. animations: Animation[];
  30270. /**
  30271. * An event triggered when the texture is disposed.
  30272. */
  30273. onDisposeObservable: Observable<BaseTexture>;
  30274. private _onDisposeObserver;
  30275. /**
  30276. * Callback triggered when the texture has been disposed.
  30277. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30278. */
  30279. set onDispose(callback: () => void);
  30280. /**
  30281. * Define the current state of the loading sequence when in delayed load mode.
  30282. */
  30283. delayLoadState: number;
  30284. private _scene;
  30285. /** @hidden */
  30286. _texture: Nullable<InternalTexture>;
  30287. private _uid;
  30288. /**
  30289. * Define if the texture is preventinga material to render or not.
  30290. * If not and the texture is not ready, the engine will use a default black texture instead.
  30291. */
  30292. get isBlocking(): boolean;
  30293. /**
  30294. * Instantiates a new BaseTexture.
  30295. * Base class of all the textures in babylon.
  30296. * It groups all the common properties the materials, post process, lights... might need
  30297. * in order to make a correct use of the texture.
  30298. * @param scene Define the scene the texture blongs to
  30299. */
  30300. constructor(scene: Nullable<Scene>);
  30301. /**
  30302. * Get the scene the texture belongs to.
  30303. * @returns the scene or null if undefined
  30304. */
  30305. getScene(): Nullable<Scene>;
  30306. /**
  30307. * Get the texture transform matrix used to offset tile the texture for istance.
  30308. * @returns the transformation matrix
  30309. */
  30310. getTextureMatrix(): Matrix;
  30311. /**
  30312. * Get the texture reflection matrix used to rotate/transform the reflection.
  30313. * @returns the reflection matrix
  30314. */
  30315. getReflectionTextureMatrix(): Matrix;
  30316. /**
  30317. * Get the underlying lower level texture from Babylon.
  30318. * @returns the insternal texture
  30319. */
  30320. getInternalTexture(): Nullable<InternalTexture>;
  30321. /**
  30322. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30323. * @returns true if ready or not blocking
  30324. */
  30325. isReadyOrNotBlocking(): boolean;
  30326. /**
  30327. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30328. * @returns true if fully ready
  30329. */
  30330. isReady(): boolean;
  30331. private _cachedSize;
  30332. /**
  30333. * Get the size of the texture.
  30334. * @returns the texture size.
  30335. */
  30336. getSize(): ISize;
  30337. /**
  30338. * Get the base size of the texture.
  30339. * It can be different from the size if the texture has been resized for POT for instance
  30340. * @returns the base size
  30341. */
  30342. getBaseSize(): ISize;
  30343. /**
  30344. * Update the sampling mode of the texture.
  30345. * Default is Trilinear mode.
  30346. *
  30347. * | Value | Type | Description |
  30348. * | ----- | ------------------ | ----------- |
  30349. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30350. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30351. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30352. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30353. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30354. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30355. * | 7 | NEAREST_LINEAR | |
  30356. * | 8 | NEAREST_NEAREST | |
  30357. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30358. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30359. * | 11 | LINEAR_LINEAR | |
  30360. * | 12 | LINEAR_NEAREST | |
  30361. *
  30362. * > _mag_: magnification filter (close to the viewer)
  30363. * > _min_: minification filter (far from the viewer)
  30364. * > _mip_: filter used between mip map levels
  30365. *@param samplingMode Define the new sampling mode of the texture
  30366. */
  30367. updateSamplingMode(samplingMode: number): void;
  30368. /**
  30369. * Scales the texture if is `canRescale()`
  30370. * @param ratio the resize factor we want to use to rescale
  30371. */
  30372. scale(ratio: number): void;
  30373. /**
  30374. * Get if the texture can rescale.
  30375. */
  30376. get canRescale(): boolean;
  30377. /** @hidden */
  30378. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30379. /** @hidden */
  30380. _rebuild(): void;
  30381. /**
  30382. * Triggers the load sequence in delayed load mode.
  30383. */
  30384. delayLoad(): void;
  30385. /**
  30386. * Clones the texture.
  30387. * @returns the cloned texture
  30388. */
  30389. clone(): Nullable<BaseTexture>;
  30390. /**
  30391. * Get the texture underlying type (INT, FLOAT...)
  30392. */
  30393. get textureType(): number;
  30394. /**
  30395. * Get the texture underlying format (RGB, RGBA...)
  30396. */
  30397. get textureFormat(): number;
  30398. /**
  30399. * Indicates that textures need to be re-calculated for all materials
  30400. */
  30401. protected _markAllSubMeshesAsTexturesDirty(): void;
  30402. /**
  30403. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30404. * This will returns an RGBA array buffer containing either in values (0-255) or
  30405. * float values (0-1) depending of the underlying buffer type.
  30406. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30407. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30408. * @param buffer defines a user defined buffer to fill with data (can be null)
  30409. * @returns The Array buffer containing the pixels data.
  30410. */
  30411. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30412. /**
  30413. * Release and destroy the underlying lower level texture aka internalTexture.
  30414. */
  30415. releaseInternalTexture(): void;
  30416. /** @hidden */
  30417. get _lodTextureHigh(): Nullable<BaseTexture>;
  30418. /** @hidden */
  30419. get _lodTextureMid(): Nullable<BaseTexture>;
  30420. /** @hidden */
  30421. get _lodTextureLow(): Nullable<BaseTexture>;
  30422. /**
  30423. * Dispose the texture and release its associated resources.
  30424. */
  30425. dispose(): void;
  30426. /**
  30427. * Serialize the texture into a JSON representation that can be parsed later on.
  30428. * @returns the JSON representation of the texture
  30429. */
  30430. serialize(): any;
  30431. /**
  30432. * Helper function to be called back once a list of texture contains only ready textures.
  30433. * @param textures Define the list of textures to wait for
  30434. * @param callback Define the callback triggered once the entire list will be ready
  30435. */
  30436. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30437. }
  30438. }
  30439. declare module BABYLON {
  30440. /**
  30441. * Options to be used when creating an effect.
  30442. */
  30443. export interface IEffectCreationOptions {
  30444. /**
  30445. * Atrributes that will be used in the shader.
  30446. */
  30447. attributes: string[];
  30448. /**
  30449. * Uniform varible names that will be set in the shader.
  30450. */
  30451. uniformsNames: string[];
  30452. /**
  30453. * Uniform buffer variable names that will be set in the shader.
  30454. */
  30455. uniformBuffersNames: string[];
  30456. /**
  30457. * Sampler texture variable names that will be set in the shader.
  30458. */
  30459. samplers: string[];
  30460. /**
  30461. * Define statements that will be set in the shader.
  30462. */
  30463. defines: any;
  30464. /**
  30465. * Possible fallbacks for this effect to improve performance when needed.
  30466. */
  30467. fallbacks: Nullable<IEffectFallbacks>;
  30468. /**
  30469. * Callback that will be called when the shader is compiled.
  30470. */
  30471. onCompiled: Nullable<(effect: Effect) => void>;
  30472. /**
  30473. * Callback that will be called if an error occurs during shader compilation.
  30474. */
  30475. onError: Nullable<(effect: Effect, errors: string) => void>;
  30476. /**
  30477. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30478. */
  30479. indexParameters?: any;
  30480. /**
  30481. * Max number of lights that can be used in the shader.
  30482. */
  30483. maxSimultaneousLights?: number;
  30484. /**
  30485. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30486. */
  30487. transformFeedbackVaryings?: Nullable<string[]>;
  30488. }
  30489. /**
  30490. * Effect containing vertex and fragment shader that can be executed on an object.
  30491. */
  30492. export class Effect implements IDisposable {
  30493. /**
  30494. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30495. */
  30496. static ShadersRepository: string;
  30497. /**
  30498. * Enable logging of the shader code when a compilation error occurs
  30499. */
  30500. static LogShaderCodeOnCompilationError: boolean;
  30501. /**
  30502. * Name of the effect.
  30503. */
  30504. name: any;
  30505. /**
  30506. * String container all the define statements that should be set on the shader.
  30507. */
  30508. defines: string;
  30509. /**
  30510. * Callback that will be called when the shader is compiled.
  30511. */
  30512. onCompiled: Nullable<(effect: Effect) => void>;
  30513. /**
  30514. * Callback that will be called if an error occurs during shader compilation.
  30515. */
  30516. onError: Nullable<(effect: Effect, errors: string) => void>;
  30517. /**
  30518. * Callback that will be called when effect is bound.
  30519. */
  30520. onBind: Nullable<(effect: Effect) => void>;
  30521. /**
  30522. * Unique ID of the effect.
  30523. */
  30524. uniqueId: number;
  30525. /**
  30526. * Observable that will be called when the shader is compiled.
  30527. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30528. */
  30529. onCompileObservable: Observable<Effect>;
  30530. /**
  30531. * Observable that will be called if an error occurs during shader compilation.
  30532. */
  30533. onErrorObservable: Observable<Effect>;
  30534. /** @hidden */
  30535. _onBindObservable: Nullable<Observable<Effect>>;
  30536. /**
  30537. * @hidden
  30538. * Specifies if the effect was previously ready
  30539. */
  30540. _wasPreviouslyReady: boolean;
  30541. /**
  30542. * Observable that will be called when effect is bound.
  30543. */
  30544. get onBindObservable(): Observable<Effect>;
  30545. /** @hidden */
  30546. _bonesComputationForcedToCPU: boolean;
  30547. private static _uniqueIdSeed;
  30548. private _engine;
  30549. private _uniformBuffersNames;
  30550. private _uniformBuffersNamesList;
  30551. private _uniformsNames;
  30552. private _samplerList;
  30553. private _samplers;
  30554. private _isReady;
  30555. private _compilationError;
  30556. private _allFallbacksProcessed;
  30557. private _attributesNames;
  30558. private _attributes;
  30559. private _attributeLocationByName;
  30560. private _uniforms;
  30561. /**
  30562. * Key for the effect.
  30563. * @hidden
  30564. */
  30565. _key: string;
  30566. private _indexParameters;
  30567. private _fallbacks;
  30568. private _vertexSourceCode;
  30569. private _fragmentSourceCode;
  30570. private _vertexSourceCodeOverride;
  30571. private _fragmentSourceCodeOverride;
  30572. private _transformFeedbackVaryings;
  30573. /**
  30574. * Compiled shader to webGL program.
  30575. * @hidden
  30576. */
  30577. _pipelineContext: Nullable<IPipelineContext>;
  30578. private _valueCache;
  30579. private static _baseCache;
  30580. /**
  30581. * Instantiates an effect.
  30582. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30583. * @param baseName Name of the effect.
  30584. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30585. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30586. * @param samplers List of sampler variables that will be passed to the shader.
  30587. * @param engine Engine to be used to render the effect
  30588. * @param defines Define statements to be added to the shader.
  30589. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30590. * @param onCompiled Callback that will be called when the shader is compiled.
  30591. * @param onError Callback that will be called if an error occurs during shader compilation.
  30592. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30593. */
  30594. 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);
  30595. private _useFinalCode;
  30596. /**
  30597. * Unique key for this effect
  30598. */
  30599. get key(): string;
  30600. /**
  30601. * If the effect has been compiled and prepared.
  30602. * @returns if the effect is compiled and prepared.
  30603. */
  30604. isReady(): boolean;
  30605. private _isReadyInternal;
  30606. /**
  30607. * The engine the effect was initialized with.
  30608. * @returns the engine.
  30609. */
  30610. getEngine(): Engine;
  30611. /**
  30612. * The pipeline context for this effect
  30613. * @returns the associated pipeline context
  30614. */
  30615. getPipelineContext(): Nullable<IPipelineContext>;
  30616. /**
  30617. * The set of names of attribute variables for the shader.
  30618. * @returns An array of attribute names.
  30619. */
  30620. getAttributesNames(): string[];
  30621. /**
  30622. * Returns the attribute at the given index.
  30623. * @param index The index of the attribute.
  30624. * @returns The location of the attribute.
  30625. */
  30626. getAttributeLocation(index: number): number;
  30627. /**
  30628. * Returns the attribute based on the name of the variable.
  30629. * @param name of the attribute to look up.
  30630. * @returns the attribute location.
  30631. */
  30632. getAttributeLocationByName(name: string): number;
  30633. /**
  30634. * The number of attributes.
  30635. * @returns the numnber of attributes.
  30636. */
  30637. getAttributesCount(): number;
  30638. /**
  30639. * Gets the index of a uniform variable.
  30640. * @param uniformName of the uniform to look up.
  30641. * @returns the index.
  30642. */
  30643. getUniformIndex(uniformName: string): number;
  30644. /**
  30645. * Returns the attribute based on the name of the variable.
  30646. * @param uniformName of the uniform to look up.
  30647. * @returns the location of the uniform.
  30648. */
  30649. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30650. /**
  30651. * Returns an array of sampler variable names
  30652. * @returns The array of sampler variable names.
  30653. */
  30654. getSamplers(): string[];
  30655. /**
  30656. * Returns an array of uniform variable names
  30657. * @returns The array of uniform variable names.
  30658. */
  30659. getUniformNames(): string[];
  30660. /**
  30661. * Returns an array of uniform buffer variable names
  30662. * @returns The array of uniform buffer variable names.
  30663. */
  30664. getUniformBuffersNames(): string[];
  30665. /**
  30666. * Returns the index parameters used to create the effect
  30667. * @returns The index parameters object
  30668. */
  30669. getIndexParameters(): any;
  30670. /**
  30671. * The error from the last compilation.
  30672. * @returns the error string.
  30673. */
  30674. getCompilationError(): string;
  30675. /**
  30676. * Gets a boolean indicating that all fallbacks were used during compilation
  30677. * @returns true if all fallbacks were used
  30678. */
  30679. allFallbacksProcessed(): boolean;
  30680. /**
  30681. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30682. * @param func The callback to be used.
  30683. */
  30684. executeWhenCompiled(func: (effect: Effect) => void): void;
  30685. private _checkIsReady;
  30686. private _loadShader;
  30687. /**
  30688. * Gets the vertex shader source code of this effect
  30689. */
  30690. get vertexSourceCode(): string;
  30691. /**
  30692. * Gets the fragment shader source code of this effect
  30693. */
  30694. get fragmentSourceCode(): string;
  30695. /**
  30696. * Recompiles the webGL program
  30697. * @param vertexSourceCode The source code for the vertex shader.
  30698. * @param fragmentSourceCode The source code for the fragment shader.
  30699. * @param onCompiled Callback called when completed.
  30700. * @param onError Callback called on error.
  30701. * @hidden
  30702. */
  30703. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30704. /**
  30705. * Prepares the effect
  30706. * @hidden
  30707. */
  30708. _prepareEffect(): void;
  30709. private _getShaderCodeAndErrorLine;
  30710. private _processCompilationErrors;
  30711. /**
  30712. * Checks if the effect is supported. (Must be called after compilation)
  30713. */
  30714. get isSupported(): boolean;
  30715. /**
  30716. * Binds a texture to the engine to be used as output of the shader.
  30717. * @param channel Name of the output variable.
  30718. * @param texture Texture to bind.
  30719. * @hidden
  30720. */
  30721. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30722. /**
  30723. * Sets a texture on the engine to be used in the shader.
  30724. * @param channel Name of the sampler variable.
  30725. * @param texture Texture to set.
  30726. */
  30727. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30728. /**
  30729. * Sets a depth stencil texture from a render target 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. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30734. /**
  30735. * Sets an array of textures on the engine to be used in the shader.
  30736. * @param channel Name of the variable.
  30737. * @param textures Textures to set.
  30738. */
  30739. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30740. /**
  30741. * 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)
  30742. * @param channel Name of the sampler variable.
  30743. * @param postProcess Post process to get the input texture from.
  30744. */
  30745. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30746. /**
  30747. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30748. * 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)
  30749. * @param channel Name of the sampler variable.
  30750. * @param postProcess Post process to get the output texture from.
  30751. */
  30752. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30753. /** @hidden */
  30754. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30755. /** @hidden */
  30756. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30757. /** @hidden */
  30758. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30759. /** @hidden */
  30760. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30761. /**
  30762. * Binds a buffer to a uniform.
  30763. * @param buffer Buffer to bind.
  30764. * @param name Name of the uniform variable to bind to.
  30765. */
  30766. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30767. /**
  30768. * Binds block to a uniform.
  30769. * @param blockName Name of the block to bind.
  30770. * @param index Index to bind.
  30771. */
  30772. bindUniformBlock(blockName: string, index: number): void;
  30773. /**
  30774. * Sets an interger value on a uniform variable.
  30775. * @param uniformName Name of the variable.
  30776. * @param value Value to be set.
  30777. * @returns this effect.
  30778. */
  30779. setInt(uniformName: string, value: number): Effect;
  30780. /**
  30781. * Sets an int array on a uniform variable.
  30782. * @param uniformName Name of the variable.
  30783. * @param array array to be set.
  30784. * @returns this effect.
  30785. */
  30786. setIntArray(uniformName: string, array: Int32Array): Effect;
  30787. /**
  30788. * 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)
  30789. * @param uniformName Name of the variable.
  30790. * @param array array to be set.
  30791. * @returns this effect.
  30792. */
  30793. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30794. /**
  30795. * 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)
  30796. * @param uniformName Name of the variable.
  30797. * @param array array to be set.
  30798. * @returns this effect.
  30799. */
  30800. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30801. /**
  30802. * 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)
  30803. * @param uniformName Name of the variable.
  30804. * @param array array to be set.
  30805. * @returns this effect.
  30806. */
  30807. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30808. /**
  30809. * Sets an float array on a uniform variable.
  30810. * @param uniformName Name of the variable.
  30811. * @param array array to be set.
  30812. * @returns this effect.
  30813. */
  30814. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30815. /**
  30816. * 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)
  30817. * @param uniformName Name of the variable.
  30818. * @param array array to be set.
  30819. * @returns this effect.
  30820. */
  30821. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30822. /**
  30823. * 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)
  30824. * @param uniformName Name of the variable.
  30825. * @param array array to be set.
  30826. * @returns this effect.
  30827. */
  30828. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30829. /**
  30830. * 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)
  30831. * @param uniformName Name of the variable.
  30832. * @param array array to be set.
  30833. * @returns this effect.
  30834. */
  30835. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30836. /**
  30837. * Sets an array on a uniform variable.
  30838. * @param uniformName Name of the variable.
  30839. * @param array array to be set.
  30840. * @returns this effect.
  30841. */
  30842. setArray(uniformName: string, array: number[]): Effect;
  30843. /**
  30844. * 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)
  30845. * @param uniformName Name of the variable.
  30846. * @param array array to be set.
  30847. * @returns this effect.
  30848. */
  30849. setArray2(uniformName: string, array: number[]): Effect;
  30850. /**
  30851. * 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)
  30852. * @param uniformName Name of the variable.
  30853. * @param array array to be set.
  30854. * @returns this effect.
  30855. */
  30856. setArray3(uniformName: string, array: number[]): Effect;
  30857. /**
  30858. * 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)
  30859. * @param uniformName Name of the variable.
  30860. * @param array array to be set.
  30861. * @returns this effect.
  30862. */
  30863. setArray4(uniformName: string, array: number[]): Effect;
  30864. /**
  30865. * Sets matrices on a uniform variable.
  30866. * @param uniformName Name of the variable.
  30867. * @param matrices matrices to be set.
  30868. * @returns this effect.
  30869. */
  30870. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30871. /**
  30872. * Sets matrix on a uniform variable.
  30873. * @param uniformName Name of the variable.
  30874. * @param matrix matrix to be set.
  30875. * @returns this effect.
  30876. */
  30877. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30878. /**
  30879. * 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)
  30880. * @param uniformName Name of the variable.
  30881. * @param matrix matrix to be set.
  30882. * @returns this effect.
  30883. */
  30884. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30885. /**
  30886. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30887. * @param uniformName Name of the variable.
  30888. * @param matrix matrix to be set.
  30889. * @returns this effect.
  30890. */
  30891. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30892. /**
  30893. * Sets a float on a uniform variable.
  30894. * @param uniformName Name of the variable.
  30895. * @param value value to be set.
  30896. * @returns this effect.
  30897. */
  30898. setFloat(uniformName: string, value: number): Effect;
  30899. /**
  30900. * Sets a boolean on a uniform variable.
  30901. * @param uniformName Name of the variable.
  30902. * @param bool value to be set.
  30903. * @returns this effect.
  30904. */
  30905. setBool(uniformName: string, bool: boolean): Effect;
  30906. /**
  30907. * Sets a Vector2 on a uniform variable.
  30908. * @param uniformName Name of the variable.
  30909. * @param vector2 vector2 to be set.
  30910. * @returns this effect.
  30911. */
  30912. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30913. /**
  30914. * Sets a float2 on a uniform variable.
  30915. * @param uniformName Name of the variable.
  30916. * @param x First float in float2.
  30917. * @param y Second float in float2.
  30918. * @returns this effect.
  30919. */
  30920. setFloat2(uniformName: string, x: number, y: number): Effect;
  30921. /**
  30922. * Sets a Vector3 on a uniform variable.
  30923. * @param uniformName Name of the variable.
  30924. * @param vector3 Value to be set.
  30925. * @returns this effect.
  30926. */
  30927. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30928. /**
  30929. * Sets a float3 on a uniform variable.
  30930. * @param uniformName Name of the variable.
  30931. * @param x First float in float3.
  30932. * @param y Second float in float3.
  30933. * @param z Third float in float3.
  30934. * @returns this effect.
  30935. */
  30936. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30937. /**
  30938. * Sets a Vector4 on a uniform variable.
  30939. * @param uniformName Name of the variable.
  30940. * @param vector4 Value to be set.
  30941. * @returns this effect.
  30942. */
  30943. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30944. /**
  30945. * Sets a float4 on a uniform variable.
  30946. * @param uniformName Name of the variable.
  30947. * @param x First float in float4.
  30948. * @param y Second float in float4.
  30949. * @param z Third float in float4.
  30950. * @param w Fourth float in float4.
  30951. * @returns this effect.
  30952. */
  30953. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30954. /**
  30955. * Sets a Color3 on a uniform variable.
  30956. * @param uniformName Name of the variable.
  30957. * @param color3 Value to be set.
  30958. * @returns this effect.
  30959. */
  30960. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30961. /**
  30962. * Sets a Color4 on a uniform variable.
  30963. * @param uniformName Name of the variable.
  30964. * @param color3 Value to be set.
  30965. * @param alpha Alpha value to be set.
  30966. * @returns this effect.
  30967. */
  30968. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30969. /**
  30970. * Sets a Color4 on a uniform variable
  30971. * @param uniformName defines the name of the variable
  30972. * @param color4 defines the value to be set
  30973. * @returns this effect.
  30974. */
  30975. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30976. /** Release all associated resources */
  30977. dispose(): void;
  30978. /**
  30979. * This function will add a new shader to the shader store
  30980. * @param name the name of the shader
  30981. * @param pixelShader optional pixel shader content
  30982. * @param vertexShader optional vertex shader content
  30983. */
  30984. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30985. /**
  30986. * Store of each shader (The can be looked up using effect.key)
  30987. */
  30988. static ShadersStore: {
  30989. [key: string]: string;
  30990. };
  30991. /**
  30992. * Store of each included file for a shader (The can be looked up using effect.key)
  30993. */
  30994. static IncludesShadersStore: {
  30995. [key: string]: string;
  30996. };
  30997. /**
  30998. * Resets the cache of effects.
  30999. */
  31000. static ResetCache(): void;
  31001. }
  31002. }
  31003. declare module BABYLON {
  31004. /**
  31005. * Interface used to describe the capabilities of the engine relatively to the current browser
  31006. */
  31007. export interface EngineCapabilities {
  31008. /** Maximum textures units per fragment shader */
  31009. maxTexturesImageUnits: number;
  31010. /** Maximum texture units per vertex shader */
  31011. maxVertexTextureImageUnits: number;
  31012. /** Maximum textures units in the entire pipeline */
  31013. maxCombinedTexturesImageUnits: number;
  31014. /** Maximum texture size */
  31015. maxTextureSize: number;
  31016. /** Maximum texture samples */
  31017. maxSamples?: number;
  31018. /** Maximum cube texture size */
  31019. maxCubemapTextureSize: number;
  31020. /** Maximum render texture size */
  31021. maxRenderTextureSize: number;
  31022. /** Maximum number of vertex attributes */
  31023. maxVertexAttribs: number;
  31024. /** Maximum number of varyings */
  31025. maxVaryingVectors: number;
  31026. /** Maximum number of uniforms per vertex shader */
  31027. maxVertexUniformVectors: number;
  31028. /** Maximum number of uniforms per fragment shader */
  31029. maxFragmentUniformVectors: number;
  31030. /** Defines if standard derivates (dx/dy) are supported */
  31031. standardDerivatives: boolean;
  31032. /** Defines if s3tc texture compression is supported */
  31033. s3tc?: WEBGL_compressed_texture_s3tc;
  31034. /** Defines if pvrtc texture compression is supported */
  31035. pvrtc: any;
  31036. /** Defines if etc1 texture compression is supported */
  31037. etc1: any;
  31038. /** Defines if etc2 texture compression is supported */
  31039. etc2: any;
  31040. /** Defines if astc texture compression is supported */
  31041. astc: any;
  31042. /** Defines if float textures are supported */
  31043. textureFloat: boolean;
  31044. /** Defines if vertex array objects are supported */
  31045. vertexArrayObject: boolean;
  31046. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31047. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31048. /** Gets the maximum level of anisotropy supported */
  31049. maxAnisotropy: number;
  31050. /** Defines if instancing is supported */
  31051. instancedArrays: boolean;
  31052. /** Defines if 32 bits indices are supported */
  31053. uintIndices: boolean;
  31054. /** Defines if high precision shaders are supported */
  31055. highPrecisionShaderSupported: boolean;
  31056. /** Defines if depth reading in the fragment shader is supported */
  31057. fragmentDepthSupported: boolean;
  31058. /** Defines if float texture linear filtering is supported*/
  31059. textureFloatLinearFiltering: boolean;
  31060. /** Defines if rendering to float textures is supported */
  31061. textureFloatRender: boolean;
  31062. /** Defines if half float textures are supported*/
  31063. textureHalfFloat: boolean;
  31064. /** Defines if half float texture linear filtering is supported*/
  31065. textureHalfFloatLinearFiltering: boolean;
  31066. /** Defines if rendering to half float textures is supported */
  31067. textureHalfFloatRender: boolean;
  31068. /** Defines if textureLOD shader command is supported */
  31069. textureLOD: boolean;
  31070. /** Defines if draw buffers extension is supported */
  31071. drawBuffersExtension: boolean;
  31072. /** Defines if depth textures are supported */
  31073. depthTextureExtension: boolean;
  31074. /** Defines if float color buffer are supported */
  31075. colorBufferFloat: boolean;
  31076. /** Gets disjoint timer query extension (null if not supported) */
  31077. timerQuery?: EXT_disjoint_timer_query;
  31078. /** Defines if timestamp can be used with timer query */
  31079. canUseTimestampForTimerQuery: boolean;
  31080. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31081. multiview?: any;
  31082. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31083. oculusMultiview?: any;
  31084. /** Function used to let the system compiles shaders in background */
  31085. parallelShaderCompile?: {
  31086. COMPLETION_STATUS_KHR: number;
  31087. };
  31088. /** Max number of texture samples for MSAA */
  31089. maxMSAASamples: number;
  31090. /** Defines if the blend min max extension is supported */
  31091. blendMinMax: boolean;
  31092. }
  31093. }
  31094. declare module BABYLON {
  31095. /**
  31096. * @hidden
  31097. **/
  31098. export class DepthCullingState {
  31099. private _isDepthTestDirty;
  31100. private _isDepthMaskDirty;
  31101. private _isDepthFuncDirty;
  31102. private _isCullFaceDirty;
  31103. private _isCullDirty;
  31104. private _isZOffsetDirty;
  31105. private _isFrontFaceDirty;
  31106. private _depthTest;
  31107. private _depthMask;
  31108. private _depthFunc;
  31109. private _cull;
  31110. private _cullFace;
  31111. private _zOffset;
  31112. private _frontFace;
  31113. /**
  31114. * Initializes the state.
  31115. */
  31116. constructor();
  31117. get isDirty(): boolean;
  31118. get zOffset(): number;
  31119. set zOffset(value: number);
  31120. get cullFace(): Nullable<number>;
  31121. set cullFace(value: Nullable<number>);
  31122. get cull(): Nullable<boolean>;
  31123. set cull(value: Nullable<boolean>);
  31124. get depthFunc(): Nullable<number>;
  31125. set depthFunc(value: Nullable<number>);
  31126. get depthMask(): boolean;
  31127. set depthMask(value: boolean);
  31128. get depthTest(): boolean;
  31129. set depthTest(value: boolean);
  31130. get frontFace(): Nullable<number>;
  31131. set frontFace(value: Nullable<number>);
  31132. reset(): void;
  31133. apply(gl: WebGLRenderingContext): void;
  31134. }
  31135. }
  31136. declare module BABYLON {
  31137. /**
  31138. * @hidden
  31139. **/
  31140. export class StencilState {
  31141. /** 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 */
  31142. static readonly ALWAYS: number;
  31143. /** Passed to stencilOperation to specify that stencil value must be kept */
  31144. static readonly KEEP: number;
  31145. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31146. static readonly REPLACE: number;
  31147. private _isStencilTestDirty;
  31148. private _isStencilMaskDirty;
  31149. private _isStencilFuncDirty;
  31150. private _isStencilOpDirty;
  31151. private _stencilTest;
  31152. private _stencilMask;
  31153. private _stencilFunc;
  31154. private _stencilFuncRef;
  31155. private _stencilFuncMask;
  31156. private _stencilOpStencilFail;
  31157. private _stencilOpDepthFail;
  31158. private _stencilOpStencilDepthPass;
  31159. get isDirty(): boolean;
  31160. get stencilFunc(): number;
  31161. set stencilFunc(value: number);
  31162. get stencilFuncRef(): number;
  31163. set stencilFuncRef(value: number);
  31164. get stencilFuncMask(): number;
  31165. set stencilFuncMask(value: number);
  31166. get stencilOpStencilFail(): number;
  31167. set stencilOpStencilFail(value: number);
  31168. get stencilOpDepthFail(): number;
  31169. set stencilOpDepthFail(value: number);
  31170. get stencilOpStencilDepthPass(): number;
  31171. set stencilOpStencilDepthPass(value: number);
  31172. get stencilMask(): number;
  31173. set stencilMask(value: number);
  31174. get stencilTest(): boolean;
  31175. set stencilTest(value: boolean);
  31176. constructor();
  31177. reset(): void;
  31178. apply(gl: WebGLRenderingContext): void;
  31179. }
  31180. }
  31181. declare module BABYLON {
  31182. /**
  31183. * @hidden
  31184. **/
  31185. export class AlphaState {
  31186. private _isAlphaBlendDirty;
  31187. private _isBlendFunctionParametersDirty;
  31188. private _isBlendEquationParametersDirty;
  31189. private _isBlendConstantsDirty;
  31190. private _alphaBlend;
  31191. private _blendFunctionParameters;
  31192. private _blendEquationParameters;
  31193. private _blendConstants;
  31194. /**
  31195. * Initializes the state.
  31196. */
  31197. constructor();
  31198. get isDirty(): boolean;
  31199. get alphaBlend(): boolean;
  31200. set alphaBlend(value: boolean);
  31201. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31202. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31203. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31204. reset(): void;
  31205. apply(gl: WebGLRenderingContext): void;
  31206. }
  31207. }
  31208. declare module BABYLON {
  31209. /** @hidden */
  31210. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31211. attributeProcessor(attribute: string): string;
  31212. varyingProcessor(varying: string, isFragment: boolean): string;
  31213. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31214. }
  31215. }
  31216. declare module BABYLON {
  31217. /**
  31218. * Interface for attribute information associated with buffer instanciation
  31219. */
  31220. export interface InstancingAttributeInfo {
  31221. /**
  31222. * Name of the GLSL attribute
  31223. * if attribute index is not specified, this is used to retrieve the index from the effect
  31224. */
  31225. attributeName: string;
  31226. /**
  31227. * Index/offset of the attribute in the vertex shader
  31228. * if not specified, this will be computes from the name.
  31229. */
  31230. index?: number;
  31231. /**
  31232. * size of the attribute, 1, 2, 3 or 4
  31233. */
  31234. attributeSize: number;
  31235. /**
  31236. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31237. */
  31238. offset: number;
  31239. /**
  31240. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31241. * default to 1
  31242. */
  31243. divisor?: number;
  31244. /**
  31245. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31246. * default is FLOAT
  31247. */
  31248. attributeType?: number;
  31249. /**
  31250. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31251. */
  31252. normalized?: boolean;
  31253. }
  31254. }
  31255. declare module BABYLON {
  31256. interface ThinEngine {
  31257. /**
  31258. * Update a video texture
  31259. * @param texture defines the texture to update
  31260. * @param video defines the video element to use
  31261. * @param invertY defines if data must be stored with Y axis inverted
  31262. */
  31263. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31264. }
  31265. }
  31266. declare module BABYLON {
  31267. /**
  31268. * Settings for finer control over video usage
  31269. */
  31270. export interface VideoTextureSettings {
  31271. /**
  31272. * Applies `autoplay` to video, if specified
  31273. */
  31274. autoPlay?: boolean;
  31275. /**
  31276. * Applies `loop` to video, if specified
  31277. */
  31278. loop?: boolean;
  31279. /**
  31280. * Automatically updates internal texture from video at every frame in the render loop
  31281. */
  31282. autoUpdateTexture: boolean;
  31283. /**
  31284. * Image src displayed during the video loading or until the user interacts with the video.
  31285. */
  31286. poster?: string;
  31287. }
  31288. /**
  31289. * If you want to display a video in your scene, this is the special texture for that.
  31290. * This special texture works similar to other textures, with the exception of a few parameters.
  31291. * @see https://doc.babylonjs.com/how_to/video_texture
  31292. */
  31293. export class VideoTexture extends Texture {
  31294. /**
  31295. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31296. */
  31297. readonly autoUpdateTexture: boolean;
  31298. /**
  31299. * The video instance used by the texture internally
  31300. */
  31301. readonly video: HTMLVideoElement;
  31302. private _onUserActionRequestedObservable;
  31303. /**
  31304. * Event triggerd when a dom action is required by the user to play the video.
  31305. * This happens due to recent changes in browser policies preventing video to auto start.
  31306. */
  31307. get onUserActionRequestedObservable(): Observable<Texture>;
  31308. private _generateMipMaps;
  31309. private _engine;
  31310. private _stillImageCaptured;
  31311. private _displayingPosterTexture;
  31312. private _settings;
  31313. private _createInternalTextureOnEvent;
  31314. private _frameId;
  31315. private _currentSrc;
  31316. /**
  31317. * Creates a video texture.
  31318. * If you want to display a video in your scene, this is the special texture for that.
  31319. * This special texture works similar to other textures, with the exception of a few parameters.
  31320. * @see https://doc.babylonjs.com/how_to/video_texture
  31321. * @param name optional name, will detect from video source, if not defined
  31322. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31323. * @param scene is obviously the current scene.
  31324. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31325. * @param invertY is false by default but can be used to invert video on Y axis
  31326. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31327. * @param settings allows finer control over video usage
  31328. */
  31329. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31330. private _getName;
  31331. private _getVideo;
  31332. private _createInternalTexture;
  31333. private reset;
  31334. /**
  31335. * @hidden Internal method to initiate `update`.
  31336. */
  31337. _rebuild(): void;
  31338. /**
  31339. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31340. */
  31341. update(): void;
  31342. /**
  31343. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31344. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31345. */
  31346. updateTexture(isVisible: boolean): void;
  31347. protected _updateInternalTexture: () => void;
  31348. /**
  31349. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31350. * @param url New url.
  31351. */
  31352. updateURL(url: string): void;
  31353. /**
  31354. * Clones the texture.
  31355. * @returns the cloned texture
  31356. */
  31357. clone(): VideoTexture;
  31358. /**
  31359. * Dispose the texture and release its associated resources.
  31360. */
  31361. dispose(): void;
  31362. /**
  31363. * Creates a video texture straight from a stream.
  31364. * @param scene Define the scene the texture should be created in
  31365. * @param stream Define the stream the texture should be created from
  31366. * @returns The created video texture as a promise
  31367. */
  31368. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31369. /**
  31370. * Creates a video texture straight from your WebCam video feed.
  31371. * @param scene Define the scene the texture should be created in
  31372. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31373. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31374. * @returns The created video texture as a promise
  31375. */
  31376. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31377. minWidth: number;
  31378. maxWidth: number;
  31379. minHeight: number;
  31380. maxHeight: number;
  31381. deviceId: string;
  31382. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31383. /**
  31384. * Creates a video texture straight from your WebCam video feed.
  31385. * @param scene Define the scene the texture should be created in
  31386. * @param onReady Define a callback to triggered once the texture will be ready
  31387. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31388. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31389. */
  31390. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31391. minWidth: number;
  31392. maxWidth: number;
  31393. minHeight: number;
  31394. maxHeight: number;
  31395. deviceId: string;
  31396. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31397. }
  31398. }
  31399. declare module BABYLON {
  31400. /**
  31401. * Defines the interface used by objects working like Scene
  31402. * @hidden
  31403. */
  31404. export interface ISceneLike {
  31405. _addPendingData(data: any): void;
  31406. _removePendingData(data: any): void;
  31407. offlineProvider: IOfflineProvider;
  31408. }
  31409. /** Interface defining initialization parameters for Engine class */
  31410. export interface EngineOptions extends WebGLContextAttributes {
  31411. /**
  31412. * Defines if the engine should no exceed a specified device ratio
  31413. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31414. */
  31415. limitDeviceRatio?: number;
  31416. /**
  31417. * Defines if webvr should be enabled automatically
  31418. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31419. */
  31420. autoEnableWebVR?: boolean;
  31421. /**
  31422. * Defines if webgl2 should be turned off even if supported
  31423. * @see http://doc.babylonjs.com/features/webgl2
  31424. */
  31425. disableWebGL2Support?: boolean;
  31426. /**
  31427. * Defines if webaudio should be initialized as well
  31428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31429. */
  31430. audioEngine?: boolean;
  31431. /**
  31432. * Defines if animations should run using a deterministic lock step
  31433. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31434. */
  31435. deterministicLockstep?: boolean;
  31436. /** Defines the maximum steps to use with deterministic lock step mode */
  31437. lockstepMaxSteps?: number;
  31438. /** Defines the seconds between each deterministic lock step */
  31439. timeStep?: number;
  31440. /**
  31441. * Defines that engine should ignore context lost events
  31442. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31443. */
  31444. doNotHandleContextLost?: boolean;
  31445. /**
  31446. * Defines that engine should ignore modifying touch action attribute and style
  31447. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31448. */
  31449. doNotHandleTouchAction?: boolean;
  31450. /**
  31451. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31452. */
  31453. useHighPrecisionFloats?: boolean;
  31454. }
  31455. /**
  31456. * The base engine class (root of all engines)
  31457. */
  31458. export class ThinEngine {
  31459. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31460. static ExceptionList: ({
  31461. key: string;
  31462. capture: string;
  31463. captureConstraint: number;
  31464. targets: string[];
  31465. } | {
  31466. key: string;
  31467. capture: null;
  31468. captureConstraint: null;
  31469. targets: string[];
  31470. })[];
  31471. /** @hidden */
  31472. static _TextureLoaders: IInternalTextureLoader[];
  31473. /**
  31474. * Returns the current npm package of the sdk
  31475. */
  31476. static get NpmPackage(): string;
  31477. /**
  31478. * Returns the current version of the framework
  31479. */
  31480. static get Version(): string;
  31481. /**
  31482. * Returns a string describing the current engine
  31483. */
  31484. get description(): string;
  31485. /**
  31486. * Gets or sets the epsilon value used by collision engine
  31487. */
  31488. static CollisionsEpsilon: number;
  31489. /**
  31490. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31491. */
  31492. static get ShadersRepository(): string;
  31493. static set ShadersRepository(value: string);
  31494. /** @hidden */
  31495. _shaderProcessor: IShaderProcessor;
  31496. /**
  31497. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31498. */
  31499. forcePOTTextures: boolean;
  31500. /**
  31501. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31502. */
  31503. isFullscreen: boolean;
  31504. /**
  31505. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31506. */
  31507. cullBackFaces: boolean;
  31508. /**
  31509. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31510. */
  31511. renderEvenInBackground: boolean;
  31512. /**
  31513. * Gets or sets a boolean indicating that cache can be kept between frames
  31514. */
  31515. preventCacheWipeBetweenFrames: boolean;
  31516. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31517. validateShaderPrograms: boolean;
  31518. /**
  31519. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31520. * This can provide greater z depth for distant objects.
  31521. */
  31522. useReverseDepthBuffer: boolean;
  31523. /**
  31524. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31525. */
  31526. disableUniformBuffers: boolean;
  31527. /** @hidden */
  31528. _uniformBuffers: UniformBuffer[];
  31529. /**
  31530. * Gets a boolean indicating that the engine supports uniform buffers
  31531. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31532. */
  31533. get supportsUniformBuffers(): boolean;
  31534. /** @hidden */
  31535. _gl: WebGLRenderingContext;
  31536. /** @hidden */
  31537. _webGLVersion: number;
  31538. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31539. protected _windowIsBackground: boolean;
  31540. protected _creationOptions: EngineOptions;
  31541. protected _highPrecisionShadersAllowed: boolean;
  31542. /** @hidden */
  31543. get _shouldUseHighPrecisionShader(): boolean;
  31544. /**
  31545. * Gets a boolean indicating that only power of 2 textures are supported
  31546. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31547. */
  31548. get needPOTTextures(): boolean;
  31549. /** @hidden */
  31550. _badOS: boolean;
  31551. /** @hidden */
  31552. _badDesktopOS: boolean;
  31553. private _hardwareScalingLevel;
  31554. /** @hidden */
  31555. _caps: EngineCapabilities;
  31556. private _isStencilEnable;
  31557. private _glVersion;
  31558. private _glRenderer;
  31559. private _glVendor;
  31560. /** @hidden */
  31561. _videoTextureSupported: boolean;
  31562. protected _renderingQueueLaunched: boolean;
  31563. protected _activeRenderLoops: (() => void)[];
  31564. /**
  31565. * Observable signaled when a context lost event is raised
  31566. */
  31567. onContextLostObservable: Observable<ThinEngine>;
  31568. /**
  31569. * Observable signaled when a context restored event is raised
  31570. */
  31571. onContextRestoredObservable: Observable<ThinEngine>;
  31572. private _onContextLost;
  31573. private _onContextRestored;
  31574. protected _contextWasLost: boolean;
  31575. /** @hidden */
  31576. _doNotHandleContextLost: boolean;
  31577. /**
  31578. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31579. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31580. */
  31581. get doNotHandleContextLost(): boolean;
  31582. set doNotHandleContextLost(value: boolean);
  31583. /**
  31584. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31585. */
  31586. disableVertexArrayObjects: boolean;
  31587. /** @hidden */
  31588. protected _colorWrite: boolean;
  31589. /** @hidden */
  31590. protected _colorWriteChanged: boolean;
  31591. /** @hidden */
  31592. protected _depthCullingState: DepthCullingState;
  31593. /** @hidden */
  31594. protected _stencilState: StencilState;
  31595. /** @hidden */
  31596. _alphaState: AlphaState;
  31597. /** @hidden */
  31598. _alphaMode: number;
  31599. /** @hidden */
  31600. _alphaEquation: number;
  31601. /** @hidden */
  31602. _internalTexturesCache: InternalTexture[];
  31603. /** @hidden */
  31604. protected _activeChannel: number;
  31605. private _currentTextureChannel;
  31606. /** @hidden */
  31607. protected _boundTexturesCache: {
  31608. [key: string]: Nullable<InternalTexture>;
  31609. };
  31610. /** @hidden */
  31611. protected _currentEffect: Nullable<Effect>;
  31612. /** @hidden */
  31613. protected _currentProgram: Nullable<WebGLProgram>;
  31614. private _compiledEffects;
  31615. private _vertexAttribArraysEnabled;
  31616. /** @hidden */
  31617. protected _cachedViewport: Nullable<IViewportLike>;
  31618. private _cachedVertexArrayObject;
  31619. /** @hidden */
  31620. protected _cachedVertexBuffers: any;
  31621. /** @hidden */
  31622. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31623. /** @hidden */
  31624. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31625. /** @hidden */
  31626. _currentRenderTarget: Nullable<InternalTexture>;
  31627. private _uintIndicesCurrentlySet;
  31628. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31629. /** @hidden */
  31630. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31631. private _currentBufferPointers;
  31632. private _currentInstanceLocations;
  31633. private _currentInstanceBuffers;
  31634. private _textureUnits;
  31635. /** @hidden */
  31636. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31637. /** @hidden */
  31638. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31639. /** @hidden */
  31640. _boundRenderFunction: any;
  31641. private _vaoRecordInProgress;
  31642. private _mustWipeVertexAttributes;
  31643. private _emptyTexture;
  31644. private _emptyCubeTexture;
  31645. private _emptyTexture3D;
  31646. private _emptyTexture2DArray;
  31647. /** @hidden */
  31648. _frameHandler: number;
  31649. private _nextFreeTextureSlots;
  31650. private _maxSimultaneousTextures;
  31651. private _activeRequests;
  31652. /** @hidden */
  31653. _transformTextureUrl: Nullable<(url: string) => string>;
  31654. protected get _supportsHardwareTextureRescaling(): boolean;
  31655. private _framebufferDimensionsObject;
  31656. /**
  31657. * sets the object from which width and height will be taken from when getting render width and height
  31658. * Will fallback to the gl object
  31659. * @param dimensions the framebuffer width and height that will be used.
  31660. */
  31661. set framebufferDimensionsObject(dimensions: Nullable<{
  31662. framebufferWidth: number;
  31663. framebufferHeight: number;
  31664. }>);
  31665. /**
  31666. * Gets the current viewport
  31667. */
  31668. get currentViewport(): Nullable<IViewportLike>;
  31669. /**
  31670. * Gets the default empty texture
  31671. */
  31672. get emptyTexture(): InternalTexture;
  31673. /**
  31674. * Gets the default empty 3D texture
  31675. */
  31676. get emptyTexture3D(): InternalTexture;
  31677. /**
  31678. * Gets the default empty 2D array texture
  31679. */
  31680. get emptyTexture2DArray(): InternalTexture;
  31681. /**
  31682. * Gets the default empty cube texture
  31683. */
  31684. get emptyCubeTexture(): InternalTexture;
  31685. /**
  31686. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31687. */
  31688. readonly premultipliedAlpha: boolean;
  31689. /**
  31690. * Observable event triggered before each texture is initialized
  31691. */
  31692. onBeforeTextureInitObservable: Observable<Texture>;
  31693. /**
  31694. * Creates a new engine
  31695. * @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
  31696. * @param antialias defines enable antialiasing (default: false)
  31697. * @param options defines further options to be sent to the getContext() function
  31698. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31699. */
  31700. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31701. private _rebuildInternalTextures;
  31702. private _rebuildEffects;
  31703. /**
  31704. * Gets a boolean indicating if all created effects are ready
  31705. * @returns true if all effects are ready
  31706. */
  31707. areAllEffectsReady(): boolean;
  31708. protected _rebuildBuffers(): void;
  31709. protected _initGLContext(): void;
  31710. /**
  31711. * Gets version of the current webGL context
  31712. */
  31713. get webGLVersion(): number;
  31714. /**
  31715. * Gets a string idenfifying the name of the class
  31716. * @returns "Engine" string
  31717. */
  31718. getClassName(): string;
  31719. /**
  31720. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31721. */
  31722. get isStencilEnable(): boolean;
  31723. /** @hidden */
  31724. _prepareWorkingCanvas(): void;
  31725. /**
  31726. * Reset the texture cache to empty state
  31727. */
  31728. resetTextureCache(): void;
  31729. /**
  31730. * Gets an object containing information about the current webGL context
  31731. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31732. */
  31733. getGlInfo(): {
  31734. vendor: string;
  31735. renderer: string;
  31736. version: string;
  31737. };
  31738. /**
  31739. * Defines the hardware scaling level.
  31740. * By default the hardware scaling level is computed from the window device ratio.
  31741. * 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.
  31742. * @param level defines the level to use
  31743. */
  31744. setHardwareScalingLevel(level: number): void;
  31745. /**
  31746. * Gets the current hardware scaling level.
  31747. * By default the hardware scaling level is computed from the window device ratio.
  31748. * 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.
  31749. * @returns a number indicating the current hardware scaling level
  31750. */
  31751. getHardwareScalingLevel(): number;
  31752. /**
  31753. * Gets the list of loaded textures
  31754. * @returns an array containing all loaded textures
  31755. */
  31756. getLoadedTexturesCache(): InternalTexture[];
  31757. /**
  31758. * Gets the object containing all engine capabilities
  31759. * @returns the EngineCapabilities object
  31760. */
  31761. getCaps(): EngineCapabilities;
  31762. /**
  31763. * stop executing a render loop function and remove it from the execution array
  31764. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31765. */
  31766. stopRenderLoop(renderFunction?: () => void): void;
  31767. /** @hidden */
  31768. _renderLoop(): void;
  31769. /**
  31770. * Gets the HTML canvas attached with the current webGL context
  31771. * @returns a HTML canvas
  31772. */
  31773. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31774. /**
  31775. * Gets host window
  31776. * @returns the host window object
  31777. */
  31778. getHostWindow(): Nullable<Window>;
  31779. /**
  31780. * Gets the current render width
  31781. * @param useScreen defines if screen size must be used (or the current render target if any)
  31782. * @returns a number defining the current render width
  31783. */
  31784. getRenderWidth(useScreen?: boolean): number;
  31785. /**
  31786. * Gets the current render height
  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 height
  31789. */
  31790. getRenderHeight(useScreen?: boolean): number;
  31791. /**
  31792. * Can be used to override the current requestAnimationFrame requester.
  31793. * @hidden
  31794. */
  31795. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31796. /**
  31797. * Register and execute a render loop. The engine can have more than one render function
  31798. * @param renderFunction defines the function to continuously execute
  31799. */
  31800. runRenderLoop(renderFunction: () => void): void;
  31801. /**
  31802. * Clear the current render buffer or the current render target (if any is set up)
  31803. * @param color defines the color to use
  31804. * @param backBuffer defines if the back buffer must be cleared
  31805. * @param depth defines if the depth buffer must be cleared
  31806. * @param stencil defines if the stencil buffer must be cleared
  31807. */
  31808. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31809. private _viewportCached;
  31810. /** @hidden */
  31811. _viewport(x: number, y: number, width: number, height: number): void;
  31812. /**
  31813. * Set the WebGL's viewport
  31814. * @param viewport defines the viewport element to be used
  31815. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31816. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31817. */
  31818. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31819. /**
  31820. * Begin a new frame
  31821. */
  31822. beginFrame(): void;
  31823. /**
  31824. * Enf the current frame
  31825. */
  31826. endFrame(): void;
  31827. /**
  31828. * Resize the view according to the canvas' size
  31829. */
  31830. resize(): void;
  31831. /**
  31832. * Force a specific size of the canvas
  31833. * @param width defines the new canvas' width
  31834. * @param height defines the new canvas' height
  31835. */
  31836. setSize(width: number, height: number): void;
  31837. /**
  31838. * Binds the frame buffer to the specified texture.
  31839. * @param texture The texture to render to or null for the default canvas
  31840. * @param faceIndex The face of the texture to render to in case of cube texture
  31841. * @param requiredWidth The width of the target to render to
  31842. * @param requiredHeight The height of the target to render to
  31843. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31844. * @param lodLevel defines the lod level to bind to the frame buffer
  31845. * @param layer defines the 2d array index to bind to frame buffer to
  31846. */
  31847. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31848. /** @hidden */
  31849. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31850. /**
  31851. * Unbind the current render target texture from the webGL context
  31852. * @param texture defines the render target texture to unbind
  31853. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31854. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31855. */
  31856. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31857. /**
  31858. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31859. */
  31860. flushFramebuffer(): void;
  31861. /**
  31862. * Unbind the current render target and bind the default framebuffer
  31863. */
  31864. restoreDefaultFramebuffer(): void;
  31865. /** @hidden */
  31866. protected _resetVertexBufferBinding(): void;
  31867. /**
  31868. * Creates a vertex buffer
  31869. * @param data the data for the vertex buffer
  31870. * @returns the new WebGL static buffer
  31871. */
  31872. createVertexBuffer(data: DataArray): DataBuffer;
  31873. private _createVertexBuffer;
  31874. /**
  31875. * Creates a dynamic vertex buffer
  31876. * @param data the data for the dynamic vertex buffer
  31877. * @returns the new WebGL dynamic buffer
  31878. */
  31879. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31880. protected _resetIndexBufferBinding(): void;
  31881. /**
  31882. * Creates a new index buffer
  31883. * @param indices defines the content of the index buffer
  31884. * @param updatable defines if the index buffer must be updatable
  31885. * @returns a new webGL buffer
  31886. */
  31887. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31888. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31889. /**
  31890. * Bind a webGL buffer to the webGL context
  31891. * @param buffer defines the buffer to bind
  31892. */
  31893. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31894. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31895. private bindBuffer;
  31896. /**
  31897. * update the bound buffer with the given data
  31898. * @param data defines the data to update
  31899. */
  31900. updateArrayBuffer(data: Float32Array): void;
  31901. private _vertexAttribPointer;
  31902. /** @hidden */
  31903. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31904. private _bindVertexBuffersAttributes;
  31905. /**
  31906. * Records a vertex array object
  31907. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31908. * @param vertexBuffers defines the list of vertex buffers to store
  31909. * @param indexBuffer defines the index buffer to store
  31910. * @param effect defines the effect to store
  31911. * @returns the new vertex array object
  31912. */
  31913. recordVertexArrayObject(vertexBuffers: {
  31914. [key: string]: VertexBuffer;
  31915. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31916. /**
  31917. * Bind a specific vertex array object
  31918. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31919. * @param vertexArrayObject defines the vertex array object to bind
  31920. * @param indexBuffer defines the index buffer to bind
  31921. */
  31922. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31923. /**
  31924. * Bind webGl buffers directly to the webGL context
  31925. * @param vertexBuffer defines the vertex buffer to bind
  31926. * @param indexBuffer defines the index buffer to bind
  31927. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31928. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31929. * @param effect defines the effect associated with the vertex buffer
  31930. */
  31931. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31932. private _unbindVertexArrayObject;
  31933. /**
  31934. * Bind a list of vertex buffers to the webGL context
  31935. * @param vertexBuffers defines the list of vertex buffers to bind
  31936. * @param indexBuffer defines the index buffer to bind
  31937. * @param effect defines the effect associated with the vertex buffers
  31938. */
  31939. bindBuffers(vertexBuffers: {
  31940. [key: string]: Nullable<VertexBuffer>;
  31941. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31942. /**
  31943. * Unbind all instance attributes
  31944. */
  31945. unbindInstanceAttributes(): void;
  31946. /**
  31947. * Release and free the memory of a vertex array object
  31948. * @param vao defines the vertex array object to delete
  31949. */
  31950. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31951. /** @hidden */
  31952. _releaseBuffer(buffer: DataBuffer): boolean;
  31953. protected _deleteBuffer(buffer: DataBuffer): void;
  31954. /**
  31955. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31956. * @param instancesBuffer defines the webGL buffer to update and bind
  31957. * @param data defines the data to store in the buffer
  31958. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31959. */
  31960. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31961. /**
  31962. * Bind the content of a webGL buffer used with instantiation
  31963. * @param instancesBuffer defines the webGL buffer to bind
  31964. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31965. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31966. */
  31967. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31968. /**
  31969. * Disable the instance attribute corresponding to the name in parameter
  31970. * @param name defines the name of the attribute to disable
  31971. */
  31972. disableInstanceAttributeByName(name: string): void;
  31973. /**
  31974. * Disable the instance attribute corresponding to the location in parameter
  31975. * @param attributeLocation defines the attribute location of the attribute to disable
  31976. */
  31977. disableInstanceAttribute(attributeLocation: number): void;
  31978. /**
  31979. * Disable the attribute corresponding to the location in parameter
  31980. * @param attributeLocation defines the attribute location of the attribute to disable
  31981. */
  31982. disableAttributeByIndex(attributeLocation: number): void;
  31983. /**
  31984. * Send a draw order
  31985. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31986. * @param indexStart defines the starting index
  31987. * @param indexCount defines the number of index to draw
  31988. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31989. */
  31990. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31991. /**
  31992. * Draw a list of points
  31993. * @param verticesStart defines the index of first vertex to draw
  31994. * @param verticesCount defines the count of vertices to draw
  31995. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31996. */
  31997. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31998. /**
  31999. * Draw a list of unindexed primitives
  32000. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32001. * @param verticesStart defines the index of first vertex to draw
  32002. * @param verticesCount defines the count of vertices to draw
  32003. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32004. */
  32005. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32006. /**
  32007. * Draw a list of indexed primitives
  32008. * @param fillMode defines the primitive to use
  32009. * @param indexStart defines the starting index
  32010. * @param indexCount defines the number of index to draw
  32011. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32012. */
  32013. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32014. /**
  32015. * Draw a list of unindexed primitives
  32016. * @param fillMode defines the primitive to use
  32017. * @param verticesStart defines the index of first vertex to draw
  32018. * @param verticesCount defines the count of vertices to draw
  32019. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32020. */
  32021. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32022. private _drawMode;
  32023. /** @hidden */
  32024. protected _reportDrawCall(): void;
  32025. /** @hidden */
  32026. _releaseEffect(effect: Effect): void;
  32027. /** @hidden */
  32028. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32029. /**
  32030. * Create a new effect (used to store vertex/fragment shaders)
  32031. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32032. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32033. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32034. * @param samplers defines an array of string used to represent textures
  32035. * @param defines defines the string containing the defines to use to compile the shaders
  32036. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32037. * @param onCompiled defines a function to call when the effect creation is successful
  32038. * @param onError defines a function to call when the effect creation has failed
  32039. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32040. * @returns the new Effect
  32041. */
  32042. 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;
  32043. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32044. private _compileShader;
  32045. private _compileRawShader;
  32046. /** @hidden */
  32047. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32048. /**
  32049. * Directly creates a webGL program
  32050. * @param pipelineContext defines the pipeline context to attach to
  32051. * @param vertexCode defines the vertex shader code to use
  32052. * @param fragmentCode defines the fragment shader code to use
  32053. * @param context defines the webGL context to use (if not set, the current one will be used)
  32054. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32055. * @returns the new webGL program
  32056. */
  32057. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32058. /**
  32059. * Creates a webGL program
  32060. * @param pipelineContext defines the pipeline context to attach to
  32061. * @param vertexCode defines the vertex shader code to use
  32062. * @param fragmentCode defines the fragment shader code to use
  32063. * @param defines defines the string containing the defines to use to compile the shaders
  32064. * @param context defines the webGL context to use (if not set, the current one will be used)
  32065. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32066. * @returns the new webGL program
  32067. */
  32068. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32069. /**
  32070. * Creates a new pipeline context
  32071. * @returns the new pipeline
  32072. */
  32073. createPipelineContext(): IPipelineContext;
  32074. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32075. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32076. /** @hidden */
  32077. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32078. /** @hidden */
  32079. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32080. /** @hidden */
  32081. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32082. /**
  32083. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32084. * @param pipelineContext defines the pipeline context to use
  32085. * @param uniformsNames defines the list of uniform names
  32086. * @returns an array of webGL uniform locations
  32087. */
  32088. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32089. /**
  32090. * Gets the lsit of active attributes for a given webGL program
  32091. * @param pipelineContext defines the pipeline context to use
  32092. * @param attributesNames defines the list of attribute names to get
  32093. * @returns an array of indices indicating the offset of each attribute
  32094. */
  32095. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32096. /**
  32097. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32098. * @param effect defines the effect to activate
  32099. */
  32100. enableEffect(effect: Nullable<Effect>): void;
  32101. /**
  32102. * Set the value of an uniform to a number (int)
  32103. * @param uniform defines the webGL uniform location where to store the value
  32104. * @param value defines the int number to store
  32105. */
  32106. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32107. /**
  32108. * Set the value of an uniform to an array of int32
  32109. * @param uniform defines the webGL uniform location where to store the value
  32110. * @param array defines the array of int32 to store
  32111. */
  32112. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32113. /**
  32114. * Set the value of an uniform to an array of int32 (stored as vec2)
  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. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32119. /**
  32120. * Set the value of an uniform to an array of int32 (stored as vec3)
  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. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32125. /**
  32126. * Set the value of an uniform to an array of int32 (stored as vec4)
  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. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32131. /**
  32132. * Set the value of an uniform to an array of number
  32133. * @param uniform defines the webGL uniform location where to store the value
  32134. * @param array defines the array of number to store
  32135. */
  32136. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32137. /**
  32138. * Set the value of an uniform to an array of number (stored as vec2)
  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. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32143. /**
  32144. * Set the value of an uniform to an array of number (stored as vec3)
  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. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32149. /**
  32150. * Set the value of an uniform to an array of number (stored as vec4)
  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. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32155. /**
  32156. * Set the value of an uniform to an array of float32 (stored as matrices)
  32157. * @param uniform defines the webGL uniform location where to store the value
  32158. * @param matrices defines the array of float32 to store
  32159. */
  32160. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32161. /**
  32162. * Set the value of an uniform to a matrix (3x3)
  32163. * @param uniform defines the webGL uniform location where to store the value
  32164. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32165. */
  32166. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32167. /**
  32168. * Set the value of an uniform to a matrix (2x2)
  32169. * @param uniform defines the webGL uniform location where to store the value
  32170. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32171. */
  32172. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32173. /**
  32174. * Set the value of an uniform to a number (float)
  32175. * @param uniform defines the webGL uniform location where to store the value
  32176. * @param value defines the float number to store
  32177. */
  32178. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32179. /**
  32180. * Set the value of an uniform to a vec2
  32181. * @param uniform defines the webGL uniform location where to store the value
  32182. * @param x defines the 1st component of the value
  32183. * @param y defines the 2nd component of the value
  32184. */
  32185. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32186. /**
  32187. * Set the value of an uniform to a vec3
  32188. * @param uniform defines the webGL uniform location where to store the value
  32189. * @param x defines the 1st component of the value
  32190. * @param y defines the 2nd component of the value
  32191. * @param z defines the 3rd component of the value
  32192. */
  32193. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32194. /**
  32195. * Set the value of an uniform to a vec4
  32196. * @param uniform defines the webGL uniform location where to store the value
  32197. * @param x defines the 1st component of the value
  32198. * @param y defines the 2nd component of the value
  32199. * @param z defines the 3rd component of the value
  32200. * @param w defines the 4th component of the value
  32201. */
  32202. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32203. /**
  32204. * Apply all cached states (depth, culling, stencil and alpha)
  32205. */
  32206. applyStates(): void;
  32207. /**
  32208. * Enable or disable color writing
  32209. * @param enable defines the state to set
  32210. */
  32211. setColorWrite(enable: boolean): void;
  32212. /**
  32213. * Gets a boolean indicating if color writing is enabled
  32214. * @returns the current color writing state
  32215. */
  32216. getColorWrite(): boolean;
  32217. /**
  32218. * Gets the depth culling state manager
  32219. */
  32220. get depthCullingState(): DepthCullingState;
  32221. /**
  32222. * Gets the alpha state manager
  32223. */
  32224. get alphaState(): AlphaState;
  32225. /**
  32226. * Gets the stencil state manager
  32227. */
  32228. get stencilState(): StencilState;
  32229. /**
  32230. * Clears the list of texture accessible through engine.
  32231. * This can help preventing texture load conflict due to name collision.
  32232. */
  32233. clearInternalTexturesCache(): void;
  32234. /**
  32235. * Force the entire cache to be cleared
  32236. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32237. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32238. */
  32239. wipeCaches(bruteForce?: boolean): void;
  32240. /** @hidden */
  32241. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32242. min: number;
  32243. mag: number;
  32244. };
  32245. /** @hidden */
  32246. _createTexture(): WebGLTexture;
  32247. /**
  32248. * Usually called from Texture.ts.
  32249. * Passed information to create a WebGLTexture
  32250. * @param url defines a value which contains one of the following:
  32251. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32252. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32253. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32254. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32255. * @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)
  32256. * @param scene needed for loading to the correct scene
  32257. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32258. * @param onLoad optional callback to be called upon successful completion
  32259. * @param onError optional callback to be called upon failure
  32260. * @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
  32261. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32262. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32263. * @param forcedExtension defines the extension to use to pick the right loader
  32264. * @param mimeType defines an optional mime type
  32265. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32266. */
  32267. 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;
  32268. /**
  32269. * Loads an image as an HTMLImageElement.
  32270. * @param input url string, ArrayBuffer, or Blob to load
  32271. * @param onLoad callback called when the image successfully loads
  32272. * @param onError callback called when the image fails to load
  32273. * @param offlineProvider offline provider for caching
  32274. * @param mimeType optional mime type
  32275. * @returns the HTMLImageElement of the loaded image
  32276. * @hidden
  32277. */
  32278. 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>;
  32279. /**
  32280. * @hidden
  32281. */
  32282. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32283. /**
  32284. * Creates a raw texture
  32285. * @param data defines the data to store in the texture
  32286. * @param width defines the width of the texture
  32287. * @param height defines the height of the texture
  32288. * @param format defines the format of the data
  32289. * @param generateMipMaps defines if the engine should generate the mip levels
  32290. * @param invertY defines if data must be stored with Y axis inverted
  32291. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32292. * @param compression defines the compression used (null by default)
  32293. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32294. * @returns the raw texture inside an InternalTexture
  32295. */
  32296. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32297. /**
  32298. * Creates a new raw cube texture
  32299. * @param data defines the array of data to use to create each face
  32300. * @param size defines the size of the textures
  32301. * @param format defines the format of the data
  32302. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32303. * @param generateMipMaps defines if the engine should generate the mip levels
  32304. * @param invertY defines if data must be stored with Y axis inverted
  32305. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32306. * @param compression defines the compression used (null by default)
  32307. * @returns the cube texture as an InternalTexture
  32308. */
  32309. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32310. /**
  32311. * Creates a new raw 3D texture
  32312. * @param data defines the data used to create the texture
  32313. * @param width defines the width of the texture
  32314. * @param height defines the height of the texture
  32315. * @param depth defines the depth of the texture
  32316. * @param format defines the format of the texture
  32317. * @param generateMipMaps defines if the engine must generate mip levels
  32318. * @param invertY defines if data must be stored with Y axis inverted
  32319. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32320. * @param compression defines the compressed used (can be null)
  32321. * @param textureType defines the compressed used (can be null)
  32322. * @returns a new raw 3D texture (stored in an InternalTexture)
  32323. */
  32324. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32325. /**
  32326. * Creates a new raw 2D array texture
  32327. * @param data defines the data used to create the texture
  32328. * @param width defines the width of the texture
  32329. * @param height defines the height of the texture
  32330. * @param depth defines the number of layers of the texture
  32331. * @param format defines the format of the texture
  32332. * @param generateMipMaps defines if the engine must generate mip levels
  32333. * @param invertY defines if data must be stored with Y axis inverted
  32334. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32335. * @param compression defines the compressed used (can be null)
  32336. * @param textureType defines the compressed used (can be null)
  32337. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32338. */
  32339. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32340. private _unpackFlipYCached;
  32341. /**
  32342. * In case you are sharing the context with other applications, it might
  32343. * be interested to not cache the unpack flip y state to ensure a consistent
  32344. * value would be set.
  32345. */
  32346. enableUnpackFlipYCached: boolean;
  32347. /** @hidden */
  32348. _unpackFlipY(value: boolean): void;
  32349. /** @hidden */
  32350. _getUnpackAlignement(): number;
  32351. private _getTextureTarget;
  32352. /**
  32353. * Update the sampling mode of a given texture
  32354. * @param samplingMode defines the required sampling mode
  32355. * @param texture defines the texture to update
  32356. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32357. */
  32358. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32359. /**
  32360. * Update the sampling mode of a given texture
  32361. * @param texture defines the texture to update
  32362. * @param wrapU defines the texture wrap mode of the u coordinates
  32363. * @param wrapV defines the texture wrap mode of the v coordinates
  32364. * @param wrapR defines the texture wrap mode of the r coordinates
  32365. */
  32366. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32367. /** @hidden */
  32368. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32369. width: number;
  32370. height: number;
  32371. layers?: number;
  32372. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32373. /** @hidden */
  32374. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32375. /** @hidden */
  32376. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32377. /**
  32378. * Update a portion of an internal texture
  32379. * @param texture defines the texture to update
  32380. * @param imageData defines the data to store into the texture
  32381. * @param xOffset defines the x coordinates of the update rectangle
  32382. * @param yOffset defines the y coordinates of the update rectangle
  32383. * @param width defines the width of the update rectangle
  32384. * @param height defines the height of the update rectangle
  32385. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32386. * @param lod defines the lod level to update (0 by default)
  32387. */
  32388. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32389. /** @hidden */
  32390. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32391. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32392. private _prepareWebGLTexture;
  32393. /** @hidden */
  32394. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32395. private _getDepthStencilBuffer;
  32396. /** @hidden */
  32397. _releaseFramebufferObjects(texture: InternalTexture): void;
  32398. /** @hidden */
  32399. _releaseTexture(texture: InternalTexture): void;
  32400. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32401. protected _setProgram(program: WebGLProgram): void;
  32402. protected _boundUniforms: {
  32403. [key: number]: WebGLUniformLocation;
  32404. };
  32405. /**
  32406. * Binds an effect to the webGL context
  32407. * @param effect defines the effect to bind
  32408. */
  32409. bindSamplers(effect: Effect): void;
  32410. private _activateCurrentTexture;
  32411. /** @hidden */
  32412. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32413. /** @hidden */
  32414. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32415. /**
  32416. * Unbind all textures from the webGL context
  32417. */
  32418. unbindAllTextures(): void;
  32419. /**
  32420. * Sets a texture to the according uniform.
  32421. * @param channel The texture channel
  32422. * @param uniform The uniform to set
  32423. * @param texture The texture to apply
  32424. */
  32425. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32426. private _bindSamplerUniformToChannel;
  32427. private _getTextureWrapMode;
  32428. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32429. /**
  32430. * Sets an array of texture to the webGL context
  32431. * @param channel defines the channel where the texture array must be set
  32432. * @param uniform defines the associated uniform location
  32433. * @param textures defines the array of textures to bind
  32434. */
  32435. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32436. /** @hidden */
  32437. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32438. private _setTextureParameterFloat;
  32439. private _setTextureParameterInteger;
  32440. /**
  32441. * Unbind all vertex attributes from the webGL context
  32442. */
  32443. unbindAllAttributes(): void;
  32444. /**
  32445. * 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
  32446. */
  32447. releaseEffects(): void;
  32448. /**
  32449. * Dispose and release all associated resources
  32450. */
  32451. dispose(): void;
  32452. /**
  32453. * Attach a new callback raised when context lost event is fired
  32454. * @param callback defines the callback to call
  32455. */
  32456. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32457. /**
  32458. * Attach a new callback raised when context restored event is fired
  32459. * @param callback defines the callback to call
  32460. */
  32461. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32462. /**
  32463. * Get the current error code of the webGL context
  32464. * @returns the error code
  32465. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32466. */
  32467. getError(): number;
  32468. private _canRenderToFloatFramebuffer;
  32469. private _canRenderToHalfFloatFramebuffer;
  32470. private _canRenderToFramebuffer;
  32471. /** @hidden */
  32472. _getWebGLTextureType(type: number): number;
  32473. /** @hidden */
  32474. _getInternalFormat(format: number): number;
  32475. /** @hidden */
  32476. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32477. /** @hidden */
  32478. _getRGBAMultiSampleBufferFormat(type: number): number;
  32479. /** @hidden */
  32480. _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;
  32481. /**
  32482. * Loads a file from a url
  32483. * @param url url to load
  32484. * @param onSuccess callback called when the file successfully loads
  32485. * @param onProgress callback called while file is loading (if the server supports this mode)
  32486. * @param offlineProvider defines the offline provider for caching
  32487. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32488. * @param onError callback called when the file fails to load
  32489. * @returns a file request object
  32490. * @hidden
  32491. */
  32492. 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;
  32493. /**
  32494. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32495. * @param x defines the x coordinate of the rectangle where pixels must be read
  32496. * @param y defines the y coordinate of the rectangle where pixels must be read
  32497. * @param width defines the width of the rectangle where pixels must be read
  32498. * @param height defines the height of the rectangle where pixels must be read
  32499. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32500. * @returns a Uint8Array containing RGBA colors
  32501. */
  32502. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32503. private static _isSupported;
  32504. /**
  32505. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32506. * @returns true if the engine can be created
  32507. * @ignorenaming
  32508. */
  32509. static isSupported(): boolean;
  32510. /**
  32511. * Find the next highest power of two.
  32512. * @param x Number to start search from.
  32513. * @return Next highest power of two.
  32514. */
  32515. static CeilingPOT(x: number): number;
  32516. /**
  32517. * Find the next lowest power of two.
  32518. * @param x Number to start search from.
  32519. * @return Next lowest power of two.
  32520. */
  32521. static FloorPOT(x: number): number;
  32522. /**
  32523. * Find the nearest power of two.
  32524. * @param x Number to start search from.
  32525. * @return Next nearest power of two.
  32526. */
  32527. static NearestPOT(x: number): number;
  32528. /**
  32529. * Get the closest exponent of two
  32530. * @param value defines the value to approximate
  32531. * @param max defines the maximum value to return
  32532. * @param mode defines how to define the closest value
  32533. * @returns closest exponent of two of the given value
  32534. */
  32535. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32536. /**
  32537. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32538. * @param func - the function to be called
  32539. * @param requester - the object that will request the next frame. Falls back to window.
  32540. * @returns frame number
  32541. */
  32542. static QueueNewFrame(func: () => void, requester?: any): number;
  32543. /**
  32544. * Gets host document
  32545. * @returns the host document object
  32546. */
  32547. getHostDocument(): Nullable<Document>;
  32548. }
  32549. }
  32550. declare module BABYLON {
  32551. /**
  32552. * Class representing spherical harmonics coefficients to the 3rd degree
  32553. */
  32554. export class SphericalHarmonics {
  32555. /**
  32556. * Defines whether or not the harmonics have been prescaled for rendering.
  32557. */
  32558. preScaled: boolean;
  32559. /**
  32560. * The l0,0 coefficients of the spherical harmonics
  32561. */
  32562. l00: Vector3;
  32563. /**
  32564. * The l1,-1 coefficients of the spherical harmonics
  32565. */
  32566. l1_1: Vector3;
  32567. /**
  32568. * The l1,0 coefficients of the spherical harmonics
  32569. */
  32570. l10: Vector3;
  32571. /**
  32572. * The l1,1 coefficients of the spherical harmonics
  32573. */
  32574. l11: Vector3;
  32575. /**
  32576. * The l2,-2 coefficients of the spherical harmonics
  32577. */
  32578. l2_2: Vector3;
  32579. /**
  32580. * The l2,-1 coefficients of the spherical harmonics
  32581. */
  32582. l2_1: Vector3;
  32583. /**
  32584. * The l2,0 coefficients of the spherical harmonics
  32585. */
  32586. l20: Vector3;
  32587. /**
  32588. * The l2,1 coefficients of the spherical harmonics
  32589. */
  32590. l21: Vector3;
  32591. /**
  32592. * The l2,2 coefficients of the spherical harmonics
  32593. */
  32594. l22: Vector3;
  32595. /**
  32596. * Adds a light to the spherical harmonics
  32597. * @param direction the direction of the light
  32598. * @param color the color of the light
  32599. * @param deltaSolidAngle the delta solid angle of the light
  32600. */
  32601. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32602. /**
  32603. * Scales the spherical harmonics by the given amount
  32604. * @param scale the amount to scale
  32605. */
  32606. scaleInPlace(scale: number): void;
  32607. /**
  32608. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32609. *
  32610. * ```
  32611. * E_lm = A_l * L_lm
  32612. * ```
  32613. *
  32614. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32615. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32616. * the scaling factors are given in equation 9.
  32617. */
  32618. convertIncidentRadianceToIrradiance(): void;
  32619. /**
  32620. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32621. *
  32622. * ```
  32623. * L = (1/pi) * E * rho
  32624. * ```
  32625. *
  32626. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32627. */
  32628. convertIrradianceToLambertianRadiance(): void;
  32629. /**
  32630. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32631. * required operations at run time.
  32632. *
  32633. * This is simply done by scaling back the SH with Ylm constants parameter.
  32634. * The trigonometric part being applied by the shader at run time.
  32635. */
  32636. preScaleForRendering(): void;
  32637. /**
  32638. * Constructs a spherical harmonics from an array.
  32639. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32640. * @returns the spherical harmonics
  32641. */
  32642. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32643. /**
  32644. * Gets the spherical harmonics from polynomial
  32645. * @param polynomial the spherical polynomial
  32646. * @returns the spherical harmonics
  32647. */
  32648. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32649. }
  32650. /**
  32651. * Class representing spherical polynomial coefficients to the 3rd degree
  32652. */
  32653. export class SphericalPolynomial {
  32654. private _harmonics;
  32655. /**
  32656. * The spherical harmonics used to create the polynomials.
  32657. */
  32658. get preScaledHarmonics(): SphericalHarmonics;
  32659. /**
  32660. * The x coefficients of the spherical polynomial
  32661. */
  32662. x: Vector3;
  32663. /**
  32664. * The y coefficients of the spherical polynomial
  32665. */
  32666. y: Vector3;
  32667. /**
  32668. * The z coefficients of the spherical polynomial
  32669. */
  32670. z: Vector3;
  32671. /**
  32672. * The xx coefficients of the spherical polynomial
  32673. */
  32674. xx: Vector3;
  32675. /**
  32676. * The yy coefficients of the spherical polynomial
  32677. */
  32678. yy: Vector3;
  32679. /**
  32680. * The zz coefficients of the spherical polynomial
  32681. */
  32682. zz: Vector3;
  32683. /**
  32684. * The xy coefficients of the spherical polynomial
  32685. */
  32686. xy: Vector3;
  32687. /**
  32688. * The yz coefficients of the spherical polynomial
  32689. */
  32690. yz: Vector3;
  32691. /**
  32692. * The zx coefficients of the spherical polynomial
  32693. */
  32694. zx: Vector3;
  32695. /**
  32696. * Adds an ambient color to the spherical polynomial
  32697. * @param color the color to add
  32698. */
  32699. addAmbient(color: Color3): void;
  32700. /**
  32701. * Scales the spherical polynomial by the given amount
  32702. * @param scale the amount to scale
  32703. */
  32704. scaleInPlace(scale: number): void;
  32705. /**
  32706. * Gets the spherical polynomial from harmonics
  32707. * @param harmonics the spherical harmonics
  32708. * @returns the spherical polynomial
  32709. */
  32710. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32711. /**
  32712. * Constructs a spherical polynomial from an array.
  32713. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32714. * @returns the spherical polynomial
  32715. */
  32716. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32717. }
  32718. }
  32719. declare module BABYLON {
  32720. /**
  32721. * Defines the source of the internal texture
  32722. */
  32723. export enum InternalTextureSource {
  32724. /**
  32725. * The source of the texture data is unknown
  32726. */
  32727. Unknown = 0,
  32728. /**
  32729. * Texture data comes from an URL
  32730. */
  32731. Url = 1,
  32732. /**
  32733. * Texture data is only used for temporary storage
  32734. */
  32735. Temp = 2,
  32736. /**
  32737. * Texture data comes from raw data (ArrayBuffer)
  32738. */
  32739. Raw = 3,
  32740. /**
  32741. * Texture content is dynamic (video or dynamic texture)
  32742. */
  32743. Dynamic = 4,
  32744. /**
  32745. * Texture content is generated by rendering to it
  32746. */
  32747. RenderTarget = 5,
  32748. /**
  32749. * Texture content is part of a multi render target process
  32750. */
  32751. MultiRenderTarget = 6,
  32752. /**
  32753. * Texture data comes from a cube data file
  32754. */
  32755. Cube = 7,
  32756. /**
  32757. * Texture data comes from a raw cube data
  32758. */
  32759. CubeRaw = 8,
  32760. /**
  32761. * Texture data come from a prefiltered cube data file
  32762. */
  32763. CubePrefiltered = 9,
  32764. /**
  32765. * Texture content is raw 3D data
  32766. */
  32767. Raw3D = 10,
  32768. /**
  32769. * Texture content is raw 2D array data
  32770. */
  32771. Raw2DArray = 11,
  32772. /**
  32773. * Texture content is a depth texture
  32774. */
  32775. Depth = 12,
  32776. /**
  32777. * Texture data comes from a raw cube data encoded with RGBD
  32778. */
  32779. CubeRawRGBD = 13
  32780. }
  32781. /**
  32782. * Class used to store data associated with WebGL texture data for the engine
  32783. * This class should not be used directly
  32784. */
  32785. export class InternalTexture {
  32786. /** @hidden */
  32787. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32788. /**
  32789. * Defines if the texture is ready
  32790. */
  32791. isReady: boolean;
  32792. /**
  32793. * Defines if the texture is a cube texture
  32794. */
  32795. isCube: boolean;
  32796. /**
  32797. * Defines if the texture contains 3D data
  32798. */
  32799. is3D: boolean;
  32800. /**
  32801. * Defines if the texture contains 2D array data
  32802. */
  32803. is2DArray: boolean;
  32804. /**
  32805. * Defines if the texture contains multiview data
  32806. */
  32807. isMultiview: boolean;
  32808. /**
  32809. * Gets the URL used to load this texture
  32810. */
  32811. url: string;
  32812. /**
  32813. * Gets the sampling mode of the texture
  32814. */
  32815. samplingMode: number;
  32816. /**
  32817. * Gets a boolean indicating if the texture needs mipmaps generation
  32818. */
  32819. generateMipMaps: boolean;
  32820. /**
  32821. * Gets the number of samples used by the texture (WebGL2+ only)
  32822. */
  32823. samples: number;
  32824. /**
  32825. * Gets the type of the texture (int, float...)
  32826. */
  32827. type: number;
  32828. /**
  32829. * Gets the format of the texture (RGB, RGBA...)
  32830. */
  32831. format: number;
  32832. /**
  32833. * Observable called when the texture is loaded
  32834. */
  32835. onLoadedObservable: Observable<InternalTexture>;
  32836. /**
  32837. * Gets the width of the texture
  32838. */
  32839. width: number;
  32840. /**
  32841. * Gets the height of the texture
  32842. */
  32843. height: number;
  32844. /**
  32845. * Gets the depth of the texture
  32846. */
  32847. depth: number;
  32848. /**
  32849. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32850. */
  32851. baseWidth: number;
  32852. /**
  32853. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32854. */
  32855. baseHeight: number;
  32856. /**
  32857. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32858. */
  32859. baseDepth: number;
  32860. /**
  32861. * Gets a boolean indicating if the texture is inverted on Y axis
  32862. */
  32863. invertY: boolean;
  32864. /** @hidden */
  32865. _invertVScale: boolean;
  32866. /** @hidden */
  32867. _associatedChannel: number;
  32868. /** @hidden */
  32869. _source: InternalTextureSource;
  32870. /** @hidden */
  32871. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32872. /** @hidden */
  32873. _bufferView: Nullable<ArrayBufferView>;
  32874. /** @hidden */
  32875. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32876. /** @hidden */
  32877. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32878. /** @hidden */
  32879. _size: number;
  32880. /** @hidden */
  32881. _extension: string;
  32882. /** @hidden */
  32883. _files: Nullable<string[]>;
  32884. /** @hidden */
  32885. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32886. /** @hidden */
  32887. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32888. /** @hidden */
  32889. _framebuffer: Nullable<WebGLFramebuffer>;
  32890. /** @hidden */
  32891. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32892. /** @hidden */
  32893. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32894. /** @hidden */
  32895. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32896. /** @hidden */
  32897. _attachments: Nullable<number[]>;
  32898. /** @hidden */
  32899. _cachedCoordinatesMode: Nullable<number>;
  32900. /** @hidden */
  32901. _cachedWrapU: Nullable<number>;
  32902. /** @hidden */
  32903. _cachedWrapV: Nullable<number>;
  32904. /** @hidden */
  32905. _cachedWrapR: Nullable<number>;
  32906. /** @hidden */
  32907. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32908. /** @hidden */
  32909. _isDisabled: boolean;
  32910. /** @hidden */
  32911. _compression: Nullable<string>;
  32912. /** @hidden */
  32913. _generateStencilBuffer: boolean;
  32914. /** @hidden */
  32915. _generateDepthBuffer: boolean;
  32916. /** @hidden */
  32917. _comparisonFunction: number;
  32918. /** @hidden */
  32919. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32920. /** @hidden */
  32921. _lodGenerationScale: number;
  32922. /** @hidden */
  32923. _lodGenerationOffset: number;
  32924. /** @hidden */
  32925. _depthStencilTexture: Nullable<InternalTexture>;
  32926. /** @hidden */
  32927. _colorTextureArray: Nullable<WebGLTexture>;
  32928. /** @hidden */
  32929. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32930. /** @hidden */
  32931. _lodTextureHigh: Nullable<BaseTexture>;
  32932. /** @hidden */
  32933. _lodTextureMid: Nullable<BaseTexture>;
  32934. /** @hidden */
  32935. _lodTextureLow: Nullable<BaseTexture>;
  32936. /** @hidden */
  32937. _isRGBD: boolean;
  32938. /** @hidden */
  32939. _linearSpecularLOD: boolean;
  32940. /** @hidden */
  32941. _irradianceTexture: Nullable<BaseTexture>;
  32942. /** @hidden */
  32943. _webGLTexture: Nullable<WebGLTexture>;
  32944. /** @hidden */
  32945. _references: number;
  32946. private _engine;
  32947. /**
  32948. * Gets the Engine the texture belongs to.
  32949. * @returns The babylon engine
  32950. */
  32951. getEngine(): ThinEngine;
  32952. /**
  32953. * Gets the data source type of the texture
  32954. */
  32955. get source(): InternalTextureSource;
  32956. /**
  32957. * Creates a new InternalTexture
  32958. * @param engine defines the engine to use
  32959. * @param source defines the type of data that will be used
  32960. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32961. */
  32962. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32963. /**
  32964. * Increments the number of references (ie. the number of Texture that point to it)
  32965. */
  32966. incrementReferences(): void;
  32967. /**
  32968. * Change the size of the texture (not the size of the content)
  32969. * @param width defines the new width
  32970. * @param height defines the new height
  32971. * @param depth defines the new depth (1 by default)
  32972. */
  32973. updateSize(width: int, height: int, depth?: int): void;
  32974. /** @hidden */
  32975. _rebuild(): void;
  32976. /** @hidden */
  32977. _swapAndDie(target: InternalTexture): void;
  32978. /**
  32979. * Dispose the current allocated resources
  32980. */
  32981. dispose(): void;
  32982. }
  32983. }
  32984. declare module BABYLON {
  32985. /**
  32986. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32988. */
  32989. export class Analyser {
  32990. /**
  32991. * Gets or sets the smoothing
  32992. * @ignorenaming
  32993. */
  32994. SMOOTHING: number;
  32995. /**
  32996. * Gets or sets the FFT table size
  32997. * @ignorenaming
  32998. */
  32999. FFT_SIZE: number;
  33000. /**
  33001. * Gets or sets the bar graph amplitude
  33002. * @ignorenaming
  33003. */
  33004. BARGRAPHAMPLITUDE: number;
  33005. /**
  33006. * Gets or sets the position of the debug canvas
  33007. * @ignorenaming
  33008. */
  33009. DEBUGCANVASPOS: {
  33010. x: number;
  33011. y: number;
  33012. };
  33013. /**
  33014. * Gets or sets the debug canvas size
  33015. * @ignorenaming
  33016. */
  33017. DEBUGCANVASSIZE: {
  33018. width: number;
  33019. height: number;
  33020. };
  33021. private _byteFreqs;
  33022. private _byteTime;
  33023. private _floatFreqs;
  33024. private _webAudioAnalyser;
  33025. private _debugCanvas;
  33026. private _debugCanvasContext;
  33027. private _scene;
  33028. private _registerFunc;
  33029. private _audioEngine;
  33030. /**
  33031. * Creates a new analyser
  33032. * @param scene defines hosting scene
  33033. */
  33034. constructor(scene: Scene);
  33035. /**
  33036. * Get the number of data values you will have to play with for the visualization
  33037. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33038. * @returns a number
  33039. */
  33040. getFrequencyBinCount(): number;
  33041. /**
  33042. * Gets the current frequency data as a byte array
  33043. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33044. * @returns a Uint8Array
  33045. */
  33046. getByteFrequencyData(): Uint8Array;
  33047. /**
  33048. * Gets the current waveform as a byte array
  33049. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33050. * @returns a Uint8Array
  33051. */
  33052. getByteTimeDomainData(): Uint8Array;
  33053. /**
  33054. * Gets the current frequency data as a float array
  33055. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33056. * @returns a Float32Array
  33057. */
  33058. getFloatFrequencyData(): Float32Array;
  33059. /**
  33060. * Renders the debug canvas
  33061. */
  33062. drawDebugCanvas(): void;
  33063. /**
  33064. * Stops rendering the debug canvas and removes it
  33065. */
  33066. stopDebugCanvas(): void;
  33067. /**
  33068. * Connects two audio nodes
  33069. * @param inputAudioNode defines first node to connect
  33070. * @param outputAudioNode defines second node to connect
  33071. */
  33072. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33073. /**
  33074. * Releases all associated resources
  33075. */
  33076. dispose(): void;
  33077. }
  33078. }
  33079. declare module BABYLON {
  33080. /**
  33081. * This represents an audio engine and it is responsible
  33082. * to play, synchronize and analyse sounds throughout the application.
  33083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33084. */
  33085. export interface IAudioEngine extends IDisposable {
  33086. /**
  33087. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33088. */
  33089. readonly canUseWebAudio: boolean;
  33090. /**
  33091. * Gets the current AudioContext if available.
  33092. */
  33093. readonly audioContext: Nullable<AudioContext>;
  33094. /**
  33095. * The master gain node defines the global audio volume of your audio engine.
  33096. */
  33097. readonly masterGain: GainNode;
  33098. /**
  33099. * Gets whether or not mp3 are supported by your browser.
  33100. */
  33101. readonly isMP3supported: boolean;
  33102. /**
  33103. * Gets whether or not ogg are supported by your browser.
  33104. */
  33105. readonly isOGGsupported: boolean;
  33106. /**
  33107. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33108. * @ignoreNaming
  33109. */
  33110. WarnedWebAudioUnsupported: boolean;
  33111. /**
  33112. * Defines if the audio engine relies on a custom unlocked button.
  33113. * In this case, the embedded button will not be displayed.
  33114. */
  33115. useCustomUnlockedButton: boolean;
  33116. /**
  33117. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33118. */
  33119. readonly unlocked: boolean;
  33120. /**
  33121. * Event raised when audio has been unlocked on the browser.
  33122. */
  33123. onAudioUnlockedObservable: Observable<AudioEngine>;
  33124. /**
  33125. * Event raised when audio has been locked on the browser.
  33126. */
  33127. onAudioLockedObservable: Observable<AudioEngine>;
  33128. /**
  33129. * Flags the audio engine in Locked state.
  33130. * This happens due to new browser policies preventing audio to autoplay.
  33131. */
  33132. lock(): void;
  33133. /**
  33134. * Unlocks the audio engine once a user action has been done on the dom.
  33135. * This is helpful to resume play once browser policies have been satisfied.
  33136. */
  33137. unlock(): void;
  33138. /**
  33139. * Gets the global volume sets on the master gain.
  33140. * @returns the global volume if set or -1 otherwise
  33141. */
  33142. getGlobalVolume(): number;
  33143. /**
  33144. * Sets the global volume of your experience (sets on the master gain).
  33145. * @param newVolume Defines the new global volume of the application
  33146. */
  33147. setGlobalVolume(newVolume: number): void;
  33148. /**
  33149. * Connect the audio engine to an audio analyser allowing some amazing
  33150. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33152. * @param analyser The analyser to connect to the engine
  33153. */
  33154. connectToAnalyser(analyser: Analyser): void;
  33155. }
  33156. /**
  33157. * This represents the default audio engine used in babylon.
  33158. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33160. */
  33161. export class AudioEngine implements IAudioEngine {
  33162. private _audioContext;
  33163. private _audioContextInitialized;
  33164. private _muteButton;
  33165. private _hostElement;
  33166. /**
  33167. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33168. */
  33169. canUseWebAudio: boolean;
  33170. /**
  33171. * The master gain node defines the global audio volume of your audio engine.
  33172. */
  33173. masterGain: GainNode;
  33174. /**
  33175. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33176. * @ignoreNaming
  33177. */
  33178. WarnedWebAudioUnsupported: boolean;
  33179. /**
  33180. * Gets whether or not mp3 are supported by your browser.
  33181. */
  33182. isMP3supported: boolean;
  33183. /**
  33184. * Gets whether or not ogg are supported by your browser.
  33185. */
  33186. isOGGsupported: boolean;
  33187. /**
  33188. * Gets whether audio has been unlocked on the device.
  33189. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33190. * a user interaction has happened.
  33191. */
  33192. unlocked: boolean;
  33193. /**
  33194. * Defines if the audio engine relies on a custom unlocked button.
  33195. * In this case, the embedded button will not be displayed.
  33196. */
  33197. useCustomUnlockedButton: boolean;
  33198. /**
  33199. * Event raised when audio has been unlocked on the browser.
  33200. */
  33201. onAudioUnlockedObservable: Observable<AudioEngine>;
  33202. /**
  33203. * Event raised when audio has been locked on the browser.
  33204. */
  33205. onAudioLockedObservable: Observable<AudioEngine>;
  33206. /**
  33207. * Gets the current AudioContext if available.
  33208. */
  33209. get audioContext(): Nullable<AudioContext>;
  33210. private _connectedAnalyser;
  33211. /**
  33212. * Instantiates a new audio engine.
  33213. *
  33214. * There should be only one per page as some browsers restrict the number
  33215. * of audio contexts you can create.
  33216. * @param hostElement defines the host element where to display the mute icon if necessary
  33217. */
  33218. constructor(hostElement?: Nullable<HTMLElement>);
  33219. /**
  33220. * Flags the audio engine in Locked state.
  33221. * This happens due to new browser policies preventing audio to autoplay.
  33222. */
  33223. lock(): void;
  33224. /**
  33225. * Unlocks the audio engine once a user action has been done on the dom.
  33226. * This is helpful to resume play once browser policies have been satisfied.
  33227. */
  33228. unlock(): void;
  33229. private _resumeAudioContext;
  33230. private _initializeAudioContext;
  33231. private _tryToRun;
  33232. private _triggerRunningState;
  33233. private _triggerSuspendedState;
  33234. private _displayMuteButton;
  33235. private _moveButtonToTopLeft;
  33236. private _onResize;
  33237. private _hideMuteButton;
  33238. /**
  33239. * Destroy and release the resources associated with the audio ccontext.
  33240. */
  33241. dispose(): void;
  33242. /**
  33243. * Gets the global volume sets on the master gain.
  33244. * @returns the global volume if set or -1 otherwise
  33245. */
  33246. getGlobalVolume(): number;
  33247. /**
  33248. * Sets the global volume of your experience (sets on the master gain).
  33249. * @param newVolume Defines the new global volume of the application
  33250. */
  33251. setGlobalVolume(newVolume: number): void;
  33252. /**
  33253. * Connect the audio engine to an audio analyser allowing some amazing
  33254. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33256. * @param analyser The analyser to connect to the engine
  33257. */
  33258. connectToAnalyser(analyser: Analyser): void;
  33259. }
  33260. }
  33261. declare module BABYLON {
  33262. /**
  33263. * Interface used to present a loading screen while loading a scene
  33264. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33265. */
  33266. export interface ILoadingScreen {
  33267. /**
  33268. * Function called to display the loading screen
  33269. */
  33270. displayLoadingUI: () => void;
  33271. /**
  33272. * Function called to hide the loading screen
  33273. */
  33274. hideLoadingUI: () => void;
  33275. /**
  33276. * Gets or sets the color to use for the background
  33277. */
  33278. loadingUIBackgroundColor: string;
  33279. /**
  33280. * Gets or sets the text to display while loading
  33281. */
  33282. loadingUIText: string;
  33283. }
  33284. /**
  33285. * Class used for the default loading screen
  33286. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33287. */
  33288. export class DefaultLoadingScreen implements ILoadingScreen {
  33289. private _renderingCanvas;
  33290. private _loadingText;
  33291. private _loadingDivBackgroundColor;
  33292. private _loadingDiv;
  33293. private _loadingTextDiv;
  33294. /** Gets or sets the logo url to use for the default loading screen */
  33295. static DefaultLogoUrl: string;
  33296. /** Gets or sets the spinner url to use for the default loading screen */
  33297. static DefaultSpinnerUrl: string;
  33298. /**
  33299. * Creates a new default loading screen
  33300. * @param _renderingCanvas defines the canvas used to render the scene
  33301. * @param _loadingText defines the default text to display
  33302. * @param _loadingDivBackgroundColor defines the default background color
  33303. */
  33304. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33305. /**
  33306. * Function called to display the loading screen
  33307. */
  33308. displayLoadingUI(): void;
  33309. /**
  33310. * Function called to hide the loading screen
  33311. */
  33312. hideLoadingUI(): void;
  33313. /**
  33314. * Gets or sets the text to display while loading
  33315. */
  33316. set loadingUIText(text: string);
  33317. get loadingUIText(): string;
  33318. /**
  33319. * Gets or sets the color to use for the background
  33320. */
  33321. get loadingUIBackgroundColor(): string;
  33322. set loadingUIBackgroundColor(color: string);
  33323. private _resizeLoadingUI;
  33324. }
  33325. }
  33326. declare module BABYLON {
  33327. /**
  33328. * Interface for any object that can request an animation frame
  33329. */
  33330. export interface ICustomAnimationFrameRequester {
  33331. /**
  33332. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33333. */
  33334. renderFunction?: Function;
  33335. /**
  33336. * Called to request the next frame to render to
  33337. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33338. */
  33339. requestAnimationFrame: Function;
  33340. /**
  33341. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33342. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33343. */
  33344. requestID?: number;
  33345. }
  33346. }
  33347. declare module BABYLON {
  33348. /**
  33349. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33350. */
  33351. export class PerformanceMonitor {
  33352. private _enabled;
  33353. private _rollingFrameTime;
  33354. private _lastFrameTimeMs;
  33355. /**
  33356. * constructor
  33357. * @param frameSampleSize The number of samples required to saturate the sliding window
  33358. */
  33359. constructor(frameSampleSize?: number);
  33360. /**
  33361. * Samples current frame
  33362. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33363. */
  33364. sampleFrame(timeMs?: number): void;
  33365. /**
  33366. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33367. */
  33368. get averageFrameTime(): number;
  33369. /**
  33370. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33371. */
  33372. get averageFrameTimeVariance(): number;
  33373. /**
  33374. * Returns the frame time of the most recent frame
  33375. */
  33376. get instantaneousFrameTime(): number;
  33377. /**
  33378. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33379. */
  33380. get averageFPS(): number;
  33381. /**
  33382. * Returns the average framerate in frames per second using the most recent frame time
  33383. */
  33384. get instantaneousFPS(): number;
  33385. /**
  33386. * Returns true if enough samples have been taken to completely fill the sliding window
  33387. */
  33388. get isSaturated(): boolean;
  33389. /**
  33390. * Enables contributions to the sliding window sample set
  33391. */
  33392. enable(): void;
  33393. /**
  33394. * Disables contributions to the sliding window sample set
  33395. * Samples will not be interpolated over the disabled period
  33396. */
  33397. disable(): void;
  33398. /**
  33399. * Returns true if sampling is enabled
  33400. */
  33401. get isEnabled(): boolean;
  33402. /**
  33403. * Resets performance monitor
  33404. */
  33405. reset(): void;
  33406. }
  33407. /**
  33408. * RollingAverage
  33409. *
  33410. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33411. */
  33412. export class RollingAverage {
  33413. /**
  33414. * Current average
  33415. */
  33416. average: number;
  33417. /**
  33418. * Current variance
  33419. */
  33420. variance: number;
  33421. protected _samples: Array<number>;
  33422. protected _sampleCount: number;
  33423. protected _pos: number;
  33424. protected _m2: number;
  33425. /**
  33426. * constructor
  33427. * @param length The number of samples required to saturate the sliding window
  33428. */
  33429. constructor(length: number);
  33430. /**
  33431. * Adds a sample to the sample set
  33432. * @param v The sample value
  33433. */
  33434. add(v: number): void;
  33435. /**
  33436. * Returns previously added values or null if outside of history or outside the sliding window domain
  33437. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33438. * @return Value previously recorded with add() or null if outside of range
  33439. */
  33440. history(i: number): number;
  33441. /**
  33442. * Returns true if enough samples have been taken to completely fill the sliding window
  33443. * @return true if sample-set saturated
  33444. */
  33445. isSaturated(): boolean;
  33446. /**
  33447. * Resets the rolling average (equivalent to 0 samples taken so far)
  33448. */
  33449. reset(): void;
  33450. /**
  33451. * Wraps a value around the sample range boundaries
  33452. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33453. * @return Wrapped position in sample range
  33454. */
  33455. protected _wrapPosition(i: number): number;
  33456. }
  33457. }
  33458. declare module BABYLON {
  33459. /**
  33460. * This class is used to track a performance counter which is number based.
  33461. * The user has access to many properties which give statistics of different nature.
  33462. *
  33463. * The implementer can track two kinds of Performance Counter: time and count.
  33464. * 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.
  33465. * 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.
  33466. */
  33467. export class PerfCounter {
  33468. /**
  33469. * Gets or sets a global boolean to turn on and off all the counters
  33470. */
  33471. static Enabled: boolean;
  33472. /**
  33473. * Returns the smallest value ever
  33474. */
  33475. get min(): number;
  33476. /**
  33477. * Returns the biggest value ever
  33478. */
  33479. get max(): number;
  33480. /**
  33481. * Returns the average value since the performance counter is running
  33482. */
  33483. get average(): number;
  33484. /**
  33485. * Returns the average value of the last second the counter was monitored
  33486. */
  33487. get lastSecAverage(): number;
  33488. /**
  33489. * Returns the current value
  33490. */
  33491. get current(): number;
  33492. /**
  33493. * Gets the accumulated total
  33494. */
  33495. get total(): number;
  33496. /**
  33497. * Gets the total value count
  33498. */
  33499. get count(): number;
  33500. /**
  33501. * Creates a new counter
  33502. */
  33503. constructor();
  33504. /**
  33505. * Call this method to start monitoring a new frame.
  33506. * 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.
  33507. */
  33508. fetchNewFrame(): void;
  33509. /**
  33510. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33511. * @param newCount the count value to add to the monitored count
  33512. * @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.
  33513. */
  33514. addCount(newCount: number, fetchResult: boolean): void;
  33515. /**
  33516. * Start monitoring this performance counter
  33517. */
  33518. beginMonitoring(): void;
  33519. /**
  33520. * Compute the time lapsed since the previous beginMonitoring() call.
  33521. * @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
  33522. */
  33523. endMonitoring(newFrame?: boolean): void;
  33524. private _fetchResult;
  33525. private _startMonitoringTime;
  33526. private _min;
  33527. private _max;
  33528. private _average;
  33529. private _current;
  33530. private _totalValueCount;
  33531. private _totalAccumulated;
  33532. private _lastSecAverage;
  33533. private _lastSecAccumulated;
  33534. private _lastSecTime;
  33535. private _lastSecValueCount;
  33536. }
  33537. }
  33538. declare module BABYLON {
  33539. interface ThinEngine {
  33540. /**
  33541. * Sets alpha constants used by some alpha blending modes
  33542. * @param r defines the red component
  33543. * @param g defines the green component
  33544. * @param b defines the blue component
  33545. * @param a defines the alpha component
  33546. */
  33547. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33548. /**
  33549. * Sets the current alpha mode
  33550. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33551. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33552. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33553. */
  33554. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33555. /**
  33556. * Gets the current alpha mode
  33557. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33558. * @returns the current alpha mode
  33559. */
  33560. getAlphaMode(): number;
  33561. /**
  33562. * Sets the current alpha equation
  33563. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33564. */
  33565. setAlphaEquation(equation: number): void;
  33566. /**
  33567. * Gets the current alpha equation.
  33568. * @returns the current alpha equation
  33569. */
  33570. getAlphaEquation(): number;
  33571. }
  33572. }
  33573. declare module BABYLON {
  33574. /**
  33575. * Defines the interface used by display changed events
  33576. */
  33577. export interface IDisplayChangedEventArgs {
  33578. /** Gets the vrDisplay object (if any) */
  33579. vrDisplay: Nullable<any>;
  33580. /** Gets a boolean indicating if webVR is supported */
  33581. vrSupported: boolean;
  33582. }
  33583. /**
  33584. * Defines the interface used by objects containing a viewport (like a camera)
  33585. */
  33586. interface IViewportOwnerLike {
  33587. /**
  33588. * Gets or sets the viewport
  33589. */
  33590. viewport: IViewportLike;
  33591. }
  33592. /**
  33593. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33594. */
  33595. export class Engine extends ThinEngine {
  33596. /** Defines that alpha blending is disabled */
  33597. static readonly ALPHA_DISABLE: number;
  33598. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33599. static readonly ALPHA_ADD: number;
  33600. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33601. static readonly ALPHA_COMBINE: number;
  33602. /** Defines that alpha blending to DEST - SRC * DEST */
  33603. static readonly ALPHA_SUBTRACT: number;
  33604. /** Defines that alpha blending to SRC * DEST */
  33605. static readonly ALPHA_MULTIPLY: number;
  33606. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33607. static readonly ALPHA_MAXIMIZED: number;
  33608. /** Defines that alpha blending to SRC + DEST */
  33609. static readonly ALPHA_ONEONE: number;
  33610. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33611. static readonly ALPHA_PREMULTIPLIED: number;
  33612. /**
  33613. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33615. */
  33616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33617. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33618. static readonly ALPHA_INTERPOLATE: number;
  33619. /**
  33620. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33622. */
  33623. static readonly ALPHA_SCREENMODE: number;
  33624. /** Defines that the ressource is not delayed*/
  33625. static readonly DELAYLOADSTATE_NONE: number;
  33626. /** Defines that the ressource was successfully delay loaded */
  33627. static readonly DELAYLOADSTATE_LOADED: number;
  33628. /** Defines that the ressource is currently delay loading */
  33629. static readonly DELAYLOADSTATE_LOADING: number;
  33630. /** Defines that the ressource is delayed and has not started loading */
  33631. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33632. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33633. static readonly NEVER: number;
  33634. /** 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 */
  33635. static readonly ALWAYS: number;
  33636. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33637. static readonly LESS: number;
  33638. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33639. static readonly EQUAL: number;
  33640. /** 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 */
  33641. static readonly LEQUAL: number;
  33642. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33643. static readonly GREATER: number;
  33644. /** 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 */
  33645. static readonly GEQUAL: number;
  33646. /** 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 */
  33647. static readonly NOTEQUAL: number;
  33648. /** Passed to stencilOperation to specify that stencil value must be kept */
  33649. static readonly KEEP: number;
  33650. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33651. static readonly REPLACE: number;
  33652. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33653. static readonly INCR: number;
  33654. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33655. static readonly DECR: number;
  33656. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33657. static readonly INVERT: number;
  33658. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33659. static readonly INCR_WRAP: number;
  33660. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33661. static readonly DECR_WRAP: number;
  33662. /** Texture is not repeating outside of 0..1 UVs */
  33663. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33664. /** Texture is repeating outside of 0..1 UVs */
  33665. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33666. /** Texture is repeating and mirrored */
  33667. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33668. /** ALPHA */
  33669. static readonly TEXTUREFORMAT_ALPHA: number;
  33670. /** LUMINANCE */
  33671. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33672. /** LUMINANCE_ALPHA */
  33673. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33674. /** RGB */
  33675. static readonly TEXTUREFORMAT_RGB: number;
  33676. /** RGBA */
  33677. static readonly TEXTUREFORMAT_RGBA: number;
  33678. /** RED */
  33679. static readonly TEXTUREFORMAT_RED: number;
  33680. /** RED (2nd reference) */
  33681. static readonly TEXTUREFORMAT_R: number;
  33682. /** RG */
  33683. static readonly TEXTUREFORMAT_RG: number;
  33684. /** RED_INTEGER */
  33685. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33686. /** RED_INTEGER (2nd reference) */
  33687. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33688. /** RG_INTEGER */
  33689. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33690. /** RGB_INTEGER */
  33691. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33692. /** RGBA_INTEGER */
  33693. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33694. /** UNSIGNED_BYTE */
  33695. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33696. /** UNSIGNED_BYTE (2nd reference) */
  33697. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33698. /** FLOAT */
  33699. static readonly TEXTURETYPE_FLOAT: number;
  33700. /** HALF_FLOAT */
  33701. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33702. /** BYTE */
  33703. static readonly TEXTURETYPE_BYTE: number;
  33704. /** SHORT */
  33705. static readonly TEXTURETYPE_SHORT: number;
  33706. /** UNSIGNED_SHORT */
  33707. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33708. /** INT */
  33709. static readonly TEXTURETYPE_INT: number;
  33710. /** UNSIGNED_INT */
  33711. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33712. /** UNSIGNED_SHORT_4_4_4_4 */
  33713. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33714. /** UNSIGNED_SHORT_5_5_5_1 */
  33715. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33716. /** UNSIGNED_SHORT_5_6_5 */
  33717. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33718. /** UNSIGNED_INT_2_10_10_10_REV */
  33719. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33720. /** UNSIGNED_INT_24_8 */
  33721. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33722. /** UNSIGNED_INT_10F_11F_11F_REV */
  33723. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33724. /** UNSIGNED_INT_5_9_9_9_REV */
  33725. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33726. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33727. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33728. /** nearest is mag = nearest and min = nearest and mip = linear */
  33729. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33730. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33731. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33732. /** Trilinear is mag = linear and min = linear and mip = linear */
  33733. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33734. /** nearest is mag = nearest and min = nearest and mip = linear */
  33735. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33736. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33737. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33738. /** Trilinear is mag = linear and min = linear and mip = linear */
  33739. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33740. /** mag = nearest and min = nearest and mip = nearest */
  33741. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33742. /** mag = nearest and min = linear and mip = nearest */
  33743. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33744. /** mag = nearest and min = linear and mip = linear */
  33745. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33746. /** mag = nearest and min = linear and mip = none */
  33747. static readonly TEXTURE_NEAREST_LINEAR: number;
  33748. /** mag = nearest and min = nearest and mip = none */
  33749. static readonly TEXTURE_NEAREST_NEAREST: number;
  33750. /** mag = linear and min = nearest and mip = nearest */
  33751. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33752. /** mag = linear and min = nearest and mip = linear */
  33753. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33754. /** mag = linear and min = linear and mip = none */
  33755. static readonly TEXTURE_LINEAR_LINEAR: number;
  33756. /** mag = linear and min = nearest and mip = none */
  33757. static readonly TEXTURE_LINEAR_NEAREST: number;
  33758. /** Explicit coordinates mode */
  33759. static readonly TEXTURE_EXPLICIT_MODE: number;
  33760. /** Spherical coordinates mode */
  33761. static readonly TEXTURE_SPHERICAL_MODE: number;
  33762. /** Planar coordinates mode */
  33763. static readonly TEXTURE_PLANAR_MODE: number;
  33764. /** Cubic coordinates mode */
  33765. static readonly TEXTURE_CUBIC_MODE: number;
  33766. /** Projection coordinates mode */
  33767. static readonly TEXTURE_PROJECTION_MODE: number;
  33768. /** Skybox coordinates mode */
  33769. static readonly TEXTURE_SKYBOX_MODE: number;
  33770. /** Inverse Cubic coordinates mode */
  33771. static readonly TEXTURE_INVCUBIC_MODE: number;
  33772. /** Equirectangular coordinates mode */
  33773. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33774. /** Equirectangular Fixed coordinates mode */
  33775. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33776. /** Equirectangular Fixed Mirrored coordinates mode */
  33777. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33778. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33779. static readonly SCALEMODE_FLOOR: number;
  33780. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33781. static readonly SCALEMODE_NEAREST: number;
  33782. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33783. static readonly SCALEMODE_CEILING: number;
  33784. /**
  33785. * Returns the current npm package of the sdk
  33786. */
  33787. static get NpmPackage(): string;
  33788. /**
  33789. * Returns the current version of the framework
  33790. */
  33791. static get Version(): string;
  33792. /** Gets the list of created engines */
  33793. static get Instances(): Engine[];
  33794. /**
  33795. * Gets the latest created engine
  33796. */
  33797. static get LastCreatedEngine(): Nullable<Engine>;
  33798. /**
  33799. * Gets the latest created scene
  33800. */
  33801. static get LastCreatedScene(): Nullable<Scene>;
  33802. /**
  33803. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33804. * @param flag defines which part of the materials must be marked as dirty
  33805. * @param predicate defines a predicate used to filter which materials should be affected
  33806. */
  33807. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33808. /**
  33809. * Method called to create the default loading screen.
  33810. * This can be overriden in your own app.
  33811. * @param canvas The rendering canvas element
  33812. * @returns The loading screen
  33813. */
  33814. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33815. /**
  33816. * Method called to create the default rescale post process on each engine.
  33817. */
  33818. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33819. /**
  33820. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33821. **/
  33822. enableOfflineSupport: boolean;
  33823. /**
  33824. * 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)
  33825. **/
  33826. disableManifestCheck: boolean;
  33827. /**
  33828. * Gets the list of created scenes
  33829. */
  33830. scenes: Scene[];
  33831. /**
  33832. * Event raised when a new scene is created
  33833. */
  33834. onNewSceneAddedObservable: Observable<Scene>;
  33835. /**
  33836. * Gets the list of created postprocesses
  33837. */
  33838. postProcesses: PostProcess[];
  33839. /**
  33840. * Gets a boolean indicating if the pointer is currently locked
  33841. */
  33842. isPointerLock: boolean;
  33843. /**
  33844. * Observable event triggered each time the rendering canvas is resized
  33845. */
  33846. onResizeObservable: Observable<Engine>;
  33847. /**
  33848. * Observable event triggered each time the canvas loses focus
  33849. */
  33850. onCanvasBlurObservable: Observable<Engine>;
  33851. /**
  33852. * Observable event triggered each time the canvas gains focus
  33853. */
  33854. onCanvasFocusObservable: Observable<Engine>;
  33855. /**
  33856. * Observable event triggered each time the canvas receives pointerout event
  33857. */
  33858. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33859. /**
  33860. * Observable raised when the engine begins a new frame
  33861. */
  33862. onBeginFrameObservable: Observable<Engine>;
  33863. /**
  33864. * If set, will be used to request the next animation frame for the render loop
  33865. */
  33866. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33867. /**
  33868. * Observable raised when the engine ends the current frame
  33869. */
  33870. onEndFrameObservable: Observable<Engine>;
  33871. /**
  33872. * Observable raised when the engine is about to compile a shader
  33873. */
  33874. onBeforeShaderCompilationObservable: Observable<Engine>;
  33875. /**
  33876. * Observable raised when the engine has jsut compiled a shader
  33877. */
  33878. onAfterShaderCompilationObservable: Observable<Engine>;
  33879. /**
  33880. * Gets the audio engine
  33881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33882. * @ignorenaming
  33883. */
  33884. static audioEngine: IAudioEngine;
  33885. /**
  33886. * Default AudioEngine factory responsible of creating the Audio Engine.
  33887. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33888. */
  33889. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33890. /**
  33891. * Default offline support factory responsible of creating a tool used to store data locally.
  33892. * By default, this will create a Database object if the workload has been embedded.
  33893. */
  33894. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33895. private _loadingScreen;
  33896. private _pointerLockRequested;
  33897. private _dummyFramebuffer;
  33898. private _rescalePostProcess;
  33899. private _deterministicLockstep;
  33900. private _lockstepMaxSteps;
  33901. private _timeStep;
  33902. protected get _supportsHardwareTextureRescaling(): boolean;
  33903. private _fps;
  33904. private _deltaTime;
  33905. /** @hidden */
  33906. _drawCalls: PerfCounter;
  33907. /** 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 */
  33908. canvasTabIndex: number;
  33909. /**
  33910. * Turn this value on if you want to pause FPS computation when in background
  33911. */
  33912. disablePerformanceMonitorInBackground: boolean;
  33913. private _performanceMonitor;
  33914. /**
  33915. * Gets the performance monitor attached to this engine
  33916. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33917. */
  33918. get performanceMonitor(): PerformanceMonitor;
  33919. private _onFocus;
  33920. private _onBlur;
  33921. private _onCanvasPointerOut;
  33922. private _onCanvasBlur;
  33923. private _onCanvasFocus;
  33924. private _onFullscreenChange;
  33925. private _onPointerLockChange;
  33926. /**
  33927. * Gets the HTML element used to attach event listeners
  33928. * @returns a HTML element
  33929. */
  33930. getInputElement(): Nullable<HTMLElement>;
  33931. /**
  33932. * Creates a new engine
  33933. * @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
  33934. * @param antialias defines enable antialiasing (default: false)
  33935. * @param options defines further options to be sent to the getContext() function
  33936. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33937. */
  33938. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33939. /**
  33940. * Gets current aspect ratio
  33941. * @param viewportOwner defines the camera to use to get the aspect ratio
  33942. * @param useScreen defines if screen size must be used (or the current render target if any)
  33943. * @returns a number defining the aspect ratio
  33944. */
  33945. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33946. /**
  33947. * Gets current screen aspect ratio
  33948. * @returns a number defining the aspect ratio
  33949. */
  33950. getScreenAspectRatio(): number;
  33951. /**
  33952. * Gets the client rect of the HTML canvas attached with the current webGL context
  33953. * @returns a client rectanglee
  33954. */
  33955. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33956. /**
  33957. * Gets the client rect of the HTML element used for events
  33958. * @returns a client rectanglee
  33959. */
  33960. getInputElementClientRect(): Nullable<ClientRect>;
  33961. /**
  33962. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33963. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33964. * @returns true if engine is in deterministic lock step mode
  33965. */
  33966. isDeterministicLockStep(): boolean;
  33967. /**
  33968. * Gets the max steps when engine is running in deterministic lock step
  33969. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33970. * @returns the max steps
  33971. */
  33972. getLockstepMaxSteps(): number;
  33973. /**
  33974. * Returns the time in ms between steps when using deterministic lock step.
  33975. * @returns time step in (ms)
  33976. */
  33977. getTimeStep(): number;
  33978. /**
  33979. * Force the mipmap generation for the given render target texture
  33980. * @param texture defines the render target texture to use
  33981. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33982. */
  33983. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33984. /** States */
  33985. /**
  33986. * Set various states to the webGL context
  33987. * @param culling defines backface culling state
  33988. * @param zOffset defines the value to apply to zOffset (0 by default)
  33989. * @param force defines if states must be applied even if cache is up to date
  33990. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33991. */
  33992. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33993. /**
  33994. * Set the z offset to apply to current rendering
  33995. * @param value defines the offset to apply
  33996. */
  33997. setZOffset(value: number): void;
  33998. /**
  33999. * Gets the current value of the zOffset
  34000. * @returns the current zOffset state
  34001. */
  34002. getZOffset(): number;
  34003. /**
  34004. * Enable or disable depth buffering
  34005. * @param enable defines the state to set
  34006. */
  34007. setDepthBuffer(enable: boolean): void;
  34008. /**
  34009. * Gets a boolean indicating if depth writing is enabled
  34010. * @returns the current depth writing state
  34011. */
  34012. getDepthWrite(): boolean;
  34013. /**
  34014. * Enable or disable depth writing
  34015. * @param enable defines the state to set
  34016. */
  34017. setDepthWrite(enable: boolean): void;
  34018. /**
  34019. * Gets a boolean indicating if stencil buffer is enabled
  34020. * @returns the current stencil buffer state
  34021. */
  34022. getStencilBuffer(): boolean;
  34023. /**
  34024. * Enable or disable the stencil buffer
  34025. * @param enable defines if the stencil buffer must be enabled or disabled
  34026. */
  34027. setStencilBuffer(enable: boolean): void;
  34028. /**
  34029. * Gets the current stencil mask
  34030. * @returns a number defining the new stencil mask to use
  34031. */
  34032. getStencilMask(): number;
  34033. /**
  34034. * Sets the current stencil mask
  34035. * @param mask defines the new stencil mask to use
  34036. */
  34037. setStencilMask(mask: number): void;
  34038. /**
  34039. * Gets the current stencil function
  34040. * @returns a number defining the stencil function to use
  34041. */
  34042. getStencilFunction(): number;
  34043. /**
  34044. * Gets the current stencil reference value
  34045. * @returns a number defining the stencil reference value to use
  34046. */
  34047. getStencilFunctionReference(): number;
  34048. /**
  34049. * Gets the current stencil mask
  34050. * @returns a number defining the stencil mask to use
  34051. */
  34052. getStencilFunctionMask(): number;
  34053. /**
  34054. * Sets the current stencil function
  34055. * @param stencilFunc defines the new stencil function to use
  34056. */
  34057. setStencilFunction(stencilFunc: number): void;
  34058. /**
  34059. * Sets the current stencil reference
  34060. * @param reference defines the new stencil reference to use
  34061. */
  34062. setStencilFunctionReference(reference: number): void;
  34063. /**
  34064. * Sets the current stencil mask
  34065. * @param mask defines the new stencil mask to use
  34066. */
  34067. setStencilFunctionMask(mask: number): void;
  34068. /**
  34069. * Gets the current stencil operation when stencil fails
  34070. * @returns a number defining stencil operation to use when stencil fails
  34071. */
  34072. getStencilOperationFail(): number;
  34073. /**
  34074. * Gets the current stencil operation when depth fails
  34075. * @returns a number defining stencil operation to use when depth fails
  34076. */
  34077. getStencilOperationDepthFail(): number;
  34078. /**
  34079. * Gets the current stencil operation when stencil passes
  34080. * @returns a number defining stencil operation to use when stencil passes
  34081. */
  34082. getStencilOperationPass(): number;
  34083. /**
  34084. * Sets the stencil operation to use when stencil fails
  34085. * @param operation defines the stencil operation to use when stencil fails
  34086. */
  34087. setStencilOperationFail(operation: number): void;
  34088. /**
  34089. * Sets the stencil operation to use when depth fails
  34090. * @param operation defines the stencil operation to use when depth fails
  34091. */
  34092. setStencilOperationDepthFail(operation: number): void;
  34093. /**
  34094. * Sets the stencil operation to use when stencil passes
  34095. * @param operation defines the stencil operation to use when stencil passes
  34096. */
  34097. setStencilOperationPass(operation: number): void;
  34098. /**
  34099. * Sets a boolean indicating if the dithering state is enabled or disabled
  34100. * @param value defines the dithering state
  34101. */
  34102. setDitheringState(value: boolean): void;
  34103. /**
  34104. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34105. * @param value defines the rasterizer state
  34106. */
  34107. setRasterizerState(value: boolean): void;
  34108. /**
  34109. * Gets the current depth function
  34110. * @returns a number defining the depth function
  34111. */
  34112. getDepthFunction(): Nullable<number>;
  34113. /**
  34114. * Sets the current depth function
  34115. * @param depthFunc defines the function to use
  34116. */
  34117. setDepthFunction(depthFunc: number): void;
  34118. /**
  34119. * Sets the current depth function to GREATER
  34120. */
  34121. setDepthFunctionToGreater(): void;
  34122. /**
  34123. * Sets the current depth function to GEQUAL
  34124. */
  34125. setDepthFunctionToGreaterOrEqual(): void;
  34126. /**
  34127. * Sets the current depth function to LESS
  34128. */
  34129. setDepthFunctionToLess(): void;
  34130. /**
  34131. * Sets the current depth function to LEQUAL
  34132. */
  34133. setDepthFunctionToLessOrEqual(): void;
  34134. private _cachedStencilBuffer;
  34135. private _cachedStencilFunction;
  34136. private _cachedStencilMask;
  34137. private _cachedStencilOperationPass;
  34138. private _cachedStencilOperationFail;
  34139. private _cachedStencilOperationDepthFail;
  34140. private _cachedStencilReference;
  34141. /**
  34142. * Caches the the state of the stencil buffer
  34143. */
  34144. cacheStencilState(): void;
  34145. /**
  34146. * Restores the state of the stencil buffer
  34147. */
  34148. restoreStencilState(): void;
  34149. /**
  34150. * Directly set the WebGL Viewport
  34151. * @param x defines the x coordinate of the viewport (in screen space)
  34152. * @param y defines the y coordinate of the viewport (in screen space)
  34153. * @param width defines the width of the viewport (in screen space)
  34154. * @param height defines the height of the viewport (in screen space)
  34155. * @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
  34156. */
  34157. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34158. /**
  34159. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34160. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34161. * @param y defines the y-coordinate of the corner of the clear rectangle
  34162. * @param width defines the width of the clear rectangle
  34163. * @param height defines the height of the clear rectangle
  34164. * @param clearColor defines the clear color
  34165. */
  34166. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34167. /**
  34168. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34169. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34170. * @param y defines the y-coordinate of the corner of the clear rectangle
  34171. * @param width defines the width of the clear rectangle
  34172. * @param height defines the height of the clear rectangle
  34173. */
  34174. enableScissor(x: number, y: number, width: number, height: number): void;
  34175. /**
  34176. * Disable previously set scissor test rectangle
  34177. */
  34178. disableScissor(): void;
  34179. protected _reportDrawCall(): void;
  34180. /**
  34181. * Initializes a webVR display and starts listening to display change events
  34182. * The onVRDisplayChangedObservable will be notified upon these changes
  34183. * @returns The onVRDisplayChangedObservable
  34184. */
  34185. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34186. /** @hidden */
  34187. _prepareVRComponent(): void;
  34188. /** @hidden */
  34189. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34190. /** @hidden */
  34191. _submitVRFrame(): void;
  34192. /**
  34193. * Call this function to leave webVR mode
  34194. * Will do nothing if webVR is not supported or if there is no webVR device
  34195. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34196. */
  34197. disableVR(): void;
  34198. /**
  34199. * Gets a boolean indicating that the system is in VR mode and is presenting
  34200. * @returns true if VR mode is engaged
  34201. */
  34202. isVRPresenting(): boolean;
  34203. /** @hidden */
  34204. _requestVRFrame(): void;
  34205. /** @hidden */
  34206. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34207. /**
  34208. * Gets the source code of the vertex shader associated with a specific webGL program
  34209. * @param program defines the program to use
  34210. * @returns a string containing the source code of the vertex shader associated with the program
  34211. */
  34212. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34213. /**
  34214. * Gets the source code of the fragment shader associated with a specific webGL program
  34215. * @param program defines the program to use
  34216. * @returns a string containing the source code of the fragment shader associated with the program
  34217. */
  34218. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34219. /**
  34220. * Sets a depth stencil texture from a render target to the according uniform.
  34221. * @param channel The texture channel
  34222. * @param uniform The uniform to set
  34223. * @param texture The render target texture containing the depth stencil texture to apply
  34224. */
  34225. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34226. /**
  34227. * Sets a texture to the webGL context from a postprocess
  34228. * @param channel defines the channel to use
  34229. * @param postProcess defines the source postprocess
  34230. */
  34231. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34232. /**
  34233. * Binds the output of the passed in post process to the texture channel specified
  34234. * @param channel The channel the texture should be bound to
  34235. * @param postProcess The post process which's output should be bound
  34236. */
  34237. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34238. /** @hidden */
  34239. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34240. protected _rebuildBuffers(): void;
  34241. /** @hidden */
  34242. _renderFrame(): void;
  34243. _renderLoop(): void;
  34244. /** @hidden */
  34245. _renderViews(): boolean;
  34246. /**
  34247. * Toggle full screen mode
  34248. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34249. */
  34250. switchFullscreen(requestPointerLock: boolean): void;
  34251. /**
  34252. * Enters full screen mode
  34253. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34254. */
  34255. enterFullscreen(requestPointerLock: boolean): void;
  34256. /**
  34257. * Exits full screen mode
  34258. */
  34259. exitFullscreen(): void;
  34260. /**
  34261. * Enters Pointerlock mode
  34262. */
  34263. enterPointerlock(): void;
  34264. /**
  34265. * Exits Pointerlock mode
  34266. */
  34267. exitPointerlock(): void;
  34268. /**
  34269. * Begin a new frame
  34270. */
  34271. beginFrame(): void;
  34272. /**
  34273. * Enf the current frame
  34274. */
  34275. endFrame(): void;
  34276. resize(): void;
  34277. /**
  34278. * Force a specific size of the canvas
  34279. * @param width defines the new canvas' width
  34280. * @param height defines the new canvas' height
  34281. */
  34282. setSize(width: number, height: number): void;
  34283. /**
  34284. * Updates a dynamic vertex buffer.
  34285. * @param vertexBuffer the vertex buffer to update
  34286. * @param data the data used to update the vertex buffer
  34287. * @param byteOffset the byte offset of the data
  34288. * @param byteLength the byte length of the data
  34289. */
  34290. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34291. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34292. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34293. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34294. _releaseTexture(texture: InternalTexture): void;
  34295. /**
  34296. * @hidden
  34297. * Rescales a texture
  34298. * @param source input texutre
  34299. * @param destination destination texture
  34300. * @param scene scene to use to render the resize
  34301. * @param internalFormat format to use when resizing
  34302. * @param onComplete callback to be called when resize has completed
  34303. */
  34304. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34305. /**
  34306. * Gets the current framerate
  34307. * @returns a number representing the framerate
  34308. */
  34309. getFps(): number;
  34310. /**
  34311. * Gets the time spent between current and previous frame
  34312. * @returns a number representing the delta time in ms
  34313. */
  34314. getDeltaTime(): number;
  34315. private _measureFps;
  34316. /** @hidden */
  34317. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34318. /**
  34319. * Update a dynamic index buffer
  34320. * @param indexBuffer defines the target index buffer
  34321. * @param indices defines the data to update
  34322. * @param offset defines the offset in the target index buffer where update should start
  34323. */
  34324. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34325. /**
  34326. * Updates the sample count of a render target texture
  34327. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34328. * @param texture defines the texture to update
  34329. * @param samples defines the sample count to set
  34330. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34331. */
  34332. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34333. /**
  34334. * Updates a depth texture Comparison Mode and Function.
  34335. * If the comparison Function is equal to 0, the mode will be set to none.
  34336. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34337. * @param texture The texture to set the comparison function for
  34338. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34339. */
  34340. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34341. /**
  34342. * Creates a webGL buffer to use with instanciation
  34343. * @param capacity defines the size of the buffer
  34344. * @returns the webGL buffer
  34345. */
  34346. createInstancesBuffer(capacity: number): DataBuffer;
  34347. /**
  34348. * Delete a webGL buffer used with instanciation
  34349. * @param buffer defines the webGL buffer to delete
  34350. */
  34351. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34352. private _clientWaitAsync;
  34353. /** @hidden */
  34354. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34355. /** @hidden */
  34356. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34357. dispose(): void;
  34358. private _disableTouchAction;
  34359. /**
  34360. * Display the loading screen
  34361. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34362. */
  34363. displayLoadingUI(): void;
  34364. /**
  34365. * Hide the loading screen
  34366. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34367. */
  34368. hideLoadingUI(): void;
  34369. /**
  34370. * Gets the current loading screen object
  34371. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34372. */
  34373. get loadingScreen(): ILoadingScreen;
  34374. /**
  34375. * Sets the current loading screen object
  34376. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34377. */
  34378. set loadingScreen(loadingScreen: ILoadingScreen);
  34379. /**
  34380. * Sets the current loading screen text
  34381. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34382. */
  34383. set loadingUIText(text: string);
  34384. /**
  34385. * Sets the current loading screen background color
  34386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34387. */
  34388. set loadingUIBackgroundColor(color: string);
  34389. /** Pointerlock and fullscreen */
  34390. /**
  34391. * Ask the browser to promote the current element to pointerlock mode
  34392. * @param element defines the DOM element to promote
  34393. */
  34394. static _RequestPointerlock(element: HTMLElement): void;
  34395. /**
  34396. * Asks the browser to exit pointerlock mode
  34397. */
  34398. static _ExitPointerlock(): void;
  34399. /**
  34400. * Ask the browser to promote the current element to fullscreen rendering mode
  34401. * @param element defines the DOM element to promote
  34402. */
  34403. static _RequestFullscreen(element: HTMLElement): void;
  34404. /**
  34405. * Asks the browser to exit fullscreen mode
  34406. */
  34407. static _ExitFullscreen(): void;
  34408. }
  34409. }
  34410. declare module BABYLON {
  34411. /**
  34412. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34413. * during the life time of the application.
  34414. */
  34415. export class EngineStore {
  34416. /** Gets the list of created engines */
  34417. static Instances: Engine[];
  34418. /** @hidden */
  34419. static _LastCreatedScene: Nullable<Scene>;
  34420. /**
  34421. * Gets the latest created engine
  34422. */
  34423. static get LastCreatedEngine(): Nullable<Engine>;
  34424. /**
  34425. * Gets the latest created scene
  34426. */
  34427. static get LastCreatedScene(): Nullable<Scene>;
  34428. /**
  34429. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34430. * @ignorenaming
  34431. */
  34432. static UseFallbackTexture: boolean;
  34433. /**
  34434. * Texture content used if a texture cannot loaded
  34435. * @ignorenaming
  34436. */
  34437. static FallbackTexture: string;
  34438. }
  34439. }
  34440. declare module BABYLON {
  34441. /**
  34442. * Helper class that provides a small promise polyfill
  34443. */
  34444. export class PromisePolyfill {
  34445. /**
  34446. * Static function used to check if the polyfill is required
  34447. * If this is the case then the function will inject the polyfill to window.Promise
  34448. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34449. */
  34450. static Apply(force?: boolean): void;
  34451. }
  34452. }
  34453. declare module BABYLON {
  34454. /**
  34455. * Interface for screenshot methods with describe argument called `size` as object with options
  34456. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34457. */
  34458. export interface IScreenshotSize {
  34459. /**
  34460. * number in pixels for canvas height
  34461. */
  34462. height?: number;
  34463. /**
  34464. * multiplier allowing render at a higher or lower resolution
  34465. * If value is defined then height and width will be ignored and taken from camera
  34466. */
  34467. precision?: number;
  34468. /**
  34469. * number in pixels for canvas width
  34470. */
  34471. width?: number;
  34472. }
  34473. }
  34474. declare module BABYLON {
  34475. interface IColor4Like {
  34476. r: float;
  34477. g: float;
  34478. b: float;
  34479. a: float;
  34480. }
  34481. /**
  34482. * Class containing a set of static utilities functions
  34483. */
  34484. export class Tools {
  34485. /**
  34486. * Gets or sets the base URL to use to load assets
  34487. */
  34488. static get BaseUrl(): string;
  34489. static set BaseUrl(value: string);
  34490. /**
  34491. * Enable/Disable Custom HTTP Request Headers globally.
  34492. * default = false
  34493. * @see CustomRequestHeaders
  34494. */
  34495. static UseCustomRequestHeaders: boolean;
  34496. /**
  34497. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34498. * i.e. when loading files, where the server/service expects an Authorization header
  34499. */
  34500. static CustomRequestHeaders: {
  34501. [key: string]: string;
  34502. };
  34503. /**
  34504. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34505. */
  34506. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34507. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34508. /**
  34509. * Default behaviour for cors in the application.
  34510. * It can be a string if the expected behavior is identical in the entire app.
  34511. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34512. */
  34513. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34514. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34515. /**
  34516. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34517. * @ignorenaming
  34518. */
  34519. static get UseFallbackTexture(): boolean;
  34520. static set UseFallbackTexture(value: boolean);
  34521. /**
  34522. * Use this object to register external classes like custom textures or material
  34523. * to allow the laoders to instantiate them
  34524. */
  34525. static get RegisteredExternalClasses(): {
  34526. [key: string]: Object;
  34527. };
  34528. static set RegisteredExternalClasses(classes: {
  34529. [key: string]: Object;
  34530. });
  34531. /**
  34532. * Texture content used if a texture cannot loaded
  34533. * @ignorenaming
  34534. */
  34535. static get fallbackTexture(): string;
  34536. static set fallbackTexture(value: string);
  34537. /**
  34538. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34539. * @param u defines the coordinate on X axis
  34540. * @param v defines the coordinate on Y axis
  34541. * @param width defines the width of the source data
  34542. * @param height defines the height of the source data
  34543. * @param pixels defines the source byte array
  34544. * @param color defines the output color
  34545. */
  34546. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34547. /**
  34548. * Interpolates between a and b via alpha
  34549. * @param a The lower value (returned when alpha = 0)
  34550. * @param b The upper value (returned when alpha = 1)
  34551. * @param alpha The interpolation-factor
  34552. * @return The mixed value
  34553. */
  34554. static Mix(a: number, b: number, alpha: number): number;
  34555. /**
  34556. * Tries to instantiate a new object from a given class name
  34557. * @param className defines the class name to instantiate
  34558. * @returns the new object or null if the system was not able to do the instantiation
  34559. */
  34560. static Instantiate(className: string): any;
  34561. /**
  34562. * Provides a slice function that will work even on IE
  34563. * @param data defines the array to slice
  34564. * @param start defines the start of the data (optional)
  34565. * @param end defines the end of the data (optional)
  34566. * @returns the new sliced array
  34567. */
  34568. static Slice<T>(data: T, start?: number, end?: number): T;
  34569. /**
  34570. * Polyfill for setImmediate
  34571. * @param action defines the action to execute after the current execution block
  34572. */
  34573. static SetImmediate(action: () => void): void;
  34574. /**
  34575. * Function indicating if a number is an exponent of 2
  34576. * @param value defines the value to test
  34577. * @returns true if the value is an exponent of 2
  34578. */
  34579. static IsExponentOfTwo(value: number): boolean;
  34580. private static _tmpFloatArray;
  34581. /**
  34582. * Returns the nearest 32-bit single precision float representation of a Number
  34583. * @param value A Number. If the parameter is of a different type, it will get converted
  34584. * to a number or to NaN if it cannot be converted
  34585. * @returns number
  34586. */
  34587. static FloatRound(value: number): number;
  34588. /**
  34589. * Extracts the filename from a path
  34590. * @param path defines the path to use
  34591. * @returns the filename
  34592. */
  34593. static GetFilename(path: string): string;
  34594. /**
  34595. * Extracts the "folder" part of a path (everything before the filename).
  34596. * @param uri The URI to extract the info from
  34597. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34598. * @returns The "folder" part of the path
  34599. */
  34600. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34601. /**
  34602. * Extracts text content from a DOM element hierarchy
  34603. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34604. */
  34605. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34606. /**
  34607. * Convert an angle in radians to degrees
  34608. * @param angle defines the angle to convert
  34609. * @returns the angle in degrees
  34610. */
  34611. static ToDegrees(angle: number): number;
  34612. /**
  34613. * Convert an angle in degrees to radians
  34614. * @param angle defines the angle to convert
  34615. * @returns the angle in radians
  34616. */
  34617. static ToRadians(angle: number): number;
  34618. /**
  34619. * Returns an array if obj is not an array
  34620. * @param obj defines the object to evaluate as an array
  34621. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34622. * @returns either obj directly if obj is an array or a new array containing obj
  34623. */
  34624. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34625. /**
  34626. * Gets the pointer prefix to use
  34627. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34628. */
  34629. static GetPointerPrefix(): string;
  34630. /**
  34631. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34632. * @param url define the url we are trying
  34633. * @param element define the dom element where to configure the cors policy
  34634. */
  34635. static SetCorsBehavior(url: string | string[], element: {
  34636. crossOrigin: string | null;
  34637. }): void;
  34638. /**
  34639. * Removes unwanted characters from an url
  34640. * @param url defines the url to clean
  34641. * @returns the cleaned url
  34642. */
  34643. static CleanUrl(url: string): string;
  34644. /**
  34645. * Gets or sets a function used to pre-process url before using them to load assets
  34646. */
  34647. static get PreprocessUrl(): (url: string) => string;
  34648. static set PreprocessUrl(processor: (url: string) => string);
  34649. /**
  34650. * Loads an image as an HTMLImageElement.
  34651. * @param input url string, ArrayBuffer, or Blob to load
  34652. * @param onLoad callback called when the image successfully loads
  34653. * @param onError callback called when the image fails to load
  34654. * @param offlineProvider offline provider for caching
  34655. * @param mimeType optional mime type
  34656. * @returns the HTMLImageElement of the loaded image
  34657. */
  34658. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34659. /**
  34660. * Loads a file from a url
  34661. * @param url url string, ArrayBuffer, or Blob to load
  34662. * @param onSuccess callback called when the file successfully loads
  34663. * @param onProgress callback called while file is loading (if the server supports this mode)
  34664. * @param offlineProvider defines the offline provider for caching
  34665. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34666. * @param onError callback called when the file fails to load
  34667. * @returns a file request object
  34668. */
  34669. 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;
  34670. /**
  34671. * Loads a file from a url
  34672. * @param url the file url to load
  34673. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34674. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34675. */
  34676. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34677. /**
  34678. * Load a script (identified by an url). When the url returns, the
  34679. * content of this file is added into a new script element, attached to the DOM (body element)
  34680. * @param scriptUrl defines the url of the script to laod
  34681. * @param onSuccess defines the callback called when the script is loaded
  34682. * @param onError defines the callback to call if an error occurs
  34683. * @param scriptId defines the id of the script element
  34684. */
  34685. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34686. /**
  34687. * Load an asynchronous script (identified by an url). When the url returns, the
  34688. * content of this file is added into a new script element, attached to the DOM (body element)
  34689. * @param scriptUrl defines the url of the script to laod
  34690. * @param scriptId defines the id of the script element
  34691. * @returns a promise request object
  34692. */
  34693. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34694. /**
  34695. * Loads a file from a blob
  34696. * @param fileToLoad defines the blob to use
  34697. * @param callback defines the callback to call when data is loaded
  34698. * @param progressCallback defines the callback to call during loading process
  34699. * @returns a file request object
  34700. */
  34701. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34702. /**
  34703. * Reads a file from a File object
  34704. * @param file defines the file to load
  34705. * @param onSuccess defines the callback to call when data is loaded
  34706. * @param onProgress defines the callback to call during loading process
  34707. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34708. * @param onError defines the callback to call when an error occurs
  34709. * @returns a file request object
  34710. */
  34711. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34712. /**
  34713. * Creates a data url from a given string content
  34714. * @param content defines the content to convert
  34715. * @returns the new data url link
  34716. */
  34717. static FileAsURL(content: string): string;
  34718. /**
  34719. * Format the given number to a specific decimal format
  34720. * @param value defines the number to format
  34721. * @param decimals defines the number of decimals to use
  34722. * @returns the formatted string
  34723. */
  34724. static Format(value: number, decimals?: number): string;
  34725. /**
  34726. * Tries to copy an object by duplicating every property
  34727. * @param source defines the source object
  34728. * @param destination defines the target object
  34729. * @param doNotCopyList defines a list of properties to avoid
  34730. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34731. */
  34732. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34733. /**
  34734. * Gets a boolean indicating if the given object has no own property
  34735. * @param obj defines the object to test
  34736. * @returns true if object has no own property
  34737. */
  34738. static IsEmpty(obj: any): boolean;
  34739. /**
  34740. * Function used to register events at window level
  34741. * @param windowElement defines the Window object to use
  34742. * @param events defines the events to register
  34743. */
  34744. static RegisterTopRootEvents(windowElement: Window, events: {
  34745. name: string;
  34746. handler: Nullable<(e: FocusEvent) => any>;
  34747. }[]): void;
  34748. /**
  34749. * Function used to unregister events from window level
  34750. * @param windowElement defines the Window object to use
  34751. * @param events defines the events to unregister
  34752. */
  34753. static UnregisterTopRootEvents(windowElement: Window, events: {
  34754. name: string;
  34755. handler: Nullable<(e: FocusEvent) => any>;
  34756. }[]): void;
  34757. /**
  34758. * @ignore
  34759. */
  34760. static _ScreenshotCanvas: HTMLCanvasElement;
  34761. /**
  34762. * Dumps the current bound framebuffer
  34763. * @param width defines the rendering width
  34764. * @param height defines the rendering height
  34765. * @param engine defines the hosting engine
  34766. * @param successCallback defines the callback triggered once the data are available
  34767. * @param mimeType defines the mime type of the result
  34768. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34769. */
  34770. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34771. /**
  34772. * Converts the canvas data to blob.
  34773. * This acts as a polyfill for browsers not supporting the to blob function.
  34774. * @param canvas Defines the canvas to extract the data from
  34775. * @param successCallback Defines the callback triggered once the data are available
  34776. * @param mimeType Defines the mime type of the result
  34777. */
  34778. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34779. /**
  34780. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34781. * @param successCallback defines the callback triggered once the data are available
  34782. * @param mimeType defines the mime type of the result
  34783. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34784. */
  34785. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34786. /**
  34787. * Downloads a blob in the browser
  34788. * @param blob defines the blob to download
  34789. * @param fileName defines the name of the downloaded file
  34790. */
  34791. static Download(blob: Blob, fileName: string): void;
  34792. /**
  34793. * Captures a screenshot of the current rendering
  34794. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34795. * @param engine defines the rendering engine
  34796. * @param camera defines the source camera
  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 successCallback defines the callback receives a single parameter which contains the
  34803. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34804. * src parameter of an <img> to display it
  34805. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34806. * Check your browser for supported MIME types
  34807. */
  34808. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34809. /**
  34810. * Captures a screenshot of the current rendering
  34811. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34812. * @param engine defines the rendering engine
  34813. * @param camera defines the source camera
  34814. * @param size This parameter can be set to a single number or to an object with the
  34815. * following (optional) properties: precision, width, height. If a single number is passed,
  34816. * it will be used for both width and height. If an object is passed, the screenshot size
  34817. * will be derived from the parameters. The precision property is a multiplier allowing
  34818. * rendering at a higher or lower resolution
  34819. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34820. * Check your browser for supported MIME types
  34821. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34822. * to the src parameter of an <img> to display it
  34823. */
  34824. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34825. /**
  34826. * Generates an image screenshot from the specified camera.
  34827. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34828. * @param engine The engine to use for rendering
  34829. * @param camera The camera to use for rendering
  34830. * @param size This parameter can be set to a single number or to an object with the
  34831. * following (optional) properties: precision, width, height. If a single number is passed,
  34832. * it will be used for both width and height. If an object is passed, the screenshot size
  34833. * will be derived from the parameters. The precision property is a multiplier allowing
  34834. * rendering at a higher or lower resolution
  34835. * @param successCallback The callback receives a single parameter which contains the
  34836. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34837. * src parameter of an <img> to display it
  34838. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34839. * Check your browser for supported MIME types
  34840. * @param samples Texture samples (default: 1)
  34841. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34842. * @param fileName A name for for the downloaded file.
  34843. */
  34844. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34845. /**
  34846. * Generates an image screenshot from the specified camera.
  34847. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34848. * @param engine The engine to use for rendering
  34849. * @param camera The camera to use for rendering
  34850. * @param size This parameter can be set to a single number or to an object with the
  34851. * following (optional) properties: precision, width, height. If a single number is passed,
  34852. * it will be used for both width and height. If an object is passed, the screenshot size
  34853. * will be derived from the parameters. The precision property is a multiplier allowing
  34854. * rendering at a higher or lower resolution
  34855. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34856. * Check your browser for supported MIME types
  34857. * @param samples Texture samples (default: 1)
  34858. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34859. * @param fileName A name for for the downloaded file.
  34860. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34861. * to the src parameter of an <img> to display it
  34862. */
  34863. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34864. /**
  34865. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34866. * Be aware Math.random() could cause collisions, but:
  34867. * "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"
  34868. * @returns a pseudo random id
  34869. */
  34870. static RandomId(): string;
  34871. /**
  34872. * Test if the given uri is a base64 string
  34873. * @param uri The uri to test
  34874. * @return True if the uri is a base64 string or false otherwise
  34875. */
  34876. static IsBase64(uri: string): boolean;
  34877. /**
  34878. * Decode the given base64 uri.
  34879. * @param uri The uri to decode
  34880. * @return The decoded base64 data.
  34881. */
  34882. static DecodeBase64(uri: string): ArrayBuffer;
  34883. /**
  34884. * Gets the absolute url.
  34885. * @param url the input url
  34886. * @return the absolute url
  34887. */
  34888. static GetAbsoluteUrl(url: string): string;
  34889. /**
  34890. * No log
  34891. */
  34892. static readonly NoneLogLevel: number;
  34893. /**
  34894. * Only message logs
  34895. */
  34896. static readonly MessageLogLevel: number;
  34897. /**
  34898. * Only warning logs
  34899. */
  34900. static readonly WarningLogLevel: number;
  34901. /**
  34902. * Only error logs
  34903. */
  34904. static readonly ErrorLogLevel: number;
  34905. /**
  34906. * All logs
  34907. */
  34908. static readonly AllLogLevel: number;
  34909. /**
  34910. * Gets a value indicating the number of loading errors
  34911. * @ignorenaming
  34912. */
  34913. static get errorsCount(): number;
  34914. /**
  34915. * Callback called when a new log is added
  34916. */
  34917. static OnNewCacheEntry: (entry: string) => void;
  34918. /**
  34919. * Log a message to the console
  34920. * @param message defines the message to log
  34921. */
  34922. static Log(message: string): void;
  34923. /**
  34924. * Write a warning message to the console
  34925. * @param message defines the message to log
  34926. */
  34927. static Warn(message: string): void;
  34928. /**
  34929. * Write an error message to the console
  34930. * @param message defines the message to log
  34931. */
  34932. static Error(message: string): void;
  34933. /**
  34934. * Gets current log cache (list of logs)
  34935. */
  34936. static get LogCache(): string;
  34937. /**
  34938. * Clears the log cache
  34939. */
  34940. static ClearLogCache(): void;
  34941. /**
  34942. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34943. */
  34944. static set LogLevels(level: number);
  34945. /**
  34946. * Checks if the window object exists
  34947. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34948. */
  34949. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34950. /**
  34951. * No performance log
  34952. */
  34953. static readonly PerformanceNoneLogLevel: number;
  34954. /**
  34955. * Use user marks to log performance
  34956. */
  34957. static readonly PerformanceUserMarkLogLevel: number;
  34958. /**
  34959. * Log performance to the console
  34960. */
  34961. static readonly PerformanceConsoleLogLevel: number;
  34962. private static _performance;
  34963. /**
  34964. * Sets the current performance log level
  34965. */
  34966. static set PerformanceLogLevel(level: number);
  34967. private static _StartPerformanceCounterDisabled;
  34968. private static _EndPerformanceCounterDisabled;
  34969. private static _StartUserMark;
  34970. private static _EndUserMark;
  34971. private static _StartPerformanceConsole;
  34972. private static _EndPerformanceConsole;
  34973. /**
  34974. * Starts a performance counter
  34975. */
  34976. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34977. /**
  34978. * Ends a specific performance coutner
  34979. */
  34980. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34981. /**
  34982. * Gets either window.performance.now() if supported or Date.now() else
  34983. */
  34984. static get Now(): number;
  34985. /**
  34986. * This method will return the name of the class used to create the instance of the given object.
  34987. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34988. * @param object the object to get the class name from
  34989. * @param isType defines if the object is actually a type
  34990. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34991. */
  34992. static GetClassName(object: any, isType?: boolean): string;
  34993. /**
  34994. * Gets the first element of an array satisfying a given predicate
  34995. * @param array defines the array to browse
  34996. * @param predicate defines the predicate to use
  34997. * @returns null if not found or the element
  34998. */
  34999. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35000. /**
  35001. * This method will return the name of the full name of the class, including its owning module (if any).
  35002. * 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).
  35003. * @param object the object to get the class name from
  35004. * @param isType defines if the object is actually a type
  35005. * @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.
  35006. * @ignorenaming
  35007. */
  35008. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35009. /**
  35010. * Returns a promise that resolves after the given amount of time.
  35011. * @param delay Number of milliseconds to delay
  35012. * @returns Promise that resolves after the given amount of time
  35013. */
  35014. static DelayAsync(delay: number): Promise<void>;
  35015. /**
  35016. * Utility function to detect if the current user agent is Safari
  35017. * @returns whether or not the current user agent is safari
  35018. */
  35019. static IsSafari(): boolean;
  35020. }
  35021. /**
  35022. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35023. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35024. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35025. * @param name The name of the class, case should be preserved
  35026. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35027. */
  35028. export function className(name: string, module?: string): (target: Object) => void;
  35029. /**
  35030. * An implementation of a loop for asynchronous functions.
  35031. */
  35032. export class AsyncLoop {
  35033. /**
  35034. * Defines the number of iterations for the loop
  35035. */
  35036. iterations: number;
  35037. /**
  35038. * Defines the current index of the loop.
  35039. */
  35040. index: number;
  35041. private _done;
  35042. private _fn;
  35043. private _successCallback;
  35044. /**
  35045. * Constructor.
  35046. * @param iterations the number of iterations.
  35047. * @param func the function to run each iteration
  35048. * @param successCallback the callback that will be called upon succesful execution
  35049. * @param offset starting offset.
  35050. */
  35051. constructor(
  35052. /**
  35053. * Defines the number of iterations for the loop
  35054. */
  35055. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35056. /**
  35057. * Execute the next iteration. Must be called after the last iteration was finished.
  35058. */
  35059. executeNext(): void;
  35060. /**
  35061. * Break the loop and run the success callback.
  35062. */
  35063. breakLoop(): void;
  35064. /**
  35065. * Create and run an async loop.
  35066. * @param iterations the number of iterations.
  35067. * @param fn the function to run each iteration
  35068. * @param successCallback the callback that will be called upon succesful execution
  35069. * @param offset starting offset.
  35070. * @returns the created async loop object
  35071. */
  35072. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35073. /**
  35074. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35075. * @param iterations total number of iterations
  35076. * @param syncedIterations number of synchronous iterations in each async iteration.
  35077. * @param fn the function to call each iteration.
  35078. * @param callback a success call back that will be called when iterating stops.
  35079. * @param breakFunction a break condition (optional)
  35080. * @param timeout timeout settings for the setTimeout function. default - 0.
  35081. * @returns the created async loop object
  35082. */
  35083. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35084. }
  35085. }
  35086. declare module BABYLON {
  35087. /**
  35088. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35089. * The underlying implementation relies on an associative array to ensure the best performances.
  35090. * The value can be anything including 'null' but except 'undefined'
  35091. */
  35092. export class StringDictionary<T> {
  35093. /**
  35094. * This will clear this dictionary and copy the content from the 'source' one.
  35095. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35096. * @param source the dictionary to take the content from and copy to this dictionary
  35097. */
  35098. copyFrom(source: StringDictionary<T>): void;
  35099. /**
  35100. * Get a value based from its key
  35101. * @param key the given key to get the matching value from
  35102. * @return the value if found, otherwise undefined is returned
  35103. */
  35104. get(key: string): T | undefined;
  35105. /**
  35106. * Get a value from its key or add it if it doesn't exist.
  35107. * This method will ensure you that a given key/data will be present in the dictionary.
  35108. * @param key the given key to get the matching value from
  35109. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35110. * The factory will only be invoked if there's no data for the given key.
  35111. * @return the value corresponding to the key.
  35112. */
  35113. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35114. /**
  35115. * Get a value from its key if present in the dictionary otherwise add it
  35116. * @param key the key to get the value from
  35117. * @param val if there's no such key/value pair in the dictionary add it with this value
  35118. * @return the value corresponding to the key
  35119. */
  35120. getOrAdd(key: string, val: T): T;
  35121. /**
  35122. * Check if there's a given key in the dictionary
  35123. * @param key the key to check for
  35124. * @return true if the key is present, false otherwise
  35125. */
  35126. contains(key: string): boolean;
  35127. /**
  35128. * Add a new key and its corresponding value
  35129. * @param key the key to add
  35130. * @param value the value corresponding to the key
  35131. * @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
  35132. */
  35133. add(key: string, value: T): boolean;
  35134. /**
  35135. * Update a specific value associated to a key
  35136. * @param key defines the key to use
  35137. * @param value defines the value to store
  35138. * @returns true if the value was updated (or false if the key was not found)
  35139. */
  35140. set(key: string, value: T): boolean;
  35141. /**
  35142. * Get the element of the given key and remove it from the dictionary
  35143. * @param key defines the key to search
  35144. * @returns the value associated with the key or null if not found
  35145. */
  35146. getAndRemove(key: string): Nullable<T>;
  35147. /**
  35148. * Remove a key/value from the dictionary.
  35149. * @param key the key to remove
  35150. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35151. */
  35152. remove(key: string): boolean;
  35153. /**
  35154. * Clear the whole content of the dictionary
  35155. */
  35156. clear(): void;
  35157. /**
  35158. * Gets the current count
  35159. */
  35160. get count(): number;
  35161. /**
  35162. * Execute a callback on each key/val of the dictionary.
  35163. * Note that you can remove any element in this dictionary in the callback implementation
  35164. * @param callback the callback to execute on a given key/value pair
  35165. */
  35166. forEach(callback: (key: string, val: T) => void): void;
  35167. /**
  35168. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35169. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35170. * Note that you can remove any element in this dictionary in the callback implementation
  35171. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35172. * @returns the first item
  35173. */
  35174. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35175. private _count;
  35176. private _data;
  35177. }
  35178. }
  35179. declare module BABYLON {
  35180. /** @hidden */
  35181. export interface ICollisionCoordinator {
  35182. createCollider(): Collider;
  35183. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35184. init(scene: Scene): void;
  35185. }
  35186. /** @hidden */
  35187. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35188. private _scene;
  35189. private _scaledPosition;
  35190. private _scaledVelocity;
  35191. private _finalPosition;
  35192. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35193. createCollider(): Collider;
  35194. init(scene: Scene): void;
  35195. private _collideWithWorld;
  35196. }
  35197. }
  35198. declare module BABYLON {
  35199. /**
  35200. * Class used to manage all inputs for the scene.
  35201. */
  35202. export class InputManager {
  35203. /** The distance in pixel that you have to move to prevent some events */
  35204. static DragMovementThreshold: number;
  35205. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35206. static LongPressDelay: number;
  35207. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35208. static DoubleClickDelay: number;
  35209. /** If you need to check double click without raising a single click at first click, enable this flag */
  35210. static ExclusiveDoubleClickMode: boolean;
  35211. private _wheelEventName;
  35212. private _onPointerMove;
  35213. private _onPointerDown;
  35214. private _onPointerUp;
  35215. private _initClickEvent;
  35216. private _initActionManager;
  35217. private _delayedSimpleClick;
  35218. private _delayedSimpleClickTimeout;
  35219. private _previousDelayedSimpleClickTimeout;
  35220. private _meshPickProceed;
  35221. private _previousButtonPressed;
  35222. private _currentPickResult;
  35223. private _previousPickResult;
  35224. private _totalPointersPressed;
  35225. private _doubleClickOccured;
  35226. private _pointerOverMesh;
  35227. private _pickedDownMesh;
  35228. private _pickedUpMesh;
  35229. private _pointerX;
  35230. private _pointerY;
  35231. private _unTranslatedPointerX;
  35232. private _unTranslatedPointerY;
  35233. private _startingPointerPosition;
  35234. private _previousStartingPointerPosition;
  35235. private _startingPointerTime;
  35236. private _previousStartingPointerTime;
  35237. private _pointerCaptures;
  35238. private _onKeyDown;
  35239. private _onKeyUp;
  35240. private _onCanvasFocusObserver;
  35241. private _onCanvasBlurObserver;
  35242. private _scene;
  35243. /**
  35244. * Creates a new InputManager
  35245. * @param scene defines the hosting scene
  35246. */
  35247. constructor(scene: Scene);
  35248. /**
  35249. * Gets the mesh that is currently under the pointer
  35250. */
  35251. get meshUnderPointer(): Nullable<AbstractMesh>;
  35252. /**
  35253. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35254. */
  35255. get unTranslatedPointer(): Vector2;
  35256. /**
  35257. * Gets or sets the current on-screen X position of the pointer
  35258. */
  35259. get pointerX(): number;
  35260. set pointerX(value: number);
  35261. /**
  35262. * Gets or sets the current on-screen Y position of the pointer
  35263. */
  35264. get pointerY(): number;
  35265. set pointerY(value: number);
  35266. private _updatePointerPosition;
  35267. private _processPointerMove;
  35268. private _setRayOnPointerInfo;
  35269. private _checkPrePointerObservable;
  35270. /**
  35271. * Use this method to simulate a pointer move on a mesh
  35272. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35273. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35274. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35275. */
  35276. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35277. /**
  35278. * Use this method to simulate a pointer down on a mesh
  35279. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35280. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35281. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35282. */
  35283. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35284. private _processPointerDown;
  35285. /** @hidden */
  35286. _isPointerSwiping(): boolean;
  35287. /**
  35288. * Use this method to simulate a pointer up on a mesh
  35289. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35290. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35291. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35292. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35293. */
  35294. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35295. private _processPointerUp;
  35296. /**
  35297. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35298. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35299. * @returns true if the pointer was captured
  35300. */
  35301. isPointerCaptured(pointerId?: number): boolean;
  35302. /**
  35303. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35304. * @param attachUp defines if you want to attach events to pointerup
  35305. * @param attachDown defines if you want to attach events to pointerdown
  35306. * @param attachMove defines if you want to attach events to pointermove
  35307. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35308. */
  35309. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35310. /**
  35311. * Detaches all event handlers
  35312. */
  35313. detachControl(): void;
  35314. /**
  35315. * Force the value of meshUnderPointer
  35316. * @param mesh defines the mesh to use
  35317. */
  35318. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35319. /**
  35320. * Gets the mesh under the pointer
  35321. * @returns a Mesh or null if no mesh is under the pointer
  35322. */
  35323. getPointerOverMesh(): Nullable<AbstractMesh>;
  35324. }
  35325. }
  35326. declare module BABYLON {
  35327. /**
  35328. * Helper class used to generate session unique ID
  35329. */
  35330. export class UniqueIdGenerator {
  35331. private static _UniqueIdCounter;
  35332. /**
  35333. * Gets an unique (relatively to the current scene) Id
  35334. */
  35335. static get UniqueId(): number;
  35336. }
  35337. }
  35338. declare module BABYLON {
  35339. /**
  35340. * This class defines the direct association between an animation and a target
  35341. */
  35342. export class TargetedAnimation {
  35343. /**
  35344. * Animation to perform
  35345. */
  35346. animation: Animation;
  35347. /**
  35348. * Target to animate
  35349. */
  35350. target: any;
  35351. /**
  35352. * Serialize the object
  35353. * @returns the JSON object representing the current entity
  35354. */
  35355. serialize(): any;
  35356. }
  35357. /**
  35358. * Use this class to create coordinated animations on multiple targets
  35359. */
  35360. export class AnimationGroup implements IDisposable {
  35361. /** The name of the animation group */
  35362. name: string;
  35363. private _scene;
  35364. private _targetedAnimations;
  35365. private _animatables;
  35366. private _from;
  35367. private _to;
  35368. private _isStarted;
  35369. private _isPaused;
  35370. private _speedRatio;
  35371. private _loopAnimation;
  35372. private _isAdditive;
  35373. /**
  35374. * Gets or sets the unique id of the node
  35375. */
  35376. uniqueId: number;
  35377. /**
  35378. * This observable will notify when one animation have ended
  35379. */
  35380. onAnimationEndObservable: Observable<TargetedAnimation>;
  35381. /**
  35382. * Observer raised when one animation loops
  35383. */
  35384. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35385. /**
  35386. * Observer raised when all animations have looped
  35387. */
  35388. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35389. /**
  35390. * This observable will notify when all animations have ended.
  35391. */
  35392. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35393. /**
  35394. * This observable will notify when all animations have paused.
  35395. */
  35396. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35397. /**
  35398. * This observable will notify when all animations are playing.
  35399. */
  35400. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35401. /**
  35402. * Gets the first frame
  35403. */
  35404. get from(): number;
  35405. /**
  35406. * Gets the last frame
  35407. */
  35408. get to(): number;
  35409. /**
  35410. * Define if the animations are started
  35411. */
  35412. get isStarted(): boolean;
  35413. /**
  35414. * Gets a value indicating that the current group is playing
  35415. */
  35416. get isPlaying(): boolean;
  35417. /**
  35418. * Gets or sets the speed ratio to use for all animations
  35419. */
  35420. get speedRatio(): number;
  35421. /**
  35422. * Gets or sets the speed ratio to use for all animations
  35423. */
  35424. set speedRatio(value: number);
  35425. /**
  35426. * Gets or sets if all animations should loop or not
  35427. */
  35428. get loopAnimation(): boolean;
  35429. set loopAnimation(value: boolean);
  35430. /**
  35431. * Gets or sets if all animations should be evaluated additively
  35432. */
  35433. get isAdditive(): boolean;
  35434. set isAdditive(value: boolean);
  35435. /**
  35436. * Gets the targeted animations for this animation group
  35437. */
  35438. get targetedAnimations(): Array<TargetedAnimation>;
  35439. /**
  35440. * returning the list of animatables controlled by this animation group.
  35441. */
  35442. get animatables(): Array<Animatable>;
  35443. /**
  35444. * Instantiates a new Animation Group.
  35445. * This helps managing several animations at once.
  35446. * @see http://doc.babylonjs.com/how_to/group
  35447. * @param name Defines the name of the group
  35448. * @param scene Defines the scene the group belongs to
  35449. */
  35450. constructor(
  35451. /** The name of the animation group */
  35452. name: string, scene?: Nullable<Scene>);
  35453. /**
  35454. * Add an animation (with its target) in the group
  35455. * @param animation defines the animation we want to add
  35456. * @param target defines the target of the animation
  35457. * @returns the TargetedAnimation object
  35458. */
  35459. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35460. /**
  35461. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35462. * It can add constant keys at begin or end
  35463. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35464. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35465. * @returns the animation group
  35466. */
  35467. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35468. private _animationLoopCount;
  35469. private _animationLoopFlags;
  35470. private _processLoop;
  35471. /**
  35472. * Start all animations on given targets
  35473. * @param loop defines if animations must loop
  35474. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35475. * @param from defines the from key (optional)
  35476. * @param to defines the to key (optional)
  35477. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35478. * @returns the current animation group
  35479. */
  35480. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35481. /**
  35482. * Pause all animations
  35483. * @returns the animation group
  35484. */
  35485. pause(): AnimationGroup;
  35486. /**
  35487. * Play all animations to initial state
  35488. * This function will start() the animations if they were not started or will restart() them if they were paused
  35489. * @param loop defines if animations must loop
  35490. * @returns the animation group
  35491. */
  35492. play(loop?: boolean): AnimationGroup;
  35493. /**
  35494. * Reset all animations to initial state
  35495. * @returns the animation group
  35496. */
  35497. reset(): AnimationGroup;
  35498. /**
  35499. * Restart animations from key 0
  35500. * @returns the animation group
  35501. */
  35502. restart(): AnimationGroup;
  35503. /**
  35504. * Stop all animations
  35505. * @returns the animation group
  35506. */
  35507. stop(): AnimationGroup;
  35508. /**
  35509. * Set animation weight for all animatables
  35510. * @param weight defines the weight to use
  35511. * @return the animationGroup
  35512. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35513. */
  35514. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35515. /**
  35516. * Synchronize and normalize all animatables with a source animatable
  35517. * @param root defines the root animatable to synchronize with
  35518. * @return the animationGroup
  35519. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35520. */
  35521. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35522. /**
  35523. * Goes to a specific frame in this animation group
  35524. * @param frame the frame number to go to
  35525. * @return the animationGroup
  35526. */
  35527. goToFrame(frame: number): AnimationGroup;
  35528. /**
  35529. * Dispose all associated resources
  35530. */
  35531. dispose(): void;
  35532. private _checkAnimationGroupEnded;
  35533. /**
  35534. * Clone the current animation group and returns a copy
  35535. * @param newName defines the name of the new group
  35536. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35537. * @returns the new aniamtion group
  35538. */
  35539. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35540. /**
  35541. * Serializes the animationGroup to an object
  35542. * @returns Serialized object
  35543. */
  35544. serialize(): any;
  35545. /**
  35546. * Returns a new AnimationGroup object parsed from the source provided.
  35547. * @param parsedAnimationGroup defines the source
  35548. * @param scene defines the scene that will receive the animationGroup
  35549. * @returns a new AnimationGroup
  35550. */
  35551. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35552. /**
  35553. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35554. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35555. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35556. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35557. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35558. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35559. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35560. */
  35561. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35562. /**
  35563. * Returns the string "AnimationGroup"
  35564. * @returns "AnimationGroup"
  35565. */
  35566. getClassName(): string;
  35567. /**
  35568. * Creates a detailled string about the object
  35569. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35570. * @returns a string representing the object
  35571. */
  35572. toString(fullDetails?: boolean): string;
  35573. }
  35574. }
  35575. declare module BABYLON {
  35576. /**
  35577. * Define an interface for all classes that will hold resources
  35578. */
  35579. export interface IDisposable {
  35580. /**
  35581. * Releases all held resources
  35582. */
  35583. dispose(): void;
  35584. }
  35585. /** Interface defining initialization parameters for Scene class */
  35586. export interface SceneOptions {
  35587. /**
  35588. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35589. * It will improve performance when the number of geometries becomes important.
  35590. */
  35591. useGeometryUniqueIdsMap?: boolean;
  35592. /**
  35593. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35594. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35595. */
  35596. useMaterialMeshMap?: boolean;
  35597. /**
  35598. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35599. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35600. */
  35601. useClonedMeshMap?: boolean;
  35602. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35603. virtual?: boolean;
  35604. }
  35605. /**
  35606. * Represents a scene to be rendered by the engine.
  35607. * @see http://doc.babylonjs.com/features/scene
  35608. */
  35609. export class Scene extends AbstractScene implements IAnimatable {
  35610. /** The fog is deactivated */
  35611. static readonly FOGMODE_NONE: number;
  35612. /** The fog density is following an exponential function */
  35613. static readonly FOGMODE_EXP: number;
  35614. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35615. static readonly FOGMODE_EXP2: number;
  35616. /** The fog density is following a linear function. */
  35617. static readonly FOGMODE_LINEAR: number;
  35618. /**
  35619. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35620. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35621. */
  35622. static MinDeltaTime: number;
  35623. /**
  35624. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35625. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35626. */
  35627. static MaxDeltaTime: number;
  35628. /**
  35629. * Factory used to create the default material.
  35630. * @param name The name of the material to create
  35631. * @param scene The scene to create the material for
  35632. * @returns The default material
  35633. */
  35634. static DefaultMaterialFactory(scene: Scene): Material;
  35635. /**
  35636. * Factory used to create the a collision coordinator.
  35637. * @returns The collision coordinator
  35638. */
  35639. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35640. /** @hidden */
  35641. _inputManager: InputManager;
  35642. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35643. cameraToUseForPointers: Nullable<Camera>;
  35644. /** @hidden */
  35645. readonly _isScene: boolean;
  35646. /** @hidden */
  35647. _blockEntityCollection: boolean;
  35648. /**
  35649. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35650. */
  35651. autoClear: boolean;
  35652. /**
  35653. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35654. */
  35655. autoClearDepthAndStencil: boolean;
  35656. /**
  35657. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35658. */
  35659. clearColor: Color4;
  35660. /**
  35661. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35662. */
  35663. ambientColor: Color3;
  35664. /**
  35665. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35666. * It should only be one of the following (if not the default embedded one):
  35667. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35668. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35669. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35670. * The material properties need to be setup according to the type of texture in use.
  35671. */
  35672. environmentBRDFTexture: BaseTexture;
  35673. /** @hidden */
  35674. protected _environmentTexture: Nullable<BaseTexture>;
  35675. /**
  35676. * Texture used in all pbr material as the reflection texture.
  35677. * As in the majority of the scene they are the same (exception for multi room and so on),
  35678. * this is easier to reference from here than from all the materials.
  35679. */
  35680. get environmentTexture(): Nullable<BaseTexture>;
  35681. /**
  35682. * Texture used in all pbr material as the reflection texture.
  35683. * As in the majority of the scene they are the same (exception for multi room and so on),
  35684. * this is easier to set here than in all the materials.
  35685. */
  35686. set environmentTexture(value: Nullable<BaseTexture>);
  35687. /** @hidden */
  35688. protected _environmentIntensity: number;
  35689. /**
  35690. * Intensity of the environment in all pbr material.
  35691. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35692. * As in the majority of the scene they are the same (exception for multi room and so on),
  35693. * this is easier to reference from here than from all the materials.
  35694. */
  35695. get environmentIntensity(): number;
  35696. /**
  35697. * Intensity of the environment in all pbr material.
  35698. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35699. * As in the majority of the scene they are the same (exception for multi room and so on),
  35700. * this is easier to set here than in all the materials.
  35701. */
  35702. set environmentIntensity(value: number);
  35703. /** @hidden */
  35704. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35705. /**
  35706. * Default image processing configuration used either in the rendering
  35707. * Forward main pass or through the imageProcessingPostProcess if present.
  35708. * As in the majority of the scene they are the same (exception for multi camera),
  35709. * this is easier to reference from here than from all the materials and post process.
  35710. *
  35711. * No setter as we it is a shared configuration, you can set the values instead.
  35712. */
  35713. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35714. private _forceWireframe;
  35715. /**
  35716. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35717. */
  35718. set forceWireframe(value: boolean);
  35719. get forceWireframe(): boolean;
  35720. private _skipFrustumClipping;
  35721. /**
  35722. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35723. */
  35724. set skipFrustumClipping(value: boolean);
  35725. get skipFrustumClipping(): boolean;
  35726. private _forcePointsCloud;
  35727. /**
  35728. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35729. */
  35730. set forcePointsCloud(value: boolean);
  35731. get forcePointsCloud(): boolean;
  35732. /**
  35733. * Gets or sets the active clipplane 1
  35734. */
  35735. clipPlane: Nullable<Plane>;
  35736. /**
  35737. * Gets or sets the active clipplane 2
  35738. */
  35739. clipPlane2: Nullable<Plane>;
  35740. /**
  35741. * Gets or sets the active clipplane 3
  35742. */
  35743. clipPlane3: Nullable<Plane>;
  35744. /**
  35745. * Gets or sets the active clipplane 4
  35746. */
  35747. clipPlane4: Nullable<Plane>;
  35748. /**
  35749. * Gets or sets the active clipplane 5
  35750. */
  35751. clipPlane5: Nullable<Plane>;
  35752. /**
  35753. * Gets or sets the active clipplane 6
  35754. */
  35755. clipPlane6: Nullable<Plane>;
  35756. /**
  35757. * Gets or sets a boolean indicating if animations are enabled
  35758. */
  35759. animationsEnabled: boolean;
  35760. private _animationPropertiesOverride;
  35761. /**
  35762. * Gets or sets the animation properties override
  35763. */
  35764. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35765. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35766. /**
  35767. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35768. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35769. */
  35770. useConstantAnimationDeltaTime: boolean;
  35771. /**
  35772. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35773. * Please note that it requires to run a ray cast through the scene on every frame
  35774. */
  35775. constantlyUpdateMeshUnderPointer: boolean;
  35776. /**
  35777. * Defines the HTML cursor to use when hovering over interactive elements
  35778. */
  35779. hoverCursor: string;
  35780. /**
  35781. * Defines the HTML default cursor to use (empty by default)
  35782. */
  35783. defaultCursor: string;
  35784. /**
  35785. * Defines whether cursors are handled by the scene.
  35786. */
  35787. doNotHandleCursors: boolean;
  35788. /**
  35789. * This is used to call preventDefault() on pointer down
  35790. * in order to block unwanted artifacts like system double clicks
  35791. */
  35792. preventDefaultOnPointerDown: boolean;
  35793. /**
  35794. * This is used to call preventDefault() on pointer up
  35795. * in order to block unwanted artifacts like system double clicks
  35796. */
  35797. preventDefaultOnPointerUp: boolean;
  35798. /**
  35799. * Gets or sets user defined metadata
  35800. */
  35801. metadata: any;
  35802. /**
  35803. * For internal use only. Please do not use.
  35804. */
  35805. reservedDataStore: any;
  35806. /**
  35807. * Gets the name of the plugin used to load this scene (null by default)
  35808. */
  35809. loadingPluginName: string;
  35810. /**
  35811. * Use this array to add regular expressions used to disable offline support for specific urls
  35812. */
  35813. disableOfflineSupportExceptionRules: RegExp[];
  35814. /**
  35815. * An event triggered when the scene is disposed.
  35816. */
  35817. onDisposeObservable: Observable<Scene>;
  35818. private _onDisposeObserver;
  35819. /** Sets a function to be executed when this scene is disposed. */
  35820. set onDispose(callback: () => void);
  35821. /**
  35822. * An event triggered before rendering the scene (right after animations and physics)
  35823. */
  35824. onBeforeRenderObservable: Observable<Scene>;
  35825. private _onBeforeRenderObserver;
  35826. /** Sets a function to be executed before rendering this scene */
  35827. set beforeRender(callback: Nullable<() => void>);
  35828. /**
  35829. * An event triggered after rendering the scene
  35830. */
  35831. onAfterRenderObservable: Observable<Scene>;
  35832. /**
  35833. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35834. */
  35835. onAfterRenderCameraObservable: Observable<Camera>;
  35836. private _onAfterRenderObserver;
  35837. /** Sets a function to be executed after rendering this scene */
  35838. set afterRender(callback: Nullable<() => void>);
  35839. /**
  35840. * An event triggered before animating the scene
  35841. */
  35842. onBeforeAnimationsObservable: Observable<Scene>;
  35843. /**
  35844. * An event triggered after animations processing
  35845. */
  35846. onAfterAnimationsObservable: Observable<Scene>;
  35847. /**
  35848. * An event triggered before draw calls are ready to be sent
  35849. */
  35850. onBeforeDrawPhaseObservable: Observable<Scene>;
  35851. /**
  35852. * An event triggered after draw calls have been sent
  35853. */
  35854. onAfterDrawPhaseObservable: Observable<Scene>;
  35855. /**
  35856. * An event triggered when the scene is ready
  35857. */
  35858. onReadyObservable: Observable<Scene>;
  35859. /**
  35860. * An event triggered before rendering a camera
  35861. */
  35862. onBeforeCameraRenderObservable: Observable<Camera>;
  35863. private _onBeforeCameraRenderObserver;
  35864. /** Sets a function to be executed before rendering a camera*/
  35865. set beforeCameraRender(callback: () => void);
  35866. /**
  35867. * An event triggered after rendering a camera
  35868. */
  35869. onAfterCameraRenderObservable: Observable<Camera>;
  35870. private _onAfterCameraRenderObserver;
  35871. /** Sets a function to be executed after rendering a camera*/
  35872. set afterCameraRender(callback: () => void);
  35873. /**
  35874. * An event triggered when active meshes evaluation is about to start
  35875. */
  35876. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35877. /**
  35878. * An event triggered when active meshes evaluation is done
  35879. */
  35880. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35881. /**
  35882. * An event triggered when particles rendering is about to start
  35883. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35884. */
  35885. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35886. /**
  35887. * An event triggered when particles rendering is done
  35888. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35889. */
  35890. onAfterParticlesRenderingObservable: Observable<Scene>;
  35891. /**
  35892. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35893. */
  35894. onDataLoadedObservable: Observable<Scene>;
  35895. /**
  35896. * An event triggered when a camera is created
  35897. */
  35898. onNewCameraAddedObservable: Observable<Camera>;
  35899. /**
  35900. * An event triggered when a camera is removed
  35901. */
  35902. onCameraRemovedObservable: Observable<Camera>;
  35903. /**
  35904. * An event triggered when a light is created
  35905. */
  35906. onNewLightAddedObservable: Observable<Light>;
  35907. /**
  35908. * An event triggered when a light is removed
  35909. */
  35910. onLightRemovedObservable: Observable<Light>;
  35911. /**
  35912. * An event triggered when a geometry is created
  35913. */
  35914. onNewGeometryAddedObservable: Observable<Geometry>;
  35915. /**
  35916. * An event triggered when a geometry is removed
  35917. */
  35918. onGeometryRemovedObservable: Observable<Geometry>;
  35919. /**
  35920. * An event triggered when a transform node is created
  35921. */
  35922. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35923. /**
  35924. * An event triggered when a transform node is removed
  35925. */
  35926. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35927. /**
  35928. * An event triggered when a mesh is created
  35929. */
  35930. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35931. /**
  35932. * An event triggered when a mesh is removed
  35933. */
  35934. onMeshRemovedObservable: Observable<AbstractMesh>;
  35935. /**
  35936. * An event triggered when a skeleton is created
  35937. */
  35938. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35939. /**
  35940. * An event triggered when a skeleton is removed
  35941. */
  35942. onSkeletonRemovedObservable: Observable<Skeleton>;
  35943. /**
  35944. * An event triggered when a material is created
  35945. */
  35946. onNewMaterialAddedObservable: Observable<Material>;
  35947. /**
  35948. * An event triggered when a material is removed
  35949. */
  35950. onMaterialRemovedObservable: Observable<Material>;
  35951. /**
  35952. * An event triggered when a texture is created
  35953. */
  35954. onNewTextureAddedObservable: Observable<BaseTexture>;
  35955. /**
  35956. * An event triggered when a texture is removed
  35957. */
  35958. onTextureRemovedObservable: Observable<BaseTexture>;
  35959. /**
  35960. * An event triggered when render targets are about to be rendered
  35961. * Can happen multiple times per frame.
  35962. */
  35963. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35964. /**
  35965. * An event triggered when render targets were rendered.
  35966. * Can happen multiple times per frame.
  35967. */
  35968. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35969. /**
  35970. * An event triggered before calculating deterministic simulation step
  35971. */
  35972. onBeforeStepObservable: Observable<Scene>;
  35973. /**
  35974. * An event triggered after calculating deterministic simulation step
  35975. */
  35976. onAfterStepObservable: Observable<Scene>;
  35977. /**
  35978. * An event triggered when the activeCamera property is updated
  35979. */
  35980. onActiveCameraChanged: Observable<Scene>;
  35981. /**
  35982. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35983. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35984. * 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)
  35985. */
  35986. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35987. /**
  35988. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35989. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35990. * 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)
  35991. */
  35992. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35993. /**
  35994. * This Observable will when a mesh has been imported into the scene.
  35995. */
  35996. onMeshImportedObservable: Observable<AbstractMesh>;
  35997. /**
  35998. * This Observable will when an animation file has been imported into the scene.
  35999. */
  36000. onAnimationFileImportedObservable: Observable<Scene>;
  36001. /**
  36002. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36003. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36004. */
  36005. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36006. /** @hidden */
  36007. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36008. /**
  36009. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36010. */
  36011. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36012. /**
  36013. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36014. */
  36015. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36016. /**
  36017. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36018. */
  36019. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36020. /** Callback called when a pointer move is detected */
  36021. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36022. /** Callback called when a pointer down is detected */
  36023. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36024. /** Callback called when a pointer up is detected */
  36025. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36026. /** Callback called when a pointer pick is detected */
  36027. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36028. /**
  36029. * 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).
  36030. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36031. */
  36032. onPrePointerObservable: Observable<PointerInfoPre>;
  36033. /**
  36034. * Observable event triggered each time an input event is received from the rendering canvas
  36035. */
  36036. onPointerObservable: Observable<PointerInfo>;
  36037. /**
  36038. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36039. */
  36040. get unTranslatedPointer(): Vector2;
  36041. /**
  36042. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36043. */
  36044. static get DragMovementThreshold(): number;
  36045. static set DragMovementThreshold(value: number);
  36046. /**
  36047. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36048. */
  36049. static get LongPressDelay(): number;
  36050. static set LongPressDelay(value: number);
  36051. /**
  36052. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36053. */
  36054. static get DoubleClickDelay(): number;
  36055. static set DoubleClickDelay(value: number);
  36056. /** If you need to check double click without raising a single click at first click, enable this flag */
  36057. static get ExclusiveDoubleClickMode(): boolean;
  36058. static set ExclusiveDoubleClickMode(value: boolean);
  36059. /** @hidden */
  36060. _mirroredCameraPosition: Nullable<Vector3>;
  36061. /**
  36062. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36063. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36064. */
  36065. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36066. /**
  36067. * Observable event triggered each time an keyboard event is received from the hosting window
  36068. */
  36069. onKeyboardObservable: Observable<KeyboardInfo>;
  36070. private _useRightHandedSystem;
  36071. /**
  36072. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36073. */
  36074. set useRightHandedSystem(value: boolean);
  36075. get useRightHandedSystem(): boolean;
  36076. private _timeAccumulator;
  36077. private _currentStepId;
  36078. private _currentInternalStep;
  36079. /**
  36080. * Sets the step Id used by deterministic lock step
  36081. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36082. * @param newStepId defines the step Id
  36083. */
  36084. setStepId(newStepId: number): void;
  36085. /**
  36086. * Gets the step Id used by deterministic lock step
  36087. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36088. * @returns the step Id
  36089. */
  36090. getStepId(): number;
  36091. /**
  36092. * Gets the internal step used by deterministic lock step
  36093. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36094. * @returns the internal step
  36095. */
  36096. getInternalStep(): number;
  36097. private _fogEnabled;
  36098. /**
  36099. * Gets or sets a boolean indicating if fog is enabled on this scene
  36100. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36101. * (Default is true)
  36102. */
  36103. set fogEnabled(value: boolean);
  36104. get fogEnabled(): boolean;
  36105. private _fogMode;
  36106. /**
  36107. * Gets or sets the fog mode to use
  36108. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36109. * | mode | value |
  36110. * | --- | --- |
  36111. * | FOGMODE_NONE | 0 |
  36112. * | FOGMODE_EXP | 1 |
  36113. * | FOGMODE_EXP2 | 2 |
  36114. * | FOGMODE_LINEAR | 3 |
  36115. */
  36116. set fogMode(value: number);
  36117. get fogMode(): number;
  36118. /**
  36119. * Gets or sets the fog color to use
  36120. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36121. * (Default is Color3(0.2, 0.2, 0.3))
  36122. */
  36123. fogColor: Color3;
  36124. /**
  36125. * Gets or sets the fog density to use
  36126. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36127. * (Default is 0.1)
  36128. */
  36129. fogDensity: number;
  36130. /**
  36131. * Gets or sets the fog start distance to use
  36132. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36133. * (Default is 0)
  36134. */
  36135. fogStart: number;
  36136. /**
  36137. * Gets or sets the fog end distance to use
  36138. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36139. * (Default is 1000)
  36140. */
  36141. fogEnd: number;
  36142. private _shadowsEnabled;
  36143. /**
  36144. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36145. */
  36146. set shadowsEnabled(value: boolean);
  36147. get shadowsEnabled(): boolean;
  36148. private _lightsEnabled;
  36149. /**
  36150. * Gets or sets a boolean indicating if lights are enabled on this scene
  36151. */
  36152. set lightsEnabled(value: boolean);
  36153. get lightsEnabled(): boolean;
  36154. /** All of the active cameras added to this scene. */
  36155. activeCameras: Camera[];
  36156. /** @hidden */
  36157. _activeCamera: Nullable<Camera>;
  36158. /** Gets or sets the current active camera */
  36159. get activeCamera(): Nullable<Camera>;
  36160. set activeCamera(value: Nullable<Camera>);
  36161. private _defaultMaterial;
  36162. /** The default material used on meshes when no material is affected */
  36163. get defaultMaterial(): Material;
  36164. /** The default material used on meshes when no material is affected */
  36165. set defaultMaterial(value: Material);
  36166. private _texturesEnabled;
  36167. /**
  36168. * Gets or sets a boolean indicating if textures are enabled on this scene
  36169. */
  36170. set texturesEnabled(value: boolean);
  36171. get texturesEnabled(): boolean;
  36172. /**
  36173. * Gets or sets a boolean indicating if particles are enabled on this scene
  36174. */
  36175. particlesEnabled: boolean;
  36176. /**
  36177. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36178. */
  36179. spritesEnabled: boolean;
  36180. private _skeletonsEnabled;
  36181. /**
  36182. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36183. */
  36184. set skeletonsEnabled(value: boolean);
  36185. get skeletonsEnabled(): boolean;
  36186. /**
  36187. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36188. */
  36189. lensFlaresEnabled: boolean;
  36190. /**
  36191. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36192. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36193. */
  36194. collisionsEnabled: boolean;
  36195. private _collisionCoordinator;
  36196. /** @hidden */
  36197. get collisionCoordinator(): ICollisionCoordinator;
  36198. /**
  36199. * Defines the gravity applied to this scene (used only for collisions)
  36200. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36201. */
  36202. gravity: Vector3;
  36203. /**
  36204. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36205. */
  36206. postProcessesEnabled: boolean;
  36207. /**
  36208. * The list of postprocesses added to the scene
  36209. */
  36210. postProcesses: PostProcess[];
  36211. /**
  36212. * Gets the current postprocess manager
  36213. */
  36214. postProcessManager: PostProcessManager;
  36215. /**
  36216. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36217. */
  36218. renderTargetsEnabled: boolean;
  36219. /**
  36220. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36221. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36222. */
  36223. dumpNextRenderTargets: boolean;
  36224. /**
  36225. * The list of user defined render targets added to the scene
  36226. */
  36227. customRenderTargets: RenderTargetTexture[];
  36228. /**
  36229. * Defines if texture loading must be delayed
  36230. * If true, textures will only be loaded when they need to be rendered
  36231. */
  36232. useDelayedTextureLoading: boolean;
  36233. /**
  36234. * Gets the list of meshes imported to the scene through SceneLoader
  36235. */
  36236. importedMeshesFiles: String[];
  36237. /**
  36238. * Gets or sets a boolean indicating if probes are enabled on this scene
  36239. */
  36240. probesEnabled: boolean;
  36241. /**
  36242. * Gets or sets the current offline provider to use to store scene data
  36243. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36244. */
  36245. offlineProvider: IOfflineProvider;
  36246. /**
  36247. * Gets or sets the action manager associated with the scene
  36248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36249. */
  36250. actionManager: AbstractActionManager;
  36251. private _meshesForIntersections;
  36252. /**
  36253. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36254. */
  36255. proceduralTexturesEnabled: boolean;
  36256. private _engine;
  36257. private _totalVertices;
  36258. /** @hidden */
  36259. _activeIndices: PerfCounter;
  36260. /** @hidden */
  36261. _activeParticles: PerfCounter;
  36262. /** @hidden */
  36263. _activeBones: PerfCounter;
  36264. private _animationRatio;
  36265. /** @hidden */
  36266. _animationTimeLast: number;
  36267. /** @hidden */
  36268. _animationTime: number;
  36269. /**
  36270. * Gets or sets a general scale for animation speed
  36271. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36272. */
  36273. animationTimeScale: number;
  36274. /** @hidden */
  36275. _cachedMaterial: Nullable<Material>;
  36276. /** @hidden */
  36277. _cachedEffect: Nullable<Effect>;
  36278. /** @hidden */
  36279. _cachedVisibility: Nullable<number>;
  36280. private _renderId;
  36281. private _frameId;
  36282. private _executeWhenReadyTimeoutId;
  36283. private _intermediateRendering;
  36284. private _viewUpdateFlag;
  36285. private _projectionUpdateFlag;
  36286. /** @hidden */
  36287. _toBeDisposed: Nullable<IDisposable>[];
  36288. private _activeRequests;
  36289. /** @hidden */
  36290. _pendingData: any[];
  36291. private _isDisposed;
  36292. /**
  36293. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36294. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36295. */
  36296. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36297. private _activeMeshes;
  36298. private _processedMaterials;
  36299. private _renderTargets;
  36300. /** @hidden */
  36301. _activeParticleSystems: SmartArray<IParticleSystem>;
  36302. private _activeSkeletons;
  36303. private _softwareSkinnedMeshes;
  36304. private _renderingManager;
  36305. /** @hidden */
  36306. _activeAnimatables: Animatable[];
  36307. private _transformMatrix;
  36308. private _sceneUbo;
  36309. /** @hidden */
  36310. _viewMatrix: Matrix;
  36311. private _projectionMatrix;
  36312. /** @hidden */
  36313. _forcedViewPosition: Nullable<Vector3>;
  36314. /** @hidden */
  36315. _frustumPlanes: Plane[];
  36316. /**
  36317. * Gets the list of frustum planes (built from the active camera)
  36318. */
  36319. get frustumPlanes(): Plane[];
  36320. /**
  36321. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36322. * This is useful if there are more lights that the maximum simulteanous authorized
  36323. */
  36324. requireLightSorting: boolean;
  36325. /** @hidden */
  36326. readonly useMaterialMeshMap: boolean;
  36327. /** @hidden */
  36328. readonly useClonedMeshMap: boolean;
  36329. private _externalData;
  36330. private _uid;
  36331. /**
  36332. * @hidden
  36333. * Backing store of defined scene components.
  36334. */
  36335. _components: ISceneComponent[];
  36336. /**
  36337. * @hidden
  36338. * Backing store of defined scene components.
  36339. */
  36340. _serializableComponents: ISceneSerializableComponent[];
  36341. /**
  36342. * List of components to register on the next registration step.
  36343. */
  36344. private _transientComponents;
  36345. /**
  36346. * Registers the transient components if needed.
  36347. */
  36348. private _registerTransientComponents;
  36349. /**
  36350. * @hidden
  36351. * Add a component to the scene.
  36352. * Note that the ccomponent could be registered on th next frame if this is called after
  36353. * the register component stage.
  36354. * @param component Defines the component to add to the scene
  36355. */
  36356. _addComponent(component: ISceneComponent): void;
  36357. /**
  36358. * @hidden
  36359. * Gets a component from the scene.
  36360. * @param name defines the name of the component to retrieve
  36361. * @returns the component or null if not present
  36362. */
  36363. _getComponent(name: string): Nullable<ISceneComponent>;
  36364. /**
  36365. * @hidden
  36366. * Defines the actions happening before camera updates.
  36367. */
  36368. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36369. /**
  36370. * @hidden
  36371. * Defines the actions happening before clear the canvas.
  36372. */
  36373. _beforeClearStage: Stage<SimpleStageAction>;
  36374. /**
  36375. * @hidden
  36376. * Defines the actions when collecting render targets for the frame.
  36377. */
  36378. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36379. /**
  36380. * @hidden
  36381. * Defines the actions happening for one camera in the frame.
  36382. */
  36383. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36384. /**
  36385. * @hidden
  36386. * Defines the actions happening during the per mesh ready checks.
  36387. */
  36388. _isReadyForMeshStage: Stage<MeshStageAction>;
  36389. /**
  36390. * @hidden
  36391. * Defines the actions happening before evaluate active mesh checks.
  36392. */
  36393. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36394. /**
  36395. * @hidden
  36396. * Defines the actions happening during the evaluate sub mesh checks.
  36397. */
  36398. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36399. /**
  36400. * @hidden
  36401. * Defines the actions happening during the active mesh stage.
  36402. */
  36403. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36404. /**
  36405. * @hidden
  36406. * Defines the actions happening during the per camera render target step.
  36407. */
  36408. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36409. /**
  36410. * @hidden
  36411. * Defines the actions happening just before the active camera is drawing.
  36412. */
  36413. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36414. /**
  36415. * @hidden
  36416. * Defines the actions happening just before a render target is drawing.
  36417. */
  36418. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36419. /**
  36420. * @hidden
  36421. * Defines the actions happening just before a rendering group is drawing.
  36422. */
  36423. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36424. /**
  36425. * @hidden
  36426. * Defines the actions happening just before a mesh is drawing.
  36427. */
  36428. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36429. /**
  36430. * @hidden
  36431. * Defines the actions happening just after a mesh has been drawn.
  36432. */
  36433. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36434. /**
  36435. * @hidden
  36436. * Defines the actions happening just after a rendering group has been drawn.
  36437. */
  36438. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36439. /**
  36440. * @hidden
  36441. * Defines the actions happening just after the active camera has been drawn.
  36442. */
  36443. _afterCameraDrawStage: Stage<CameraStageAction>;
  36444. /**
  36445. * @hidden
  36446. * Defines the actions happening just after a render target has been drawn.
  36447. */
  36448. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36449. /**
  36450. * @hidden
  36451. * Defines the actions happening just after rendering all cameras and computing intersections.
  36452. */
  36453. _afterRenderStage: Stage<SimpleStageAction>;
  36454. /**
  36455. * @hidden
  36456. * Defines the actions happening when a pointer move event happens.
  36457. */
  36458. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36459. /**
  36460. * @hidden
  36461. * Defines the actions happening when a pointer down event happens.
  36462. */
  36463. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36464. /**
  36465. * @hidden
  36466. * Defines the actions happening when a pointer up event happens.
  36467. */
  36468. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36469. /**
  36470. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36471. */
  36472. private geometriesByUniqueId;
  36473. /**
  36474. * Creates a new Scene
  36475. * @param engine defines the engine to use to render this scene
  36476. * @param options defines the scene options
  36477. */
  36478. constructor(engine: Engine, options?: SceneOptions);
  36479. /**
  36480. * Gets a string idenfifying the name of the class
  36481. * @returns "Scene" string
  36482. */
  36483. getClassName(): string;
  36484. private _defaultMeshCandidates;
  36485. /**
  36486. * @hidden
  36487. */
  36488. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36489. private _defaultSubMeshCandidates;
  36490. /**
  36491. * @hidden
  36492. */
  36493. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36494. /**
  36495. * Sets the default candidate providers for the scene.
  36496. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36497. * and getCollidingSubMeshCandidates to their default function
  36498. */
  36499. setDefaultCandidateProviders(): void;
  36500. /**
  36501. * Gets the mesh that is currently under the pointer
  36502. */
  36503. get meshUnderPointer(): Nullable<AbstractMesh>;
  36504. /**
  36505. * Gets or sets the current on-screen X position of the pointer
  36506. */
  36507. get pointerX(): number;
  36508. set pointerX(value: number);
  36509. /**
  36510. * Gets or sets the current on-screen Y position of the pointer
  36511. */
  36512. get pointerY(): number;
  36513. set pointerY(value: number);
  36514. /**
  36515. * Gets the cached material (ie. the latest rendered one)
  36516. * @returns the cached material
  36517. */
  36518. getCachedMaterial(): Nullable<Material>;
  36519. /**
  36520. * Gets the cached effect (ie. the latest rendered one)
  36521. * @returns the cached effect
  36522. */
  36523. getCachedEffect(): Nullable<Effect>;
  36524. /**
  36525. * Gets the cached visibility state (ie. the latest rendered one)
  36526. * @returns the cached visibility state
  36527. */
  36528. getCachedVisibility(): Nullable<number>;
  36529. /**
  36530. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36531. * @param material defines the current material
  36532. * @param effect defines the current effect
  36533. * @param visibility defines the current visibility state
  36534. * @returns true if one parameter is not cached
  36535. */
  36536. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36537. /**
  36538. * Gets the engine associated with the scene
  36539. * @returns an Engine
  36540. */
  36541. getEngine(): Engine;
  36542. /**
  36543. * Gets the total number of vertices rendered per frame
  36544. * @returns the total number of vertices rendered per frame
  36545. */
  36546. getTotalVertices(): number;
  36547. /**
  36548. * Gets the performance counter for total vertices
  36549. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36550. */
  36551. get totalVerticesPerfCounter(): PerfCounter;
  36552. /**
  36553. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36554. * @returns the total number of active indices rendered per frame
  36555. */
  36556. getActiveIndices(): number;
  36557. /**
  36558. * Gets the performance counter for active indices
  36559. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36560. */
  36561. get totalActiveIndicesPerfCounter(): PerfCounter;
  36562. /**
  36563. * Gets the total number of active particles rendered per frame
  36564. * @returns the total number of active particles rendered per frame
  36565. */
  36566. getActiveParticles(): number;
  36567. /**
  36568. * Gets the performance counter for active particles
  36569. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36570. */
  36571. get activeParticlesPerfCounter(): PerfCounter;
  36572. /**
  36573. * Gets the total number of active bones rendered per frame
  36574. * @returns the total number of active bones rendered per frame
  36575. */
  36576. getActiveBones(): number;
  36577. /**
  36578. * Gets the performance counter for active bones
  36579. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36580. */
  36581. get activeBonesPerfCounter(): PerfCounter;
  36582. /**
  36583. * Gets the array of active meshes
  36584. * @returns an array of AbstractMesh
  36585. */
  36586. getActiveMeshes(): SmartArray<AbstractMesh>;
  36587. /**
  36588. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36589. * @returns a number
  36590. */
  36591. getAnimationRatio(): number;
  36592. /**
  36593. * Gets an unique Id for the current render phase
  36594. * @returns a number
  36595. */
  36596. getRenderId(): number;
  36597. /**
  36598. * Gets an unique Id for the current frame
  36599. * @returns a number
  36600. */
  36601. getFrameId(): number;
  36602. /** Call this function if you want to manually increment the render Id*/
  36603. incrementRenderId(): void;
  36604. private _createUbo;
  36605. /**
  36606. * Use this method to simulate a pointer move on a mesh
  36607. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36608. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36609. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36610. * @returns the current scene
  36611. */
  36612. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36613. /**
  36614. * Use this method to simulate a pointer down on a mesh
  36615. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36616. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36617. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36618. * @returns the current scene
  36619. */
  36620. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36621. /**
  36622. * Use this method to simulate a pointer up on a mesh
  36623. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36624. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36625. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36626. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36627. * @returns the current scene
  36628. */
  36629. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36630. /**
  36631. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36632. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36633. * @returns true if the pointer was captured
  36634. */
  36635. isPointerCaptured(pointerId?: number): boolean;
  36636. /**
  36637. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36638. * @param attachUp defines if you want to attach events to pointerup
  36639. * @param attachDown defines if you want to attach events to pointerdown
  36640. * @param attachMove defines if you want to attach events to pointermove
  36641. */
  36642. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36643. /** Detaches all event handlers*/
  36644. detachControl(): void;
  36645. /**
  36646. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36647. * Delay loaded resources are not taking in account
  36648. * @return true if all required resources are ready
  36649. */
  36650. isReady(): boolean;
  36651. /** Resets all cached information relative to material (including effect and visibility) */
  36652. resetCachedMaterial(): void;
  36653. /**
  36654. * Registers a function to be called before every frame render
  36655. * @param func defines the function to register
  36656. */
  36657. registerBeforeRender(func: () => void): void;
  36658. /**
  36659. * Unregisters a function called before every frame render
  36660. * @param func defines the function to unregister
  36661. */
  36662. unregisterBeforeRender(func: () => void): void;
  36663. /**
  36664. * Registers a function to be called after every frame render
  36665. * @param func defines the function to register
  36666. */
  36667. registerAfterRender(func: () => void): void;
  36668. /**
  36669. * Unregisters a function called after every frame render
  36670. * @param func defines the function to unregister
  36671. */
  36672. unregisterAfterRender(func: () => void): void;
  36673. private _executeOnceBeforeRender;
  36674. /**
  36675. * The provided function will run before render once and will be disposed afterwards.
  36676. * A timeout delay can be provided so that the function will be executed in N ms.
  36677. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36678. * @param func The function to be executed.
  36679. * @param timeout optional delay in ms
  36680. */
  36681. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36682. /** @hidden */
  36683. _addPendingData(data: any): void;
  36684. /** @hidden */
  36685. _removePendingData(data: any): void;
  36686. /**
  36687. * Returns the number of items waiting to be loaded
  36688. * @returns the number of items waiting to be loaded
  36689. */
  36690. getWaitingItemsCount(): number;
  36691. /**
  36692. * Returns a boolean indicating if the scene is still loading data
  36693. */
  36694. get isLoading(): boolean;
  36695. /**
  36696. * Registers a function to be executed when the scene is ready
  36697. * @param {Function} func - the function to be executed
  36698. */
  36699. executeWhenReady(func: () => void): void;
  36700. /**
  36701. * Returns a promise that resolves when the scene is ready
  36702. * @returns A promise that resolves when the scene is ready
  36703. */
  36704. whenReadyAsync(): Promise<void>;
  36705. /** @hidden */
  36706. _checkIsReady(): void;
  36707. /**
  36708. * Gets all animatable attached to the scene
  36709. */
  36710. get animatables(): Animatable[];
  36711. /**
  36712. * Resets the last animation time frame.
  36713. * Useful to override when animations start running when loading a scene for the first time.
  36714. */
  36715. resetLastAnimationTimeFrame(): void;
  36716. /**
  36717. * Gets the current view matrix
  36718. * @returns a Matrix
  36719. */
  36720. getViewMatrix(): Matrix;
  36721. /**
  36722. * Gets the current projection matrix
  36723. * @returns a Matrix
  36724. */
  36725. getProjectionMatrix(): Matrix;
  36726. /**
  36727. * Gets the current transform matrix
  36728. * @returns a Matrix made of View * Projection
  36729. */
  36730. getTransformMatrix(): Matrix;
  36731. /**
  36732. * Sets the current transform matrix
  36733. * @param viewL defines the View matrix to use
  36734. * @param projectionL defines the Projection matrix to use
  36735. * @param viewR defines the right View matrix to use (if provided)
  36736. * @param projectionR defines the right Projection matrix to use (if provided)
  36737. */
  36738. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36739. /**
  36740. * Gets the uniform buffer used to store scene data
  36741. * @returns a UniformBuffer
  36742. */
  36743. getSceneUniformBuffer(): UniformBuffer;
  36744. /**
  36745. * Gets an unique (relatively to the current scene) Id
  36746. * @returns an unique number for the scene
  36747. */
  36748. getUniqueId(): number;
  36749. /**
  36750. * Add a mesh to the list of scene's meshes
  36751. * @param newMesh defines the mesh to add
  36752. * @param recursive if all child meshes should also be added to the scene
  36753. */
  36754. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36755. /**
  36756. * Remove a mesh for the list of scene's meshes
  36757. * @param toRemove defines the mesh to remove
  36758. * @param recursive if all child meshes should also be removed from the scene
  36759. * @returns the index where the mesh was in the mesh list
  36760. */
  36761. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36762. /**
  36763. * Add a transform node to the list of scene's transform nodes
  36764. * @param newTransformNode defines the transform node to add
  36765. */
  36766. addTransformNode(newTransformNode: TransformNode): void;
  36767. /**
  36768. * Remove a transform node for the list of scene's transform nodes
  36769. * @param toRemove defines the transform node to remove
  36770. * @returns the index where the transform node was in the transform node list
  36771. */
  36772. removeTransformNode(toRemove: TransformNode): number;
  36773. /**
  36774. * Remove a skeleton for the list of scene's skeletons
  36775. * @param toRemove defines the skeleton to remove
  36776. * @returns the index where the skeleton was in the skeleton list
  36777. */
  36778. removeSkeleton(toRemove: Skeleton): number;
  36779. /**
  36780. * Remove a morph target for the list of scene's morph targets
  36781. * @param toRemove defines the morph target to remove
  36782. * @returns the index where the morph target was in the morph target list
  36783. */
  36784. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36785. /**
  36786. * Remove a light for the list of scene's lights
  36787. * @param toRemove defines the light to remove
  36788. * @returns the index where the light was in the light list
  36789. */
  36790. removeLight(toRemove: Light): number;
  36791. /**
  36792. * Remove a camera for the list of scene's cameras
  36793. * @param toRemove defines the camera to remove
  36794. * @returns the index where the camera was in the camera list
  36795. */
  36796. removeCamera(toRemove: Camera): number;
  36797. /**
  36798. * Remove a particle system for the list of scene's particle systems
  36799. * @param toRemove defines the particle system to remove
  36800. * @returns the index where the particle system was in the particle system list
  36801. */
  36802. removeParticleSystem(toRemove: IParticleSystem): number;
  36803. /**
  36804. * Remove a animation for the list of scene's animations
  36805. * @param toRemove defines the animation to remove
  36806. * @returns the index where the animation was in the animation list
  36807. */
  36808. removeAnimation(toRemove: Animation): number;
  36809. /**
  36810. * Will stop the animation of the given target
  36811. * @param target - the target
  36812. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36813. * @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)
  36814. */
  36815. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36816. /**
  36817. * Removes the given animation group from this scene.
  36818. * @param toRemove The animation group to remove
  36819. * @returns The index of the removed animation group
  36820. */
  36821. removeAnimationGroup(toRemove: AnimationGroup): number;
  36822. /**
  36823. * Removes the given multi-material from this scene.
  36824. * @param toRemove The multi-material to remove
  36825. * @returns The index of the removed multi-material
  36826. */
  36827. removeMultiMaterial(toRemove: MultiMaterial): number;
  36828. /**
  36829. * Removes the given material from this scene.
  36830. * @param toRemove The material to remove
  36831. * @returns The index of the removed material
  36832. */
  36833. removeMaterial(toRemove: Material): number;
  36834. /**
  36835. * Removes the given action manager from this scene.
  36836. * @param toRemove The action manager to remove
  36837. * @returns The index of the removed action manager
  36838. */
  36839. removeActionManager(toRemove: AbstractActionManager): number;
  36840. /**
  36841. * Removes the given texture from this scene.
  36842. * @param toRemove The texture to remove
  36843. * @returns The index of the removed texture
  36844. */
  36845. removeTexture(toRemove: BaseTexture): number;
  36846. /**
  36847. * Adds the given light to this scene
  36848. * @param newLight The light to add
  36849. */
  36850. addLight(newLight: Light): void;
  36851. /**
  36852. * Sorts the list list based on light priorities
  36853. */
  36854. sortLightsByPriority(): void;
  36855. /**
  36856. * Adds the given camera to this scene
  36857. * @param newCamera The camera to add
  36858. */
  36859. addCamera(newCamera: Camera): void;
  36860. /**
  36861. * Adds the given skeleton to this scene
  36862. * @param newSkeleton The skeleton to add
  36863. */
  36864. addSkeleton(newSkeleton: Skeleton): void;
  36865. /**
  36866. * Adds the given particle system to this scene
  36867. * @param newParticleSystem The particle system to add
  36868. */
  36869. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36870. /**
  36871. * Adds the given animation to this scene
  36872. * @param newAnimation The animation to add
  36873. */
  36874. addAnimation(newAnimation: Animation): void;
  36875. /**
  36876. * Adds the given animation group to this scene.
  36877. * @param newAnimationGroup The animation group to add
  36878. */
  36879. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36880. /**
  36881. * Adds the given multi-material to this scene
  36882. * @param newMultiMaterial The multi-material to add
  36883. */
  36884. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36885. /**
  36886. * Adds the given material to this scene
  36887. * @param newMaterial The material to add
  36888. */
  36889. addMaterial(newMaterial: Material): void;
  36890. /**
  36891. * Adds the given morph target to this scene
  36892. * @param newMorphTargetManager The morph target to add
  36893. */
  36894. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36895. /**
  36896. * Adds the given geometry to this scene
  36897. * @param newGeometry The geometry to add
  36898. */
  36899. addGeometry(newGeometry: Geometry): void;
  36900. /**
  36901. * Adds the given action manager to this scene
  36902. * @param newActionManager The action manager to add
  36903. */
  36904. addActionManager(newActionManager: AbstractActionManager): void;
  36905. /**
  36906. * Adds the given texture to this scene.
  36907. * @param newTexture The texture to add
  36908. */
  36909. addTexture(newTexture: BaseTexture): void;
  36910. /**
  36911. * Switch active camera
  36912. * @param newCamera defines the new active camera
  36913. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36914. */
  36915. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36916. /**
  36917. * sets the active camera of the scene using its ID
  36918. * @param id defines the camera's ID
  36919. * @return the new active camera or null if none found.
  36920. */
  36921. setActiveCameraByID(id: string): Nullable<Camera>;
  36922. /**
  36923. * sets the active camera of the scene using its name
  36924. * @param name defines the camera's name
  36925. * @returns the new active camera or null if none found.
  36926. */
  36927. setActiveCameraByName(name: string): Nullable<Camera>;
  36928. /**
  36929. * get an animation group using its name
  36930. * @param name defines the material's name
  36931. * @return the animation group or null if none found.
  36932. */
  36933. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36934. /**
  36935. * Get a material using its unique id
  36936. * @param uniqueId defines the material's unique id
  36937. * @return the material or null if none found.
  36938. */
  36939. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36940. /**
  36941. * get a material using its id
  36942. * @param id defines the material's ID
  36943. * @return the material or null if none found.
  36944. */
  36945. getMaterialByID(id: string): Nullable<Material>;
  36946. /**
  36947. * Gets a the last added material using a given id
  36948. * @param id defines the material's ID
  36949. * @return the last material with the given id or null if none found.
  36950. */
  36951. getLastMaterialByID(id: string): Nullable<Material>;
  36952. /**
  36953. * Gets a material using its name
  36954. * @param name defines the material's name
  36955. * @return the material or null if none found.
  36956. */
  36957. getMaterialByName(name: string): Nullable<Material>;
  36958. /**
  36959. * Get a texture using its unique id
  36960. * @param uniqueId defines the texture's unique id
  36961. * @return the texture or null if none found.
  36962. */
  36963. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36964. /**
  36965. * Gets a camera using its id
  36966. * @param id defines the id to look for
  36967. * @returns the camera or null if not found
  36968. */
  36969. getCameraByID(id: string): Nullable<Camera>;
  36970. /**
  36971. * Gets a camera using its unique id
  36972. * @param uniqueId defines the unique id to look for
  36973. * @returns the camera or null if not found
  36974. */
  36975. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36976. /**
  36977. * Gets a camera using its name
  36978. * @param name defines the camera's name
  36979. * @return the camera or null if none found.
  36980. */
  36981. getCameraByName(name: string): Nullable<Camera>;
  36982. /**
  36983. * Gets a bone using its id
  36984. * @param id defines the bone's id
  36985. * @return the bone or null if not found
  36986. */
  36987. getBoneByID(id: string): Nullable<Bone>;
  36988. /**
  36989. * Gets a bone using its id
  36990. * @param name defines the bone's name
  36991. * @return the bone or null if not found
  36992. */
  36993. getBoneByName(name: string): Nullable<Bone>;
  36994. /**
  36995. * Gets a light node using its name
  36996. * @param name defines the the light's name
  36997. * @return the light or null if none found.
  36998. */
  36999. getLightByName(name: string): Nullable<Light>;
  37000. /**
  37001. * Gets a light node using its id
  37002. * @param id defines the light's id
  37003. * @return the light or null if none found.
  37004. */
  37005. getLightByID(id: string): Nullable<Light>;
  37006. /**
  37007. * Gets a light node using its scene-generated unique ID
  37008. * @param uniqueId defines the light's unique id
  37009. * @return the light or null if none found.
  37010. */
  37011. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37012. /**
  37013. * Gets a particle system by id
  37014. * @param id defines the particle system id
  37015. * @return the corresponding system or null if none found
  37016. */
  37017. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37018. /**
  37019. * Gets a geometry using its ID
  37020. * @param id defines the geometry's id
  37021. * @return the geometry or null if none found.
  37022. */
  37023. getGeometryByID(id: string): Nullable<Geometry>;
  37024. private _getGeometryByUniqueID;
  37025. /**
  37026. * Add a new geometry to this scene
  37027. * @param geometry defines the geometry to be added to the scene.
  37028. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37029. * @return a boolean defining if the geometry was added or not
  37030. */
  37031. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37032. /**
  37033. * Removes an existing geometry
  37034. * @param geometry defines the geometry to be removed from the scene
  37035. * @return a boolean defining if the geometry was removed or not
  37036. */
  37037. removeGeometry(geometry: Geometry): boolean;
  37038. /**
  37039. * Gets the list of geometries attached to the scene
  37040. * @returns an array of Geometry
  37041. */
  37042. getGeometries(): Geometry[];
  37043. /**
  37044. * Gets the first added mesh found of a given ID
  37045. * @param id defines the id to search for
  37046. * @return the mesh found or null if not found at all
  37047. */
  37048. getMeshByID(id: string): Nullable<AbstractMesh>;
  37049. /**
  37050. * Gets a list of meshes using their id
  37051. * @param id defines the id to search for
  37052. * @returns a list of meshes
  37053. */
  37054. getMeshesByID(id: string): Array<AbstractMesh>;
  37055. /**
  37056. * Gets the first added transform node found of a given ID
  37057. * @param id defines the id to search for
  37058. * @return the found transform node or null if not found at all.
  37059. */
  37060. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37061. /**
  37062. * Gets a transform node with its auto-generated unique id
  37063. * @param uniqueId efines the unique id to search for
  37064. * @return the found transform node or null if not found at all.
  37065. */
  37066. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37067. /**
  37068. * Gets a list of transform nodes using their id
  37069. * @param id defines the id to search for
  37070. * @returns a list of transform nodes
  37071. */
  37072. getTransformNodesByID(id: string): Array<TransformNode>;
  37073. /**
  37074. * Gets a mesh with its auto-generated unique id
  37075. * @param uniqueId defines the unique id to search for
  37076. * @return the found mesh or null if not found at all.
  37077. */
  37078. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37079. /**
  37080. * Gets a the last added mesh using a given id
  37081. * @param id defines the id to search for
  37082. * @return the found mesh or null if not found at all.
  37083. */
  37084. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37085. /**
  37086. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37087. * @param id defines the id to search for
  37088. * @return the found node or null if not found at all
  37089. */
  37090. getLastEntryByID(id: string): Nullable<Node>;
  37091. /**
  37092. * Gets a node (Mesh, Camera, Light) using a given id
  37093. * @param id defines the id to search for
  37094. * @return the found node or null if not found at all
  37095. */
  37096. getNodeByID(id: string): Nullable<Node>;
  37097. /**
  37098. * Gets a node (Mesh, Camera, Light) using a given name
  37099. * @param name defines the name to search for
  37100. * @return the found node or null if not found at all.
  37101. */
  37102. getNodeByName(name: string): Nullable<Node>;
  37103. /**
  37104. * Gets a mesh using a given name
  37105. * @param name defines the name to search for
  37106. * @return the found mesh or null if not found at all.
  37107. */
  37108. getMeshByName(name: string): Nullable<AbstractMesh>;
  37109. /**
  37110. * Gets a transform node using a given name
  37111. * @param name defines the name to search for
  37112. * @return the found transform node or null if not found at all.
  37113. */
  37114. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37115. /**
  37116. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37117. * @param id defines the id to search for
  37118. * @return the found skeleton or null if not found at all.
  37119. */
  37120. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37121. /**
  37122. * Gets a skeleton using a given auto generated unique id
  37123. * @param uniqueId defines the unique id to search for
  37124. * @return the found skeleton or null if not found at all.
  37125. */
  37126. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37127. /**
  37128. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37129. * @param id defines the id to search for
  37130. * @return the found skeleton or null if not found at all.
  37131. */
  37132. getSkeletonById(id: string): Nullable<Skeleton>;
  37133. /**
  37134. * Gets a skeleton using a given name
  37135. * @param name defines the name to search for
  37136. * @return the found skeleton or null if not found at all.
  37137. */
  37138. getSkeletonByName(name: string): Nullable<Skeleton>;
  37139. /**
  37140. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37141. * @param id defines the id to search for
  37142. * @return the found morph target manager or null if not found at all.
  37143. */
  37144. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37145. /**
  37146. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37147. * @param id defines the id to search for
  37148. * @return the found morph target or null if not found at all.
  37149. */
  37150. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37151. /**
  37152. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37153. * @param name defines the name to search for
  37154. * @return the found morph target or null if not found at all.
  37155. */
  37156. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37157. /**
  37158. * Gets a boolean indicating if the given mesh is active
  37159. * @param mesh defines the mesh to look for
  37160. * @returns true if the mesh is in the active list
  37161. */
  37162. isActiveMesh(mesh: AbstractMesh): boolean;
  37163. /**
  37164. * Return a unique id as a string which can serve as an identifier for the scene
  37165. */
  37166. get uid(): string;
  37167. /**
  37168. * Add an externaly attached data from its key.
  37169. * This method call will fail and return false, if such key already exists.
  37170. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37171. * @param key the unique key that identifies the data
  37172. * @param data the data object to associate to the key for this Engine instance
  37173. * @return true if no such key were already present and the data was added successfully, false otherwise
  37174. */
  37175. addExternalData<T>(key: string, data: T): boolean;
  37176. /**
  37177. * Get an externaly attached data from its key
  37178. * @param key the unique key that identifies the data
  37179. * @return the associated data, if present (can be null), or undefined if not present
  37180. */
  37181. getExternalData<T>(key: string): Nullable<T>;
  37182. /**
  37183. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37184. * @param key the unique key that identifies the data
  37185. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37186. * @return the associated data, can be null if the factory returned null.
  37187. */
  37188. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37189. /**
  37190. * Remove an externaly attached data from the Engine instance
  37191. * @param key the unique key that identifies the data
  37192. * @return true if the data was successfully removed, false if it doesn't exist
  37193. */
  37194. removeExternalData(key: string): boolean;
  37195. private _evaluateSubMesh;
  37196. /**
  37197. * Clear the processed materials smart array preventing retention point in material dispose.
  37198. */
  37199. freeProcessedMaterials(): void;
  37200. private _preventFreeActiveMeshesAndRenderingGroups;
  37201. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37202. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37203. * when disposing several meshes in a row or a hierarchy of meshes.
  37204. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37205. */
  37206. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37207. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37208. /**
  37209. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37210. */
  37211. freeActiveMeshes(): void;
  37212. /**
  37213. * Clear the info related to rendering groups preventing retention points during dispose.
  37214. */
  37215. freeRenderingGroups(): void;
  37216. /** @hidden */
  37217. _isInIntermediateRendering(): boolean;
  37218. /**
  37219. * Lambda returning the list of potentially active meshes.
  37220. */
  37221. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37222. /**
  37223. * Lambda returning the list of potentially active sub meshes.
  37224. */
  37225. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37226. /**
  37227. * Lambda returning the list of potentially intersecting sub meshes.
  37228. */
  37229. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37230. /**
  37231. * Lambda returning the list of potentially colliding sub meshes.
  37232. */
  37233. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37234. private _activeMeshesFrozen;
  37235. private _skipEvaluateActiveMeshesCompletely;
  37236. /**
  37237. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37238. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37239. * @returns the current scene
  37240. */
  37241. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37242. /**
  37243. * Use this function to restart evaluating active meshes on every frame
  37244. * @returns the current scene
  37245. */
  37246. unfreezeActiveMeshes(): Scene;
  37247. private _evaluateActiveMeshes;
  37248. private _activeMesh;
  37249. /**
  37250. * Update the transform matrix to update from the current active camera
  37251. * @param force defines a boolean used to force the update even if cache is up to date
  37252. */
  37253. updateTransformMatrix(force?: boolean): void;
  37254. private _bindFrameBuffer;
  37255. /** @hidden */
  37256. _allowPostProcessClearColor: boolean;
  37257. /** @hidden */
  37258. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37259. private _processSubCameras;
  37260. private _checkIntersections;
  37261. /** @hidden */
  37262. _advancePhysicsEngineStep(step: number): void;
  37263. /**
  37264. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37265. */
  37266. getDeterministicFrameTime: () => number;
  37267. /** @hidden */
  37268. _animate(): void;
  37269. /** Execute all animations (for a frame) */
  37270. animate(): void;
  37271. /**
  37272. * Render the scene
  37273. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37274. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37275. */
  37276. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37277. /**
  37278. * Freeze all materials
  37279. * A frozen material will not be updatable but should be faster to render
  37280. */
  37281. freezeMaterials(): void;
  37282. /**
  37283. * Unfreeze all materials
  37284. * A frozen material will not be updatable but should be faster to render
  37285. */
  37286. unfreezeMaterials(): void;
  37287. /**
  37288. * Releases all held ressources
  37289. */
  37290. dispose(): void;
  37291. /**
  37292. * Gets if the scene is already disposed
  37293. */
  37294. get isDisposed(): boolean;
  37295. /**
  37296. * Call this function to reduce memory footprint of the scene.
  37297. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37298. */
  37299. clearCachedVertexData(): void;
  37300. /**
  37301. * This function will remove the local cached buffer data from texture.
  37302. * It will save memory but will prevent the texture from being rebuilt
  37303. */
  37304. cleanCachedTextureBuffer(): void;
  37305. /**
  37306. * Get the world extend vectors with an optional filter
  37307. *
  37308. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37309. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37310. */
  37311. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37312. min: Vector3;
  37313. max: Vector3;
  37314. };
  37315. /**
  37316. * Creates a ray that can be used to pick in the scene
  37317. * @param x defines the x coordinate of the origin (on-screen)
  37318. * @param y defines the y coordinate of the origin (on-screen)
  37319. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37320. * @param camera defines the camera to use for the picking
  37321. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37322. * @returns a Ray
  37323. */
  37324. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37325. /**
  37326. * Creates a ray that can be used to pick in the scene
  37327. * @param x defines the x coordinate of the origin (on-screen)
  37328. * @param y defines the y coordinate of the origin (on-screen)
  37329. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37330. * @param result defines the ray where to store the picking ray
  37331. * @param camera defines the camera to use for the picking
  37332. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37333. * @returns the current scene
  37334. */
  37335. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37336. /**
  37337. * Creates a ray that can be used to pick in the scene
  37338. * @param x defines the x coordinate of the origin (on-screen)
  37339. * @param y defines the y coordinate of the origin (on-screen)
  37340. * @param camera defines the camera to use for the picking
  37341. * @returns a Ray
  37342. */
  37343. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37344. /**
  37345. * Creates a ray that can be used to pick in the scene
  37346. * @param x defines the x coordinate of the origin (on-screen)
  37347. * @param y defines the y coordinate of the origin (on-screen)
  37348. * @param result defines the ray where to store the picking ray
  37349. * @param camera defines the camera to use for the picking
  37350. * @returns the current scene
  37351. */
  37352. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37353. /** Launch a ray to try to pick a mesh in the scene
  37354. * @param x position on screen
  37355. * @param y position on screen
  37356. * @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
  37357. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37358. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37359. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37360. * @returns a PickingInfo
  37361. */
  37362. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37363. /** Use the given ray to pick a mesh in the scene
  37364. * @param ray The ray to use to pick meshes
  37365. * @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
  37366. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37367. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37368. * @returns a PickingInfo
  37369. */
  37370. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37371. /**
  37372. * Launch a ray to try to pick a mesh in the scene
  37373. * @param x X position on screen
  37374. * @param y Y position on screen
  37375. * @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
  37376. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37377. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37378. * @returns an array of PickingInfo
  37379. */
  37380. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37381. /**
  37382. * Launch a ray to try to pick a mesh in the scene
  37383. * @param ray Ray to use
  37384. * @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
  37385. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37386. * @returns an array of PickingInfo
  37387. */
  37388. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37389. /**
  37390. * Force the value of meshUnderPointer
  37391. * @param mesh defines the mesh to use
  37392. */
  37393. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37394. /**
  37395. * Gets the mesh under the pointer
  37396. * @returns a Mesh or null if no mesh is under the pointer
  37397. */
  37398. getPointerOverMesh(): Nullable<AbstractMesh>;
  37399. /** @hidden */
  37400. _rebuildGeometries(): void;
  37401. /** @hidden */
  37402. _rebuildTextures(): void;
  37403. private _getByTags;
  37404. /**
  37405. * Get a list of meshes by tags
  37406. * @param tagsQuery defines the tags query to use
  37407. * @param forEach defines a predicate used to filter results
  37408. * @returns an array of Mesh
  37409. */
  37410. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37411. /**
  37412. * Get a list of cameras by tags
  37413. * @param tagsQuery defines the tags query to use
  37414. * @param forEach defines a predicate used to filter results
  37415. * @returns an array of Camera
  37416. */
  37417. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37418. /**
  37419. * Get a list of lights by tags
  37420. * @param tagsQuery defines the tags query to use
  37421. * @param forEach defines a predicate used to filter results
  37422. * @returns an array of Light
  37423. */
  37424. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37425. /**
  37426. * Get a list of materials by tags
  37427. * @param tagsQuery defines the tags query to use
  37428. * @param forEach defines a predicate used to filter results
  37429. * @returns an array of Material
  37430. */
  37431. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37432. /**
  37433. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37434. * This allowed control for front to back rendering or reversly depending of the special needs.
  37435. *
  37436. * @param renderingGroupId The rendering group id corresponding to its index
  37437. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37438. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37439. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37440. */
  37441. 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;
  37442. /**
  37443. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37444. *
  37445. * @param renderingGroupId The rendering group id corresponding to its index
  37446. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37447. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37448. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37449. */
  37450. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37451. /**
  37452. * Gets the current auto clear configuration for one rendering group of the rendering
  37453. * manager.
  37454. * @param index the rendering group index to get the information for
  37455. * @returns The auto clear setup for the requested rendering group
  37456. */
  37457. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37458. private _blockMaterialDirtyMechanism;
  37459. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37460. get blockMaterialDirtyMechanism(): boolean;
  37461. set blockMaterialDirtyMechanism(value: boolean);
  37462. /**
  37463. * Will flag all materials as dirty to trigger new shader compilation
  37464. * @param flag defines the flag used to specify which material part must be marked as dirty
  37465. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37466. */
  37467. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37468. /** @hidden */
  37469. _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;
  37470. /** @hidden */
  37471. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37472. /** @hidden */
  37473. _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;
  37474. /** @hidden */
  37475. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37476. /** @hidden */
  37477. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37478. /** @hidden */
  37479. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37480. }
  37481. }
  37482. declare module BABYLON {
  37483. /**
  37484. * Set of assets to keep when moving a scene into an asset container.
  37485. */
  37486. export class KeepAssets extends AbstractScene {
  37487. }
  37488. /**
  37489. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37490. */
  37491. export class InstantiatedEntries {
  37492. /**
  37493. * List of new root nodes (eg. nodes with no parent)
  37494. */
  37495. rootNodes: TransformNode[];
  37496. /**
  37497. * List of new skeletons
  37498. */
  37499. skeletons: Skeleton[];
  37500. /**
  37501. * List of new animation groups
  37502. */
  37503. animationGroups: AnimationGroup[];
  37504. }
  37505. /**
  37506. * Container with a set of assets that can be added or removed from a scene.
  37507. */
  37508. export class AssetContainer extends AbstractScene {
  37509. private _wasAddedToScene;
  37510. /**
  37511. * The scene the AssetContainer belongs to.
  37512. */
  37513. scene: Scene;
  37514. /**
  37515. * Instantiates an AssetContainer.
  37516. * @param scene The scene the AssetContainer belongs to.
  37517. */
  37518. constructor(scene: Scene);
  37519. /**
  37520. * Instantiate or clone all meshes and add the new ones to the scene.
  37521. * Skeletons and animation groups will all be cloned
  37522. * @param nameFunction defines an optional function used to get new names for clones
  37523. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37524. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37525. */
  37526. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37527. /**
  37528. * Adds all the assets from the container to the scene.
  37529. */
  37530. addAllToScene(): void;
  37531. /**
  37532. * Removes all the assets in the container from the scene
  37533. */
  37534. removeAllFromScene(): void;
  37535. /**
  37536. * Disposes all the assets in the container
  37537. */
  37538. dispose(): void;
  37539. private _moveAssets;
  37540. /**
  37541. * Removes all the assets contained in the scene and adds them to the container.
  37542. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37543. */
  37544. moveAllFromScene(keepAssets?: KeepAssets): void;
  37545. /**
  37546. * 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.
  37547. * @returns the root mesh
  37548. */
  37549. createRootMesh(): Mesh;
  37550. /**
  37551. * Merge animations from this asset container into a scene
  37552. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37553. * @param animatables set of animatables to retarget to a node from the scene
  37554. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37555. */
  37556. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37557. }
  37558. }
  37559. declare module BABYLON {
  37560. /**
  37561. * Defines how the parser contract is defined.
  37562. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37563. */
  37564. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37565. /**
  37566. * Defines how the individual parser contract is defined.
  37567. * These parser can parse an individual asset
  37568. */
  37569. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37570. /**
  37571. * Base class of the scene acting as a container for the different elements composing a scene.
  37572. * This class is dynamically extended by the different components of the scene increasing
  37573. * flexibility and reducing coupling
  37574. */
  37575. export abstract class AbstractScene {
  37576. /**
  37577. * Stores the list of available parsers in the application.
  37578. */
  37579. private static _BabylonFileParsers;
  37580. /**
  37581. * Stores the list of available individual parsers in the application.
  37582. */
  37583. private static _IndividualBabylonFileParsers;
  37584. /**
  37585. * Adds a parser in the list of available ones
  37586. * @param name Defines the name of the parser
  37587. * @param parser Defines the parser to add
  37588. */
  37589. static AddParser(name: string, parser: BabylonFileParser): void;
  37590. /**
  37591. * Gets a general parser from the list of avaialble ones
  37592. * @param name Defines the name of the parser
  37593. * @returns the requested parser or null
  37594. */
  37595. static GetParser(name: string): Nullable<BabylonFileParser>;
  37596. /**
  37597. * Adds n individual parser in the list of available ones
  37598. * @param name Defines the name of the parser
  37599. * @param parser Defines the parser to add
  37600. */
  37601. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37602. /**
  37603. * Gets an individual parser from the list of avaialble ones
  37604. * @param name Defines the name of the parser
  37605. * @returns the requested parser or null
  37606. */
  37607. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37608. /**
  37609. * Parser json data and populate both a scene and its associated container object
  37610. * @param jsonData Defines the data to parse
  37611. * @param scene Defines the scene to parse the data for
  37612. * @param container Defines the container attached to the parsing sequence
  37613. * @param rootUrl Defines the root url of the data
  37614. */
  37615. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37616. /**
  37617. * Gets the list of root nodes (ie. nodes with no parent)
  37618. */
  37619. rootNodes: Node[];
  37620. /** All of the cameras added to this scene
  37621. * @see http://doc.babylonjs.com/babylon101/cameras
  37622. */
  37623. cameras: Camera[];
  37624. /**
  37625. * All of the lights added to this scene
  37626. * @see http://doc.babylonjs.com/babylon101/lights
  37627. */
  37628. lights: Light[];
  37629. /**
  37630. * All of the (abstract) meshes added to this scene
  37631. */
  37632. meshes: AbstractMesh[];
  37633. /**
  37634. * The list of skeletons added to the scene
  37635. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37636. */
  37637. skeletons: Skeleton[];
  37638. /**
  37639. * All of the particle systems added to this scene
  37640. * @see http://doc.babylonjs.com/babylon101/particles
  37641. */
  37642. particleSystems: IParticleSystem[];
  37643. /**
  37644. * Gets a list of Animations associated with the scene
  37645. */
  37646. animations: Animation[];
  37647. /**
  37648. * All of the animation groups added to this scene
  37649. * @see http://doc.babylonjs.com/how_to/group
  37650. */
  37651. animationGroups: AnimationGroup[];
  37652. /**
  37653. * All of the multi-materials added to this scene
  37654. * @see http://doc.babylonjs.com/how_to/multi_materials
  37655. */
  37656. multiMaterials: MultiMaterial[];
  37657. /**
  37658. * All of the materials added to this scene
  37659. * In the context of a Scene, it is not supposed to be modified manually.
  37660. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37661. * Note also that the order of the Material within the array is not significant and might change.
  37662. * @see http://doc.babylonjs.com/babylon101/materials
  37663. */
  37664. materials: Material[];
  37665. /**
  37666. * The list of morph target managers added to the scene
  37667. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37668. */
  37669. morphTargetManagers: MorphTargetManager[];
  37670. /**
  37671. * The list of geometries used in the scene.
  37672. */
  37673. geometries: Geometry[];
  37674. /**
  37675. * All of the tranform nodes added to this scene
  37676. * In the context of a Scene, it is not supposed to be modified manually.
  37677. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37678. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37679. * @see http://doc.babylonjs.com/how_to/transformnode
  37680. */
  37681. transformNodes: TransformNode[];
  37682. /**
  37683. * ActionManagers available on the scene.
  37684. */
  37685. actionManagers: AbstractActionManager[];
  37686. /**
  37687. * Textures to keep.
  37688. */
  37689. textures: BaseTexture[];
  37690. /**
  37691. * Environment texture for the scene
  37692. */
  37693. environmentTexture: Nullable<BaseTexture>;
  37694. /**
  37695. * @returns all meshes, lights, cameras, transformNodes and bones
  37696. */
  37697. getNodes(): Array<Node>;
  37698. }
  37699. }
  37700. declare module BABYLON {
  37701. /**
  37702. * Interface used to define options for Sound class
  37703. */
  37704. export interface ISoundOptions {
  37705. /**
  37706. * Does the sound autoplay once loaded.
  37707. */
  37708. autoplay?: boolean;
  37709. /**
  37710. * Does the sound loop after it finishes playing once.
  37711. */
  37712. loop?: boolean;
  37713. /**
  37714. * Sound's volume
  37715. */
  37716. volume?: number;
  37717. /**
  37718. * Is it a spatial sound?
  37719. */
  37720. spatialSound?: boolean;
  37721. /**
  37722. * Maximum distance to hear that sound
  37723. */
  37724. maxDistance?: number;
  37725. /**
  37726. * Uses user defined attenuation function
  37727. */
  37728. useCustomAttenuation?: boolean;
  37729. /**
  37730. * Define the roll off factor of spatial sounds.
  37731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37732. */
  37733. rolloffFactor?: number;
  37734. /**
  37735. * Define the reference distance the sound should be heard perfectly.
  37736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37737. */
  37738. refDistance?: number;
  37739. /**
  37740. * Define the distance attenuation model the sound will follow.
  37741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37742. */
  37743. distanceModel?: string;
  37744. /**
  37745. * Defines the playback speed (1 by default)
  37746. */
  37747. playbackRate?: number;
  37748. /**
  37749. * Defines if the sound is from a streaming source
  37750. */
  37751. streaming?: boolean;
  37752. /**
  37753. * Defines an optional length (in seconds) inside the sound file
  37754. */
  37755. length?: number;
  37756. /**
  37757. * Defines an optional offset (in seconds) inside the sound file
  37758. */
  37759. offset?: number;
  37760. /**
  37761. * If true, URLs will not be required to state the audio file codec to use.
  37762. */
  37763. skipCodecCheck?: boolean;
  37764. }
  37765. /**
  37766. * Defines a sound that can be played in the application.
  37767. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37769. */
  37770. export class Sound {
  37771. /**
  37772. * The name of the sound in the scene.
  37773. */
  37774. name: string;
  37775. /**
  37776. * Does the sound autoplay once loaded.
  37777. */
  37778. autoplay: boolean;
  37779. /**
  37780. * Does the sound loop after it finishes playing once.
  37781. */
  37782. loop: boolean;
  37783. /**
  37784. * Does the sound use a custom attenuation curve to simulate the falloff
  37785. * happening when the source gets further away from the camera.
  37786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37787. */
  37788. useCustomAttenuation: boolean;
  37789. /**
  37790. * The sound track id this sound belongs to.
  37791. */
  37792. soundTrackId: number;
  37793. /**
  37794. * Is this sound currently played.
  37795. */
  37796. isPlaying: boolean;
  37797. /**
  37798. * Is this sound currently paused.
  37799. */
  37800. isPaused: boolean;
  37801. /**
  37802. * Does this sound enables spatial sound.
  37803. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37804. */
  37805. spatialSound: boolean;
  37806. /**
  37807. * Define the reference distance the sound should be heard perfectly.
  37808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37809. */
  37810. refDistance: number;
  37811. /**
  37812. * Define the roll off factor of spatial sounds.
  37813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37814. */
  37815. rolloffFactor: number;
  37816. /**
  37817. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37819. */
  37820. maxDistance: number;
  37821. /**
  37822. * Define the distance attenuation model the sound will follow.
  37823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37824. */
  37825. distanceModel: string;
  37826. /**
  37827. * @hidden
  37828. * Back Compat
  37829. **/
  37830. onended: () => any;
  37831. /**
  37832. * Observable event when the current playing sound finishes.
  37833. */
  37834. onEndedObservable: Observable<Sound>;
  37835. private _panningModel;
  37836. private _playbackRate;
  37837. private _streaming;
  37838. private _startTime;
  37839. private _startOffset;
  37840. private _position;
  37841. /** @hidden */
  37842. _positionInEmitterSpace: boolean;
  37843. private _localDirection;
  37844. private _volume;
  37845. private _isReadyToPlay;
  37846. private _isDirectional;
  37847. private _readyToPlayCallback;
  37848. private _audioBuffer;
  37849. private _soundSource;
  37850. private _streamingSource;
  37851. private _soundPanner;
  37852. private _soundGain;
  37853. private _inputAudioNode;
  37854. private _outputAudioNode;
  37855. private _coneInnerAngle;
  37856. private _coneOuterAngle;
  37857. private _coneOuterGain;
  37858. private _scene;
  37859. private _connectedTransformNode;
  37860. private _customAttenuationFunction;
  37861. private _registerFunc;
  37862. private _isOutputConnected;
  37863. private _htmlAudioElement;
  37864. private _urlType;
  37865. private _length?;
  37866. private _offset?;
  37867. /** @hidden */
  37868. static _SceneComponentInitialization: (scene: Scene) => void;
  37869. /**
  37870. * Create a sound and attach it to a scene
  37871. * @param name Name of your sound
  37872. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37873. * @param scene defines the scene the sound belongs to
  37874. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37875. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37876. */
  37877. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37878. /**
  37879. * Release the sound and its associated resources
  37880. */
  37881. dispose(): void;
  37882. /**
  37883. * Gets if the sounds is ready to be played or not.
  37884. * @returns true if ready, otherwise false
  37885. */
  37886. isReady(): boolean;
  37887. private _soundLoaded;
  37888. /**
  37889. * Sets the data of the sound from an audiobuffer
  37890. * @param audioBuffer The audioBuffer containing the data
  37891. */
  37892. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37893. /**
  37894. * Updates the current sounds options such as maxdistance, loop...
  37895. * @param options A JSON object containing values named as the object properties
  37896. */
  37897. updateOptions(options: ISoundOptions): void;
  37898. private _createSpatialParameters;
  37899. private _updateSpatialParameters;
  37900. /**
  37901. * Switch the panning model to HRTF:
  37902. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37904. */
  37905. switchPanningModelToHRTF(): void;
  37906. /**
  37907. * Switch the panning model to Equal Power:
  37908. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37910. */
  37911. switchPanningModelToEqualPower(): void;
  37912. private _switchPanningModel;
  37913. /**
  37914. * Connect this sound to a sound track audio node like gain...
  37915. * @param soundTrackAudioNode the sound track audio node to connect to
  37916. */
  37917. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37918. /**
  37919. * Transform this sound into a directional source
  37920. * @param coneInnerAngle Size of the inner cone in degree
  37921. * @param coneOuterAngle Size of the outer cone in degree
  37922. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37923. */
  37924. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37925. /**
  37926. * Gets or sets the inner angle for the directional cone.
  37927. */
  37928. get directionalConeInnerAngle(): number;
  37929. /**
  37930. * Gets or sets the inner angle for the directional cone.
  37931. */
  37932. set directionalConeInnerAngle(value: number);
  37933. /**
  37934. * Gets or sets the outer angle for the directional cone.
  37935. */
  37936. get directionalConeOuterAngle(): number;
  37937. /**
  37938. * Gets or sets the outer angle for the directional cone.
  37939. */
  37940. set directionalConeOuterAngle(value: number);
  37941. /**
  37942. * Sets the position of the emitter if spatial sound is enabled
  37943. * @param newPosition Defines the new posisiton
  37944. */
  37945. setPosition(newPosition: Vector3): void;
  37946. /**
  37947. * Sets the local direction of the emitter if spatial sound is enabled
  37948. * @param newLocalDirection Defines the new local direction
  37949. */
  37950. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37951. private _updateDirection;
  37952. /** @hidden */
  37953. updateDistanceFromListener(): void;
  37954. /**
  37955. * Sets a new custom attenuation function for the sound.
  37956. * @param callback Defines the function used for the attenuation
  37957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37958. */
  37959. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37960. /**
  37961. * Play the sound
  37962. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37963. * @param offset (optional) Start the sound at a specific time in seconds
  37964. * @param length (optional) Sound duration (in seconds)
  37965. */
  37966. play(time?: number, offset?: number, length?: number): void;
  37967. private _onended;
  37968. /**
  37969. * Stop the sound
  37970. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37971. */
  37972. stop(time?: number): void;
  37973. /**
  37974. * Put the sound in pause
  37975. */
  37976. pause(): void;
  37977. /**
  37978. * Sets a dedicated volume for this sounds
  37979. * @param newVolume Define the new volume of the sound
  37980. * @param time Define time for gradual change to new volume
  37981. */
  37982. setVolume(newVolume: number, time?: number): void;
  37983. /**
  37984. * Set the sound play back rate
  37985. * @param newPlaybackRate Define the playback rate the sound should be played at
  37986. */
  37987. setPlaybackRate(newPlaybackRate: number): void;
  37988. /**
  37989. * Gets the volume of the sound.
  37990. * @returns the volume of the sound
  37991. */
  37992. getVolume(): number;
  37993. /**
  37994. * Attach the sound to a dedicated mesh
  37995. * @param transformNode The transform node to connect the sound with
  37996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37997. */
  37998. attachToMesh(transformNode: TransformNode): void;
  37999. /**
  38000. * Detach the sound from the previously attached mesh
  38001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38002. */
  38003. detachFromMesh(): void;
  38004. private _onRegisterAfterWorldMatrixUpdate;
  38005. /**
  38006. * Clone the current sound in the scene.
  38007. * @returns the new sound clone
  38008. */
  38009. clone(): Nullable<Sound>;
  38010. /**
  38011. * Gets the current underlying audio buffer containing the data
  38012. * @returns the audio buffer
  38013. */
  38014. getAudioBuffer(): Nullable<AudioBuffer>;
  38015. /**
  38016. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38017. * @returns the source node
  38018. */
  38019. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38020. /**
  38021. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38022. * @returns the gain node
  38023. */
  38024. getSoundGain(): Nullable<GainNode>;
  38025. /**
  38026. * Serializes the Sound in a JSON representation
  38027. * @returns the JSON representation of the sound
  38028. */
  38029. serialize(): any;
  38030. /**
  38031. * Parse a JSON representation of a sound to innstantiate in a given scene
  38032. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38033. * @param scene Define the scene the new parsed sound should be created in
  38034. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38035. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38036. * @returns the newly parsed sound
  38037. */
  38038. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38039. }
  38040. }
  38041. declare module BABYLON {
  38042. /**
  38043. * This defines an action helpful to play a defined sound on a triggered action.
  38044. */
  38045. export class PlaySoundAction extends Action {
  38046. private _sound;
  38047. /**
  38048. * Instantiate the action
  38049. * @param triggerOptions defines the trigger options
  38050. * @param sound defines the sound to play
  38051. * @param condition defines the trigger related conditions
  38052. */
  38053. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38054. /** @hidden */
  38055. _prepare(): void;
  38056. /**
  38057. * Execute the action and play the sound.
  38058. */
  38059. execute(): void;
  38060. /**
  38061. * Serializes the actions and its related information.
  38062. * @param parent defines the object to serialize in
  38063. * @returns the serialized object
  38064. */
  38065. serialize(parent: any): any;
  38066. }
  38067. /**
  38068. * This defines an action helpful to stop a defined sound on a triggered action.
  38069. */
  38070. export class StopSoundAction extends Action {
  38071. private _sound;
  38072. /**
  38073. * Instantiate the action
  38074. * @param triggerOptions defines the trigger options
  38075. * @param sound defines the sound to stop
  38076. * @param condition defines the trigger related conditions
  38077. */
  38078. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38079. /** @hidden */
  38080. _prepare(): void;
  38081. /**
  38082. * Execute the action and stop the sound.
  38083. */
  38084. execute(): void;
  38085. /**
  38086. * Serializes the actions and its related information.
  38087. * @param parent defines the object to serialize in
  38088. * @returns the serialized object
  38089. */
  38090. serialize(parent: any): any;
  38091. }
  38092. }
  38093. declare module BABYLON {
  38094. /**
  38095. * This defines an action responsible to change the value of a property
  38096. * by interpolating between its current value and the newly set one once triggered.
  38097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38098. */
  38099. export class InterpolateValueAction extends Action {
  38100. /**
  38101. * Defines the path of the property where the value should be interpolated
  38102. */
  38103. propertyPath: string;
  38104. /**
  38105. * Defines the target value at the end of the interpolation.
  38106. */
  38107. value: any;
  38108. /**
  38109. * Defines the time it will take for the property to interpolate to the value.
  38110. */
  38111. duration: number;
  38112. /**
  38113. * Defines if the other scene animations should be stopped when the action has been triggered
  38114. */
  38115. stopOtherAnimations?: boolean;
  38116. /**
  38117. * Defines a callback raised once the interpolation animation has been done.
  38118. */
  38119. onInterpolationDone?: () => void;
  38120. /**
  38121. * Observable triggered once the interpolation animation has been done.
  38122. */
  38123. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38124. private _target;
  38125. private _effectiveTarget;
  38126. private _property;
  38127. /**
  38128. * Instantiate the action
  38129. * @param triggerOptions defines the trigger options
  38130. * @param target defines the object containing the value to interpolate
  38131. * @param propertyPath defines the path to the property in the target object
  38132. * @param value defines the target value at the end of the interpolation
  38133. * @param duration deines the time it will take for the property to interpolate to the value.
  38134. * @param condition defines the trigger related conditions
  38135. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38136. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38137. */
  38138. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38139. /** @hidden */
  38140. _prepare(): void;
  38141. /**
  38142. * Execute the action starts the value interpolation.
  38143. */
  38144. execute(): void;
  38145. /**
  38146. * Serializes the actions and its related information.
  38147. * @param parent defines the object to serialize in
  38148. * @returns the serialized object
  38149. */
  38150. serialize(parent: any): any;
  38151. }
  38152. }
  38153. declare module BABYLON {
  38154. /**
  38155. * Options allowed during the creation of a sound track.
  38156. */
  38157. export interface ISoundTrackOptions {
  38158. /**
  38159. * The volume the sound track should take during creation
  38160. */
  38161. volume?: number;
  38162. /**
  38163. * Define if the sound track is the main sound track of the scene
  38164. */
  38165. mainTrack?: boolean;
  38166. }
  38167. /**
  38168. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38169. * It will be also used in a future release to apply effects on a specific track.
  38170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38171. */
  38172. export class SoundTrack {
  38173. /**
  38174. * The unique identifier of the sound track in the scene.
  38175. */
  38176. id: number;
  38177. /**
  38178. * The list of sounds included in the sound track.
  38179. */
  38180. soundCollection: Array<Sound>;
  38181. private _outputAudioNode;
  38182. private _scene;
  38183. private _connectedAnalyser;
  38184. private _options;
  38185. private _isInitialized;
  38186. /**
  38187. * Creates a new sound track.
  38188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38189. * @param scene Define the scene the sound track belongs to
  38190. * @param options
  38191. */
  38192. constructor(scene: Scene, options?: ISoundTrackOptions);
  38193. private _initializeSoundTrackAudioGraph;
  38194. /**
  38195. * Release the sound track and its associated resources
  38196. */
  38197. dispose(): void;
  38198. /**
  38199. * Adds a sound to this sound track
  38200. * @param sound define the cound to add
  38201. * @ignoreNaming
  38202. */
  38203. AddSound(sound: Sound): void;
  38204. /**
  38205. * Removes a sound to this sound track
  38206. * @param sound define the cound to remove
  38207. * @ignoreNaming
  38208. */
  38209. RemoveSound(sound: Sound): void;
  38210. /**
  38211. * Set a global volume for the full sound track.
  38212. * @param newVolume Define the new volume of the sound track
  38213. */
  38214. setVolume(newVolume: number): void;
  38215. /**
  38216. * Switch the panning model to HRTF:
  38217. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38219. */
  38220. switchPanningModelToHRTF(): void;
  38221. /**
  38222. * Switch the panning model to Equal Power:
  38223. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38225. */
  38226. switchPanningModelToEqualPower(): void;
  38227. /**
  38228. * Connect the sound track to an audio analyser allowing some amazing
  38229. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38231. * @param analyser The analyser to connect to the engine
  38232. */
  38233. connectToAnalyser(analyser: Analyser): void;
  38234. }
  38235. }
  38236. declare module BABYLON {
  38237. interface AbstractScene {
  38238. /**
  38239. * The list of sounds used in the scene.
  38240. */
  38241. sounds: Nullable<Array<Sound>>;
  38242. }
  38243. interface Scene {
  38244. /**
  38245. * @hidden
  38246. * Backing field
  38247. */
  38248. _mainSoundTrack: SoundTrack;
  38249. /**
  38250. * The main sound track played by the scene.
  38251. * It cotains your primary collection of sounds.
  38252. */
  38253. mainSoundTrack: SoundTrack;
  38254. /**
  38255. * The list of sound tracks added to the scene
  38256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38257. */
  38258. soundTracks: Nullable<Array<SoundTrack>>;
  38259. /**
  38260. * Gets a sound using a given name
  38261. * @param name defines the name to search for
  38262. * @return the found sound or null if not found at all.
  38263. */
  38264. getSoundByName(name: string): Nullable<Sound>;
  38265. /**
  38266. * Gets or sets if audio support is enabled
  38267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38268. */
  38269. audioEnabled: boolean;
  38270. /**
  38271. * Gets or sets if audio will be output to headphones
  38272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38273. */
  38274. headphone: boolean;
  38275. /**
  38276. * Gets or sets custom audio listener position provider
  38277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38278. */
  38279. audioListenerPositionProvider: Nullable<() => Vector3>;
  38280. /**
  38281. * Gets or sets a refresh rate when using 3D audio positioning
  38282. */
  38283. audioPositioningRefreshRate: number;
  38284. }
  38285. /**
  38286. * Defines the sound scene component responsible to manage any sounds
  38287. * in a given scene.
  38288. */
  38289. export class AudioSceneComponent implements ISceneSerializableComponent {
  38290. /**
  38291. * The component name helpfull to identify the component in the list of scene components.
  38292. */
  38293. readonly name: string;
  38294. /**
  38295. * The scene the component belongs to.
  38296. */
  38297. scene: Scene;
  38298. private _audioEnabled;
  38299. /**
  38300. * Gets whether audio is enabled or not.
  38301. * Please use related enable/disable method to switch state.
  38302. */
  38303. get audioEnabled(): boolean;
  38304. private _headphone;
  38305. /**
  38306. * Gets whether audio is outputing to headphone or not.
  38307. * Please use the according Switch methods to change output.
  38308. */
  38309. get headphone(): boolean;
  38310. /**
  38311. * Gets or sets a refresh rate when using 3D audio positioning
  38312. */
  38313. audioPositioningRefreshRate: number;
  38314. private _audioListenerPositionProvider;
  38315. /**
  38316. * Gets the current audio listener position provider
  38317. */
  38318. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38319. /**
  38320. * Sets a custom listener position for all sounds in the scene
  38321. * By default, this is the position of the first active camera
  38322. */
  38323. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38324. /**
  38325. * Creates a new instance of the component for the given scene
  38326. * @param scene Defines the scene to register the component in
  38327. */
  38328. constructor(scene: Scene);
  38329. /**
  38330. * Registers the component in a given scene
  38331. */
  38332. register(): void;
  38333. /**
  38334. * Rebuilds the elements related to this component in case of
  38335. * context lost for instance.
  38336. */
  38337. rebuild(): void;
  38338. /**
  38339. * Serializes the component data to the specified json object
  38340. * @param serializationObject The object to serialize to
  38341. */
  38342. serialize(serializationObject: any): void;
  38343. /**
  38344. * Adds all the elements from the container to the scene
  38345. * @param container the container holding the elements
  38346. */
  38347. addFromContainer(container: AbstractScene): void;
  38348. /**
  38349. * Removes all the elements in the container from the scene
  38350. * @param container contains the elements to remove
  38351. * @param dispose if the removed element should be disposed (default: false)
  38352. */
  38353. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38354. /**
  38355. * Disposes the component and the associated ressources.
  38356. */
  38357. dispose(): void;
  38358. /**
  38359. * Disables audio in the associated scene.
  38360. */
  38361. disableAudio(): void;
  38362. /**
  38363. * Enables audio in the associated scene.
  38364. */
  38365. enableAudio(): void;
  38366. /**
  38367. * Switch audio to headphone output.
  38368. */
  38369. switchAudioModeForHeadphones(): void;
  38370. /**
  38371. * Switch audio to normal speakers.
  38372. */
  38373. switchAudioModeForNormalSpeakers(): void;
  38374. private _cachedCameraDirection;
  38375. private _cachedCameraPosition;
  38376. private _lastCheck;
  38377. private _afterRender;
  38378. }
  38379. }
  38380. declare module BABYLON {
  38381. /**
  38382. * Wraps one or more Sound objects and selects one with random weight for playback.
  38383. */
  38384. export class WeightedSound {
  38385. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38386. loop: boolean;
  38387. private _coneInnerAngle;
  38388. private _coneOuterAngle;
  38389. private _volume;
  38390. /** A Sound is currently playing. */
  38391. isPlaying: boolean;
  38392. /** A Sound is currently paused. */
  38393. isPaused: boolean;
  38394. private _sounds;
  38395. private _weights;
  38396. private _currentIndex?;
  38397. /**
  38398. * Creates a new WeightedSound from the list of sounds given.
  38399. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38400. * @param sounds Array of Sounds that will be selected from.
  38401. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38402. */
  38403. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38404. /**
  38405. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38406. */
  38407. get directionalConeInnerAngle(): number;
  38408. /**
  38409. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38410. */
  38411. set directionalConeInnerAngle(value: number);
  38412. /**
  38413. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38414. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38415. */
  38416. get directionalConeOuterAngle(): number;
  38417. /**
  38418. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38419. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38420. */
  38421. set directionalConeOuterAngle(value: number);
  38422. /**
  38423. * Playback volume.
  38424. */
  38425. get volume(): number;
  38426. /**
  38427. * Playback volume.
  38428. */
  38429. set volume(value: number);
  38430. private _onended;
  38431. /**
  38432. * Suspend playback
  38433. */
  38434. pause(): void;
  38435. /**
  38436. * Stop playback
  38437. */
  38438. stop(): void;
  38439. /**
  38440. * Start playback.
  38441. * @param startOffset Position the clip head at a specific time in seconds.
  38442. */
  38443. play(startOffset?: number): void;
  38444. }
  38445. }
  38446. declare module BABYLON {
  38447. /**
  38448. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38449. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38450. */
  38451. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38452. /**
  38453. * Gets the name of the behavior.
  38454. */
  38455. get name(): string;
  38456. /**
  38457. * The easing function used by animations
  38458. */
  38459. static EasingFunction: BackEase;
  38460. /**
  38461. * The easing mode used by animations
  38462. */
  38463. static EasingMode: number;
  38464. /**
  38465. * The duration of the animation, in milliseconds
  38466. */
  38467. transitionDuration: number;
  38468. /**
  38469. * Length of the distance animated by the transition when lower radius is reached
  38470. */
  38471. lowerRadiusTransitionRange: number;
  38472. /**
  38473. * Length of the distance animated by the transition when upper radius is reached
  38474. */
  38475. upperRadiusTransitionRange: number;
  38476. private _autoTransitionRange;
  38477. /**
  38478. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38479. */
  38480. get autoTransitionRange(): boolean;
  38481. /**
  38482. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38483. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38484. */
  38485. set autoTransitionRange(value: boolean);
  38486. private _attachedCamera;
  38487. private _onAfterCheckInputsObserver;
  38488. private _onMeshTargetChangedObserver;
  38489. /**
  38490. * Initializes the behavior.
  38491. */
  38492. init(): void;
  38493. /**
  38494. * Attaches the behavior to its arc rotate camera.
  38495. * @param camera Defines the camera to attach the behavior to
  38496. */
  38497. attach(camera: ArcRotateCamera): void;
  38498. /**
  38499. * Detaches the behavior from its current arc rotate camera.
  38500. */
  38501. detach(): void;
  38502. private _radiusIsAnimating;
  38503. private _radiusBounceTransition;
  38504. private _animatables;
  38505. private _cachedWheelPrecision;
  38506. /**
  38507. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38508. * @param radiusLimit The limit to check against.
  38509. * @return Bool to indicate if at limit.
  38510. */
  38511. private _isRadiusAtLimit;
  38512. /**
  38513. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38514. * @param radiusDelta The delta by which to animate to. Can be negative.
  38515. */
  38516. private _applyBoundRadiusAnimation;
  38517. /**
  38518. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38519. */
  38520. protected _clearAnimationLocks(): void;
  38521. /**
  38522. * Stops and removes all animations that have been applied to the camera
  38523. */
  38524. stopAllAnimations(): void;
  38525. }
  38526. }
  38527. declare module BABYLON {
  38528. /**
  38529. * 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.
  38530. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38531. */
  38532. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38533. /**
  38534. * Gets the name of the behavior.
  38535. */
  38536. get name(): string;
  38537. private _mode;
  38538. private _radiusScale;
  38539. private _positionScale;
  38540. private _defaultElevation;
  38541. private _elevationReturnTime;
  38542. private _elevationReturnWaitTime;
  38543. private _zoomStopsAnimation;
  38544. private _framingTime;
  38545. /**
  38546. * The easing function used by animations
  38547. */
  38548. static EasingFunction: ExponentialEase;
  38549. /**
  38550. * The easing mode used by animations
  38551. */
  38552. static EasingMode: number;
  38553. /**
  38554. * Sets the current mode used by the behavior
  38555. */
  38556. set mode(mode: number);
  38557. /**
  38558. * Gets current mode used by the behavior.
  38559. */
  38560. get mode(): number;
  38561. /**
  38562. * Sets the scale applied to the radius (1 by default)
  38563. */
  38564. set radiusScale(radius: number);
  38565. /**
  38566. * Gets the scale applied to the radius
  38567. */
  38568. get radiusScale(): number;
  38569. /**
  38570. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38571. */
  38572. set positionScale(scale: number);
  38573. /**
  38574. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38575. */
  38576. get positionScale(): number;
  38577. /**
  38578. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38579. * behaviour is triggered, in radians.
  38580. */
  38581. set defaultElevation(elevation: number);
  38582. /**
  38583. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38584. * behaviour is triggered, in radians.
  38585. */
  38586. get defaultElevation(): number;
  38587. /**
  38588. * Sets the time (in milliseconds) taken to return to the default beta position.
  38589. * Negative value indicates camera should not return to default.
  38590. */
  38591. set elevationReturnTime(speed: number);
  38592. /**
  38593. * Gets the time (in milliseconds) taken to return to the default beta position.
  38594. * Negative value indicates camera should not return to default.
  38595. */
  38596. get elevationReturnTime(): number;
  38597. /**
  38598. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38599. */
  38600. set elevationReturnWaitTime(time: number);
  38601. /**
  38602. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38603. */
  38604. get elevationReturnWaitTime(): number;
  38605. /**
  38606. * Sets the flag that indicates if user zooming should stop animation.
  38607. */
  38608. set zoomStopsAnimation(flag: boolean);
  38609. /**
  38610. * Gets the flag that indicates if user zooming should stop animation.
  38611. */
  38612. get zoomStopsAnimation(): boolean;
  38613. /**
  38614. * Sets the transition time when framing the mesh, in milliseconds
  38615. */
  38616. set framingTime(time: number);
  38617. /**
  38618. * Gets the transition time when framing the mesh, in milliseconds
  38619. */
  38620. get framingTime(): number;
  38621. /**
  38622. * Define if the behavior should automatically change the configured
  38623. * camera limits and sensibilities.
  38624. */
  38625. autoCorrectCameraLimitsAndSensibility: boolean;
  38626. private _onPrePointerObservableObserver;
  38627. private _onAfterCheckInputsObserver;
  38628. private _onMeshTargetChangedObserver;
  38629. private _attachedCamera;
  38630. private _isPointerDown;
  38631. private _lastInteractionTime;
  38632. /**
  38633. * Initializes the behavior.
  38634. */
  38635. init(): void;
  38636. /**
  38637. * Attaches the behavior to its arc rotate camera.
  38638. * @param camera Defines the camera to attach the behavior to
  38639. */
  38640. attach(camera: ArcRotateCamera): void;
  38641. /**
  38642. * Detaches the behavior from its current arc rotate camera.
  38643. */
  38644. detach(): void;
  38645. private _animatables;
  38646. private _betaIsAnimating;
  38647. private _betaTransition;
  38648. private _radiusTransition;
  38649. private _vectorTransition;
  38650. /**
  38651. * Targets the given mesh and updates zoom level accordingly.
  38652. * @param mesh The mesh to target.
  38653. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38654. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38655. */
  38656. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38657. /**
  38658. * Targets the given mesh with its children and updates zoom level accordingly.
  38659. * @param mesh The mesh to target.
  38660. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38661. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38662. */
  38663. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38664. /**
  38665. * Targets the given meshes with their children and updates zoom level accordingly.
  38666. * @param meshes The mesh to target.
  38667. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38668. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38669. */
  38670. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38671. /**
  38672. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38673. * @param minimumWorld Determines the smaller position of the bounding box extend
  38674. * @param maximumWorld Determines the bigger position of the bounding box extend
  38675. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38676. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38677. */
  38678. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38679. /**
  38680. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38681. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38682. * frustum width.
  38683. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38684. * to fully enclose the mesh in the viewing frustum.
  38685. */
  38686. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38687. /**
  38688. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38689. * is automatically returned to its default position (expected to be above ground plane).
  38690. */
  38691. private _maintainCameraAboveGround;
  38692. /**
  38693. * Returns the frustum slope based on the canvas ratio and camera FOV
  38694. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38695. */
  38696. private _getFrustumSlope;
  38697. /**
  38698. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38699. */
  38700. private _clearAnimationLocks;
  38701. /**
  38702. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38703. */
  38704. private _applyUserInteraction;
  38705. /**
  38706. * Stops and removes all animations that have been applied to the camera
  38707. */
  38708. stopAllAnimations(): void;
  38709. /**
  38710. * Gets a value indicating if the user is moving the camera
  38711. */
  38712. get isUserIsMoving(): boolean;
  38713. /**
  38714. * The camera can move all the way towards the mesh.
  38715. */
  38716. static IgnoreBoundsSizeMode: number;
  38717. /**
  38718. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38719. */
  38720. static FitFrustumSidesMode: number;
  38721. }
  38722. }
  38723. declare module BABYLON {
  38724. /**
  38725. * Base class for Camera Pointer Inputs.
  38726. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38727. * for example usage.
  38728. */
  38729. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38730. /**
  38731. * Defines the camera the input is attached to.
  38732. */
  38733. abstract camera: Camera;
  38734. /**
  38735. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38736. */
  38737. protected _altKey: boolean;
  38738. protected _ctrlKey: boolean;
  38739. protected _metaKey: boolean;
  38740. protected _shiftKey: boolean;
  38741. /**
  38742. * Which mouse buttons were pressed at time of last mouse event.
  38743. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38744. */
  38745. protected _buttonsPressed: number;
  38746. /**
  38747. * Defines the buttons associated with the input to handle camera move.
  38748. */
  38749. buttons: number[];
  38750. /**
  38751. * Attach the input controls to a specific dom element to get the input from.
  38752. * @param element Defines the element the controls should be listened from
  38753. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38754. */
  38755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38756. /**
  38757. * Detach the current controls from the specified dom element.
  38758. * @param element Defines the element to stop listening the inputs from
  38759. */
  38760. detachControl(element: Nullable<HTMLElement>): void;
  38761. /**
  38762. * Gets the class name of the current input.
  38763. * @returns the class name
  38764. */
  38765. getClassName(): string;
  38766. /**
  38767. * Get the friendly name associated with the input class.
  38768. * @returns the input friendly name
  38769. */
  38770. getSimpleName(): string;
  38771. /**
  38772. * Called on pointer POINTERDOUBLETAP event.
  38773. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38774. */
  38775. protected onDoubleTap(type: string): void;
  38776. /**
  38777. * Called on pointer POINTERMOVE event if only a single touch is active.
  38778. * Override this method to provide functionality.
  38779. */
  38780. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38781. /**
  38782. * Called on pointer POINTERMOVE event if multiple touches are active.
  38783. * Override this method to provide functionality.
  38784. */
  38785. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38786. /**
  38787. * Called on JS contextmenu event.
  38788. * Override this method to provide functionality.
  38789. */
  38790. protected onContextMenu(evt: PointerEvent): void;
  38791. /**
  38792. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38793. * press.
  38794. * Override this method to provide functionality.
  38795. */
  38796. protected onButtonDown(evt: PointerEvent): void;
  38797. /**
  38798. * Called each time a new POINTERUP event occurs. Ie, for each button
  38799. * release.
  38800. * Override this method to provide functionality.
  38801. */
  38802. protected onButtonUp(evt: PointerEvent): void;
  38803. /**
  38804. * Called when window becomes inactive.
  38805. * Override this method to provide functionality.
  38806. */
  38807. protected onLostFocus(): void;
  38808. private _pointerInput;
  38809. private _observer;
  38810. private _onLostFocus;
  38811. private pointA;
  38812. private pointB;
  38813. }
  38814. }
  38815. declare module BABYLON {
  38816. /**
  38817. * Manage the pointers inputs to control an arc rotate camera.
  38818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38819. */
  38820. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38821. /**
  38822. * Defines the camera the input is attached to.
  38823. */
  38824. camera: ArcRotateCamera;
  38825. /**
  38826. * Gets the class name of the current input.
  38827. * @returns the class name
  38828. */
  38829. getClassName(): string;
  38830. /**
  38831. * Defines the buttons associated with the input to handle camera move.
  38832. */
  38833. buttons: number[];
  38834. /**
  38835. * Defines the pointer angular sensibility along the X axis or how fast is
  38836. * the camera rotating.
  38837. */
  38838. angularSensibilityX: number;
  38839. /**
  38840. * Defines the pointer angular sensibility along the Y axis or how fast is
  38841. * the camera rotating.
  38842. */
  38843. angularSensibilityY: number;
  38844. /**
  38845. * Defines the pointer pinch precision or how fast is the camera zooming.
  38846. */
  38847. pinchPrecision: number;
  38848. /**
  38849. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38850. * from 0.
  38851. * It defines the percentage of current camera.radius to use as delta when
  38852. * pinch zoom is used.
  38853. */
  38854. pinchDeltaPercentage: number;
  38855. /**
  38856. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38857. * that any object in the plane at the camera's target point will scale
  38858. * perfectly with finger motion.
  38859. * Overrides pinchDeltaPercentage and pinchPrecision.
  38860. */
  38861. useNaturalPinchZoom: boolean;
  38862. /**
  38863. * Defines the pointer panning sensibility or how fast is the camera moving.
  38864. */
  38865. panningSensibility: number;
  38866. /**
  38867. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38868. */
  38869. multiTouchPanning: boolean;
  38870. /**
  38871. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38872. * zoom (pinch) through multitouch.
  38873. */
  38874. multiTouchPanAndZoom: boolean;
  38875. /**
  38876. * Revers pinch action direction.
  38877. */
  38878. pinchInwards: boolean;
  38879. private _isPanClick;
  38880. private _twoFingerActivityCount;
  38881. private _isPinching;
  38882. /**
  38883. * Called on pointer POINTERMOVE event if only a single touch is active.
  38884. */
  38885. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38886. /**
  38887. * Called on pointer POINTERDOUBLETAP event.
  38888. */
  38889. protected onDoubleTap(type: string): void;
  38890. /**
  38891. * Called on pointer POINTERMOVE event if multiple touches are active.
  38892. */
  38893. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38894. /**
  38895. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38896. * press.
  38897. */
  38898. protected onButtonDown(evt: PointerEvent): void;
  38899. /**
  38900. * Called each time a new POINTERUP event occurs. Ie, for each button
  38901. * release.
  38902. */
  38903. protected onButtonUp(evt: PointerEvent): void;
  38904. /**
  38905. * Called when window becomes inactive.
  38906. */
  38907. protected onLostFocus(): void;
  38908. }
  38909. }
  38910. declare module BABYLON {
  38911. /**
  38912. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38913. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38914. */
  38915. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38916. /**
  38917. * Defines the camera the input is attached to.
  38918. */
  38919. camera: ArcRotateCamera;
  38920. /**
  38921. * Defines the list of key codes associated with the up action (increase alpha)
  38922. */
  38923. keysUp: number[];
  38924. /**
  38925. * Defines the list of key codes associated with the down action (decrease alpha)
  38926. */
  38927. keysDown: number[];
  38928. /**
  38929. * Defines the list of key codes associated with the left action (increase beta)
  38930. */
  38931. keysLeft: number[];
  38932. /**
  38933. * Defines the list of key codes associated with the right action (decrease beta)
  38934. */
  38935. keysRight: number[];
  38936. /**
  38937. * Defines the list of key codes associated with the reset action.
  38938. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38939. */
  38940. keysReset: number[];
  38941. /**
  38942. * Defines the panning sensibility of the inputs.
  38943. * (How fast is the camera panning)
  38944. */
  38945. panningSensibility: number;
  38946. /**
  38947. * Defines the zooming sensibility of the inputs.
  38948. * (How fast is the camera zooming)
  38949. */
  38950. zoomingSensibility: number;
  38951. /**
  38952. * Defines whether maintaining the alt key down switch the movement mode from
  38953. * orientation to zoom.
  38954. */
  38955. useAltToZoom: boolean;
  38956. /**
  38957. * Rotation speed of the camera
  38958. */
  38959. angularSpeed: number;
  38960. private _keys;
  38961. private _ctrlPressed;
  38962. private _altPressed;
  38963. private _onCanvasBlurObserver;
  38964. private _onKeyboardObserver;
  38965. private _engine;
  38966. private _scene;
  38967. /**
  38968. * Attach the input controls to a specific dom element to get the input from.
  38969. * @param element Defines the element the controls should be listened from
  38970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38971. */
  38972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38973. /**
  38974. * Detach the current controls from the specified dom element.
  38975. * @param element Defines the element to stop listening the inputs from
  38976. */
  38977. detachControl(element: Nullable<HTMLElement>): void;
  38978. /**
  38979. * Update the current camera state depending on the inputs that have been used this frame.
  38980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38981. */
  38982. checkInputs(): void;
  38983. /**
  38984. * Gets the class name of the current intput.
  38985. * @returns the class name
  38986. */
  38987. getClassName(): string;
  38988. /**
  38989. * Get the friendly name associated with the input class.
  38990. * @returns the input friendly name
  38991. */
  38992. getSimpleName(): string;
  38993. }
  38994. }
  38995. declare module BABYLON {
  38996. /**
  38997. * Manage the mouse wheel inputs to control an arc rotate camera.
  38998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38999. */
  39000. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39001. /**
  39002. * Defines the camera the input is attached to.
  39003. */
  39004. camera: ArcRotateCamera;
  39005. /**
  39006. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39007. */
  39008. wheelPrecision: number;
  39009. /**
  39010. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39011. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39012. */
  39013. wheelDeltaPercentage: number;
  39014. private _wheel;
  39015. private _observer;
  39016. private computeDeltaFromMouseWheelLegacyEvent;
  39017. /**
  39018. * Attach the input controls to a specific dom element to get the input from.
  39019. * @param element Defines the element the controls should be listened from
  39020. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39021. */
  39022. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39023. /**
  39024. * Detach the current controls from the specified dom element.
  39025. * @param element Defines the element to stop listening the inputs from
  39026. */
  39027. detachControl(element: Nullable<HTMLElement>): void;
  39028. /**
  39029. * Gets the class name of the current intput.
  39030. * @returns the class name
  39031. */
  39032. getClassName(): string;
  39033. /**
  39034. * Get the friendly name associated with the input class.
  39035. * @returns the input friendly name
  39036. */
  39037. getSimpleName(): string;
  39038. }
  39039. }
  39040. declare module BABYLON {
  39041. /**
  39042. * Default Inputs manager for the ArcRotateCamera.
  39043. * It groups all the default supported inputs for ease of use.
  39044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39045. */
  39046. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39047. /**
  39048. * Instantiates a new ArcRotateCameraInputsManager.
  39049. * @param camera Defines the camera the inputs belong to
  39050. */
  39051. constructor(camera: ArcRotateCamera);
  39052. /**
  39053. * Add mouse wheel input support to the input manager.
  39054. * @returns the current input manager
  39055. */
  39056. addMouseWheel(): ArcRotateCameraInputsManager;
  39057. /**
  39058. * Add pointers input support to the input manager.
  39059. * @returns the current input manager
  39060. */
  39061. addPointers(): ArcRotateCameraInputsManager;
  39062. /**
  39063. * Add keyboard input support to the input manager.
  39064. * @returns the current input manager
  39065. */
  39066. addKeyboard(): ArcRotateCameraInputsManager;
  39067. }
  39068. }
  39069. declare module BABYLON {
  39070. /**
  39071. * This represents an orbital type of camera.
  39072. *
  39073. * 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.
  39074. * 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.
  39075. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39076. */
  39077. export class ArcRotateCamera extends TargetCamera {
  39078. /**
  39079. * Defines the rotation angle of the camera along the longitudinal axis.
  39080. */
  39081. alpha: number;
  39082. /**
  39083. * Defines the rotation angle of the camera along the latitudinal axis.
  39084. */
  39085. beta: number;
  39086. /**
  39087. * Defines the radius of the camera from it s target point.
  39088. */
  39089. radius: number;
  39090. protected _target: Vector3;
  39091. protected _targetHost: Nullable<AbstractMesh>;
  39092. /**
  39093. * Defines the target point of the camera.
  39094. * The camera looks towards it form the radius distance.
  39095. */
  39096. get target(): Vector3;
  39097. set target(value: Vector3);
  39098. /**
  39099. * Define the current local position of the camera in the scene
  39100. */
  39101. get position(): Vector3;
  39102. set position(newPosition: Vector3);
  39103. protected _upVector: Vector3;
  39104. protected _upToYMatrix: Matrix;
  39105. protected _YToUpMatrix: Matrix;
  39106. /**
  39107. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39108. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39109. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39110. */
  39111. set upVector(vec: Vector3);
  39112. get upVector(): Vector3;
  39113. /**
  39114. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39115. */
  39116. setMatUp(): void;
  39117. /**
  39118. * Current inertia value on the longitudinal axis.
  39119. * The bigger this number the longer it will take for the camera to stop.
  39120. */
  39121. inertialAlphaOffset: number;
  39122. /**
  39123. * Current inertia value on the latitudinal axis.
  39124. * The bigger this number the longer it will take for the camera to stop.
  39125. */
  39126. inertialBetaOffset: number;
  39127. /**
  39128. * Current inertia value on the radius axis.
  39129. * The bigger this number the longer it will take for the camera to stop.
  39130. */
  39131. inertialRadiusOffset: number;
  39132. /**
  39133. * Minimum allowed angle on the longitudinal axis.
  39134. * This can help limiting how the Camera is able to move in the scene.
  39135. */
  39136. lowerAlphaLimit: Nullable<number>;
  39137. /**
  39138. * Maximum allowed angle on the longitudinal axis.
  39139. * This can help limiting how the Camera is able to move in the scene.
  39140. */
  39141. upperAlphaLimit: Nullable<number>;
  39142. /**
  39143. * Minimum allowed angle on the latitudinal axis.
  39144. * This can help limiting how the Camera is able to move in the scene.
  39145. */
  39146. lowerBetaLimit: number;
  39147. /**
  39148. * Maximum allowed angle on the latitudinal axis.
  39149. * This can help limiting how the Camera is able to move in the scene.
  39150. */
  39151. upperBetaLimit: number;
  39152. /**
  39153. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39154. * This can help limiting how the Camera is able to move in the scene.
  39155. */
  39156. lowerRadiusLimit: Nullable<number>;
  39157. /**
  39158. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39159. * This can help limiting how the Camera is able to move in the scene.
  39160. */
  39161. upperRadiusLimit: Nullable<number>;
  39162. /**
  39163. * Defines the current inertia value used during panning of the camera along the X axis.
  39164. */
  39165. inertialPanningX: number;
  39166. /**
  39167. * Defines the current inertia value used during panning of the camera along the Y axis.
  39168. */
  39169. inertialPanningY: number;
  39170. /**
  39171. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39172. * Basically if your fingers moves away from more than this distance you will be considered
  39173. * in pinch mode.
  39174. */
  39175. pinchToPanMaxDistance: number;
  39176. /**
  39177. * Defines the maximum distance the camera can pan.
  39178. * This could help keeping the cammera always in your scene.
  39179. */
  39180. panningDistanceLimit: Nullable<number>;
  39181. /**
  39182. * Defines the target of the camera before paning.
  39183. */
  39184. panningOriginTarget: Vector3;
  39185. /**
  39186. * Defines the value of the inertia used during panning.
  39187. * 0 would mean stop inertia and one would mean no decelleration at all.
  39188. */
  39189. panningInertia: number;
  39190. /**
  39191. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39192. */
  39193. get angularSensibilityX(): number;
  39194. set angularSensibilityX(value: number);
  39195. /**
  39196. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39197. */
  39198. get angularSensibilityY(): number;
  39199. set angularSensibilityY(value: number);
  39200. /**
  39201. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39202. */
  39203. get pinchPrecision(): number;
  39204. set pinchPrecision(value: number);
  39205. /**
  39206. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39207. * It will be used instead of pinchDeltaPrecision if different from 0.
  39208. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39209. */
  39210. get pinchDeltaPercentage(): number;
  39211. set pinchDeltaPercentage(value: number);
  39212. /**
  39213. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39214. * and pinch delta percentage.
  39215. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39216. * that any object in the plane at the camera's target point will scale
  39217. * perfectly with finger motion.
  39218. */
  39219. get useNaturalPinchZoom(): boolean;
  39220. set useNaturalPinchZoom(value: boolean);
  39221. /**
  39222. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39223. */
  39224. get panningSensibility(): number;
  39225. set panningSensibility(value: number);
  39226. /**
  39227. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39228. */
  39229. get keysUp(): number[];
  39230. set keysUp(value: number[]);
  39231. /**
  39232. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39233. */
  39234. get keysDown(): number[];
  39235. set keysDown(value: number[]);
  39236. /**
  39237. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39238. */
  39239. get keysLeft(): number[];
  39240. set keysLeft(value: number[]);
  39241. /**
  39242. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39243. */
  39244. get keysRight(): number[];
  39245. set keysRight(value: number[]);
  39246. /**
  39247. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39248. */
  39249. get wheelPrecision(): number;
  39250. set wheelPrecision(value: number);
  39251. /**
  39252. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39253. * It will be used instead of pinchDeltaPrecision if different from 0.
  39254. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39255. */
  39256. get wheelDeltaPercentage(): number;
  39257. set wheelDeltaPercentage(value: number);
  39258. /**
  39259. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39260. */
  39261. zoomOnFactor: number;
  39262. /**
  39263. * Defines a screen offset for the camera position.
  39264. */
  39265. targetScreenOffset: Vector2;
  39266. /**
  39267. * Allows the camera to be completely reversed.
  39268. * If false the camera can not arrive upside down.
  39269. */
  39270. allowUpsideDown: boolean;
  39271. /**
  39272. * Define if double tap/click is used to restore the previously saved state of the camera.
  39273. */
  39274. useInputToRestoreState: boolean;
  39275. /** @hidden */
  39276. _viewMatrix: Matrix;
  39277. /** @hidden */
  39278. _useCtrlForPanning: boolean;
  39279. /** @hidden */
  39280. _panningMouseButton: number;
  39281. /**
  39282. * Defines the input associated to the camera.
  39283. */
  39284. inputs: ArcRotateCameraInputsManager;
  39285. /** @hidden */
  39286. _reset: () => void;
  39287. /**
  39288. * Defines the allowed panning axis.
  39289. */
  39290. panningAxis: Vector3;
  39291. protected _localDirection: Vector3;
  39292. protected _transformedDirection: Vector3;
  39293. private _bouncingBehavior;
  39294. /**
  39295. * Gets the bouncing behavior of the camera if it has been enabled.
  39296. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39297. */
  39298. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39299. /**
  39300. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39301. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39302. */
  39303. get useBouncingBehavior(): boolean;
  39304. set useBouncingBehavior(value: boolean);
  39305. private _framingBehavior;
  39306. /**
  39307. * Gets the framing behavior of the camera if it has been enabled.
  39308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39309. */
  39310. get framingBehavior(): Nullable<FramingBehavior>;
  39311. /**
  39312. * Defines if the framing behavior of the camera is enabled on the camera.
  39313. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39314. */
  39315. get useFramingBehavior(): boolean;
  39316. set useFramingBehavior(value: boolean);
  39317. private _autoRotationBehavior;
  39318. /**
  39319. * Gets the auto rotation behavior of the camera if it has been enabled.
  39320. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39321. */
  39322. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39323. /**
  39324. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39325. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39326. */
  39327. get useAutoRotationBehavior(): boolean;
  39328. set useAutoRotationBehavior(value: boolean);
  39329. /**
  39330. * Observable triggered when the mesh target has been changed on the camera.
  39331. */
  39332. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39333. /**
  39334. * Event raised when the camera is colliding with a mesh.
  39335. */
  39336. onCollide: (collidedMesh: AbstractMesh) => void;
  39337. /**
  39338. * Defines whether the camera should check collision with the objects oh the scene.
  39339. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39340. */
  39341. checkCollisions: boolean;
  39342. /**
  39343. * Defines the collision radius of the camera.
  39344. * This simulates a sphere around the camera.
  39345. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39346. */
  39347. collisionRadius: Vector3;
  39348. protected _collider: Collider;
  39349. protected _previousPosition: Vector3;
  39350. protected _collisionVelocity: Vector3;
  39351. protected _newPosition: Vector3;
  39352. protected _previousAlpha: number;
  39353. protected _previousBeta: number;
  39354. protected _previousRadius: number;
  39355. protected _collisionTriggered: boolean;
  39356. protected _targetBoundingCenter: Nullable<Vector3>;
  39357. private _computationVector;
  39358. /**
  39359. * Instantiates a new ArcRotateCamera in a given scene
  39360. * @param name Defines the name of the camera
  39361. * @param alpha Defines the camera rotation along the logitudinal axis
  39362. * @param beta Defines the camera rotation along the latitudinal axis
  39363. * @param radius Defines the camera distance from its target
  39364. * @param target Defines the camera target
  39365. * @param scene Defines the scene the camera belongs to
  39366. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39367. */
  39368. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39369. /** @hidden */
  39370. _initCache(): void;
  39371. /** @hidden */
  39372. _updateCache(ignoreParentClass?: boolean): void;
  39373. protected _getTargetPosition(): Vector3;
  39374. private _storedAlpha;
  39375. private _storedBeta;
  39376. private _storedRadius;
  39377. private _storedTarget;
  39378. private _storedTargetScreenOffset;
  39379. /**
  39380. * Stores the current state of the camera (alpha, beta, radius and target)
  39381. * @returns the camera itself
  39382. */
  39383. storeState(): Camera;
  39384. /**
  39385. * @hidden
  39386. * Restored camera state. You must call storeState() first
  39387. */
  39388. _restoreStateValues(): boolean;
  39389. /** @hidden */
  39390. _isSynchronizedViewMatrix(): boolean;
  39391. /**
  39392. * Attached controls to the current camera.
  39393. * @param element Defines the element the controls should be listened from
  39394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39395. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39396. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39397. */
  39398. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39399. /**
  39400. * Detach the current controls from the camera.
  39401. * The camera will stop reacting to inputs.
  39402. * @param element Defines the element to stop listening the inputs from
  39403. */
  39404. detachControl(element: HTMLElement): void;
  39405. /** @hidden */
  39406. _checkInputs(): void;
  39407. protected _checkLimits(): void;
  39408. /**
  39409. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39410. */
  39411. rebuildAnglesAndRadius(): void;
  39412. /**
  39413. * Use a position to define the current camera related information like alpha, beta and radius
  39414. * @param position Defines the position to set the camera at
  39415. */
  39416. setPosition(position: Vector3): void;
  39417. /**
  39418. * Defines the target the camera should look at.
  39419. * This will automatically adapt alpha beta and radius to fit within the new target.
  39420. * @param target Defines the new target as a Vector or a mesh
  39421. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39422. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39423. */
  39424. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39425. /** @hidden */
  39426. _getViewMatrix(): Matrix;
  39427. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39428. /**
  39429. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39430. * @param meshes Defines the mesh to zoom on
  39431. * @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)
  39432. */
  39433. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39434. /**
  39435. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39436. * The target will be changed but the radius
  39437. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39438. * @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)
  39439. */
  39440. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39441. min: Vector3;
  39442. max: Vector3;
  39443. distance: number;
  39444. }, doNotUpdateMaxZ?: boolean): void;
  39445. /**
  39446. * @override
  39447. * Override Camera.createRigCamera
  39448. */
  39449. createRigCamera(name: string, cameraIndex: number): Camera;
  39450. /**
  39451. * @hidden
  39452. * @override
  39453. * Override Camera._updateRigCameras
  39454. */
  39455. _updateRigCameras(): void;
  39456. /**
  39457. * Destroy the camera and release the current resources hold by it.
  39458. */
  39459. dispose(): void;
  39460. /**
  39461. * Gets the current object class name.
  39462. * @return the class name
  39463. */
  39464. getClassName(): string;
  39465. }
  39466. }
  39467. declare module BABYLON {
  39468. /**
  39469. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39470. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39471. */
  39472. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39473. /**
  39474. * Gets the name of the behavior.
  39475. */
  39476. get name(): string;
  39477. private _zoomStopsAnimation;
  39478. private _idleRotationSpeed;
  39479. private _idleRotationWaitTime;
  39480. private _idleRotationSpinupTime;
  39481. /**
  39482. * Sets the flag that indicates if user zooming should stop animation.
  39483. */
  39484. set zoomStopsAnimation(flag: boolean);
  39485. /**
  39486. * Gets the flag that indicates if user zooming should stop animation.
  39487. */
  39488. get zoomStopsAnimation(): boolean;
  39489. /**
  39490. * Sets the default speed at which the camera rotates around the model.
  39491. */
  39492. set idleRotationSpeed(speed: number);
  39493. /**
  39494. * Gets the default speed at which the camera rotates around the model.
  39495. */
  39496. get idleRotationSpeed(): number;
  39497. /**
  39498. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39499. */
  39500. set idleRotationWaitTime(time: number);
  39501. /**
  39502. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39503. */
  39504. get idleRotationWaitTime(): number;
  39505. /**
  39506. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39507. */
  39508. set idleRotationSpinupTime(time: number);
  39509. /**
  39510. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39511. */
  39512. get idleRotationSpinupTime(): number;
  39513. /**
  39514. * Gets a value indicating if the camera is currently rotating because of this behavior
  39515. */
  39516. get rotationInProgress(): boolean;
  39517. private _onPrePointerObservableObserver;
  39518. private _onAfterCheckInputsObserver;
  39519. private _attachedCamera;
  39520. private _isPointerDown;
  39521. private _lastFrameTime;
  39522. private _lastInteractionTime;
  39523. private _cameraRotationSpeed;
  39524. /**
  39525. * Initializes the behavior.
  39526. */
  39527. init(): void;
  39528. /**
  39529. * Attaches the behavior to its arc rotate camera.
  39530. * @param camera Defines the camera to attach the behavior to
  39531. */
  39532. attach(camera: ArcRotateCamera): void;
  39533. /**
  39534. * Detaches the behavior from its current arc rotate camera.
  39535. */
  39536. detach(): void;
  39537. /**
  39538. * Returns true if user is scrolling.
  39539. * @return true if user is scrolling.
  39540. */
  39541. private _userIsZooming;
  39542. private _lastFrameRadius;
  39543. private _shouldAnimationStopForInteraction;
  39544. /**
  39545. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39546. */
  39547. private _applyUserInteraction;
  39548. private _userIsMoving;
  39549. }
  39550. }
  39551. declare module BABYLON {
  39552. /**
  39553. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39554. */
  39555. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39556. private ui;
  39557. /**
  39558. * The name of the behavior
  39559. */
  39560. name: string;
  39561. /**
  39562. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39563. */
  39564. distanceAwayFromFace: number;
  39565. /**
  39566. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39567. */
  39568. distanceAwayFromBottomOfFace: number;
  39569. private _faceVectors;
  39570. private _target;
  39571. private _scene;
  39572. private _onRenderObserver;
  39573. private _tmpMatrix;
  39574. private _tmpVector;
  39575. /**
  39576. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39577. * @param ui The transform node that should be attched to the mesh
  39578. */
  39579. constructor(ui: TransformNode);
  39580. /**
  39581. * Initializes the behavior
  39582. */
  39583. init(): void;
  39584. private _closestFace;
  39585. private _zeroVector;
  39586. private _lookAtTmpMatrix;
  39587. private _lookAtToRef;
  39588. /**
  39589. * Attaches the AttachToBoxBehavior to the passed in mesh
  39590. * @param target The mesh that the specified node will be attached to
  39591. */
  39592. attach(target: Mesh): void;
  39593. /**
  39594. * Detaches the behavior from the mesh
  39595. */
  39596. detach(): void;
  39597. }
  39598. }
  39599. declare module BABYLON {
  39600. /**
  39601. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39602. */
  39603. export class FadeInOutBehavior implements Behavior<Mesh> {
  39604. /**
  39605. * Time in milliseconds to delay before fading in (Default: 0)
  39606. */
  39607. delay: number;
  39608. /**
  39609. * Time in milliseconds for the mesh to fade in (Default: 300)
  39610. */
  39611. fadeInTime: number;
  39612. private _millisecondsPerFrame;
  39613. private _hovered;
  39614. private _hoverValue;
  39615. private _ownerNode;
  39616. /**
  39617. * Instatiates the FadeInOutBehavior
  39618. */
  39619. constructor();
  39620. /**
  39621. * The name of the behavior
  39622. */
  39623. get name(): string;
  39624. /**
  39625. * Initializes the behavior
  39626. */
  39627. init(): void;
  39628. /**
  39629. * Attaches the fade behavior on the passed in mesh
  39630. * @param ownerNode The mesh that will be faded in/out once attached
  39631. */
  39632. attach(ownerNode: Mesh): void;
  39633. /**
  39634. * Detaches the behavior from the mesh
  39635. */
  39636. detach(): void;
  39637. /**
  39638. * Triggers the mesh to begin fading in or out
  39639. * @param value if the object should fade in or out (true to fade in)
  39640. */
  39641. fadeIn(value: boolean): void;
  39642. private _update;
  39643. private _setAllVisibility;
  39644. }
  39645. }
  39646. declare module BABYLON {
  39647. /**
  39648. * Class containing a set of static utilities functions for managing Pivots
  39649. * @hidden
  39650. */
  39651. export class PivotTools {
  39652. private static _PivotCached;
  39653. private static _OldPivotPoint;
  39654. private static _PivotTranslation;
  39655. private static _PivotTmpVector;
  39656. /** @hidden */
  39657. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39658. /** @hidden */
  39659. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39660. }
  39661. }
  39662. declare module BABYLON {
  39663. /**
  39664. * Class containing static functions to help procedurally build meshes
  39665. */
  39666. export class PlaneBuilder {
  39667. /**
  39668. * Creates a plane mesh
  39669. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39670. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39671. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39673. * * 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
  39674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39675. * @param name defines the name of the mesh
  39676. * @param options defines the options used to create the mesh
  39677. * @param scene defines the hosting scene
  39678. * @returns the plane mesh
  39679. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39680. */
  39681. static CreatePlane(name: string, options: {
  39682. size?: number;
  39683. width?: number;
  39684. height?: number;
  39685. sideOrientation?: number;
  39686. frontUVs?: Vector4;
  39687. backUVs?: Vector4;
  39688. updatable?: boolean;
  39689. sourcePlane?: Plane;
  39690. }, scene?: Nullable<Scene>): Mesh;
  39691. }
  39692. }
  39693. declare module BABYLON {
  39694. /**
  39695. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39696. */
  39697. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39698. private static _AnyMouseID;
  39699. /**
  39700. * Abstract mesh the behavior is set on
  39701. */
  39702. attachedNode: AbstractMesh;
  39703. private _dragPlane;
  39704. private _scene;
  39705. private _pointerObserver;
  39706. private _beforeRenderObserver;
  39707. private static _planeScene;
  39708. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39709. /**
  39710. * 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)
  39711. */
  39712. maxDragAngle: number;
  39713. /**
  39714. * @hidden
  39715. */
  39716. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39717. /**
  39718. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39719. */
  39720. currentDraggingPointerID: number;
  39721. /**
  39722. * The last position where the pointer hit the drag plane in world space
  39723. */
  39724. lastDragPosition: Vector3;
  39725. /**
  39726. * If the behavior is currently in a dragging state
  39727. */
  39728. dragging: boolean;
  39729. /**
  39730. * 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)
  39731. */
  39732. dragDeltaRatio: number;
  39733. /**
  39734. * If the drag plane orientation should be updated during the dragging (Default: true)
  39735. */
  39736. updateDragPlane: boolean;
  39737. private _debugMode;
  39738. private _moving;
  39739. /**
  39740. * Fires each time the attached mesh is dragged with the pointer
  39741. * * delta between last drag position and current drag position in world space
  39742. * * dragDistance along the drag axis
  39743. * * dragPlaneNormal normal of the current drag plane used during the drag
  39744. * * dragPlanePoint in world space where the drag intersects the drag plane
  39745. */
  39746. onDragObservable: Observable<{
  39747. delta: Vector3;
  39748. dragPlanePoint: Vector3;
  39749. dragPlaneNormal: Vector3;
  39750. dragDistance: number;
  39751. pointerId: number;
  39752. }>;
  39753. /**
  39754. * Fires each time a drag begins (eg. mouse down on mesh)
  39755. */
  39756. onDragStartObservable: Observable<{
  39757. dragPlanePoint: Vector3;
  39758. pointerId: number;
  39759. }>;
  39760. /**
  39761. * Fires each time a drag ends (eg. mouse release after drag)
  39762. */
  39763. onDragEndObservable: Observable<{
  39764. dragPlanePoint: Vector3;
  39765. pointerId: number;
  39766. }>;
  39767. /**
  39768. * If the attached mesh should be moved when dragged
  39769. */
  39770. moveAttached: boolean;
  39771. /**
  39772. * If the drag behavior will react to drag events (Default: true)
  39773. */
  39774. enabled: boolean;
  39775. /**
  39776. * If pointer events should start and release the drag (Default: true)
  39777. */
  39778. startAndReleaseDragOnPointerEvents: boolean;
  39779. /**
  39780. * If camera controls should be detached during the drag
  39781. */
  39782. detachCameraControls: boolean;
  39783. /**
  39784. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39785. */
  39786. useObjectOrientationForDragging: boolean;
  39787. private _options;
  39788. /**
  39789. * Gets the options used by the behavior
  39790. */
  39791. get options(): {
  39792. dragAxis?: Vector3;
  39793. dragPlaneNormal?: Vector3;
  39794. };
  39795. /**
  39796. * Sets the options used by the behavior
  39797. */
  39798. set options(options: {
  39799. dragAxis?: Vector3;
  39800. dragPlaneNormal?: Vector3;
  39801. });
  39802. /**
  39803. * Creates a pointer drag behavior that can be attached to a mesh
  39804. * @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)
  39805. */
  39806. constructor(options?: {
  39807. dragAxis?: Vector3;
  39808. dragPlaneNormal?: Vector3;
  39809. });
  39810. /**
  39811. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39812. */
  39813. validateDrag: (targetPosition: Vector3) => boolean;
  39814. /**
  39815. * The name of the behavior
  39816. */
  39817. get name(): string;
  39818. /**
  39819. * Initializes the behavior
  39820. */
  39821. init(): void;
  39822. private _tmpVector;
  39823. private _alternatePickedPoint;
  39824. private _worldDragAxis;
  39825. private _targetPosition;
  39826. private _attachedElement;
  39827. /**
  39828. * Attaches the drag behavior the passed in mesh
  39829. * @param ownerNode The mesh that will be dragged around once attached
  39830. * @param predicate Predicate to use for pick filtering
  39831. */
  39832. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39833. /**
  39834. * Force relase the drag action by code.
  39835. */
  39836. releaseDrag(): void;
  39837. private _startDragRay;
  39838. private _lastPointerRay;
  39839. /**
  39840. * Simulates the start of a pointer drag event on the behavior
  39841. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39842. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39843. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39844. */
  39845. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39846. private _startDrag;
  39847. private _dragDelta;
  39848. private _moveDrag;
  39849. private _pickWithRayOnDragPlane;
  39850. private _pointA;
  39851. private _pointB;
  39852. private _pointC;
  39853. private _lineA;
  39854. private _lineB;
  39855. private _localAxis;
  39856. private _lookAt;
  39857. private _updateDragPlanePosition;
  39858. /**
  39859. * Detaches the behavior from the mesh
  39860. */
  39861. detach(): void;
  39862. }
  39863. }
  39864. declare module BABYLON {
  39865. /**
  39866. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39867. */
  39868. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39869. private _dragBehaviorA;
  39870. private _dragBehaviorB;
  39871. private _startDistance;
  39872. private _initialScale;
  39873. private _targetScale;
  39874. private _ownerNode;
  39875. private _sceneRenderObserver;
  39876. /**
  39877. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39878. */
  39879. constructor();
  39880. /**
  39881. * The name of the behavior
  39882. */
  39883. get name(): string;
  39884. /**
  39885. * Initializes the behavior
  39886. */
  39887. init(): void;
  39888. private _getCurrentDistance;
  39889. /**
  39890. * Attaches the scale behavior the passed in mesh
  39891. * @param ownerNode The mesh that will be scaled around once attached
  39892. */
  39893. attach(ownerNode: Mesh): void;
  39894. /**
  39895. * Detaches the behavior from the mesh
  39896. */
  39897. detach(): void;
  39898. }
  39899. }
  39900. declare module BABYLON {
  39901. /**
  39902. * 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
  39903. */
  39904. export class SixDofDragBehavior implements Behavior<Mesh> {
  39905. private static _virtualScene;
  39906. private _ownerNode;
  39907. private _sceneRenderObserver;
  39908. private _scene;
  39909. private _targetPosition;
  39910. private _virtualOriginMesh;
  39911. private _virtualDragMesh;
  39912. private _pointerObserver;
  39913. private _moving;
  39914. private _startingOrientation;
  39915. private _attachedElement;
  39916. /**
  39917. * 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)
  39918. */
  39919. private zDragFactor;
  39920. /**
  39921. * If the object should rotate to face the drag origin
  39922. */
  39923. rotateDraggedObject: boolean;
  39924. /**
  39925. * If the behavior is currently in a dragging state
  39926. */
  39927. dragging: boolean;
  39928. /**
  39929. * 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)
  39930. */
  39931. dragDeltaRatio: number;
  39932. /**
  39933. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39934. */
  39935. currentDraggingPointerID: number;
  39936. /**
  39937. * If camera controls should be detached during the drag
  39938. */
  39939. detachCameraControls: boolean;
  39940. /**
  39941. * Fires each time a drag starts
  39942. */
  39943. onDragStartObservable: Observable<{}>;
  39944. /**
  39945. * Fires each time a drag ends (eg. mouse release after drag)
  39946. */
  39947. onDragEndObservable: Observable<{}>;
  39948. /**
  39949. * 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
  39950. */
  39951. constructor();
  39952. /**
  39953. * The name of the behavior
  39954. */
  39955. get name(): string;
  39956. /**
  39957. * Initializes the behavior
  39958. */
  39959. init(): void;
  39960. /**
  39961. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39962. */
  39963. private get _pointerCamera();
  39964. /**
  39965. * Attaches the scale behavior the passed in mesh
  39966. * @param ownerNode The mesh that will be scaled around once attached
  39967. */
  39968. attach(ownerNode: Mesh): void;
  39969. /**
  39970. * Detaches the behavior from the mesh
  39971. */
  39972. detach(): void;
  39973. }
  39974. }
  39975. declare module BABYLON {
  39976. /**
  39977. * Class used to apply inverse kinematics to bones
  39978. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39979. */
  39980. export class BoneIKController {
  39981. private static _tmpVecs;
  39982. private static _tmpQuat;
  39983. private static _tmpMats;
  39984. /**
  39985. * Gets or sets the target mesh
  39986. */
  39987. targetMesh: AbstractMesh;
  39988. /** Gets or sets the mesh used as pole */
  39989. poleTargetMesh: AbstractMesh;
  39990. /**
  39991. * Gets or sets the bone used as pole
  39992. */
  39993. poleTargetBone: Nullable<Bone>;
  39994. /**
  39995. * Gets or sets the target position
  39996. */
  39997. targetPosition: Vector3;
  39998. /**
  39999. * Gets or sets the pole target position
  40000. */
  40001. poleTargetPosition: Vector3;
  40002. /**
  40003. * Gets or sets the pole target local offset
  40004. */
  40005. poleTargetLocalOffset: Vector3;
  40006. /**
  40007. * Gets or sets the pole angle
  40008. */
  40009. poleAngle: number;
  40010. /**
  40011. * Gets or sets the mesh associated with the controller
  40012. */
  40013. mesh: AbstractMesh;
  40014. /**
  40015. * 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)
  40016. */
  40017. slerpAmount: number;
  40018. private _bone1Quat;
  40019. private _bone1Mat;
  40020. private _bone2Ang;
  40021. private _bone1;
  40022. private _bone2;
  40023. private _bone1Length;
  40024. private _bone2Length;
  40025. private _maxAngle;
  40026. private _maxReach;
  40027. private _rightHandedSystem;
  40028. private _bendAxis;
  40029. private _slerping;
  40030. private _adjustRoll;
  40031. /**
  40032. * Gets or sets maximum allowed angle
  40033. */
  40034. get maxAngle(): number;
  40035. set maxAngle(value: number);
  40036. /**
  40037. * Creates a new BoneIKController
  40038. * @param mesh defines the mesh to control
  40039. * @param bone defines the bone to control
  40040. * @param options defines options to set up the controller
  40041. */
  40042. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40043. targetMesh?: AbstractMesh;
  40044. poleTargetMesh?: AbstractMesh;
  40045. poleTargetBone?: Bone;
  40046. poleTargetLocalOffset?: Vector3;
  40047. poleAngle?: number;
  40048. bendAxis?: Vector3;
  40049. maxAngle?: number;
  40050. slerpAmount?: number;
  40051. });
  40052. private _setMaxAngle;
  40053. /**
  40054. * Force the controller to update the bones
  40055. */
  40056. update(): void;
  40057. }
  40058. }
  40059. declare module BABYLON {
  40060. /**
  40061. * Class used to make a bone look toward a point in space
  40062. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40063. */
  40064. export class BoneLookController {
  40065. private static _tmpVecs;
  40066. private static _tmpQuat;
  40067. private static _tmpMats;
  40068. /**
  40069. * The target Vector3 that the bone will look at
  40070. */
  40071. target: Vector3;
  40072. /**
  40073. * The mesh that the bone is attached to
  40074. */
  40075. mesh: AbstractMesh;
  40076. /**
  40077. * The bone that will be looking to the target
  40078. */
  40079. bone: Bone;
  40080. /**
  40081. * The up axis of the coordinate system that is used when the bone is rotated
  40082. */
  40083. upAxis: Vector3;
  40084. /**
  40085. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40086. */
  40087. upAxisSpace: Space;
  40088. /**
  40089. * Used to make an adjustment to the yaw of the bone
  40090. */
  40091. adjustYaw: number;
  40092. /**
  40093. * Used to make an adjustment to the pitch of the bone
  40094. */
  40095. adjustPitch: number;
  40096. /**
  40097. * Used to make an adjustment to the roll of the bone
  40098. */
  40099. adjustRoll: number;
  40100. /**
  40101. * 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)
  40102. */
  40103. slerpAmount: number;
  40104. private _minYaw;
  40105. private _maxYaw;
  40106. private _minPitch;
  40107. private _maxPitch;
  40108. private _minYawSin;
  40109. private _minYawCos;
  40110. private _maxYawSin;
  40111. private _maxYawCos;
  40112. private _midYawConstraint;
  40113. private _minPitchTan;
  40114. private _maxPitchTan;
  40115. private _boneQuat;
  40116. private _slerping;
  40117. private _transformYawPitch;
  40118. private _transformYawPitchInv;
  40119. private _firstFrameSkipped;
  40120. private _yawRange;
  40121. private _fowardAxis;
  40122. /**
  40123. * Gets or sets the minimum yaw angle that the bone can look to
  40124. */
  40125. get minYaw(): number;
  40126. set minYaw(value: number);
  40127. /**
  40128. * Gets or sets the maximum yaw angle that the bone can look to
  40129. */
  40130. get maxYaw(): number;
  40131. set maxYaw(value: number);
  40132. /**
  40133. * Gets or sets the minimum pitch angle that the bone can look to
  40134. */
  40135. get minPitch(): number;
  40136. set minPitch(value: number);
  40137. /**
  40138. * Gets or sets the maximum pitch angle that the bone can look to
  40139. */
  40140. get maxPitch(): number;
  40141. set maxPitch(value: number);
  40142. /**
  40143. * Create a BoneLookController
  40144. * @param mesh the mesh that the bone belongs to
  40145. * @param bone the bone that will be looking to the target
  40146. * @param target the target Vector3 to look at
  40147. * @param options optional settings:
  40148. * * maxYaw: the maximum angle the bone will yaw to
  40149. * * minYaw: the minimum angle the bone will yaw to
  40150. * * maxPitch: the maximum angle the bone will pitch to
  40151. * * minPitch: the minimum angle the bone will yaw to
  40152. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40153. * * upAxis: the up axis of the coordinate system
  40154. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40155. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40156. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40157. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40158. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40159. * * adjustRoll: used to make an adjustment to the roll of the bone
  40160. **/
  40161. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40162. maxYaw?: number;
  40163. minYaw?: number;
  40164. maxPitch?: number;
  40165. minPitch?: number;
  40166. slerpAmount?: number;
  40167. upAxis?: Vector3;
  40168. upAxisSpace?: Space;
  40169. yawAxis?: Vector3;
  40170. pitchAxis?: Vector3;
  40171. adjustYaw?: number;
  40172. adjustPitch?: number;
  40173. adjustRoll?: number;
  40174. });
  40175. /**
  40176. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40177. */
  40178. update(): void;
  40179. private _getAngleDiff;
  40180. private _getAngleBetween;
  40181. private _isAngleBetween;
  40182. }
  40183. }
  40184. declare module BABYLON {
  40185. /**
  40186. * Manage the gamepad inputs to control an arc rotate camera.
  40187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40188. */
  40189. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40190. /**
  40191. * Defines the camera the input is attached to.
  40192. */
  40193. camera: ArcRotateCamera;
  40194. /**
  40195. * Defines the gamepad the input is gathering event from.
  40196. */
  40197. gamepad: Nullable<Gamepad>;
  40198. /**
  40199. * Defines the gamepad rotation sensiblity.
  40200. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40201. */
  40202. gamepadRotationSensibility: number;
  40203. /**
  40204. * Defines the gamepad move sensiblity.
  40205. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40206. */
  40207. gamepadMoveSensibility: number;
  40208. private _yAxisScale;
  40209. /**
  40210. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40211. */
  40212. get invertYAxis(): boolean;
  40213. set invertYAxis(value: boolean);
  40214. private _onGamepadConnectedObserver;
  40215. private _onGamepadDisconnectedObserver;
  40216. /**
  40217. * Attach the input controls to a specific dom element to get the input from.
  40218. * @param element Defines the element the controls should be listened from
  40219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40220. */
  40221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40222. /**
  40223. * Detach the current controls from the specified dom element.
  40224. * @param element Defines the element to stop listening the inputs from
  40225. */
  40226. detachControl(element: Nullable<HTMLElement>): void;
  40227. /**
  40228. * Update the current camera state depending on the inputs that have been used this frame.
  40229. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40230. */
  40231. checkInputs(): void;
  40232. /**
  40233. * Gets the class name of the current intput.
  40234. * @returns the class name
  40235. */
  40236. getClassName(): string;
  40237. /**
  40238. * Get the friendly name associated with the input class.
  40239. * @returns the input friendly name
  40240. */
  40241. getSimpleName(): string;
  40242. }
  40243. }
  40244. declare module BABYLON {
  40245. interface ArcRotateCameraInputsManager {
  40246. /**
  40247. * Add orientation input support to the input manager.
  40248. * @returns the current input manager
  40249. */
  40250. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40251. }
  40252. /**
  40253. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40255. */
  40256. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40257. /**
  40258. * Defines the camera the input is attached to.
  40259. */
  40260. camera: ArcRotateCamera;
  40261. /**
  40262. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40263. */
  40264. alphaCorrection: number;
  40265. /**
  40266. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40267. */
  40268. gammaCorrection: number;
  40269. private _alpha;
  40270. private _gamma;
  40271. private _dirty;
  40272. private _deviceOrientationHandler;
  40273. /**
  40274. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40275. */
  40276. constructor();
  40277. /**
  40278. * Attach the input controls to a specific dom element to get the input from.
  40279. * @param element Defines the element the controls should be listened from
  40280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40281. */
  40282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40283. /** @hidden */
  40284. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40285. /**
  40286. * Update the current camera state depending on the inputs that have been used this frame.
  40287. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40288. */
  40289. checkInputs(): void;
  40290. /**
  40291. * Detach the current controls from the specified dom element.
  40292. * @param element Defines the element to stop listening the inputs from
  40293. */
  40294. detachControl(element: Nullable<HTMLElement>): void;
  40295. /**
  40296. * Gets the class name of the current intput.
  40297. * @returns the class name
  40298. */
  40299. getClassName(): string;
  40300. /**
  40301. * Get the friendly name associated with the input class.
  40302. * @returns the input friendly name
  40303. */
  40304. getSimpleName(): string;
  40305. }
  40306. }
  40307. declare module BABYLON {
  40308. /**
  40309. * Listen to mouse events to control the camera.
  40310. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40311. */
  40312. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40313. /**
  40314. * Defines the camera the input is attached to.
  40315. */
  40316. camera: FlyCamera;
  40317. /**
  40318. * Defines if touch is enabled. (Default is true.)
  40319. */
  40320. touchEnabled: boolean;
  40321. /**
  40322. * Defines the buttons associated with the input to handle camera rotation.
  40323. */
  40324. buttons: number[];
  40325. /**
  40326. * Assign buttons for Yaw control.
  40327. */
  40328. buttonsYaw: number[];
  40329. /**
  40330. * Assign buttons for Pitch control.
  40331. */
  40332. buttonsPitch: number[];
  40333. /**
  40334. * Assign buttons for Roll control.
  40335. */
  40336. buttonsRoll: number[];
  40337. /**
  40338. * Detect if any button is being pressed while mouse is moved.
  40339. * -1 = Mouse locked.
  40340. * 0 = Left button.
  40341. * 1 = Middle Button.
  40342. * 2 = Right Button.
  40343. */
  40344. activeButton: number;
  40345. /**
  40346. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40347. * Higher values reduce its sensitivity.
  40348. */
  40349. angularSensibility: number;
  40350. private _mousemoveCallback;
  40351. private _observer;
  40352. private _rollObserver;
  40353. private previousPosition;
  40354. private noPreventDefault;
  40355. private element;
  40356. /**
  40357. * Listen to mouse events to control the camera.
  40358. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40360. */
  40361. constructor(touchEnabled?: boolean);
  40362. /**
  40363. * Attach the mouse control to the HTML DOM element.
  40364. * @param element Defines the element that listens to the input events.
  40365. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40366. */
  40367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40368. /**
  40369. * Detach the current controls from the specified dom element.
  40370. * @param element Defines the element to stop listening the inputs from
  40371. */
  40372. detachControl(element: Nullable<HTMLElement>): void;
  40373. /**
  40374. * Gets the class name of the current input.
  40375. * @returns the class name.
  40376. */
  40377. getClassName(): string;
  40378. /**
  40379. * Get the friendly name associated with the input class.
  40380. * @returns the input's friendly name.
  40381. */
  40382. getSimpleName(): string;
  40383. private _pointerInput;
  40384. private _onMouseMove;
  40385. /**
  40386. * Rotate camera by mouse offset.
  40387. */
  40388. private rotateCamera;
  40389. }
  40390. }
  40391. declare module BABYLON {
  40392. /**
  40393. * Default Inputs manager for the FlyCamera.
  40394. * It groups all the default supported inputs for ease of use.
  40395. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40396. */
  40397. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40398. /**
  40399. * Instantiates a new FlyCameraInputsManager.
  40400. * @param camera Defines the camera the inputs belong to.
  40401. */
  40402. constructor(camera: FlyCamera);
  40403. /**
  40404. * Add keyboard input support to the input manager.
  40405. * @returns the new FlyCameraKeyboardMoveInput().
  40406. */
  40407. addKeyboard(): FlyCameraInputsManager;
  40408. /**
  40409. * Add mouse input support to the input manager.
  40410. * @param touchEnabled Enable touch screen support.
  40411. * @returns the new FlyCameraMouseInput().
  40412. */
  40413. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40414. }
  40415. }
  40416. declare module BABYLON {
  40417. /**
  40418. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40419. * such as in a 3D Space Shooter or a Flight Simulator.
  40420. */
  40421. export class FlyCamera extends TargetCamera {
  40422. /**
  40423. * Define the collision ellipsoid of the camera.
  40424. * This is helpful for simulating a camera body, like a player's body.
  40425. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40426. */
  40427. ellipsoid: Vector3;
  40428. /**
  40429. * Define an offset for the position of the ellipsoid around the camera.
  40430. * This can be helpful if the camera is attached away from the player's body center,
  40431. * such as at its head.
  40432. */
  40433. ellipsoidOffset: Vector3;
  40434. /**
  40435. * Enable or disable collisions of the camera with the rest of the scene objects.
  40436. */
  40437. checkCollisions: boolean;
  40438. /**
  40439. * Enable or disable gravity on the camera.
  40440. */
  40441. applyGravity: boolean;
  40442. /**
  40443. * Define the current direction the camera is moving to.
  40444. */
  40445. cameraDirection: Vector3;
  40446. /**
  40447. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40448. * This overrides and empties cameraRotation.
  40449. */
  40450. rotationQuaternion: Quaternion;
  40451. /**
  40452. * Track Roll to maintain the wanted Rolling when looking around.
  40453. */
  40454. _trackRoll: number;
  40455. /**
  40456. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40457. */
  40458. rollCorrect: number;
  40459. /**
  40460. * Mimic a banked turn, Rolling the camera when Yawing.
  40461. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40462. */
  40463. bankedTurn: boolean;
  40464. /**
  40465. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40466. */
  40467. bankedTurnLimit: number;
  40468. /**
  40469. * Value of 0 disables the banked Roll.
  40470. * Value of 1 is equal to the Yaw angle in radians.
  40471. */
  40472. bankedTurnMultiplier: number;
  40473. /**
  40474. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40475. */
  40476. inputs: FlyCameraInputsManager;
  40477. /**
  40478. * Gets the input sensibility for mouse input.
  40479. * Higher values reduce sensitivity.
  40480. */
  40481. get angularSensibility(): number;
  40482. /**
  40483. * Sets the input sensibility for a mouse input.
  40484. * Higher values reduce sensitivity.
  40485. */
  40486. set angularSensibility(value: number);
  40487. /**
  40488. * Get the keys for camera movement forward.
  40489. */
  40490. get keysForward(): number[];
  40491. /**
  40492. * Set the keys for camera movement forward.
  40493. */
  40494. set keysForward(value: number[]);
  40495. /**
  40496. * Get the keys for camera movement backward.
  40497. */
  40498. get keysBackward(): number[];
  40499. set keysBackward(value: number[]);
  40500. /**
  40501. * Get the keys for camera movement up.
  40502. */
  40503. get keysUp(): number[];
  40504. /**
  40505. * Set the keys for camera movement up.
  40506. */
  40507. set keysUp(value: number[]);
  40508. /**
  40509. * Get the keys for camera movement down.
  40510. */
  40511. get keysDown(): number[];
  40512. /**
  40513. * Set the keys for camera movement down.
  40514. */
  40515. set keysDown(value: number[]);
  40516. /**
  40517. * Get the keys for camera movement left.
  40518. */
  40519. get keysLeft(): number[];
  40520. /**
  40521. * Set the keys for camera movement left.
  40522. */
  40523. set keysLeft(value: number[]);
  40524. /**
  40525. * Set the keys for camera movement right.
  40526. */
  40527. get keysRight(): number[];
  40528. /**
  40529. * Set the keys for camera movement right.
  40530. */
  40531. set keysRight(value: number[]);
  40532. /**
  40533. * Event raised when the camera collides with a mesh in the scene.
  40534. */
  40535. onCollide: (collidedMesh: AbstractMesh) => void;
  40536. private _collider;
  40537. private _needMoveForGravity;
  40538. private _oldPosition;
  40539. private _diffPosition;
  40540. private _newPosition;
  40541. /** @hidden */
  40542. _localDirection: Vector3;
  40543. /** @hidden */
  40544. _transformedDirection: Vector3;
  40545. /**
  40546. * Instantiates a FlyCamera.
  40547. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40548. * such as in a 3D Space Shooter or a Flight Simulator.
  40549. * @param name Define the name of the camera in the scene.
  40550. * @param position Define the starting position of the camera in the scene.
  40551. * @param scene Define the scene the camera belongs to.
  40552. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40553. */
  40554. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40555. /**
  40556. * Attach a control to the HTML DOM element.
  40557. * @param element Defines the element that listens to the input events.
  40558. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40559. */
  40560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40561. /**
  40562. * Detach a control from the HTML DOM element.
  40563. * The camera will stop reacting to that input.
  40564. * @param element Defines the element that listens to the input events.
  40565. */
  40566. detachControl(element: HTMLElement): void;
  40567. private _collisionMask;
  40568. /**
  40569. * Get the mask that the camera ignores in collision events.
  40570. */
  40571. get collisionMask(): number;
  40572. /**
  40573. * Set the mask that the camera ignores in collision events.
  40574. */
  40575. set collisionMask(mask: number);
  40576. /** @hidden */
  40577. _collideWithWorld(displacement: Vector3): void;
  40578. /** @hidden */
  40579. private _onCollisionPositionChange;
  40580. /** @hidden */
  40581. _checkInputs(): void;
  40582. /** @hidden */
  40583. _decideIfNeedsToMove(): boolean;
  40584. /** @hidden */
  40585. _updatePosition(): void;
  40586. /**
  40587. * Restore the Roll to its target value at the rate specified.
  40588. * @param rate - Higher means slower restoring.
  40589. * @hidden
  40590. */
  40591. restoreRoll(rate: number): void;
  40592. /**
  40593. * Destroy the camera and release the current resources held by it.
  40594. */
  40595. dispose(): void;
  40596. /**
  40597. * Get the current object class name.
  40598. * @returns the class name.
  40599. */
  40600. getClassName(): string;
  40601. }
  40602. }
  40603. declare module BABYLON {
  40604. /**
  40605. * Listen to keyboard events to control the camera.
  40606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40607. */
  40608. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40609. /**
  40610. * Defines the camera the input is attached to.
  40611. */
  40612. camera: FlyCamera;
  40613. /**
  40614. * The list of keyboard keys used to control the forward move of the camera.
  40615. */
  40616. keysForward: number[];
  40617. /**
  40618. * The list of keyboard keys used to control the backward move of the camera.
  40619. */
  40620. keysBackward: number[];
  40621. /**
  40622. * The list of keyboard keys used to control the forward move of the camera.
  40623. */
  40624. keysUp: number[];
  40625. /**
  40626. * The list of keyboard keys used to control the backward move of the camera.
  40627. */
  40628. keysDown: number[];
  40629. /**
  40630. * The list of keyboard keys used to control the right strafe move of the camera.
  40631. */
  40632. keysRight: number[];
  40633. /**
  40634. * The list of keyboard keys used to control the left strafe move of the camera.
  40635. */
  40636. keysLeft: number[];
  40637. private _keys;
  40638. private _onCanvasBlurObserver;
  40639. private _onKeyboardObserver;
  40640. private _engine;
  40641. private _scene;
  40642. /**
  40643. * Attach the input controls to a specific dom element to get the input from.
  40644. * @param element Defines the element the controls should be listened from
  40645. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40646. */
  40647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40648. /**
  40649. * Detach the current controls from the specified dom element.
  40650. * @param element Defines the element to stop listening the inputs from
  40651. */
  40652. detachControl(element: Nullable<HTMLElement>): void;
  40653. /**
  40654. * Gets the class name of the current intput.
  40655. * @returns the class name
  40656. */
  40657. getClassName(): string;
  40658. /** @hidden */
  40659. _onLostFocus(e: FocusEvent): void;
  40660. /**
  40661. * Get the friendly name associated with the input class.
  40662. * @returns the input friendly name
  40663. */
  40664. getSimpleName(): string;
  40665. /**
  40666. * Update the current camera state depending on the inputs that have been used this frame.
  40667. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40668. */
  40669. checkInputs(): void;
  40670. }
  40671. }
  40672. declare module BABYLON {
  40673. /**
  40674. * Manage the mouse wheel inputs to control a follow camera.
  40675. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40676. */
  40677. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40678. /**
  40679. * Defines the camera the input is attached to.
  40680. */
  40681. camera: FollowCamera;
  40682. /**
  40683. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40684. */
  40685. axisControlRadius: boolean;
  40686. /**
  40687. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40688. */
  40689. axisControlHeight: boolean;
  40690. /**
  40691. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40692. */
  40693. axisControlRotation: boolean;
  40694. /**
  40695. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40696. * relation to mouseWheel events.
  40697. */
  40698. wheelPrecision: number;
  40699. /**
  40700. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40701. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40702. */
  40703. wheelDeltaPercentage: number;
  40704. private _wheel;
  40705. private _observer;
  40706. /**
  40707. * Attach the input controls to a specific dom element to get the input from.
  40708. * @param element Defines the element the controls should be listened from
  40709. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40710. */
  40711. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40712. /**
  40713. * Detach the current controls from the specified dom element.
  40714. * @param element Defines the element to stop listening the inputs from
  40715. */
  40716. detachControl(element: Nullable<HTMLElement>): void;
  40717. /**
  40718. * Gets the class name of the current intput.
  40719. * @returns the class name
  40720. */
  40721. getClassName(): string;
  40722. /**
  40723. * Get the friendly name associated with the input class.
  40724. * @returns the input friendly name
  40725. */
  40726. getSimpleName(): string;
  40727. }
  40728. }
  40729. declare module BABYLON {
  40730. /**
  40731. * Manage the pointers inputs to control an follow camera.
  40732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40733. */
  40734. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40735. /**
  40736. * Defines the camera the input is attached to.
  40737. */
  40738. camera: FollowCamera;
  40739. /**
  40740. * Gets the class name of the current input.
  40741. * @returns the class name
  40742. */
  40743. getClassName(): string;
  40744. /**
  40745. * Defines the pointer angular sensibility along the X axis or how fast is
  40746. * the camera rotating.
  40747. * A negative number will reverse the axis direction.
  40748. */
  40749. angularSensibilityX: number;
  40750. /**
  40751. * Defines the pointer angular sensibility along the Y axis or how fast is
  40752. * the camera rotating.
  40753. * A negative number will reverse the axis direction.
  40754. */
  40755. angularSensibilityY: number;
  40756. /**
  40757. * Defines the pointer pinch precision or how fast is the camera zooming.
  40758. * A negative number will reverse the axis direction.
  40759. */
  40760. pinchPrecision: number;
  40761. /**
  40762. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40763. * from 0.
  40764. * It defines the percentage of current camera.radius to use as delta when
  40765. * pinch zoom is used.
  40766. */
  40767. pinchDeltaPercentage: number;
  40768. /**
  40769. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40770. */
  40771. axisXControlRadius: boolean;
  40772. /**
  40773. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40774. */
  40775. axisXControlHeight: boolean;
  40776. /**
  40777. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40778. */
  40779. axisXControlRotation: boolean;
  40780. /**
  40781. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40782. */
  40783. axisYControlRadius: boolean;
  40784. /**
  40785. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40786. */
  40787. axisYControlHeight: boolean;
  40788. /**
  40789. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40790. */
  40791. axisYControlRotation: boolean;
  40792. /**
  40793. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40794. */
  40795. axisPinchControlRadius: boolean;
  40796. /**
  40797. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40798. */
  40799. axisPinchControlHeight: boolean;
  40800. /**
  40801. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40802. */
  40803. axisPinchControlRotation: boolean;
  40804. /**
  40805. * Log error messages if basic misconfiguration has occurred.
  40806. */
  40807. warningEnable: boolean;
  40808. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40809. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40810. private _warningCounter;
  40811. private _warning;
  40812. }
  40813. }
  40814. declare module BABYLON {
  40815. /**
  40816. * Default Inputs manager for the FollowCamera.
  40817. * It groups all the default supported inputs for ease of use.
  40818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40819. */
  40820. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40821. /**
  40822. * Instantiates a new FollowCameraInputsManager.
  40823. * @param camera Defines the camera the inputs belong to
  40824. */
  40825. constructor(camera: FollowCamera);
  40826. /**
  40827. * Add keyboard input support to the input manager.
  40828. * @returns the current input manager
  40829. */
  40830. addKeyboard(): FollowCameraInputsManager;
  40831. /**
  40832. * Add mouse wheel input support to the input manager.
  40833. * @returns the current input manager
  40834. */
  40835. addMouseWheel(): FollowCameraInputsManager;
  40836. /**
  40837. * Add pointers input support to the input manager.
  40838. * @returns the current input manager
  40839. */
  40840. addPointers(): FollowCameraInputsManager;
  40841. /**
  40842. * Add orientation input support to the input manager.
  40843. * @returns the current input manager
  40844. */
  40845. addVRDeviceOrientation(): FollowCameraInputsManager;
  40846. }
  40847. }
  40848. declare module BABYLON {
  40849. /**
  40850. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40851. * an arc rotate version arcFollowCamera are available.
  40852. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40853. */
  40854. export class FollowCamera extends TargetCamera {
  40855. /**
  40856. * Distance the follow camera should follow an object at
  40857. */
  40858. radius: number;
  40859. /**
  40860. * Minimum allowed distance of the camera to the axis of rotation
  40861. * (The camera can not get closer).
  40862. * This can help limiting how the Camera is able to move in the scene.
  40863. */
  40864. lowerRadiusLimit: Nullable<number>;
  40865. /**
  40866. * Maximum allowed distance of the camera to the axis of rotation
  40867. * (The camera can not get further).
  40868. * This can help limiting how the Camera is able to move in the scene.
  40869. */
  40870. upperRadiusLimit: Nullable<number>;
  40871. /**
  40872. * Define a rotation offset between the camera and the object it follows
  40873. */
  40874. rotationOffset: number;
  40875. /**
  40876. * Minimum allowed angle to camera position relative to target object.
  40877. * This can help limiting how the Camera is able to move in the scene.
  40878. */
  40879. lowerRotationOffsetLimit: Nullable<number>;
  40880. /**
  40881. * Maximum allowed angle to camera position relative to target object.
  40882. * This can help limiting how the Camera is able to move in the scene.
  40883. */
  40884. upperRotationOffsetLimit: Nullable<number>;
  40885. /**
  40886. * Define a height offset between the camera and the object it follows.
  40887. * It can help following an object from the top (like a car chaing a plane)
  40888. */
  40889. heightOffset: number;
  40890. /**
  40891. * Minimum allowed height of camera position relative to target object.
  40892. * This can help limiting how the Camera is able to move in the scene.
  40893. */
  40894. lowerHeightOffsetLimit: Nullable<number>;
  40895. /**
  40896. * Maximum allowed height of camera position relative to target object.
  40897. * This can help limiting how the Camera is able to move in the scene.
  40898. */
  40899. upperHeightOffsetLimit: Nullable<number>;
  40900. /**
  40901. * Define how fast the camera can accelerate to follow it s target.
  40902. */
  40903. cameraAcceleration: number;
  40904. /**
  40905. * Define the speed limit of the camera following an object.
  40906. */
  40907. maxCameraSpeed: number;
  40908. /**
  40909. * Define the target of the camera.
  40910. */
  40911. lockedTarget: Nullable<AbstractMesh>;
  40912. /**
  40913. * Defines the input associated with the camera.
  40914. */
  40915. inputs: FollowCameraInputsManager;
  40916. /**
  40917. * Instantiates the follow camera.
  40918. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40919. * @param name Define the name of the camera in the scene
  40920. * @param position Define the position of the camera
  40921. * @param scene Define the scene the camera belong to
  40922. * @param lockedTarget Define the target of the camera
  40923. */
  40924. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40925. private _follow;
  40926. /**
  40927. * Attached controls to the current camera.
  40928. * @param element Defines the element the controls should be listened from
  40929. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40930. */
  40931. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40932. /**
  40933. * Detach the current controls from the camera.
  40934. * The camera will stop reacting to inputs.
  40935. * @param element Defines the element to stop listening the inputs from
  40936. */
  40937. detachControl(element: HTMLElement): void;
  40938. /** @hidden */
  40939. _checkInputs(): void;
  40940. private _checkLimits;
  40941. /**
  40942. * Gets the camera class name.
  40943. * @returns the class name
  40944. */
  40945. getClassName(): string;
  40946. }
  40947. /**
  40948. * Arc Rotate version of the follow camera.
  40949. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40950. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40951. */
  40952. export class ArcFollowCamera extends TargetCamera {
  40953. /** The longitudinal angle of the camera */
  40954. alpha: number;
  40955. /** The latitudinal angle of the camera */
  40956. beta: number;
  40957. /** The radius of the camera from its target */
  40958. radius: number;
  40959. /** Define the camera target (the messh it should follow) */
  40960. target: Nullable<AbstractMesh>;
  40961. private _cartesianCoordinates;
  40962. /**
  40963. * Instantiates a new ArcFollowCamera
  40964. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40965. * @param name Define the name of the camera
  40966. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40967. * @param beta Define the rotation angle of the camera around the elevation axis
  40968. * @param radius Define the radius of the camera from its target point
  40969. * @param target Define the target of the camera
  40970. * @param scene Define the scene the camera belongs to
  40971. */
  40972. constructor(name: string,
  40973. /** The longitudinal angle of the camera */
  40974. alpha: number,
  40975. /** The latitudinal angle of the camera */
  40976. beta: number,
  40977. /** The radius of the camera from its target */
  40978. radius: number,
  40979. /** Define the camera target (the messh it should follow) */
  40980. target: Nullable<AbstractMesh>, scene: Scene);
  40981. private _follow;
  40982. /** @hidden */
  40983. _checkInputs(): void;
  40984. /**
  40985. * Returns the class name of the object.
  40986. * It is mostly used internally for serialization purposes.
  40987. */
  40988. getClassName(): string;
  40989. }
  40990. }
  40991. declare module BABYLON {
  40992. /**
  40993. * Manage the keyboard inputs to control the movement of a follow camera.
  40994. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40995. */
  40996. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40997. /**
  40998. * Defines the camera the input is attached to.
  40999. */
  41000. camera: FollowCamera;
  41001. /**
  41002. * Defines the list of key codes associated with the up action (increase heightOffset)
  41003. */
  41004. keysHeightOffsetIncr: number[];
  41005. /**
  41006. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41007. */
  41008. keysHeightOffsetDecr: number[];
  41009. /**
  41010. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41011. */
  41012. keysHeightOffsetModifierAlt: boolean;
  41013. /**
  41014. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41015. */
  41016. keysHeightOffsetModifierCtrl: boolean;
  41017. /**
  41018. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41019. */
  41020. keysHeightOffsetModifierShift: boolean;
  41021. /**
  41022. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41023. */
  41024. keysRotationOffsetIncr: number[];
  41025. /**
  41026. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41027. */
  41028. keysRotationOffsetDecr: number[];
  41029. /**
  41030. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41031. */
  41032. keysRotationOffsetModifierAlt: boolean;
  41033. /**
  41034. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41035. */
  41036. keysRotationOffsetModifierCtrl: boolean;
  41037. /**
  41038. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41039. */
  41040. keysRotationOffsetModifierShift: boolean;
  41041. /**
  41042. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41043. */
  41044. keysRadiusIncr: number[];
  41045. /**
  41046. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41047. */
  41048. keysRadiusDecr: number[];
  41049. /**
  41050. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41051. */
  41052. keysRadiusModifierAlt: boolean;
  41053. /**
  41054. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41055. */
  41056. keysRadiusModifierCtrl: boolean;
  41057. /**
  41058. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41059. */
  41060. keysRadiusModifierShift: boolean;
  41061. /**
  41062. * Defines the rate of change of heightOffset.
  41063. */
  41064. heightSensibility: number;
  41065. /**
  41066. * Defines the rate of change of rotationOffset.
  41067. */
  41068. rotationSensibility: number;
  41069. /**
  41070. * Defines the rate of change of radius.
  41071. */
  41072. radiusSensibility: number;
  41073. private _keys;
  41074. private _ctrlPressed;
  41075. private _altPressed;
  41076. private _shiftPressed;
  41077. private _onCanvasBlurObserver;
  41078. private _onKeyboardObserver;
  41079. private _engine;
  41080. private _scene;
  41081. /**
  41082. * Attach the input controls to a specific dom element to get the input from.
  41083. * @param element Defines the element the controls should be listened from
  41084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41085. */
  41086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41087. /**
  41088. * Detach the current controls from the specified dom element.
  41089. * @param element Defines the element to stop listening the inputs from
  41090. */
  41091. detachControl(element: Nullable<HTMLElement>): void;
  41092. /**
  41093. * Update the current camera state depending on the inputs that have been used this frame.
  41094. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41095. */
  41096. checkInputs(): void;
  41097. /**
  41098. * Gets the class name of the current input.
  41099. * @returns the class name
  41100. */
  41101. getClassName(): string;
  41102. /**
  41103. * Get the friendly name associated with the input class.
  41104. * @returns the input friendly name
  41105. */
  41106. getSimpleName(): string;
  41107. /**
  41108. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41109. * allow modification of the heightOffset value.
  41110. */
  41111. private _modifierHeightOffset;
  41112. /**
  41113. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41114. * allow modification of the rotationOffset value.
  41115. */
  41116. private _modifierRotationOffset;
  41117. /**
  41118. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41119. * allow modification of the radius value.
  41120. */
  41121. private _modifierRadius;
  41122. }
  41123. }
  41124. declare module BABYLON {
  41125. interface FreeCameraInputsManager {
  41126. /**
  41127. * @hidden
  41128. */
  41129. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41130. /**
  41131. * Add orientation input support to the input manager.
  41132. * @returns the current input manager
  41133. */
  41134. addDeviceOrientation(): FreeCameraInputsManager;
  41135. }
  41136. /**
  41137. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41138. * Screen rotation is taken into account.
  41139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41140. */
  41141. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41142. private _camera;
  41143. private _screenOrientationAngle;
  41144. private _constantTranform;
  41145. private _screenQuaternion;
  41146. private _alpha;
  41147. private _beta;
  41148. private _gamma;
  41149. /**
  41150. * Can be used to detect if a device orientation sensor is available on a device
  41151. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41152. * @returns a promise that will resolve on orientation change
  41153. */
  41154. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41155. /**
  41156. * @hidden
  41157. */
  41158. _onDeviceOrientationChangedObservable: Observable<void>;
  41159. /**
  41160. * Instantiates a new input
  41161. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41162. */
  41163. constructor();
  41164. /**
  41165. * Define the camera controlled by the input.
  41166. */
  41167. get camera(): FreeCamera;
  41168. set camera(camera: FreeCamera);
  41169. /**
  41170. * Attach the input controls to a specific dom element to get the input from.
  41171. * @param element Defines the element the controls should be listened from
  41172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41173. */
  41174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41175. private _orientationChanged;
  41176. private _deviceOrientation;
  41177. /**
  41178. * Detach the current controls from the specified dom element.
  41179. * @param element Defines the element to stop listening the inputs from
  41180. */
  41181. detachControl(element: Nullable<HTMLElement>): void;
  41182. /**
  41183. * Update the current camera state depending on the inputs that have been used this frame.
  41184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41185. */
  41186. checkInputs(): void;
  41187. /**
  41188. * Gets the class name of the current intput.
  41189. * @returns the class name
  41190. */
  41191. getClassName(): string;
  41192. /**
  41193. * Get the friendly name associated with the input class.
  41194. * @returns the input friendly name
  41195. */
  41196. getSimpleName(): string;
  41197. }
  41198. }
  41199. declare module BABYLON {
  41200. /**
  41201. * Manage the gamepad inputs to control a free camera.
  41202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41203. */
  41204. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41205. /**
  41206. * Define the camera the input is attached to.
  41207. */
  41208. camera: FreeCamera;
  41209. /**
  41210. * Define the Gamepad controlling the input
  41211. */
  41212. gamepad: Nullable<Gamepad>;
  41213. /**
  41214. * Defines the gamepad rotation sensiblity.
  41215. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41216. */
  41217. gamepadAngularSensibility: number;
  41218. /**
  41219. * Defines the gamepad move sensiblity.
  41220. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41221. */
  41222. gamepadMoveSensibility: number;
  41223. private _yAxisScale;
  41224. /**
  41225. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41226. */
  41227. get invertYAxis(): boolean;
  41228. set invertYAxis(value: boolean);
  41229. private _onGamepadConnectedObserver;
  41230. private _onGamepadDisconnectedObserver;
  41231. private _cameraTransform;
  41232. private _deltaTransform;
  41233. private _vector3;
  41234. private _vector2;
  41235. /**
  41236. * Attach the input controls to a specific dom element to get the input from.
  41237. * @param element Defines the element the controls should be listened from
  41238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41239. */
  41240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41241. /**
  41242. * Detach the current controls from the specified dom element.
  41243. * @param element Defines the element to stop listening the inputs from
  41244. */
  41245. detachControl(element: Nullable<HTMLElement>): void;
  41246. /**
  41247. * Update the current camera state depending on the inputs that have been used this frame.
  41248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41249. */
  41250. checkInputs(): void;
  41251. /**
  41252. * Gets the class name of the current intput.
  41253. * @returns the class name
  41254. */
  41255. getClassName(): string;
  41256. /**
  41257. * Get the friendly name associated with the input class.
  41258. * @returns the input friendly name
  41259. */
  41260. getSimpleName(): string;
  41261. }
  41262. }
  41263. declare module BABYLON {
  41264. /**
  41265. * Defines the potential axis of a Joystick
  41266. */
  41267. export enum JoystickAxis {
  41268. /** X axis */
  41269. X = 0,
  41270. /** Y axis */
  41271. Y = 1,
  41272. /** Z axis */
  41273. Z = 2
  41274. }
  41275. /**
  41276. * Class used to define virtual joystick (used in touch mode)
  41277. */
  41278. export class VirtualJoystick {
  41279. /**
  41280. * Gets or sets a boolean indicating that left and right values must be inverted
  41281. */
  41282. reverseLeftRight: boolean;
  41283. /**
  41284. * Gets or sets a boolean indicating that up and down values must be inverted
  41285. */
  41286. reverseUpDown: boolean;
  41287. /**
  41288. * Gets the offset value for the position (ie. the change of the position value)
  41289. */
  41290. deltaPosition: Vector3;
  41291. /**
  41292. * Gets a boolean indicating if the virtual joystick was pressed
  41293. */
  41294. pressed: boolean;
  41295. /**
  41296. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41297. */
  41298. static Canvas: Nullable<HTMLCanvasElement>;
  41299. private static _globalJoystickIndex;
  41300. private static vjCanvasContext;
  41301. private static vjCanvasWidth;
  41302. private static vjCanvasHeight;
  41303. private static halfWidth;
  41304. private _action;
  41305. private _axisTargetedByLeftAndRight;
  41306. private _axisTargetedByUpAndDown;
  41307. private _joystickSensibility;
  41308. private _inversedSensibility;
  41309. private _joystickPointerID;
  41310. private _joystickColor;
  41311. private _joystickPointerPos;
  41312. private _joystickPreviousPointerPos;
  41313. private _joystickPointerStartPos;
  41314. private _deltaJoystickVector;
  41315. private _leftJoystick;
  41316. private _touches;
  41317. private _onPointerDownHandlerRef;
  41318. private _onPointerMoveHandlerRef;
  41319. private _onPointerUpHandlerRef;
  41320. private _onResize;
  41321. /**
  41322. * Creates a new virtual joystick
  41323. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41324. */
  41325. constructor(leftJoystick?: boolean);
  41326. /**
  41327. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41328. * @param newJoystickSensibility defines the new sensibility
  41329. */
  41330. setJoystickSensibility(newJoystickSensibility: number): void;
  41331. private _onPointerDown;
  41332. private _onPointerMove;
  41333. private _onPointerUp;
  41334. /**
  41335. * Change the color of the virtual joystick
  41336. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41337. */
  41338. setJoystickColor(newColor: string): void;
  41339. /**
  41340. * Defines a callback to call when the joystick is touched
  41341. * @param action defines the callback
  41342. */
  41343. setActionOnTouch(action: () => any): void;
  41344. /**
  41345. * Defines which axis you'd like to control for left & right
  41346. * @param axis defines the axis to use
  41347. */
  41348. setAxisForLeftRight(axis: JoystickAxis): void;
  41349. /**
  41350. * Defines which axis you'd like to control for up & down
  41351. * @param axis defines the axis to use
  41352. */
  41353. setAxisForUpDown(axis: JoystickAxis): void;
  41354. private _drawVirtualJoystick;
  41355. /**
  41356. * Release internal HTML canvas
  41357. */
  41358. releaseCanvas(): void;
  41359. }
  41360. }
  41361. declare module BABYLON {
  41362. interface FreeCameraInputsManager {
  41363. /**
  41364. * Add virtual joystick input support to the input manager.
  41365. * @returns the current input manager
  41366. */
  41367. addVirtualJoystick(): FreeCameraInputsManager;
  41368. }
  41369. /**
  41370. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41371. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41372. */
  41373. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41374. /**
  41375. * Defines the camera the input is attached to.
  41376. */
  41377. camera: FreeCamera;
  41378. private _leftjoystick;
  41379. private _rightjoystick;
  41380. /**
  41381. * Gets the left stick of the virtual joystick.
  41382. * @returns The virtual Joystick
  41383. */
  41384. getLeftJoystick(): VirtualJoystick;
  41385. /**
  41386. * Gets the right stick of the virtual joystick.
  41387. * @returns The virtual Joystick
  41388. */
  41389. getRightJoystick(): VirtualJoystick;
  41390. /**
  41391. * Update the current camera state depending on the inputs that have been used this frame.
  41392. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41393. */
  41394. checkInputs(): void;
  41395. /**
  41396. * Attach the input controls to a specific dom element to get the input from.
  41397. * @param element Defines the element the controls should be listened from
  41398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41399. */
  41400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41401. /**
  41402. * Detach the current controls from the specified dom element.
  41403. * @param element Defines the element to stop listening the inputs from
  41404. */
  41405. detachControl(element: Nullable<HTMLElement>): void;
  41406. /**
  41407. * Gets the class name of the current intput.
  41408. * @returns the class name
  41409. */
  41410. getClassName(): string;
  41411. /**
  41412. * Get the friendly name associated with the input class.
  41413. * @returns the input friendly name
  41414. */
  41415. getSimpleName(): string;
  41416. }
  41417. }
  41418. declare module BABYLON {
  41419. /**
  41420. * This represents a FPS type of camera controlled by touch.
  41421. * This is like a universal camera minus the Gamepad controls.
  41422. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41423. */
  41424. export class TouchCamera extends FreeCamera {
  41425. /**
  41426. * Defines the touch sensibility for rotation.
  41427. * The higher the faster.
  41428. */
  41429. get touchAngularSensibility(): number;
  41430. set touchAngularSensibility(value: number);
  41431. /**
  41432. * Defines the touch sensibility for move.
  41433. * The higher the faster.
  41434. */
  41435. get touchMoveSensibility(): number;
  41436. set touchMoveSensibility(value: number);
  41437. /**
  41438. * Instantiates a new touch camera.
  41439. * This represents a FPS type of camera controlled by touch.
  41440. * This is like a universal camera minus the Gamepad controls.
  41441. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41442. * @param name Define the name of the camera in the scene
  41443. * @param position Define the start position of the camera in the scene
  41444. * @param scene Define the scene the camera belongs to
  41445. */
  41446. constructor(name: string, position: Vector3, scene: Scene);
  41447. /**
  41448. * Gets the current object class name.
  41449. * @return the class name
  41450. */
  41451. getClassName(): string;
  41452. /** @hidden */
  41453. _setupInputs(): void;
  41454. }
  41455. }
  41456. declare module BABYLON {
  41457. /**
  41458. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41459. * being tilted forward or back and left or right.
  41460. */
  41461. export class DeviceOrientationCamera extends FreeCamera {
  41462. private _initialQuaternion;
  41463. private _quaternionCache;
  41464. private _tmpDragQuaternion;
  41465. private _disablePointerInputWhenUsingDeviceOrientation;
  41466. /**
  41467. * Creates a new device orientation camera
  41468. * @param name The name of the camera
  41469. * @param position The start position camera
  41470. * @param scene The scene the camera belongs to
  41471. */
  41472. constructor(name: string, position: Vector3, scene: Scene);
  41473. /**
  41474. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41475. */
  41476. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41477. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41478. private _dragFactor;
  41479. /**
  41480. * Enabled turning on the y axis when the orientation sensor is active
  41481. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41482. */
  41483. enableHorizontalDragging(dragFactor?: number): void;
  41484. /**
  41485. * Gets the current instance class name ("DeviceOrientationCamera").
  41486. * This helps avoiding instanceof at run time.
  41487. * @returns the class name
  41488. */
  41489. getClassName(): string;
  41490. /**
  41491. * @hidden
  41492. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41493. */
  41494. _checkInputs(): void;
  41495. /**
  41496. * Reset the camera to its default orientation on the specified axis only.
  41497. * @param axis The axis to reset
  41498. */
  41499. resetToCurrentRotation(axis?: Axis): void;
  41500. }
  41501. }
  41502. declare module BABYLON {
  41503. /**
  41504. * Defines supported buttons for XBox360 compatible gamepads
  41505. */
  41506. export enum Xbox360Button {
  41507. /** A */
  41508. A = 0,
  41509. /** B */
  41510. B = 1,
  41511. /** X */
  41512. X = 2,
  41513. /** Y */
  41514. Y = 3,
  41515. /** Left button */
  41516. LB = 4,
  41517. /** Right button */
  41518. RB = 5,
  41519. /** Back */
  41520. Back = 8,
  41521. /** Start */
  41522. Start = 9,
  41523. /** Left stick */
  41524. LeftStick = 10,
  41525. /** Right stick */
  41526. RightStick = 11
  41527. }
  41528. /** Defines values for XBox360 DPad */
  41529. export enum Xbox360Dpad {
  41530. /** Up */
  41531. Up = 12,
  41532. /** Down */
  41533. Down = 13,
  41534. /** Left */
  41535. Left = 14,
  41536. /** Right */
  41537. Right = 15
  41538. }
  41539. /**
  41540. * Defines a XBox360 gamepad
  41541. */
  41542. export class Xbox360Pad extends Gamepad {
  41543. private _leftTrigger;
  41544. private _rightTrigger;
  41545. private _onlefttriggerchanged;
  41546. private _onrighttriggerchanged;
  41547. private _onbuttondown;
  41548. private _onbuttonup;
  41549. private _ondpaddown;
  41550. private _ondpadup;
  41551. /** Observable raised when a button is pressed */
  41552. onButtonDownObservable: Observable<Xbox360Button>;
  41553. /** Observable raised when a button is released */
  41554. onButtonUpObservable: Observable<Xbox360Button>;
  41555. /** Observable raised when a pad is pressed */
  41556. onPadDownObservable: Observable<Xbox360Dpad>;
  41557. /** Observable raised when a pad is released */
  41558. onPadUpObservable: Observable<Xbox360Dpad>;
  41559. private _buttonA;
  41560. private _buttonB;
  41561. private _buttonX;
  41562. private _buttonY;
  41563. private _buttonBack;
  41564. private _buttonStart;
  41565. private _buttonLB;
  41566. private _buttonRB;
  41567. private _buttonLeftStick;
  41568. private _buttonRightStick;
  41569. private _dPadUp;
  41570. private _dPadDown;
  41571. private _dPadLeft;
  41572. private _dPadRight;
  41573. private _isXboxOnePad;
  41574. /**
  41575. * Creates a new XBox360 gamepad object
  41576. * @param id defines the id of this gamepad
  41577. * @param index defines its index
  41578. * @param gamepad defines the internal HTML gamepad object
  41579. * @param xboxOne defines if it is a XBox One gamepad
  41580. */
  41581. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41582. /**
  41583. * Defines the callback to call when left trigger is pressed
  41584. * @param callback defines the callback to use
  41585. */
  41586. onlefttriggerchanged(callback: (value: number) => void): void;
  41587. /**
  41588. * Defines the callback to call when right trigger is pressed
  41589. * @param callback defines the callback to use
  41590. */
  41591. onrighttriggerchanged(callback: (value: number) => void): void;
  41592. /**
  41593. * Gets the left trigger value
  41594. */
  41595. get leftTrigger(): number;
  41596. /**
  41597. * Sets the left trigger value
  41598. */
  41599. set leftTrigger(newValue: number);
  41600. /**
  41601. * Gets the right trigger value
  41602. */
  41603. get rightTrigger(): number;
  41604. /**
  41605. * Sets the right trigger value
  41606. */
  41607. set rightTrigger(newValue: number);
  41608. /**
  41609. * Defines the callback to call when a button is pressed
  41610. * @param callback defines the callback to use
  41611. */
  41612. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41613. /**
  41614. * Defines the callback to call when a button is released
  41615. * @param callback defines the callback to use
  41616. */
  41617. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41618. /**
  41619. * Defines the callback to call when a pad is pressed
  41620. * @param callback defines the callback to use
  41621. */
  41622. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41623. /**
  41624. * Defines the callback to call when a pad is released
  41625. * @param callback defines the callback to use
  41626. */
  41627. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41628. private _setButtonValue;
  41629. private _setDPadValue;
  41630. /**
  41631. * Gets the value of the `A` button
  41632. */
  41633. get buttonA(): number;
  41634. /**
  41635. * Sets the value of the `A` button
  41636. */
  41637. set buttonA(value: number);
  41638. /**
  41639. * Gets the value of the `B` button
  41640. */
  41641. get buttonB(): number;
  41642. /**
  41643. * Sets the value of the `B` button
  41644. */
  41645. set buttonB(value: number);
  41646. /**
  41647. * Gets the value of the `X` button
  41648. */
  41649. get buttonX(): number;
  41650. /**
  41651. * Sets the value of the `X` button
  41652. */
  41653. set buttonX(value: number);
  41654. /**
  41655. * Gets the value of the `Y` button
  41656. */
  41657. get buttonY(): number;
  41658. /**
  41659. * Sets the value of the `Y` button
  41660. */
  41661. set buttonY(value: number);
  41662. /**
  41663. * Gets the value of the `Start` button
  41664. */
  41665. get buttonStart(): number;
  41666. /**
  41667. * Sets the value of the `Start` button
  41668. */
  41669. set buttonStart(value: number);
  41670. /**
  41671. * Gets the value of the `Back` button
  41672. */
  41673. get buttonBack(): number;
  41674. /**
  41675. * Sets the value of the `Back` button
  41676. */
  41677. set buttonBack(value: number);
  41678. /**
  41679. * Gets the value of the `Left` button
  41680. */
  41681. get buttonLB(): number;
  41682. /**
  41683. * Sets the value of the `Left` button
  41684. */
  41685. set buttonLB(value: number);
  41686. /**
  41687. * Gets the value of the `Right` button
  41688. */
  41689. get buttonRB(): number;
  41690. /**
  41691. * Sets the value of the `Right` button
  41692. */
  41693. set buttonRB(value: number);
  41694. /**
  41695. * Gets the value of the Left joystick
  41696. */
  41697. get buttonLeftStick(): number;
  41698. /**
  41699. * Sets the value of the Left joystick
  41700. */
  41701. set buttonLeftStick(value: number);
  41702. /**
  41703. * Gets the value of the Right joystick
  41704. */
  41705. get buttonRightStick(): number;
  41706. /**
  41707. * Sets the value of the Right joystick
  41708. */
  41709. set buttonRightStick(value: number);
  41710. /**
  41711. * Gets the value of D-pad up
  41712. */
  41713. get dPadUp(): number;
  41714. /**
  41715. * Sets the value of D-pad up
  41716. */
  41717. set dPadUp(value: number);
  41718. /**
  41719. * Gets the value of D-pad down
  41720. */
  41721. get dPadDown(): number;
  41722. /**
  41723. * Sets the value of D-pad down
  41724. */
  41725. set dPadDown(value: number);
  41726. /**
  41727. * Gets the value of D-pad left
  41728. */
  41729. get dPadLeft(): number;
  41730. /**
  41731. * Sets the value of D-pad left
  41732. */
  41733. set dPadLeft(value: number);
  41734. /**
  41735. * Gets the value of D-pad right
  41736. */
  41737. get dPadRight(): number;
  41738. /**
  41739. * Sets the value of D-pad right
  41740. */
  41741. set dPadRight(value: number);
  41742. /**
  41743. * Force the gamepad to synchronize with device values
  41744. */
  41745. update(): void;
  41746. /**
  41747. * Disposes the gamepad
  41748. */
  41749. dispose(): void;
  41750. }
  41751. }
  41752. declare module BABYLON {
  41753. /**
  41754. * Defines supported buttons for DualShock compatible gamepads
  41755. */
  41756. export enum DualShockButton {
  41757. /** Cross */
  41758. Cross = 0,
  41759. /** Circle */
  41760. Circle = 1,
  41761. /** Square */
  41762. Square = 2,
  41763. /** Triangle */
  41764. Triangle = 3,
  41765. /** L1 */
  41766. L1 = 4,
  41767. /** R1 */
  41768. R1 = 5,
  41769. /** Share */
  41770. Share = 8,
  41771. /** Options */
  41772. Options = 9,
  41773. /** Left stick */
  41774. LeftStick = 10,
  41775. /** Right stick */
  41776. RightStick = 11
  41777. }
  41778. /** Defines values for DualShock DPad */
  41779. export enum DualShockDpad {
  41780. /** Up */
  41781. Up = 12,
  41782. /** Down */
  41783. Down = 13,
  41784. /** Left */
  41785. Left = 14,
  41786. /** Right */
  41787. Right = 15
  41788. }
  41789. /**
  41790. * Defines a DualShock gamepad
  41791. */
  41792. export class DualShockPad extends Gamepad {
  41793. private _leftTrigger;
  41794. private _rightTrigger;
  41795. private _onlefttriggerchanged;
  41796. private _onrighttriggerchanged;
  41797. private _onbuttondown;
  41798. private _onbuttonup;
  41799. private _ondpaddown;
  41800. private _ondpadup;
  41801. /** Observable raised when a button is pressed */
  41802. onButtonDownObservable: Observable<DualShockButton>;
  41803. /** Observable raised when a button is released */
  41804. onButtonUpObservable: Observable<DualShockButton>;
  41805. /** Observable raised when a pad is pressed */
  41806. onPadDownObservable: Observable<DualShockDpad>;
  41807. /** Observable raised when a pad is released */
  41808. onPadUpObservable: Observable<DualShockDpad>;
  41809. private _buttonCross;
  41810. private _buttonCircle;
  41811. private _buttonSquare;
  41812. private _buttonTriangle;
  41813. private _buttonShare;
  41814. private _buttonOptions;
  41815. private _buttonL1;
  41816. private _buttonR1;
  41817. private _buttonLeftStick;
  41818. private _buttonRightStick;
  41819. private _dPadUp;
  41820. private _dPadDown;
  41821. private _dPadLeft;
  41822. private _dPadRight;
  41823. /**
  41824. * Creates a new DualShock gamepad object
  41825. * @param id defines the id of this gamepad
  41826. * @param index defines its index
  41827. * @param gamepad defines the internal HTML gamepad object
  41828. */
  41829. constructor(id: string, index: number, gamepad: any);
  41830. /**
  41831. * Defines the callback to call when left trigger is pressed
  41832. * @param callback defines the callback to use
  41833. */
  41834. onlefttriggerchanged(callback: (value: number) => void): void;
  41835. /**
  41836. * Defines the callback to call when right trigger is pressed
  41837. * @param callback defines the callback to use
  41838. */
  41839. onrighttriggerchanged(callback: (value: number) => void): void;
  41840. /**
  41841. * Gets the left trigger value
  41842. */
  41843. get leftTrigger(): number;
  41844. /**
  41845. * Sets the left trigger value
  41846. */
  41847. set leftTrigger(newValue: number);
  41848. /**
  41849. * Gets the right trigger value
  41850. */
  41851. get rightTrigger(): number;
  41852. /**
  41853. * Sets the right trigger value
  41854. */
  41855. set rightTrigger(newValue: number);
  41856. /**
  41857. * Defines the callback to call when a button is pressed
  41858. * @param callback defines the callback to use
  41859. */
  41860. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41861. /**
  41862. * Defines the callback to call when a button is released
  41863. * @param callback defines the callback to use
  41864. */
  41865. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41866. /**
  41867. * Defines the callback to call when a pad is pressed
  41868. * @param callback defines the callback to use
  41869. */
  41870. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41871. /**
  41872. * Defines the callback to call when a pad is released
  41873. * @param callback defines the callback to use
  41874. */
  41875. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41876. private _setButtonValue;
  41877. private _setDPadValue;
  41878. /**
  41879. * Gets the value of the `Cross` button
  41880. */
  41881. get buttonCross(): number;
  41882. /**
  41883. * Sets the value of the `Cross` button
  41884. */
  41885. set buttonCross(value: number);
  41886. /**
  41887. * Gets the value of the `Circle` button
  41888. */
  41889. get buttonCircle(): number;
  41890. /**
  41891. * Sets the value of the `Circle` button
  41892. */
  41893. set buttonCircle(value: number);
  41894. /**
  41895. * Gets the value of the `Square` button
  41896. */
  41897. get buttonSquare(): number;
  41898. /**
  41899. * Sets the value of the `Square` button
  41900. */
  41901. set buttonSquare(value: number);
  41902. /**
  41903. * Gets the value of the `Triangle` button
  41904. */
  41905. get buttonTriangle(): number;
  41906. /**
  41907. * Sets the value of the `Triangle` button
  41908. */
  41909. set buttonTriangle(value: number);
  41910. /**
  41911. * Gets the value of the `Options` button
  41912. */
  41913. get buttonOptions(): number;
  41914. /**
  41915. * Sets the value of the `Options` button
  41916. */
  41917. set buttonOptions(value: number);
  41918. /**
  41919. * Gets the value of the `Share` button
  41920. */
  41921. get buttonShare(): number;
  41922. /**
  41923. * Sets the value of the `Share` button
  41924. */
  41925. set buttonShare(value: number);
  41926. /**
  41927. * Gets the value of the `L1` button
  41928. */
  41929. get buttonL1(): number;
  41930. /**
  41931. * Sets the value of the `L1` button
  41932. */
  41933. set buttonL1(value: number);
  41934. /**
  41935. * Gets the value of the `R1` button
  41936. */
  41937. get buttonR1(): number;
  41938. /**
  41939. * Sets the value of the `R1` button
  41940. */
  41941. set buttonR1(value: number);
  41942. /**
  41943. * Gets the value of the Left joystick
  41944. */
  41945. get buttonLeftStick(): number;
  41946. /**
  41947. * Sets the value of the Left joystick
  41948. */
  41949. set buttonLeftStick(value: number);
  41950. /**
  41951. * Gets the value of the Right joystick
  41952. */
  41953. get buttonRightStick(): number;
  41954. /**
  41955. * Sets the value of the Right joystick
  41956. */
  41957. set buttonRightStick(value: number);
  41958. /**
  41959. * Gets the value of D-pad up
  41960. */
  41961. get dPadUp(): number;
  41962. /**
  41963. * Sets the value of D-pad up
  41964. */
  41965. set dPadUp(value: number);
  41966. /**
  41967. * Gets the value of D-pad down
  41968. */
  41969. get dPadDown(): number;
  41970. /**
  41971. * Sets the value of D-pad down
  41972. */
  41973. set dPadDown(value: number);
  41974. /**
  41975. * Gets the value of D-pad left
  41976. */
  41977. get dPadLeft(): number;
  41978. /**
  41979. * Sets the value of D-pad left
  41980. */
  41981. set dPadLeft(value: number);
  41982. /**
  41983. * Gets the value of D-pad right
  41984. */
  41985. get dPadRight(): number;
  41986. /**
  41987. * Sets the value of D-pad right
  41988. */
  41989. set dPadRight(value: number);
  41990. /**
  41991. * Force the gamepad to synchronize with device values
  41992. */
  41993. update(): void;
  41994. /**
  41995. * Disposes the gamepad
  41996. */
  41997. dispose(): void;
  41998. }
  41999. }
  42000. declare module BABYLON {
  42001. /**
  42002. * Manager for handling gamepads
  42003. */
  42004. export class GamepadManager {
  42005. private _scene?;
  42006. private _babylonGamepads;
  42007. private _oneGamepadConnected;
  42008. /** @hidden */
  42009. _isMonitoring: boolean;
  42010. private _gamepadEventSupported;
  42011. private _gamepadSupport?;
  42012. /**
  42013. * observable to be triggered when the gamepad controller has been connected
  42014. */
  42015. onGamepadConnectedObservable: Observable<Gamepad>;
  42016. /**
  42017. * observable to be triggered when the gamepad controller has been disconnected
  42018. */
  42019. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42020. private _onGamepadConnectedEvent;
  42021. private _onGamepadDisconnectedEvent;
  42022. /**
  42023. * Initializes the gamepad manager
  42024. * @param _scene BabylonJS scene
  42025. */
  42026. constructor(_scene?: Scene | undefined);
  42027. /**
  42028. * The gamepads in the game pad manager
  42029. */
  42030. get gamepads(): Gamepad[];
  42031. /**
  42032. * Get the gamepad controllers based on type
  42033. * @param type The type of gamepad controller
  42034. * @returns Nullable gamepad
  42035. */
  42036. getGamepadByType(type?: number): Nullable<Gamepad>;
  42037. /**
  42038. * Disposes the gamepad manager
  42039. */
  42040. dispose(): void;
  42041. private _addNewGamepad;
  42042. private _startMonitoringGamepads;
  42043. private _stopMonitoringGamepads;
  42044. /** @hidden */
  42045. _checkGamepadsStatus(): void;
  42046. private _updateGamepadObjects;
  42047. }
  42048. }
  42049. declare module BABYLON {
  42050. interface Scene {
  42051. /** @hidden */
  42052. _gamepadManager: Nullable<GamepadManager>;
  42053. /**
  42054. * Gets the gamepad manager associated with the scene
  42055. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42056. */
  42057. gamepadManager: GamepadManager;
  42058. }
  42059. /**
  42060. * Interface representing a free camera inputs manager
  42061. */
  42062. interface FreeCameraInputsManager {
  42063. /**
  42064. * Adds gamepad input support to the FreeCameraInputsManager.
  42065. * @returns the FreeCameraInputsManager
  42066. */
  42067. addGamepad(): FreeCameraInputsManager;
  42068. }
  42069. /**
  42070. * Interface representing an arc rotate camera inputs manager
  42071. */
  42072. interface ArcRotateCameraInputsManager {
  42073. /**
  42074. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42075. * @returns the camera inputs manager
  42076. */
  42077. addGamepad(): ArcRotateCameraInputsManager;
  42078. }
  42079. /**
  42080. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42081. */
  42082. export class GamepadSystemSceneComponent implements ISceneComponent {
  42083. /**
  42084. * The component name helpfull to identify the component in the list of scene components.
  42085. */
  42086. readonly name: string;
  42087. /**
  42088. * The scene the component belongs to.
  42089. */
  42090. scene: Scene;
  42091. /**
  42092. * Creates a new instance of the component for the given scene
  42093. * @param scene Defines the scene to register the component in
  42094. */
  42095. constructor(scene: Scene);
  42096. /**
  42097. * Registers the component in a given scene
  42098. */
  42099. register(): void;
  42100. /**
  42101. * Rebuilds the elements related to this component in case of
  42102. * context lost for instance.
  42103. */
  42104. rebuild(): void;
  42105. /**
  42106. * Disposes the component and the associated ressources
  42107. */
  42108. dispose(): void;
  42109. private _beforeCameraUpdate;
  42110. }
  42111. }
  42112. declare module BABYLON {
  42113. /**
  42114. * 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,
  42115. * which still works and will still be found in many Playgrounds.
  42116. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42117. */
  42118. export class UniversalCamera extends TouchCamera {
  42119. /**
  42120. * Defines the gamepad rotation sensiblity.
  42121. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42122. */
  42123. get gamepadAngularSensibility(): number;
  42124. set gamepadAngularSensibility(value: number);
  42125. /**
  42126. * Defines the gamepad move sensiblity.
  42127. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42128. */
  42129. get gamepadMoveSensibility(): number;
  42130. set gamepadMoveSensibility(value: number);
  42131. /**
  42132. * 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,
  42133. * which still works and will still be found in many Playgrounds.
  42134. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42135. * @param name Define the name of the camera in the scene
  42136. * @param position Define the start position of the camera in the scene
  42137. * @param scene Define the scene the camera belongs to
  42138. */
  42139. constructor(name: string, position: Vector3, scene: Scene);
  42140. /**
  42141. * Gets the current object class name.
  42142. * @return the class name
  42143. */
  42144. getClassName(): string;
  42145. }
  42146. }
  42147. declare module BABYLON {
  42148. /**
  42149. * This represents a FPS type of camera. This is only here for back compat purpose.
  42150. * Please use the UniversalCamera instead as both are identical.
  42151. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42152. */
  42153. export class GamepadCamera extends UniversalCamera {
  42154. /**
  42155. * Instantiates a new Gamepad Camera
  42156. * This represents a FPS type of camera. This is only here for back compat purpose.
  42157. * Please use the UniversalCamera instead as both are identical.
  42158. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42159. * @param name Define the name of the camera in the scene
  42160. * @param position Define the start position of the camera in the scene
  42161. * @param scene Define the scene the camera belongs to
  42162. */
  42163. constructor(name: string, position: Vector3, scene: Scene);
  42164. /**
  42165. * Gets the current object class name.
  42166. * @return the class name
  42167. */
  42168. getClassName(): string;
  42169. }
  42170. }
  42171. declare module BABYLON {
  42172. /** @hidden */
  42173. export var passPixelShader: {
  42174. name: string;
  42175. shader: string;
  42176. };
  42177. }
  42178. declare module BABYLON {
  42179. /** @hidden */
  42180. export var passCubePixelShader: {
  42181. name: string;
  42182. shader: string;
  42183. };
  42184. }
  42185. declare module BABYLON {
  42186. /**
  42187. * PassPostProcess which produces an output the same as it's input
  42188. */
  42189. export class PassPostProcess extends PostProcess {
  42190. /**
  42191. * Creates the PassPostProcess
  42192. * @param name The name of the effect.
  42193. * @param options The required width/height ratio to downsize to before computing the render pass.
  42194. * @param camera The camera to apply the render pass to.
  42195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42196. * @param engine The engine which the post process will be applied. (default: current engine)
  42197. * @param reusable If the post process can be reused on the same frame. (default: false)
  42198. * @param textureType The type of texture to be used when performing the post processing.
  42199. * @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)
  42200. */
  42201. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42202. }
  42203. /**
  42204. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42205. */
  42206. export class PassCubePostProcess extends PostProcess {
  42207. private _face;
  42208. /**
  42209. * Gets or sets the cube face to display.
  42210. * * 0 is +X
  42211. * * 1 is -X
  42212. * * 2 is +Y
  42213. * * 3 is -Y
  42214. * * 4 is +Z
  42215. * * 5 is -Z
  42216. */
  42217. get face(): number;
  42218. set face(value: number);
  42219. /**
  42220. * Creates the PassCubePostProcess
  42221. * @param name The name of the effect.
  42222. * @param options The required width/height ratio to downsize to before computing the render pass.
  42223. * @param camera The camera to apply the render pass to.
  42224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42225. * @param engine The engine which the post process will be applied. (default: current engine)
  42226. * @param reusable If the post process can be reused on the same frame. (default: false)
  42227. * @param textureType The type of texture to be used when performing the post processing.
  42228. * @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)
  42229. */
  42230. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42231. }
  42232. }
  42233. declare module BABYLON {
  42234. /** @hidden */
  42235. export var anaglyphPixelShader: {
  42236. name: string;
  42237. shader: string;
  42238. };
  42239. }
  42240. declare module BABYLON {
  42241. /**
  42242. * Postprocess used to generate anaglyphic rendering
  42243. */
  42244. export class AnaglyphPostProcess extends PostProcess {
  42245. private _passedProcess;
  42246. /**
  42247. * Creates a new AnaglyphPostProcess
  42248. * @param name defines postprocess name
  42249. * @param options defines creation options or target ratio scale
  42250. * @param rigCameras defines cameras using this postprocess
  42251. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42252. * @param engine defines hosting engine
  42253. * @param reusable defines if the postprocess will be reused multiple times per frame
  42254. */
  42255. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42256. }
  42257. }
  42258. declare module BABYLON {
  42259. /**
  42260. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42261. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42262. */
  42263. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42264. /**
  42265. * Creates a new AnaglyphArcRotateCamera
  42266. * @param name defines camera name
  42267. * @param alpha defines alpha angle (in radians)
  42268. * @param beta defines beta angle (in radians)
  42269. * @param radius defines radius
  42270. * @param target defines camera target
  42271. * @param interaxialDistance defines distance between each color axis
  42272. * @param scene defines the hosting scene
  42273. */
  42274. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42275. /**
  42276. * Gets camera class name
  42277. * @returns AnaglyphArcRotateCamera
  42278. */
  42279. getClassName(): string;
  42280. }
  42281. }
  42282. declare module BABYLON {
  42283. /**
  42284. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42285. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42286. */
  42287. export class AnaglyphFreeCamera extends FreeCamera {
  42288. /**
  42289. * Creates a new AnaglyphFreeCamera
  42290. * @param name defines camera name
  42291. * @param position defines initial position
  42292. * @param interaxialDistance defines distance between each color axis
  42293. * @param scene defines the hosting scene
  42294. */
  42295. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42296. /**
  42297. * Gets camera class name
  42298. * @returns AnaglyphFreeCamera
  42299. */
  42300. getClassName(): string;
  42301. }
  42302. }
  42303. declare module BABYLON {
  42304. /**
  42305. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42306. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42307. */
  42308. export class AnaglyphGamepadCamera extends GamepadCamera {
  42309. /**
  42310. * Creates a new AnaglyphGamepadCamera
  42311. * @param name defines camera name
  42312. * @param position defines initial position
  42313. * @param interaxialDistance defines distance between each color axis
  42314. * @param scene defines the hosting scene
  42315. */
  42316. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42317. /**
  42318. * Gets camera class name
  42319. * @returns AnaglyphGamepadCamera
  42320. */
  42321. getClassName(): string;
  42322. }
  42323. }
  42324. declare module BABYLON {
  42325. /**
  42326. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42327. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42328. */
  42329. export class AnaglyphUniversalCamera extends UniversalCamera {
  42330. /**
  42331. * Creates a new AnaglyphUniversalCamera
  42332. * @param name defines camera name
  42333. * @param position defines initial position
  42334. * @param interaxialDistance defines distance between each color axis
  42335. * @param scene defines the hosting scene
  42336. */
  42337. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42338. /**
  42339. * Gets camera class name
  42340. * @returns AnaglyphUniversalCamera
  42341. */
  42342. getClassName(): string;
  42343. }
  42344. }
  42345. declare module BABYLON {
  42346. /** @hidden */
  42347. export var stereoscopicInterlacePixelShader: {
  42348. name: string;
  42349. shader: string;
  42350. };
  42351. }
  42352. declare module BABYLON {
  42353. /**
  42354. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42355. */
  42356. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42357. private _stepSize;
  42358. private _passedProcess;
  42359. /**
  42360. * Initializes a StereoscopicInterlacePostProcessI
  42361. * @param name The name of the effect.
  42362. * @param rigCameras The rig cameras to be appled to the post process
  42363. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  42364. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42366. * @param engine The engine which the post process will be applied. (default: current engine)
  42367. * @param reusable If the post process can be reused on the same frame. (default: false)
  42368. */
  42369. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42370. }
  42371. /**
  42372. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42373. */
  42374. export class StereoscopicInterlacePostProcess extends PostProcess {
  42375. private _stepSize;
  42376. private _passedProcess;
  42377. /**
  42378. * Initializes a StereoscopicInterlacePostProcess
  42379. * @param name The name of the effect.
  42380. * @param rigCameras The rig cameras to be appled to the post process
  42381. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42383. * @param engine The engine which the post process will be applied. (default: current engine)
  42384. * @param reusable If the post process can be reused on the same frame. (default: false)
  42385. */
  42386. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42387. }
  42388. }
  42389. declare module BABYLON {
  42390. /**
  42391. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42392. * @see http://doc.babylonjs.com/features/cameras
  42393. */
  42394. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42395. /**
  42396. * Creates a new StereoscopicArcRotateCamera
  42397. * @param name defines camera name
  42398. * @param alpha defines alpha angle (in radians)
  42399. * @param beta defines beta angle (in radians)
  42400. * @param radius defines radius
  42401. * @param target defines camera target
  42402. * @param interaxialDistance defines distance between each color axis
  42403. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42404. * @param scene defines the hosting scene
  42405. */
  42406. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42407. /**
  42408. * Gets camera class name
  42409. * @returns StereoscopicArcRotateCamera
  42410. */
  42411. getClassName(): string;
  42412. }
  42413. }
  42414. declare module BABYLON {
  42415. /**
  42416. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42417. * @see http://doc.babylonjs.com/features/cameras
  42418. */
  42419. export class StereoscopicFreeCamera extends FreeCamera {
  42420. /**
  42421. * Creates a new StereoscopicFreeCamera
  42422. * @param name defines camera name
  42423. * @param position defines initial position
  42424. * @param interaxialDistance defines distance between each color axis
  42425. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42426. * @param scene defines the hosting scene
  42427. */
  42428. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42429. /**
  42430. * Gets camera class name
  42431. * @returns StereoscopicFreeCamera
  42432. */
  42433. getClassName(): string;
  42434. }
  42435. }
  42436. declare module BABYLON {
  42437. /**
  42438. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42439. * @see http://doc.babylonjs.com/features/cameras
  42440. */
  42441. export class StereoscopicGamepadCamera extends GamepadCamera {
  42442. /**
  42443. * Creates a new StereoscopicGamepadCamera
  42444. * @param name defines camera name
  42445. * @param position defines initial position
  42446. * @param interaxialDistance defines distance between each color axis
  42447. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42448. * @param scene defines the hosting scene
  42449. */
  42450. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42451. /**
  42452. * Gets camera class name
  42453. * @returns StereoscopicGamepadCamera
  42454. */
  42455. getClassName(): string;
  42456. }
  42457. }
  42458. declare module BABYLON {
  42459. /**
  42460. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42461. * @see http://doc.babylonjs.com/features/cameras
  42462. */
  42463. export class StereoscopicUniversalCamera extends UniversalCamera {
  42464. /**
  42465. * Creates a new StereoscopicUniversalCamera
  42466. * @param name defines camera name
  42467. * @param position defines initial position
  42468. * @param interaxialDistance defines distance between each color axis
  42469. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42470. * @param scene defines the hosting scene
  42471. */
  42472. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42473. /**
  42474. * Gets camera class name
  42475. * @returns StereoscopicUniversalCamera
  42476. */
  42477. getClassName(): string;
  42478. }
  42479. }
  42480. declare module BABYLON {
  42481. /**
  42482. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42483. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42484. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42485. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42486. */
  42487. export class VirtualJoysticksCamera extends FreeCamera {
  42488. /**
  42489. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42490. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42491. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42492. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42493. * @param name Define the name of the camera in the scene
  42494. * @param position Define the start position of the camera in the scene
  42495. * @param scene Define the scene the camera belongs to
  42496. */
  42497. constructor(name: string, position: Vector3, scene: Scene);
  42498. /**
  42499. * Gets the current object class name.
  42500. * @return the class name
  42501. */
  42502. getClassName(): string;
  42503. }
  42504. }
  42505. declare module BABYLON {
  42506. /**
  42507. * This represents all the required metrics to create a VR camera.
  42508. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42509. */
  42510. export class VRCameraMetrics {
  42511. /**
  42512. * Define the horizontal resolution off the screen.
  42513. */
  42514. hResolution: number;
  42515. /**
  42516. * Define the vertical resolution off the screen.
  42517. */
  42518. vResolution: number;
  42519. /**
  42520. * Define the horizontal screen size.
  42521. */
  42522. hScreenSize: number;
  42523. /**
  42524. * Define the vertical screen size.
  42525. */
  42526. vScreenSize: number;
  42527. /**
  42528. * Define the vertical screen center position.
  42529. */
  42530. vScreenCenter: number;
  42531. /**
  42532. * Define the distance of the eyes to the screen.
  42533. */
  42534. eyeToScreenDistance: number;
  42535. /**
  42536. * Define the distance between both lenses
  42537. */
  42538. lensSeparationDistance: number;
  42539. /**
  42540. * Define the distance between both viewer's eyes.
  42541. */
  42542. interpupillaryDistance: number;
  42543. /**
  42544. * Define the distortion factor of the VR postprocess.
  42545. * Please, touch with care.
  42546. */
  42547. distortionK: number[];
  42548. /**
  42549. * Define the chromatic aberration correction factors for the VR post process.
  42550. */
  42551. chromaAbCorrection: number[];
  42552. /**
  42553. * Define the scale factor of the post process.
  42554. * The smaller the better but the slower.
  42555. */
  42556. postProcessScaleFactor: number;
  42557. /**
  42558. * Define an offset for the lens center.
  42559. */
  42560. lensCenterOffset: number;
  42561. /**
  42562. * Define if the current vr camera should compensate the distortion of the lense or not.
  42563. */
  42564. compensateDistortion: boolean;
  42565. /**
  42566. * Defines if multiview should be enabled when rendering (Default: false)
  42567. */
  42568. multiviewEnabled: boolean;
  42569. /**
  42570. * Gets the rendering aspect ratio based on the provided resolutions.
  42571. */
  42572. get aspectRatio(): number;
  42573. /**
  42574. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42575. */
  42576. get aspectRatioFov(): number;
  42577. /**
  42578. * @hidden
  42579. */
  42580. get leftHMatrix(): Matrix;
  42581. /**
  42582. * @hidden
  42583. */
  42584. get rightHMatrix(): Matrix;
  42585. /**
  42586. * @hidden
  42587. */
  42588. get leftPreViewMatrix(): Matrix;
  42589. /**
  42590. * @hidden
  42591. */
  42592. get rightPreViewMatrix(): Matrix;
  42593. /**
  42594. * Get the default VRMetrics based on the most generic setup.
  42595. * @returns the default vr metrics
  42596. */
  42597. static GetDefault(): VRCameraMetrics;
  42598. }
  42599. }
  42600. declare module BABYLON {
  42601. /** @hidden */
  42602. export var vrDistortionCorrectionPixelShader: {
  42603. name: string;
  42604. shader: string;
  42605. };
  42606. }
  42607. declare module BABYLON {
  42608. /**
  42609. * VRDistortionCorrectionPostProcess used for mobile VR
  42610. */
  42611. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42612. private _isRightEye;
  42613. private _distortionFactors;
  42614. private _postProcessScaleFactor;
  42615. private _lensCenterOffset;
  42616. private _scaleIn;
  42617. private _scaleFactor;
  42618. private _lensCenter;
  42619. /**
  42620. * Initializes the VRDistortionCorrectionPostProcess
  42621. * @param name The name of the effect.
  42622. * @param camera The camera to apply the render pass to.
  42623. * @param isRightEye If this is for the right eye distortion
  42624. * @param vrMetrics All the required metrics for the VR camera
  42625. */
  42626. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42627. }
  42628. }
  42629. declare module BABYLON {
  42630. /**
  42631. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42632. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42633. */
  42634. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42635. /**
  42636. * Creates a new VRDeviceOrientationArcRotateCamera
  42637. * @param name defines camera name
  42638. * @param alpha defines the camera rotation along the logitudinal axis
  42639. * @param beta defines the camera rotation along the latitudinal axis
  42640. * @param radius defines the camera distance from its target
  42641. * @param target defines the camera target
  42642. * @param scene defines the scene the camera belongs to
  42643. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42644. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42645. */
  42646. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42647. /**
  42648. * Gets camera class name
  42649. * @returns VRDeviceOrientationArcRotateCamera
  42650. */
  42651. getClassName(): string;
  42652. }
  42653. }
  42654. declare module BABYLON {
  42655. /**
  42656. * Camera used to simulate VR rendering (based on FreeCamera)
  42657. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42658. */
  42659. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42660. /**
  42661. * Creates a new VRDeviceOrientationFreeCamera
  42662. * @param name defines camera name
  42663. * @param position defines the start position of the camera
  42664. * @param scene defines the scene the camera belongs to
  42665. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42666. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42667. */
  42668. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42669. /**
  42670. * Gets camera class name
  42671. * @returns VRDeviceOrientationFreeCamera
  42672. */
  42673. getClassName(): string;
  42674. }
  42675. }
  42676. declare module BABYLON {
  42677. /**
  42678. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42679. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42680. */
  42681. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42682. /**
  42683. * Creates a new VRDeviceOrientationGamepadCamera
  42684. * @param name defines camera name
  42685. * @param position defines the start position of the camera
  42686. * @param scene defines the scene the camera belongs to
  42687. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42688. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42689. */
  42690. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42691. /**
  42692. * Gets camera class name
  42693. * @returns VRDeviceOrientationGamepadCamera
  42694. */
  42695. getClassName(): string;
  42696. }
  42697. }
  42698. declare module BABYLON {
  42699. /** @hidden */
  42700. export var imageProcessingPixelShader: {
  42701. name: string;
  42702. shader: string;
  42703. };
  42704. }
  42705. declare module BABYLON {
  42706. /**
  42707. * ImageProcessingPostProcess
  42708. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42709. */
  42710. export class ImageProcessingPostProcess extends PostProcess {
  42711. /**
  42712. * Default configuration related to image processing available in the PBR Material.
  42713. */
  42714. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42715. /**
  42716. * Gets the image processing configuration used either in this material.
  42717. */
  42718. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42719. /**
  42720. * Sets the Default image processing configuration used either in the this material.
  42721. *
  42722. * If sets to null, the scene one is in use.
  42723. */
  42724. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42725. /**
  42726. * Keep track of the image processing observer to allow dispose and replace.
  42727. */
  42728. private _imageProcessingObserver;
  42729. /**
  42730. * Attaches a new image processing configuration to the PBR Material.
  42731. * @param configuration
  42732. */
  42733. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42734. /**
  42735. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42736. */
  42737. get colorCurves(): Nullable<ColorCurves>;
  42738. /**
  42739. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42740. */
  42741. set colorCurves(value: Nullable<ColorCurves>);
  42742. /**
  42743. * Gets wether the color curves effect is enabled.
  42744. */
  42745. get colorCurvesEnabled(): boolean;
  42746. /**
  42747. * Sets wether the color curves effect is enabled.
  42748. */
  42749. set colorCurvesEnabled(value: boolean);
  42750. /**
  42751. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42752. */
  42753. get colorGradingTexture(): Nullable<BaseTexture>;
  42754. /**
  42755. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42756. */
  42757. set colorGradingTexture(value: Nullable<BaseTexture>);
  42758. /**
  42759. * Gets wether the color grading effect is enabled.
  42760. */
  42761. get colorGradingEnabled(): boolean;
  42762. /**
  42763. * Gets wether the color grading effect is enabled.
  42764. */
  42765. set colorGradingEnabled(value: boolean);
  42766. /**
  42767. * Gets exposure used in the effect.
  42768. */
  42769. get exposure(): number;
  42770. /**
  42771. * Sets exposure used in the effect.
  42772. */
  42773. set exposure(value: number);
  42774. /**
  42775. * Gets wether tonemapping is enabled or not.
  42776. */
  42777. get toneMappingEnabled(): boolean;
  42778. /**
  42779. * Sets wether tonemapping is enabled or not
  42780. */
  42781. set toneMappingEnabled(value: boolean);
  42782. /**
  42783. * Gets the type of tone mapping effect.
  42784. */
  42785. get toneMappingType(): number;
  42786. /**
  42787. * Sets the type of tone mapping effect.
  42788. */
  42789. set toneMappingType(value: number);
  42790. /**
  42791. * Gets contrast used in the effect.
  42792. */
  42793. get contrast(): number;
  42794. /**
  42795. * Sets contrast used in the effect.
  42796. */
  42797. set contrast(value: number);
  42798. /**
  42799. * Gets Vignette stretch size.
  42800. */
  42801. get vignetteStretch(): number;
  42802. /**
  42803. * Sets Vignette stretch size.
  42804. */
  42805. set vignetteStretch(value: number);
  42806. /**
  42807. * Gets Vignette centre X Offset.
  42808. */
  42809. get vignetteCentreX(): number;
  42810. /**
  42811. * Sets Vignette centre X Offset.
  42812. */
  42813. set vignetteCentreX(value: number);
  42814. /**
  42815. * Gets Vignette centre Y Offset.
  42816. */
  42817. get vignetteCentreY(): number;
  42818. /**
  42819. * Sets Vignette centre Y Offset.
  42820. */
  42821. set vignetteCentreY(value: number);
  42822. /**
  42823. * Gets Vignette weight or intensity of the vignette effect.
  42824. */
  42825. get vignetteWeight(): number;
  42826. /**
  42827. * Sets Vignette weight or intensity of the vignette effect.
  42828. */
  42829. set vignetteWeight(value: number);
  42830. /**
  42831. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42832. * if vignetteEnabled is set to true.
  42833. */
  42834. get vignetteColor(): Color4;
  42835. /**
  42836. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42837. * if vignetteEnabled is set to true.
  42838. */
  42839. set vignetteColor(value: Color4);
  42840. /**
  42841. * Gets Camera field of view used by the Vignette effect.
  42842. */
  42843. get vignetteCameraFov(): number;
  42844. /**
  42845. * Sets Camera field of view used by the Vignette effect.
  42846. */
  42847. set vignetteCameraFov(value: number);
  42848. /**
  42849. * Gets the vignette blend mode allowing different kind of effect.
  42850. */
  42851. get vignetteBlendMode(): number;
  42852. /**
  42853. * Sets the vignette blend mode allowing different kind of effect.
  42854. */
  42855. set vignetteBlendMode(value: number);
  42856. /**
  42857. * Gets wether the vignette effect is enabled.
  42858. */
  42859. get vignetteEnabled(): boolean;
  42860. /**
  42861. * Sets wether the vignette effect is enabled.
  42862. */
  42863. set vignetteEnabled(value: boolean);
  42864. private _fromLinearSpace;
  42865. /**
  42866. * Gets wether the input of the processing is in Gamma or Linear Space.
  42867. */
  42868. get fromLinearSpace(): boolean;
  42869. /**
  42870. * Sets wether the input of the processing is in Gamma or Linear Space.
  42871. */
  42872. set fromLinearSpace(value: boolean);
  42873. /**
  42874. * Defines cache preventing GC.
  42875. */
  42876. private _defines;
  42877. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42878. /**
  42879. * "ImageProcessingPostProcess"
  42880. * @returns "ImageProcessingPostProcess"
  42881. */
  42882. getClassName(): string;
  42883. protected _updateParameters(): void;
  42884. dispose(camera?: Camera): void;
  42885. }
  42886. }
  42887. declare module BABYLON {
  42888. /**
  42889. * Class containing static functions to help procedurally build meshes
  42890. */
  42891. export class GroundBuilder {
  42892. /**
  42893. * Creates a ground mesh
  42894. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42895. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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 options defines the options used to create the mesh
  42899. * @param scene defines the hosting scene
  42900. * @returns the ground mesh
  42901. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42902. */
  42903. static CreateGround(name: string, options: {
  42904. width?: number;
  42905. height?: number;
  42906. subdivisions?: number;
  42907. subdivisionsX?: number;
  42908. subdivisionsY?: number;
  42909. updatable?: boolean;
  42910. }, scene: any): Mesh;
  42911. /**
  42912. * Creates a tiled ground mesh
  42913. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42914. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42915. * * 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
  42916. * * 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
  42917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42918. * @param name defines the name of the mesh
  42919. * @param options defines the options used to create the mesh
  42920. * @param scene defines the hosting scene
  42921. * @returns the tiled ground mesh
  42922. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42923. */
  42924. static CreateTiledGround(name: string, options: {
  42925. xmin: number;
  42926. zmin: number;
  42927. xmax: number;
  42928. zmax: number;
  42929. subdivisions?: {
  42930. w: number;
  42931. h: number;
  42932. };
  42933. precision?: {
  42934. w: number;
  42935. h: number;
  42936. };
  42937. updatable?: boolean;
  42938. }, scene?: Nullable<Scene>): Mesh;
  42939. /**
  42940. * Creates a ground mesh from a height map
  42941. * * The parameter `url` sets the URL of the height map image resource.
  42942. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42943. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42944. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42945. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42946. * * 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.
  42947. * * 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).
  42948. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42950. * @param name defines the name of the mesh
  42951. * @param url defines the url to the height map
  42952. * @param options defines the options used to create the mesh
  42953. * @param scene defines the hosting scene
  42954. * @returns the ground mesh
  42955. * @see https://doc.babylonjs.com/babylon101/height_map
  42956. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42957. */
  42958. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42959. width?: number;
  42960. height?: number;
  42961. subdivisions?: number;
  42962. minHeight?: number;
  42963. maxHeight?: number;
  42964. colorFilter?: Color3;
  42965. alphaFilter?: number;
  42966. updatable?: boolean;
  42967. onReady?: (mesh: GroundMesh) => void;
  42968. }, scene?: Nullable<Scene>): GroundMesh;
  42969. }
  42970. }
  42971. declare module BABYLON {
  42972. /**
  42973. * Class containing static functions to help procedurally build meshes
  42974. */
  42975. export class TorusBuilder {
  42976. /**
  42977. * Creates a torus mesh
  42978. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42979. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42980. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42982. * * 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
  42983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42984. * @param name defines the name of the mesh
  42985. * @param options defines the options used to create the mesh
  42986. * @param scene defines the hosting scene
  42987. * @returns the torus mesh
  42988. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42989. */
  42990. static CreateTorus(name: string, options: {
  42991. diameter?: number;
  42992. thickness?: number;
  42993. tessellation?: number;
  42994. updatable?: boolean;
  42995. sideOrientation?: number;
  42996. frontUVs?: Vector4;
  42997. backUVs?: Vector4;
  42998. }, scene: any): Mesh;
  42999. }
  43000. }
  43001. declare module BABYLON {
  43002. /**
  43003. * Class containing static functions to help procedurally build meshes
  43004. */
  43005. export class CylinderBuilder {
  43006. /**
  43007. * Creates a cylinder or a cone mesh
  43008. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43009. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43010. * * 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.
  43011. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43012. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43013. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43014. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43015. * * 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).
  43016. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43017. * * 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).
  43018. * * 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
  43019. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43020. * * 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
  43021. * * 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.
  43022. * * If `enclose` is false, a ring surface is one element.
  43023. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43024. * * 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
  43025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43026. * * 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
  43027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43028. * @param name defines the name of the mesh
  43029. * @param options defines the options used to create the mesh
  43030. * @param scene defines the hosting scene
  43031. * @returns the cylinder mesh
  43032. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43033. */
  43034. static CreateCylinder(name: string, options: {
  43035. height?: number;
  43036. diameterTop?: number;
  43037. diameterBottom?: number;
  43038. diameter?: number;
  43039. tessellation?: number;
  43040. subdivisions?: number;
  43041. arc?: number;
  43042. faceColors?: Color4[];
  43043. faceUV?: Vector4[];
  43044. updatable?: boolean;
  43045. hasRings?: boolean;
  43046. enclose?: boolean;
  43047. cap?: number;
  43048. sideOrientation?: number;
  43049. frontUVs?: Vector4;
  43050. backUVs?: Vector4;
  43051. }, scene: any): Mesh;
  43052. }
  43053. }
  43054. declare module BABYLON {
  43055. /**
  43056. * States of the webXR experience
  43057. */
  43058. export enum WebXRState {
  43059. /**
  43060. * Transitioning to being in XR mode
  43061. */
  43062. ENTERING_XR = 0,
  43063. /**
  43064. * Transitioning to non XR mode
  43065. */
  43066. EXITING_XR = 1,
  43067. /**
  43068. * In XR mode and presenting
  43069. */
  43070. IN_XR = 2,
  43071. /**
  43072. * Not entered XR mode
  43073. */
  43074. NOT_IN_XR = 3
  43075. }
  43076. /**
  43077. * Abstraction of the XR render target
  43078. */
  43079. export interface WebXRRenderTarget extends IDisposable {
  43080. /**
  43081. * xrpresent context of the canvas which can be used to display/mirror xr content
  43082. */
  43083. canvasContext: WebGLRenderingContext;
  43084. /**
  43085. * xr layer for the canvas
  43086. */
  43087. xrLayer: Nullable<XRWebGLLayer>;
  43088. /**
  43089. * Initializes the xr layer for the session
  43090. * @param xrSession xr session
  43091. * @returns a promise that will resolve once the XR Layer has been created
  43092. */
  43093. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43094. }
  43095. }
  43096. declare module BABYLON {
  43097. /**
  43098. * COnfiguration object for WebXR output canvas
  43099. */
  43100. export class WebXRManagedOutputCanvasOptions {
  43101. /**
  43102. * An optional canvas in case you wish to create it yourself and provide it here.
  43103. * If not provided, a new canvas will be created
  43104. */
  43105. canvasElement?: HTMLCanvasElement;
  43106. /**
  43107. * Options for this XR Layer output
  43108. */
  43109. canvasOptions?: XRWebGLLayerOptions;
  43110. /**
  43111. * CSS styling for a newly created canvas (if not provided)
  43112. */
  43113. newCanvasCssStyle?: string;
  43114. /**
  43115. * Get the default values of the configuration object
  43116. * @returns default values of this configuration object
  43117. */
  43118. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43119. }
  43120. /**
  43121. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43122. */
  43123. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43124. private _options;
  43125. private _canvas;
  43126. private _engine;
  43127. /**
  43128. * Rendering context of the canvas which can be used to display/mirror xr content
  43129. */
  43130. canvasContext: WebGLRenderingContext;
  43131. /**
  43132. * xr layer for the canvas
  43133. */
  43134. xrLayer: Nullable<XRWebGLLayer>;
  43135. /**
  43136. * Initializes the canvas to be added/removed upon entering/exiting xr
  43137. * @param _xrSessionManager The XR Session manager
  43138. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43139. */
  43140. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43141. /**
  43142. * Disposes of the object
  43143. */
  43144. dispose(): void;
  43145. /**
  43146. * Initializes the xr layer for the session
  43147. * @param xrSession xr session
  43148. * @returns a promise that will resolve once the XR Layer has been created
  43149. */
  43150. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43151. private _addCanvas;
  43152. private _removeCanvas;
  43153. private _setManagedOutputCanvas;
  43154. }
  43155. }
  43156. declare module BABYLON {
  43157. /**
  43158. * Manages an XRSession to work with Babylon's engine
  43159. * @see https://doc.babylonjs.com/how_to/webxr
  43160. */
  43161. export class WebXRSessionManager implements IDisposable {
  43162. /** The scene which the session should be created for */
  43163. scene: Scene;
  43164. private _referenceSpace;
  43165. private _rttProvider;
  43166. private _sessionEnded;
  43167. private _xrNavigator;
  43168. private baseLayer;
  43169. /**
  43170. * The base reference space from which the session started. good if you want to reset your
  43171. * reference space
  43172. */
  43173. baseReferenceSpace: XRReferenceSpace;
  43174. /**
  43175. * Current XR frame
  43176. */
  43177. currentFrame: Nullable<XRFrame>;
  43178. /** WebXR timestamp updated every frame */
  43179. currentTimestamp: number;
  43180. /**
  43181. * Used just in case of a failure to initialize an immersive session.
  43182. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43183. */
  43184. defaultHeightCompensation: number;
  43185. /**
  43186. * Fires every time a new xrFrame arrives which can be used to update the camera
  43187. */
  43188. onXRFrameObservable: Observable<XRFrame>;
  43189. /**
  43190. * Fires when the reference space changed
  43191. */
  43192. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43193. /**
  43194. * Fires when the xr session is ended either by the device or manually done
  43195. */
  43196. onXRSessionEnded: Observable<any>;
  43197. /**
  43198. * Fires when the xr session is ended either by the device or manually done
  43199. */
  43200. onXRSessionInit: Observable<XRSession>;
  43201. /**
  43202. * Underlying xr session
  43203. */
  43204. session: XRSession;
  43205. /**
  43206. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43207. * or get the offset the player is currently at.
  43208. */
  43209. viewerReferenceSpace: XRReferenceSpace;
  43210. /**
  43211. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43212. * @param scene The scene which the session should be created for
  43213. */
  43214. constructor(
  43215. /** The scene which the session should be created for */
  43216. scene: Scene);
  43217. /**
  43218. * The current reference space used in this session. This reference space can constantly change!
  43219. * It is mainly used to offset the camera's position.
  43220. */
  43221. get referenceSpace(): XRReferenceSpace;
  43222. /**
  43223. * Set a new reference space and triggers the observable
  43224. */
  43225. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43226. /**
  43227. * Disposes of the session manager
  43228. */
  43229. dispose(): void;
  43230. /**
  43231. * Stops the xrSession and restores the render loop
  43232. * @returns Promise which resolves after it exits XR
  43233. */
  43234. exitXRAsync(): Promise<void>;
  43235. /**
  43236. * Gets the correct render target texture to be rendered this frame for this eye
  43237. * @param eye the eye for which to get the render target
  43238. * @returns the render target for the specified eye
  43239. */
  43240. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43241. /**
  43242. * Creates a WebXRRenderTarget object for the XR session
  43243. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43244. * @param options optional options to provide when creating a new render target
  43245. * @returns a WebXR render target to which the session can render
  43246. */
  43247. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43248. /**
  43249. * Initializes the manager
  43250. * After initialization enterXR can be called to start an XR session
  43251. * @returns Promise which resolves after it is initialized
  43252. */
  43253. initializeAsync(): Promise<void>;
  43254. /**
  43255. * Initializes an xr session
  43256. * @param xrSessionMode mode to initialize
  43257. * @param xrSessionInit defines optional and required values to pass to the session builder
  43258. * @returns a promise which will resolve once the session has been initialized
  43259. */
  43260. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43261. /**
  43262. * Checks if a session would be supported for the creation options specified
  43263. * @param sessionMode session mode to check if supported eg. immersive-vr
  43264. * @returns A Promise that resolves to true if supported and false if not
  43265. */
  43266. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43267. /**
  43268. * Resets the reference space to the one started the session
  43269. */
  43270. resetReferenceSpace(): void;
  43271. /**
  43272. * Starts rendering to the xr layer
  43273. */
  43274. runXRRenderLoop(): void;
  43275. /**
  43276. * Sets the reference space on the xr session
  43277. * @param referenceSpaceType space to set
  43278. * @returns a promise that will resolve once the reference space has been set
  43279. */
  43280. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43281. /**
  43282. * Updates the render state of the session
  43283. * @param state state to set
  43284. * @returns a promise that resolves once the render state has been updated
  43285. */
  43286. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43287. /**
  43288. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43289. * @param sessionMode defines the session to test
  43290. * @returns a promise with boolean as final value
  43291. */
  43292. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43293. private _createRenderTargetTexture;
  43294. }
  43295. }
  43296. declare module BABYLON {
  43297. /**
  43298. * WebXR Camera which holds the views for the xrSession
  43299. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43300. */
  43301. export class WebXRCamera extends FreeCamera {
  43302. private _xrSessionManager;
  43303. private _firstFrame;
  43304. private _referenceQuaternion;
  43305. private _referencedPosition;
  43306. private _xrInvPositionCache;
  43307. private _xrInvQuaternionCache;
  43308. /**
  43309. * Should position compensation execute on first frame.
  43310. * This is used when copying the position from a native (non XR) camera
  43311. */
  43312. compensateOnFirstFrame: boolean;
  43313. /**
  43314. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43315. * @param name the name of the camera
  43316. * @param scene the scene to add the camera to
  43317. * @param _xrSessionManager a constructed xr session manager
  43318. */
  43319. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43320. /**
  43321. * Return the user's height, unrelated to the current ground.
  43322. * This will be the y position of this camera, when ground level is 0.
  43323. */
  43324. get realWorldHeight(): number;
  43325. /** @hidden */
  43326. _updateForDualEyeDebugging(): void;
  43327. /**
  43328. * Sets this camera's transformation based on a non-vr camera
  43329. * @param otherCamera the non-vr camera to copy the transformation from
  43330. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43331. */
  43332. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43333. /**
  43334. * Gets the current instance class name ("WebXRCamera").
  43335. * @returns the class name
  43336. */
  43337. getClassName(): string;
  43338. private _updateFromXRSession;
  43339. private _updateNumberOfRigCameras;
  43340. private _updateReferenceSpace;
  43341. private _updateReferenceSpaceOffset;
  43342. }
  43343. }
  43344. declare module BABYLON {
  43345. /**
  43346. * Defining the interface required for a (webxr) feature
  43347. */
  43348. export interface IWebXRFeature extends IDisposable {
  43349. /**
  43350. * Is this feature attached
  43351. */
  43352. attached: boolean;
  43353. /**
  43354. * Should auto-attach be disabled?
  43355. */
  43356. disableAutoAttach: boolean;
  43357. /**
  43358. * Attach the feature to the session
  43359. * Will usually be called by the features manager
  43360. *
  43361. * @param force should attachment be forced (even when already attached)
  43362. * @returns true if successful.
  43363. */
  43364. attach(force?: boolean): boolean;
  43365. /**
  43366. * Detach the feature from the session
  43367. * Will usually be called by the features manager
  43368. *
  43369. * @returns true if successful.
  43370. */
  43371. detach(): boolean;
  43372. }
  43373. /**
  43374. * A list of the currently available features without referencing them
  43375. */
  43376. export class WebXRFeatureName {
  43377. /**
  43378. * The name of the anchor system feature
  43379. */
  43380. static ANCHOR_SYSTEM: string;
  43381. /**
  43382. * The name of the background remover feature
  43383. */
  43384. static BACKGROUND_REMOVER: string;
  43385. /**
  43386. * The name of the hit test feature
  43387. */
  43388. static HIT_TEST: string;
  43389. /**
  43390. * physics impostors for xr controllers feature
  43391. */
  43392. static PHYSICS_CONTROLLERS: string;
  43393. /**
  43394. * The name of the plane detection feature
  43395. */
  43396. static PLANE_DETECTION: string;
  43397. /**
  43398. * The name of the pointer selection feature
  43399. */
  43400. static POINTER_SELECTION: string;
  43401. /**
  43402. * The name of the teleportation feature
  43403. */
  43404. static TELEPORTATION: string;
  43405. }
  43406. /**
  43407. * Defining the constructor of a feature. Used to register the modules.
  43408. */
  43409. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43410. /**
  43411. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43412. * It is mainly used in AR sessions.
  43413. *
  43414. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43415. */
  43416. export class WebXRFeaturesManager implements IDisposable {
  43417. private _xrSessionManager;
  43418. private static readonly _AvailableFeatures;
  43419. private _features;
  43420. /**
  43421. * constructs a new features manages.
  43422. *
  43423. * @param _xrSessionManager an instance of WebXRSessionManager
  43424. */
  43425. constructor(_xrSessionManager: WebXRSessionManager);
  43426. /**
  43427. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43428. * Mainly used internally.
  43429. *
  43430. * @param featureName the name of the feature to register
  43431. * @param constructorFunction the function used to construct the module
  43432. * @param version the (babylon) version of the module
  43433. * @param stable is that a stable version of this module
  43434. */
  43435. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43436. /**
  43437. * Returns a constructor of a specific feature.
  43438. *
  43439. * @param featureName the name of the feature to construct
  43440. * @param version the version of the feature to load
  43441. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43442. * @param options optional options provided to the module.
  43443. * @returns a function that, when called, will return a new instance of this feature
  43444. */
  43445. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43446. /**
  43447. * Can be used to return the list of features currently registered
  43448. *
  43449. * @returns an Array of available features
  43450. */
  43451. static GetAvailableFeatures(): string[];
  43452. /**
  43453. * Gets the versions available for a specific feature
  43454. * @param featureName the name of the feature
  43455. * @returns an array with the available versions
  43456. */
  43457. static GetAvailableVersions(featureName: string): string[];
  43458. /**
  43459. * Return the latest unstable version of this feature
  43460. * @param featureName the name of the feature to search
  43461. * @returns the version number. if not found will return -1
  43462. */
  43463. static GetLatestVersionOfFeature(featureName: string): number;
  43464. /**
  43465. * Return the latest stable version of this feature
  43466. * @param featureName the name of the feature to search
  43467. * @returns the version number. if not found will return -1
  43468. */
  43469. static GetStableVersionOfFeature(featureName: string): number;
  43470. /**
  43471. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43472. * Can be used during a session to start a feature
  43473. * @param featureName the name of feature to attach
  43474. */
  43475. attachFeature(featureName: string): void;
  43476. /**
  43477. * Can be used inside a session or when the session ends to detach a specific feature
  43478. * @param featureName the name of the feature to detach
  43479. */
  43480. detachFeature(featureName: string): void;
  43481. /**
  43482. * Used to disable an already-enabled feature
  43483. * The feature will be disposed and will be recreated once enabled.
  43484. * @param featureName the feature to disable
  43485. * @returns true if disable was successful
  43486. */
  43487. disableFeature(featureName: string | {
  43488. Name: string;
  43489. }): boolean;
  43490. /**
  43491. * dispose this features manager
  43492. */
  43493. dispose(): void;
  43494. /**
  43495. * 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.
  43496. * 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.
  43497. *
  43498. * @param featureName the name of the feature to load or the class of the feature
  43499. * @param version optional version to load. if not provided the latest version will be enabled
  43500. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43501. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43502. * @returns a new constructed feature or throws an error if feature not found.
  43503. */
  43504. enableFeature(featureName: string | {
  43505. Name: string;
  43506. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43507. /**
  43508. * get the implementation of an enabled feature.
  43509. * @param featureName the name of the feature to load
  43510. * @returns the feature class, if found
  43511. */
  43512. getEnabledFeature(featureName: string): IWebXRFeature;
  43513. /**
  43514. * Get the list of enabled features
  43515. * @returns an array of enabled features
  43516. */
  43517. getEnabledFeatures(): string[];
  43518. }
  43519. }
  43520. declare module BABYLON {
  43521. /**
  43522. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43523. * @see https://doc.babylonjs.com/how_to/webxr
  43524. */
  43525. export class WebXRExperienceHelper implements IDisposable {
  43526. private scene;
  43527. private _nonVRCamera;
  43528. private _originalSceneAutoClear;
  43529. private _supported;
  43530. /**
  43531. * Camera used to render xr content
  43532. */
  43533. camera: WebXRCamera;
  43534. /** A features manager for this xr session */
  43535. featuresManager: WebXRFeaturesManager;
  43536. /**
  43537. * Observers registered here will be triggered after the camera's initial transformation is set
  43538. * This can be used to set a different ground level or an extra rotation.
  43539. *
  43540. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43541. * to the position set after this observable is done executing.
  43542. */
  43543. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43544. /**
  43545. * Fires when the state of the experience helper has changed
  43546. */
  43547. onStateChangedObservable: Observable<WebXRState>;
  43548. /** Session manager used to keep track of xr session */
  43549. sessionManager: WebXRSessionManager;
  43550. /**
  43551. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43552. */
  43553. state: WebXRState;
  43554. /**
  43555. * Creates a WebXRExperienceHelper
  43556. * @param scene The scene the helper should be created in
  43557. */
  43558. private constructor();
  43559. /**
  43560. * Creates the experience helper
  43561. * @param scene the scene to attach the experience helper to
  43562. * @returns a promise for the experience helper
  43563. */
  43564. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43565. /**
  43566. * Disposes of the experience helper
  43567. */
  43568. dispose(): void;
  43569. /**
  43570. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43571. * @param sessionMode options for the XR session
  43572. * @param referenceSpaceType frame of reference of the XR session
  43573. * @param renderTarget the output canvas that will be used to enter XR mode
  43574. * @returns promise that resolves after xr mode has entered
  43575. */
  43576. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43577. /**
  43578. * Exits XR mode and returns the scene to its original state
  43579. * @returns promise that resolves after xr mode has exited
  43580. */
  43581. exitXRAsync(): Promise<void>;
  43582. private _nonXRToXRCamera;
  43583. private _setState;
  43584. }
  43585. }
  43586. declare module BABYLON {
  43587. /**
  43588. * X-Y values for axes in WebXR
  43589. */
  43590. export interface IWebXRMotionControllerAxesValue {
  43591. /**
  43592. * The value of the x axis
  43593. */
  43594. x: number;
  43595. /**
  43596. * The value of the y-axis
  43597. */
  43598. y: number;
  43599. }
  43600. /**
  43601. * changed / previous values for the values of this component
  43602. */
  43603. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43604. /**
  43605. * current (this frame) value
  43606. */
  43607. current: T;
  43608. /**
  43609. * previous (last change) value
  43610. */
  43611. previous: T;
  43612. }
  43613. /**
  43614. * Represents changes in the component between current frame and last values recorded
  43615. */
  43616. export interface IWebXRMotionControllerComponentChanges {
  43617. /**
  43618. * will be populated with previous and current values if axes changed
  43619. */
  43620. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43621. /**
  43622. * will be populated with previous and current values if pressed changed
  43623. */
  43624. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43625. /**
  43626. * will be populated with previous and current values if touched changed
  43627. */
  43628. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43629. /**
  43630. * will be populated with previous and current values if value changed
  43631. */
  43632. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43633. }
  43634. /**
  43635. * This class represents a single component (for example button or thumbstick) of a motion controller
  43636. */
  43637. export class WebXRControllerComponent implements IDisposable {
  43638. /**
  43639. * the id of this component
  43640. */
  43641. id: string;
  43642. /**
  43643. * the type of the component
  43644. */
  43645. type: MotionControllerComponentType;
  43646. private _buttonIndex;
  43647. private _axesIndices;
  43648. private _axes;
  43649. private _changes;
  43650. private _currentValue;
  43651. private _hasChanges;
  43652. private _pressed;
  43653. private _touched;
  43654. /**
  43655. * button component type
  43656. */
  43657. static BUTTON_TYPE: MotionControllerComponentType;
  43658. /**
  43659. * squeeze component type
  43660. */
  43661. static SQUEEZE_TYPE: MotionControllerComponentType;
  43662. /**
  43663. * Thumbstick component type
  43664. */
  43665. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43666. /**
  43667. * Touchpad component type
  43668. */
  43669. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43670. /**
  43671. * trigger component type
  43672. */
  43673. static TRIGGER_TYPE: MotionControllerComponentType;
  43674. /**
  43675. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43676. * the axes data changes
  43677. */
  43678. onAxisValueChangedObservable: Observable<{
  43679. x: number;
  43680. y: number;
  43681. }>;
  43682. /**
  43683. * Observers registered here will be triggered when the state of a button changes
  43684. * State change is either pressed / touched / value
  43685. */
  43686. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43687. /**
  43688. * Creates a new component for a motion controller.
  43689. * It is created by the motion controller itself
  43690. *
  43691. * @param id the id of this component
  43692. * @param type the type of the component
  43693. * @param _buttonIndex index in the buttons array of the gamepad
  43694. * @param _axesIndices indices of the values in the axes array of the gamepad
  43695. */
  43696. constructor(
  43697. /**
  43698. * the id of this component
  43699. */
  43700. id: string,
  43701. /**
  43702. * the type of the component
  43703. */
  43704. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43705. /**
  43706. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43707. */
  43708. get axes(): IWebXRMotionControllerAxesValue;
  43709. /**
  43710. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43711. */
  43712. get changes(): IWebXRMotionControllerComponentChanges;
  43713. /**
  43714. * Return whether or not the component changed the last frame
  43715. */
  43716. get hasChanges(): boolean;
  43717. /**
  43718. * is the button currently pressed
  43719. */
  43720. get pressed(): boolean;
  43721. /**
  43722. * is the button currently touched
  43723. */
  43724. get touched(): boolean;
  43725. /**
  43726. * Get the current value of this component
  43727. */
  43728. get value(): number;
  43729. /**
  43730. * Dispose this component
  43731. */
  43732. dispose(): void;
  43733. /**
  43734. * Are there axes correlating to this component
  43735. * @return true is axes data is available
  43736. */
  43737. isAxes(): boolean;
  43738. /**
  43739. * Is this component a button (hence - pressable)
  43740. * @returns true if can be pressed
  43741. */
  43742. isButton(): boolean;
  43743. /**
  43744. * update this component using the gamepad object it is in. Called on every frame
  43745. * @param nativeController the native gamepad controller object
  43746. */
  43747. update(nativeController: IMinimalMotionControllerObject): void;
  43748. }
  43749. }
  43750. declare module BABYLON {
  43751. /**
  43752. * Class used to represent data loading progression
  43753. */
  43754. export class SceneLoaderProgressEvent {
  43755. /** defines if data length to load can be evaluated */
  43756. readonly lengthComputable: boolean;
  43757. /** defines the loaded data length */
  43758. readonly loaded: number;
  43759. /** defines the data length to load */
  43760. readonly total: number;
  43761. /**
  43762. * Create a new progress event
  43763. * @param lengthComputable defines if data length to load can be evaluated
  43764. * @param loaded defines the loaded data length
  43765. * @param total defines the data length to load
  43766. */
  43767. constructor(
  43768. /** defines if data length to load can be evaluated */
  43769. lengthComputable: boolean,
  43770. /** defines the loaded data length */
  43771. loaded: number,
  43772. /** defines the data length to load */
  43773. total: number);
  43774. /**
  43775. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43776. * @param event defines the source event
  43777. * @returns a new SceneLoaderProgressEvent
  43778. */
  43779. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43780. }
  43781. /**
  43782. * Interface used by SceneLoader plugins to define supported file extensions
  43783. */
  43784. export interface ISceneLoaderPluginExtensions {
  43785. /**
  43786. * Defines the list of supported extensions
  43787. */
  43788. [extension: string]: {
  43789. isBinary: boolean;
  43790. };
  43791. }
  43792. /**
  43793. * Interface used by SceneLoader plugin factory
  43794. */
  43795. export interface ISceneLoaderPluginFactory {
  43796. /**
  43797. * Defines the name of the factory
  43798. */
  43799. name: string;
  43800. /**
  43801. * Function called to create a new plugin
  43802. * @return the new plugin
  43803. */
  43804. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43805. /**
  43806. * The callback that returns true if the data can be directly loaded.
  43807. * @param data string containing the file data
  43808. * @returns if the data can be loaded directly
  43809. */
  43810. canDirectLoad?(data: string): boolean;
  43811. }
  43812. /**
  43813. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43814. */
  43815. export interface ISceneLoaderPluginBase {
  43816. /**
  43817. * The friendly name of this plugin.
  43818. */
  43819. name: string;
  43820. /**
  43821. * The file extensions supported by this plugin.
  43822. */
  43823. extensions: string | ISceneLoaderPluginExtensions;
  43824. /**
  43825. * The callback called when loading from a url.
  43826. * @param scene scene loading this url
  43827. * @param url url to load
  43828. * @param onSuccess callback called when the file successfully loads
  43829. * @param onProgress callback called while file is loading (if the server supports this mode)
  43830. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43831. * @param onError callback called when the file fails to load
  43832. * @returns a file request object
  43833. */
  43834. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43835. /**
  43836. * The callback called when loading from a file object.
  43837. * @param scene scene loading this file
  43838. * @param file defines the file to load
  43839. * @param onSuccess defines the callback to call when data is loaded
  43840. * @param onProgress defines the callback to call during loading process
  43841. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43842. * @param onError defines the callback to call when an error occurs
  43843. * @returns a file request object
  43844. */
  43845. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43846. /**
  43847. * The callback that returns true if the data can be directly loaded.
  43848. * @param data string containing the file data
  43849. * @returns if the data can be loaded directly
  43850. */
  43851. canDirectLoad?(data: string): boolean;
  43852. /**
  43853. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43854. * @param scene scene loading this data
  43855. * @param data string containing the data
  43856. * @returns data to pass to the plugin
  43857. */
  43858. directLoad?(scene: Scene, data: string): any;
  43859. /**
  43860. * The callback that allows custom handling of the root url based on the response url.
  43861. * @param rootUrl the original root url
  43862. * @param responseURL the response url if available
  43863. * @returns the new root url
  43864. */
  43865. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43866. }
  43867. /**
  43868. * Interface used to define a SceneLoader plugin
  43869. */
  43870. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43871. /**
  43872. * Import meshes into a scene.
  43873. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43874. * @param scene The scene to import into
  43875. * @param data The data to import
  43876. * @param rootUrl The root url for scene and resources
  43877. * @param meshes The meshes array to import into
  43878. * @param particleSystems The particle systems array to import into
  43879. * @param skeletons The skeletons array to import into
  43880. * @param onError The callback when import fails
  43881. * @returns True if successful or false otherwise
  43882. */
  43883. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43884. /**
  43885. * Load into a scene.
  43886. * @param scene The scene to load into
  43887. * @param data The data to import
  43888. * @param rootUrl The root url for scene and resources
  43889. * @param onError The callback when import fails
  43890. * @returns True if successful or false otherwise
  43891. */
  43892. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43893. /**
  43894. * Load into an asset container.
  43895. * @param scene The scene to load into
  43896. * @param data The data to import
  43897. * @param rootUrl The root url for scene and resources
  43898. * @param onError The callback when import fails
  43899. * @returns The loaded asset container
  43900. */
  43901. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43902. }
  43903. /**
  43904. * Interface used to define an async SceneLoader plugin
  43905. */
  43906. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43907. /**
  43908. * Import meshes into a scene.
  43909. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43910. * @param scene The scene to import into
  43911. * @param data The data to import
  43912. * @param rootUrl The root url for scene and resources
  43913. * @param onProgress The callback when the load progresses
  43914. * @param fileName Defines the name of the file to load
  43915. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43916. */
  43917. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43918. meshes: AbstractMesh[];
  43919. particleSystems: IParticleSystem[];
  43920. skeletons: Skeleton[];
  43921. animationGroups: AnimationGroup[];
  43922. }>;
  43923. /**
  43924. * Load into a scene.
  43925. * @param scene The scene to load into
  43926. * @param data The data to import
  43927. * @param rootUrl The root url for scene and resources
  43928. * @param onProgress The callback when the load progresses
  43929. * @param fileName Defines the name of the file to load
  43930. * @returns Nothing
  43931. */
  43932. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43933. /**
  43934. * Load into an asset container.
  43935. * @param scene The scene to load into
  43936. * @param data The data to import
  43937. * @param rootUrl The root url for scene and resources
  43938. * @param onProgress The callback when the load progresses
  43939. * @param fileName Defines the name of the file to load
  43940. * @returns The loaded asset container
  43941. */
  43942. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43943. }
  43944. /**
  43945. * Mode that determines how to handle old animation groups before loading new ones.
  43946. */
  43947. export enum SceneLoaderAnimationGroupLoadingMode {
  43948. /**
  43949. * Reset all old animations to initial state then dispose them.
  43950. */
  43951. Clean = 0,
  43952. /**
  43953. * Stop all old animations.
  43954. */
  43955. Stop = 1,
  43956. /**
  43957. * Restart old animations from first frame.
  43958. */
  43959. Sync = 2,
  43960. /**
  43961. * Old animations remains untouched.
  43962. */
  43963. NoSync = 3
  43964. }
  43965. /**
  43966. * Class used to load scene from various file formats using registered plugins
  43967. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43968. */
  43969. export class SceneLoader {
  43970. /**
  43971. * No logging while loading
  43972. */
  43973. static readonly NO_LOGGING: number;
  43974. /**
  43975. * Minimal logging while loading
  43976. */
  43977. static readonly MINIMAL_LOGGING: number;
  43978. /**
  43979. * Summary logging while loading
  43980. */
  43981. static readonly SUMMARY_LOGGING: number;
  43982. /**
  43983. * Detailled logging while loading
  43984. */
  43985. static readonly DETAILED_LOGGING: number;
  43986. /**
  43987. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43988. */
  43989. static get ForceFullSceneLoadingForIncremental(): boolean;
  43990. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43991. /**
  43992. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43993. */
  43994. static get ShowLoadingScreen(): boolean;
  43995. static set ShowLoadingScreen(value: boolean);
  43996. /**
  43997. * Defines the current logging level (while loading the scene)
  43998. * @ignorenaming
  43999. */
  44000. static get loggingLevel(): number;
  44001. static set loggingLevel(value: number);
  44002. /**
  44003. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44004. */
  44005. static get CleanBoneMatrixWeights(): boolean;
  44006. static set CleanBoneMatrixWeights(value: boolean);
  44007. /**
  44008. * Event raised when a plugin is used to load a scene
  44009. */
  44010. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44011. private static _registeredPlugins;
  44012. private static _getDefaultPlugin;
  44013. private static _getPluginForExtension;
  44014. private static _getPluginForDirectLoad;
  44015. private static _getPluginForFilename;
  44016. private static _getDirectLoad;
  44017. private static _loadData;
  44018. private static _getFileInfo;
  44019. /**
  44020. * Gets a plugin that can load the given extension
  44021. * @param extension defines the extension to load
  44022. * @returns a plugin or null if none works
  44023. */
  44024. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44025. /**
  44026. * Gets a boolean indicating that the given extension can be loaded
  44027. * @param extension defines the extension to load
  44028. * @returns true if the extension is supported
  44029. */
  44030. static IsPluginForExtensionAvailable(extension: string): boolean;
  44031. /**
  44032. * Adds a new plugin to the list of registered plugins
  44033. * @param plugin defines the plugin to add
  44034. */
  44035. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44036. /**
  44037. * Import meshes into a scene
  44038. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44039. * @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)
  44040. * @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)
  44041. * @param scene the instance of BABYLON.Scene to append to
  44042. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44043. * @param onProgress a callback with a progress event for each file being loaded
  44044. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44045. * @param pluginExtension the extension used to determine the plugin
  44046. * @returns The loaded plugin
  44047. */
  44048. 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>;
  44049. /**
  44050. * Import meshes into a scene
  44051. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44052. * @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)
  44053. * @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)
  44054. * @param scene the instance of BABYLON.Scene to append to
  44055. * @param onProgress a callback with a progress event for each file being loaded
  44056. * @param pluginExtension the extension used to determine the plugin
  44057. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44058. */
  44059. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44060. meshes: AbstractMesh[];
  44061. particleSystems: IParticleSystem[];
  44062. skeletons: Skeleton[];
  44063. animationGroups: AnimationGroup[];
  44064. }>;
  44065. /**
  44066. * Load a scene
  44067. * @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)
  44068. * @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)
  44069. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44070. * @param onSuccess a callback with the scene when import succeeds
  44071. * @param onProgress a callback with a progress event for each file being loaded
  44072. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44073. * @param pluginExtension the extension used to determine the plugin
  44074. * @returns The loaded plugin
  44075. */
  44076. 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>;
  44077. /**
  44078. * Load a scene
  44079. * @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)
  44080. * @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)
  44081. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44082. * @param onProgress a callback with a progress event for each file being loaded
  44083. * @param pluginExtension the extension used to determine the plugin
  44084. * @returns The loaded scene
  44085. */
  44086. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44087. /**
  44088. * Append a scene
  44089. * @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)
  44090. * @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)
  44091. * @param scene is the instance of BABYLON.Scene to append to
  44092. * @param onSuccess a callback with the scene when import succeeds
  44093. * @param onProgress a callback with a progress event for each file being loaded
  44094. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44095. * @param pluginExtension the extension used to determine the plugin
  44096. * @returns The loaded plugin
  44097. */
  44098. 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>;
  44099. /**
  44100. * Append a scene
  44101. * @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)
  44102. * @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)
  44103. * @param scene is the instance of BABYLON.Scene to append to
  44104. * @param onProgress a callback with a progress event for each file being loaded
  44105. * @param pluginExtension the extension used to determine the plugin
  44106. * @returns The given scene
  44107. */
  44108. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44109. /**
  44110. * Load a scene into an asset container
  44111. * @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)
  44112. * @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)
  44113. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44114. * @param onSuccess a callback with the scene when import succeeds
  44115. * @param onProgress a callback with a progress event for each file being loaded
  44116. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44117. * @param pluginExtension the extension used to determine the plugin
  44118. * @returns The loaded plugin
  44119. */
  44120. 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>;
  44121. /**
  44122. * Load a scene into an asset container
  44123. * @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)
  44124. * @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)
  44125. * @param scene is the instance of Scene to append to
  44126. * @param onProgress a callback with a progress event for each file being loaded
  44127. * @param pluginExtension the extension used to determine the plugin
  44128. * @returns The loaded asset container
  44129. */
  44130. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44131. /**
  44132. * Import animations from a file into a scene
  44133. * @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)
  44134. * @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)
  44135. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44136. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44137. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44138. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44139. * @param onSuccess a callback with the scene when import succeeds
  44140. * @param onProgress a callback with a progress event for each file being loaded
  44141. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44142. */
  44143. 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;
  44144. /**
  44145. * Import animations from a file into a scene
  44146. * @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)
  44147. * @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)
  44148. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44149. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44150. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44151. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44152. * @param onSuccess a callback with the scene when import succeeds
  44153. * @param onProgress a callback with a progress event for each file being loaded
  44154. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44155. * @returns the updated scene with imported animations
  44156. */
  44157. 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>;
  44158. }
  44159. }
  44160. declare module BABYLON {
  44161. /**
  44162. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44163. */
  44164. export type MotionControllerHandness = "none" | "left" | "right";
  44165. /**
  44166. * The type of components available in motion controllers.
  44167. * This is not the name of the component.
  44168. */
  44169. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44170. /**
  44171. * The state of a controller component
  44172. */
  44173. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44174. /**
  44175. * The schema of motion controller layout.
  44176. * No object will be initialized using this interface
  44177. * This is used just to define the profile.
  44178. */
  44179. export interface IMotionControllerLayout {
  44180. /**
  44181. * Path to load the assets. Usually relative to the base path
  44182. */
  44183. assetPath: string;
  44184. /**
  44185. * Available components (unsorted)
  44186. */
  44187. components: {
  44188. /**
  44189. * A map of component Ids
  44190. */
  44191. [componentId: string]: {
  44192. /**
  44193. * The type of input the component outputs
  44194. */
  44195. type: MotionControllerComponentType;
  44196. /**
  44197. * The indices of this component in the gamepad object
  44198. */
  44199. gamepadIndices: {
  44200. /**
  44201. * Index of button
  44202. */
  44203. button?: number;
  44204. /**
  44205. * If available, index of x-axis
  44206. */
  44207. xAxis?: number;
  44208. /**
  44209. * If available, index of y-axis
  44210. */
  44211. yAxis?: number;
  44212. };
  44213. /**
  44214. * The mesh's root node name
  44215. */
  44216. rootNodeName: string;
  44217. /**
  44218. * Animation definitions for this model
  44219. */
  44220. visualResponses: {
  44221. [stateKey: string]: {
  44222. /**
  44223. * What property will be animated
  44224. */
  44225. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44226. /**
  44227. * What states influence this visual response
  44228. */
  44229. states: MotionControllerComponentStateType[];
  44230. /**
  44231. * Type of animation - movement or visibility
  44232. */
  44233. valueNodeProperty: "transform" | "visibility";
  44234. /**
  44235. * Base node name to move. Its position will be calculated according to the min and max nodes
  44236. */
  44237. valueNodeName?: string;
  44238. /**
  44239. * Minimum movement node
  44240. */
  44241. minNodeName?: string;
  44242. /**
  44243. * Max movement node
  44244. */
  44245. maxNodeName?: string;
  44246. };
  44247. };
  44248. /**
  44249. * If touch enabled, what is the name of node to display user feedback
  44250. */
  44251. touchPointNodeName?: string;
  44252. };
  44253. };
  44254. /**
  44255. * Is it xr standard mapping or not
  44256. */
  44257. gamepadMapping: "" | "xr-standard";
  44258. /**
  44259. * Base root node of this entire model
  44260. */
  44261. rootNodeName: string;
  44262. /**
  44263. * Defines the main button component id
  44264. */
  44265. selectComponentId: string;
  44266. }
  44267. /**
  44268. * A definition for the layout map in the input profile
  44269. */
  44270. export interface IMotionControllerLayoutMap {
  44271. /**
  44272. * Layouts with handness type as a key
  44273. */
  44274. [handness: string]: IMotionControllerLayout;
  44275. }
  44276. /**
  44277. * The XR Input profile schema
  44278. * Profiles can be found here:
  44279. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44280. */
  44281. export interface IMotionControllerProfile {
  44282. /**
  44283. * fallback profiles for this profileId
  44284. */
  44285. fallbackProfileIds: string[];
  44286. /**
  44287. * The layout map, with handness as key
  44288. */
  44289. layouts: IMotionControllerLayoutMap;
  44290. /**
  44291. * The id of this profile
  44292. * correlates to the profile(s) in the xrInput.profiles array
  44293. */
  44294. profileId: string;
  44295. }
  44296. /**
  44297. * A helper-interface for the 3 meshes needed for controller button animation
  44298. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44299. */
  44300. export interface IMotionControllerButtonMeshMap {
  44301. /**
  44302. * the mesh that defines the pressed value mesh position.
  44303. * This is used to find the max-position of this button
  44304. */
  44305. pressedMesh: AbstractMesh;
  44306. /**
  44307. * the mesh that defines the unpressed value mesh position.
  44308. * This is used to find the min (or initial) position of this button
  44309. */
  44310. unpressedMesh: AbstractMesh;
  44311. /**
  44312. * The mesh that will be changed when value changes
  44313. */
  44314. valueMesh: AbstractMesh;
  44315. }
  44316. /**
  44317. * A helper-interface for the 3 meshes needed for controller axis animation.
  44318. * This will be expanded when touchpad animations are fully supported
  44319. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44320. */
  44321. export interface IMotionControllerMeshMap {
  44322. /**
  44323. * the mesh that defines the maximum value mesh position.
  44324. */
  44325. maxMesh?: AbstractMesh;
  44326. /**
  44327. * the mesh that defines the minimum value mesh position.
  44328. */
  44329. minMesh?: AbstractMesh;
  44330. /**
  44331. * The mesh that will be changed when axis value changes
  44332. */
  44333. valueMesh: AbstractMesh;
  44334. }
  44335. /**
  44336. * The elements needed for change-detection of the gamepad objects in motion controllers
  44337. */
  44338. export interface IMinimalMotionControllerObject {
  44339. /**
  44340. * Available axes of this controller
  44341. */
  44342. axes: number[];
  44343. /**
  44344. * An array of available buttons
  44345. */
  44346. buttons: Array<{
  44347. /**
  44348. * Value of the button/trigger
  44349. */
  44350. value: number;
  44351. /**
  44352. * If the button/trigger is currently touched
  44353. */
  44354. touched: boolean;
  44355. /**
  44356. * If the button/trigger is currently pressed
  44357. */
  44358. pressed: boolean;
  44359. }>;
  44360. }
  44361. /**
  44362. * An Abstract Motion controller
  44363. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44364. * Each component has an observable to check for changes in value and state
  44365. */
  44366. export abstract class WebXRAbstractMotionController implements IDisposable {
  44367. protected scene: Scene;
  44368. protected layout: IMotionControllerLayout;
  44369. /**
  44370. * The gamepad object correlating to this controller
  44371. */
  44372. gamepadObject: IMinimalMotionControllerObject;
  44373. /**
  44374. * handness (left/right/none) of this controller
  44375. */
  44376. handness: MotionControllerHandness;
  44377. private _initComponent;
  44378. private _modelReady;
  44379. /**
  44380. * A map of components (WebXRControllerComponent) in this motion controller
  44381. * Components have a ComponentType and can also have both button and axis definitions
  44382. */
  44383. readonly components: {
  44384. [id: string]: WebXRControllerComponent;
  44385. };
  44386. /**
  44387. * Disable the model's animation. Can be set at any time.
  44388. */
  44389. disableAnimation: boolean;
  44390. /**
  44391. * Observers registered here will be triggered when the model of this controller is done loading
  44392. */
  44393. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44394. /**
  44395. * The profile id of this motion controller
  44396. */
  44397. abstract profileId: string;
  44398. /**
  44399. * The root mesh of the model. It is null if the model was not yet initialized
  44400. */
  44401. rootMesh: Nullable<AbstractMesh>;
  44402. /**
  44403. * constructs a new abstract motion controller
  44404. * @param scene the scene to which the model of the controller will be added
  44405. * @param layout The profile layout to load
  44406. * @param gamepadObject The gamepad object correlating to this controller
  44407. * @param handness handness (left/right/none) of this controller
  44408. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44409. */
  44410. constructor(scene: Scene, layout: IMotionControllerLayout,
  44411. /**
  44412. * The gamepad object correlating to this controller
  44413. */
  44414. gamepadObject: IMinimalMotionControllerObject,
  44415. /**
  44416. * handness (left/right/none) of this controller
  44417. */
  44418. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44419. /**
  44420. * Dispose this controller, the model mesh and all its components
  44421. */
  44422. dispose(): void;
  44423. /**
  44424. * Returns all components of specific type
  44425. * @param type the type to search for
  44426. * @return an array of components with this type
  44427. */
  44428. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44429. /**
  44430. * get a component based an its component id as defined in layout.components
  44431. * @param id the id of the component
  44432. * @returns the component correlates to the id or undefined if not found
  44433. */
  44434. getComponent(id: string): WebXRControllerComponent;
  44435. /**
  44436. * Get the list of components available in this motion controller
  44437. * @returns an array of strings correlating to available components
  44438. */
  44439. getComponentIds(): string[];
  44440. /**
  44441. * Get the first component of specific type
  44442. * @param type type of component to find
  44443. * @return a controller component or null if not found
  44444. */
  44445. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44446. /**
  44447. * Get the main (Select) component of this controller as defined in the layout
  44448. * @returns the main component of this controller
  44449. */
  44450. getMainComponent(): WebXRControllerComponent;
  44451. /**
  44452. * Loads the model correlating to this controller
  44453. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44454. * @returns A promise fulfilled with the result of the model loading
  44455. */
  44456. loadModel(): Promise<boolean>;
  44457. /**
  44458. * Update this model using the current XRFrame
  44459. * @param xrFrame the current xr frame to use and update the model
  44460. */
  44461. updateFromXRFrame(xrFrame: XRFrame): void;
  44462. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44463. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44464. /**
  44465. * Moves the axis on the controller mesh based on its current state
  44466. * @param axis the index of the axis
  44467. * @param axisValue the value of the axis which determines the meshes new position
  44468. * @hidden
  44469. */
  44470. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44471. /**
  44472. * Update the model itself with the current frame data
  44473. * @param xrFrame the frame to use for updating the model mesh
  44474. */
  44475. protected updateModel(xrFrame: XRFrame): void;
  44476. /**
  44477. * Get the filename and path for this controller's model
  44478. * @returns a map of filename and path
  44479. */
  44480. protected abstract _getFilenameAndPath(): {
  44481. filename: string;
  44482. path: string;
  44483. };
  44484. /**
  44485. * This function is called before the mesh is loaded. It checks for loading constraints.
  44486. * For example, this function can check if the GLB loader is available
  44487. * If this function returns false, the generic controller will be loaded instead
  44488. * @returns Is the client ready to load the mesh
  44489. */
  44490. protected abstract _getModelLoadingConstraints(): boolean;
  44491. /**
  44492. * This function will be called after the model was successfully loaded and can be used
  44493. * for mesh transformations before it is available for the user
  44494. * @param meshes the loaded meshes
  44495. */
  44496. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44497. /**
  44498. * Set the root mesh for this controller. Important for the WebXR controller class
  44499. * @param meshes the loaded meshes
  44500. */
  44501. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44502. /**
  44503. * A function executed each frame that updates the mesh (if needed)
  44504. * @param xrFrame the current xrFrame
  44505. */
  44506. protected abstract _updateModel(xrFrame: XRFrame): void;
  44507. private _getGenericFilenameAndPath;
  44508. private _getGenericParentMesh;
  44509. }
  44510. }
  44511. declare module BABYLON {
  44512. /**
  44513. * A generic trigger-only motion controller for WebXR
  44514. */
  44515. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44516. /**
  44517. * Static version of the profile id of this controller
  44518. */
  44519. static ProfileId: string;
  44520. profileId: string;
  44521. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44522. protected _getFilenameAndPath(): {
  44523. filename: string;
  44524. path: string;
  44525. };
  44526. protected _getModelLoadingConstraints(): boolean;
  44527. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44528. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44529. protected _updateModel(): void;
  44530. }
  44531. }
  44532. declare module BABYLON {
  44533. /**
  44534. * Class containing static functions to help procedurally build meshes
  44535. */
  44536. export class SphereBuilder {
  44537. /**
  44538. * Creates a sphere mesh
  44539. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44540. * * 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`)
  44541. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44542. * * 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
  44543. * * 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)
  44544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44545. * * 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
  44546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44547. * @param name defines the name of the mesh
  44548. * @param options defines the options used to create the mesh
  44549. * @param scene defines the hosting scene
  44550. * @returns the sphere mesh
  44551. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44552. */
  44553. static CreateSphere(name: string, options: {
  44554. segments?: number;
  44555. diameter?: number;
  44556. diameterX?: number;
  44557. diameterY?: number;
  44558. diameterZ?: number;
  44559. arc?: number;
  44560. slice?: number;
  44561. sideOrientation?: number;
  44562. frontUVs?: Vector4;
  44563. backUVs?: Vector4;
  44564. updatable?: boolean;
  44565. }, scene?: Nullable<Scene>): Mesh;
  44566. }
  44567. }
  44568. declare module BABYLON {
  44569. /**
  44570. * A profiled motion controller has its profile loaded from an online repository.
  44571. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44572. */
  44573. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44574. private _repositoryUrl;
  44575. private _buttonMeshMapping;
  44576. private _touchDots;
  44577. /**
  44578. * The profile ID of this controller. Will be populated when the controller initializes.
  44579. */
  44580. profileId: string;
  44581. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44582. dispose(): void;
  44583. protected _getFilenameAndPath(): {
  44584. filename: string;
  44585. path: string;
  44586. };
  44587. protected _getModelLoadingConstraints(): boolean;
  44588. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44589. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44590. protected _updateModel(_xrFrame: XRFrame): void;
  44591. }
  44592. }
  44593. declare module BABYLON {
  44594. /**
  44595. * A construction function type to create a new controller based on an xrInput object
  44596. */
  44597. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44598. /**
  44599. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44600. *
  44601. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44602. * it should be replaced with auto-loaded controllers.
  44603. *
  44604. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44605. */
  44606. export class WebXRMotionControllerManager {
  44607. private static _AvailableControllers;
  44608. private static _Fallbacks;
  44609. private static _ProfileLoadingPromises;
  44610. private static _ProfilesList;
  44611. /**
  44612. * The base URL of the online controller repository. Can be changed at any time.
  44613. */
  44614. static BaseRepositoryUrl: string;
  44615. /**
  44616. * Which repository gets priority - local or online
  44617. */
  44618. static PrioritizeOnlineRepository: boolean;
  44619. /**
  44620. * Use the online repository, or use only locally-defined controllers
  44621. */
  44622. static UseOnlineRepository: boolean;
  44623. /**
  44624. * Clear the cache used for profile loading and reload when requested again
  44625. */
  44626. static ClearProfilesCache(): void;
  44627. /**
  44628. * Register the default fallbacks.
  44629. * This function is called automatically when this file is imported.
  44630. */
  44631. static DefaultFallbacks(): void;
  44632. /**
  44633. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44634. * @param profileId the profile to which a fallback needs to be found
  44635. * @return an array with corresponding fallback profiles
  44636. */
  44637. static FindFallbackWithProfileId(profileId: string): string[];
  44638. /**
  44639. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44640. * The order of search:
  44641. *
  44642. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44643. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44644. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44645. * 4) return the generic trigger controller if none were found
  44646. *
  44647. * @param xrInput the xrInput to which a new controller is initialized
  44648. * @param scene the scene to which the model will be added
  44649. * @param forceProfile force a certain profile for this controller
  44650. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44651. */
  44652. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44653. /**
  44654. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44655. *
  44656. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44657. *
  44658. * @param type the profile type to register
  44659. * @param constructFunction the function to be called when loading this profile
  44660. */
  44661. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44662. /**
  44663. * Register a fallback to a specific profile.
  44664. * @param profileId the profileId that will receive the fallbacks
  44665. * @param fallbacks A list of fallback profiles
  44666. */
  44667. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44668. /**
  44669. * Will update the list of profiles available in the repository
  44670. * @return a promise that resolves to a map of profiles available online
  44671. */
  44672. static UpdateProfilesList(): Promise<{
  44673. [profile: string]: string;
  44674. }>;
  44675. private static _LoadProfileFromRepository;
  44676. private static _LoadProfilesFromAvailableControllers;
  44677. }
  44678. }
  44679. declare module BABYLON {
  44680. /**
  44681. * Configuration options for the WebXR controller creation
  44682. */
  44683. export interface IWebXRControllerOptions {
  44684. /**
  44685. * Should the controller mesh be animated when a user interacts with it
  44686. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44687. */
  44688. disableMotionControllerAnimation?: boolean;
  44689. /**
  44690. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44691. */
  44692. doNotLoadControllerMesh?: boolean;
  44693. /**
  44694. * Force a specific controller type for this controller.
  44695. * This can be used when creating your own profile or when testing different controllers
  44696. */
  44697. forceControllerProfile?: string;
  44698. }
  44699. /**
  44700. * Represents an XR controller
  44701. */
  44702. export class WebXRInputSource {
  44703. private _scene;
  44704. /** The underlying input source for the controller */
  44705. inputSource: XRInputSource;
  44706. private _options;
  44707. private _tmpQuaternion;
  44708. private _tmpVector;
  44709. private _uniqueId;
  44710. /**
  44711. * 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
  44712. */
  44713. grip?: AbstractMesh;
  44714. /**
  44715. * If available, this is the gamepad object related to this controller.
  44716. * Using this object it is possible to get click events and trackpad changes of the
  44717. * webxr controller that is currently being used.
  44718. */
  44719. motionController?: WebXRAbstractMotionController;
  44720. /**
  44721. * Event that fires when the controller is removed/disposed.
  44722. * The object provided as event data is this controller, after associated assets were disposed.
  44723. * uniqueId is still available.
  44724. */
  44725. onDisposeObservable: Observable<WebXRInputSource>;
  44726. /**
  44727. * Will be triggered when the mesh associated with the motion controller is done loading.
  44728. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44729. * A shortened version of controller -> motion controller -> on mesh loaded.
  44730. */
  44731. onMeshLoadedObservable: Observable<AbstractMesh>;
  44732. /**
  44733. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44734. */
  44735. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44736. /**
  44737. * Pointer which can be used to select objects or attach a visible laser to
  44738. */
  44739. pointer: AbstractMesh;
  44740. /**
  44741. * Creates the controller
  44742. * @see https://doc.babylonjs.com/how_to/webxr
  44743. * @param _scene the scene which the controller should be associated to
  44744. * @param inputSource the underlying input source for the controller
  44745. * @param _options options for this controller creation
  44746. */
  44747. constructor(_scene: Scene,
  44748. /** The underlying input source for the controller */
  44749. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44750. /**
  44751. * Get this controllers unique id
  44752. */
  44753. get uniqueId(): string;
  44754. /**
  44755. * Disposes of the object
  44756. */
  44757. dispose(): void;
  44758. /**
  44759. * Gets a world space ray coming from the pointer or grip
  44760. * @param result the resulting ray
  44761. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44762. */
  44763. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44764. /**
  44765. * Updates the controller pose based on the given XRFrame
  44766. * @param xrFrame xr frame to update the pose with
  44767. * @param referenceSpace reference space to use
  44768. */
  44769. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44770. }
  44771. }
  44772. declare module BABYLON {
  44773. /**
  44774. * The schema for initialization options of the XR Input class
  44775. */
  44776. export interface IWebXRInputOptions {
  44777. /**
  44778. * If set to true no model will be automatically loaded
  44779. */
  44780. doNotLoadControllerMeshes?: boolean;
  44781. /**
  44782. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44783. * If not found, the xr input profile data will be used.
  44784. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44785. */
  44786. forceInputProfile?: string;
  44787. /**
  44788. * Do not send a request to the controller repository to load the profile.
  44789. *
  44790. * Instead, use the controllers available in babylon itself.
  44791. */
  44792. disableOnlineControllerRepository?: boolean;
  44793. /**
  44794. * A custom URL for the controllers repository
  44795. */
  44796. customControllersRepositoryURL?: string;
  44797. /**
  44798. * Should the controller model's components not move according to the user input
  44799. */
  44800. disableControllerAnimation?: boolean;
  44801. }
  44802. /**
  44803. * XR input used to track XR inputs such as controllers/rays
  44804. */
  44805. export class WebXRInput implements IDisposable {
  44806. /**
  44807. * the xr session manager for this session
  44808. */
  44809. xrSessionManager: WebXRSessionManager;
  44810. /**
  44811. * the WebXR camera for this session. Mainly used for teleportation
  44812. */
  44813. xrCamera: WebXRCamera;
  44814. private readonly options;
  44815. /**
  44816. * XR controllers being tracked
  44817. */
  44818. controllers: Array<WebXRInputSource>;
  44819. private _frameObserver;
  44820. private _sessionEndedObserver;
  44821. private _sessionInitObserver;
  44822. /**
  44823. * Event when a controller has been connected/added
  44824. */
  44825. onControllerAddedObservable: Observable<WebXRInputSource>;
  44826. /**
  44827. * Event when a controller has been removed/disconnected
  44828. */
  44829. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44830. /**
  44831. * Initializes the WebXRInput
  44832. * @param xrSessionManager the xr session manager for this session
  44833. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44834. * @param options = initialization options for this xr input
  44835. */
  44836. constructor(
  44837. /**
  44838. * the xr session manager for this session
  44839. */
  44840. xrSessionManager: WebXRSessionManager,
  44841. /**
  44842. * the WebXR camera for this session. Mainly used for teleportation
  44843. */
  44844. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44845. private _onInputSourcesChange;
  44846. private _addAndRemoveControllers;
  44847. /**
  44848. * Disposes of the object
  44849. */
  44850. dispose(): void;
  44851. }
  44852. }
  44853. declare module BABYLON {
  44854. /**
  44855. * This is the base class for all WebXR features.
  44856. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44857. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44858. */
  44859. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44860. protected _xrSessionManager: WebXRSessionManager;
  44861. private _attached;
  44862. private _removeOnDetach;
  44863. /**
  44864. * Should auto-attach be disabled?
  44865. */
  44866. disableAutoAttach: boolean;
  44867. /**
  44868. * Construct a new (abstract) WebXR feature
  44869. * @param _xrSessionManager the xr session manager for this feature
  44870. */
  44871. constructor(_xrSessionManager: WebXRSessionManager);
  44872. /**
  44873. * Is this feature attached
  44874. */
  44875. get attached(): boolean;
  44876. /**
  44877. * attach this feature
  44878. *
  44879. * @param force should attachment be forced (even when already attached)
  44880. * @returns true if successful, false is failed or already attached
  44881. */
  44882. attach(force?: boolean): boolean;
  44883. /**
  44884. * detach this feature.
  44885. *
  44886. * @returns true if successful, false if failed or already detached
  44887. */
  44888. detach(): boolean;
  44889. /**
  44890. * Dispose this feature and all of the resources attached
  44891. */
  44892. dispose(): void;
  44893. /**
  44894. * This is used to register callbacks that will automatically be removed when detach is called.
  44895. * @param observable the observable to which the observer will be attached
  44896. * @param callback the callback to register
  44897. */
  44898. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44899. /**
  44900. * Code in this function will be executed on each xrFrame received from the browser.
  44901. * This function will not execute after the feature is detached.
  44902. * @param _xrFrame the current frame
  44903. */
  44904. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44905. }
  44906. }
  44907. declare module BABYLON {
  44908. /**
  44909. * Renders a layer on top of an existing scene
  44910. */
  44911. export class UtilityLayerRenderer implements IDisposable {
  44912. /** the original scene that will be rendered on top of */
  44913. originalScene: Scene;
  44914. private _pointerCaptures;
  44915. private _lastPointerEvents;
  44916. private static _DefaultUtilityLayer;
  44917. private static _DefaultKeepDepthUtilityLayer;
  44918. private _sharedGizmoLight;
  44919. private _renderCamera;
  44920. /**
  44921. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44922. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44923. * @returns the camera that is used when rendering the utility layer
  44924. */
  44925. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44926. /**
  44927. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44928. * @param cam the camera that should be used when rendering the utility layer
  44929. */
  44930. setRenderCamera(cam: Nullable<Camera>): void;
  44931. /**
  44932. * @hidden
  44933. * Light which used by gizmos to get light shading
  44934. */
  44935. _getSharedGizmoLight(): HemisphericLight;
  44936. /**
  44937. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44938. */
  44939. pickUtilitySceneFirst: boolean;
  44940. /**
  44941. * 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)
  44942. */
  44943. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44944. /**
  44945. * 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)
  44946. */
  44947. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44948. /**
  44949. * The scene that is rendered on top of the original scene
  44950. */
  44951. utilityLayerScene: Scene;
  44952. /**
  44953. * If the utility layer should automatically be rendered on top of existing scene
  44954. */
  44955. shouldRender: boolean;
  44956. /**
  44957. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44958. */
  44959. onlyCheckPointerDownEvents: boolean;
  44960. /**
  44961. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44962. */
  44963. processAllEvents: boolean;
  44964. /**
  44965. * Observable raised when the pointer move from the utility layer scene to the main scene
  44966. */
  44967. onPointerOutObservable: Observable<number>;
  44968. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44969. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44970. private _afterRenderObserver;
  44971. private _sceneDisposeObserver;
  44972. private _originalPointerObserver;
  44973. /**
  44974. * Instantiates a UtilityLayerRenderer
  44975. * @param originalScene the original scene that will be rendered on top of
  44976. * @param handleEvents boolean indicating if the utility layer should handle events
  44977. */
  44978. constructor(
  44979. /** the original scene that will be rendered on top of */
  44980. originalScene: Scene, handleEvents?: boolean);
  44981. private _notifyObservers;
  44982. /**
  44983. * Renders the utility layers scene on top of the original scene
  44984. */
  44985. render(): void;
  44986. /**
  44987. * Disposes of the renderer
  44988. */
  44989. dispose(): void;
  44990. private _updateCamera;
  44991. }
  44992. }
  44993. declare module BABYLON {
  44994. /**
  44995. * Options interface for the pointer selection module
  44996. */
  44997. export interface IWebXRControllerPointerSelectionOptions {
  44998. /**
  44999. * if provided, this scene will be used to render meshes.
  45000. */
  45001. customUtilityLayerScene?: Scene;
  45002. /**
  45003. * 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)
  45004. * If not disabled, the last picked point will be used to execute a pointer up event
  45005. * If disabled, pointer up event will be triggered right after the pointer down event.
  45006. * Used in screen and gaze target ray mode only
  45007. */
  45008. disablePointerUpOnTouchOut: boolean;
  45009. /**
  45010. * For gaze mode (time to select instead of press)
  45011. */
  45012. forceGazeMode: boolean;
  45013. /**
  45014. * 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
  45015. * to start a new countdown to the pointer down event.
  45016. * Defaults to 1.
  45017. */
  45018. gazeModePointerMovedFactor?: number;
  45019. /**
  45020. * Different button type to use instead of the main component
  45021. */
  45022. overrideButtonId?: string;
  45023. /**
  45024. * use this rendering group id for the meshes (optional)
  45025. */
  45026. renderingGroupId?: number;
  45027. /**
  45028. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  45029. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45030. * 3000 means 3 seconds between pointing at something and selecting it
  45031. */
  45032. timeToSelect?: number;
  45033. /**
  45034. * Should meshes created here be added to a utility layer or the main scene
  45035. */
  45036. useUtilityLayer?: boolean;
  45037. /**
  45038. * the xr input to use with this pointer selection
  45039. */
  45040. xrInput: WebXRInput;
  45041. }
  45042. /**
  45043. * A module that will enable pointer selection for motion controllers of XR Input Sources
  45044. */
  45045. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  45046. private readonly _options;
  45047. private static _idCounter;
  45048. private _attachController;
  45049. private _controllers;
  45050. private _scene;
  45051. private _tmpVectorForPickCompare;
  45052. /**
  45053. * The module's name
  45054. */
  45055. static readonly Name: string;
  45056. /**
  45057. * The (Babylon) version of this module.
  45058. * This is an integer representing the implementation version.
  45059. * This number does not correspond to the WebXR specs version
  45060. */
  45061. static readonly Version: number;
  45062. /**
  45063. * Disable lighting on the laser pointer (so it will always be visible)
  45064. */
  45065. disablePointerLighting: boolean;
  45066. /**
  45067. * Disable lighting on the selection mesh (so it will always be visible)
  45068. */
  45069. disableSelectionMeshLighting: boolean;
  45070. /**
  45071. * Should the laser pointer be displayed
  45072. */
  45073. displayLaserPointer: boolean;
  45074. /**
  45075. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45076. */
  45077. displaySelectionMesh: boolean;
  45078. /**
  45079. * This color will be set to the laser pointer when selection is triggered
  45080. */
  45081. laserPointerPickedColor: Color3;
  45082. /**
  45083. * Default color of the laser pointer
  45084. */
  45085. lasterPointerDefaultColor: Color3;
  45086. /**
  45087. * default color of the selection ring
  45088. */
  45089. selectionMeshDefaultColor: Color3;
  45090. /**
  45091. * This color will be applied to the selection ring when selection is triggered
  45092. */
  45093. selectionMeshPickedColor: Color3;
  45094. /**
  45095. * Optional filter to be used for ray selection. This predicate shares behavior with
  45096. * scene.pointerMovePredicate which takes priority if it is also assigned.
  45097. */
  45098. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45099. /**
  45100. * constructs a new background remover module
  45101. * @param _xrSessionManager the session manager for this module
  45102. * @param _options read-only options to be used in this module
  45103. */
  45104. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45105. /**
  45106. * attach this feature
  45107. * Will usually be called by the features manager
  45108. *
  45109. * @returns true if successful.
  45110. */
  45111. attach(): boolean;
  45112. /**
  45113. * detach this feature.
  45114. * Will usually be called by the features manager
  45115. *
  45116. * @returns true if successful.
  45117. */
  45118. detach(): boolean;
  45119. /**
  45120. * Will get the mesh under a specific pointer.
  45121. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  45122. * @param controllerId the controllerId to check
  45123. * @returns The mesh under pointer or null if no mesh is under the pointer
  45124. */
  45125. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  45126. /**
  45127. * Get the xr controller that correlates to the pointer id in the pointer event
  45128. *
  45129. * @param id the pointer id to search for
  45130. * @returns the controller that correlates to this id or null if not found
  45131. */
  45132. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  45133. protected _onXRFrame(_xrFrame: XRFrame): void;
  45134. private _attachGazeMode;
  45135. private _attachScreenRayMode;
  45136. private _attachTrackedPointerRayMode;
  45137. private _convertNormalToDirectionOfRay;
  45138. private _detachController;
  45139. private _generateNewMeshPair;
  45140. private _pickingMoved;
  45141. private _updatePointerDistance;
  45142. }
  45143. }
  45144. declare module BABYLON {
  45145. /**
  45146. * Button which can be used to enter a different mode of XR
  45147. */
  45148. export class WebXREnterExitUIButton {
  45149. /** button element */
  45150. element: HTMLElement;
  45151. /** XR initialization options for the button */
  45152. sessionMode: XRSessionMode;
  45153. /** Reference space type */
  45154. referenceSpaceType: XRReferenceSpaceType;
  45155. /**
  45156. * Creates a WebXREnterExitUIButton
  45157. * @param element button element
  45158. * @param sessionMode XR initialization session mode
  45159. * @param referenceSpaceType the type of reference space to be used
  45160. */
  45161. constructor(
  45162. /** button element */
  45163. element: HTMLElement,
  45164. /** XR initialization options for the button */
  45165. sessionMode: XRSessionMode,
  45166. /** Reference space type */
  45167. referenceSpaceType: XRReferenceSpaceType);
  45168. /**
  45169. * Extendable function which can be used to update the button's visuals when the state changes
  45170. * @param activeButton the current active button in the UI
  45171. */
  45172. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45173. }
  45174. /**
  45175. * Options to create the webXR UI
  45176. */
  45177. export class WebXREnterExitUIOptions {
  45178. /**
  45179. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45180. */
  45181. customButtons?: Array<WebXREnterExitUIButton>;
  45182. /**
  45183. * A reference space type to use when creating the default button.
  45184. * Default is local-floor
  45185. */
  45186. referenceSpaceType?: XRReferenceSpaceType;
  45187. /**
  45188. * Context to enter xr with
  45189. */
  45190. renderTarget?: Nullable<WebXRRenderTarget>;
  45191. /**
  45192. * A session mode to use when creating the default button.
  45193. * Default is immersive-vr
  45194. */
  45195. sessionMode?: XRSessionMode;
  45196. }
  45197. /**
  45198. * UI to allow the user to enter/exit XR mode
  45199. */
  45200. export class WebXREnterExitUI implements IDisposable {
  45201. private scene;
  45202. /** version of the options passed to this UI */
  45203. options: WebXREnterExitUIOptions;
  45204. private _activeButton;
  45205. private _buttons;
  45206. private _overlay;
  45207. /**
  45208. * Fired every time the active button is changed.
  45209. *
  45210. * When xr is entered via a button that launches xr that button will be the callback parameter
  45211. *
  45212. * When exiting xr the callback parameter will be null)
  45213. */
  45214. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45215. /**
  45216. *
  45217. * @param scene babylon scene object to use
  45218. * @param options (read-only) version of the options passed to this UI
  45219. */
  45220. private constructor();
  45221. /**
  45222. * Creates UI to allow the user to enter/exit XR mode
  45223. * @param scene the scene to add the ui to
  45224. * @param helper the xr experience helper to enter/exit xr with
  45225. * @param options options to configure the UI
  45226. * @returns the created ui
  45227. */
  45228. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45229. /**
  45230. * Disposes of the XR UI component
  45231. */
  45232. dispose(): void;
  45233. private _updateButtons;
  45234. }
  45235. }
  45236. declare module BABYLON {
  45237. /**
  45238. * Class containing static functions to help procedurally build meshes
  45239. */
  45240. export class LinesBuilder {
  45241. /**
  45242. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45243. * * 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
  45244. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45245. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45246. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45247. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45248. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45249. * * 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
  45250. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45253. * @param name defines the name of the new line system
  45254. * @param options defines the options used to create the line system
  45255. * @param scene defines the hosting scene
  45256. * @returns a new line system mesh
  45257. */
  45258. static CreateLineSystem(name: string, options: {
  45259. lines: Vector3[][];
  45260. updatable?: boolean;
  45261. instance?: Nullable<LinesMesh>;
  45262. colors?: Nullable<Color4[][]>;
  45263. useVertexAlpha?: boolean;
  45264. }, scene: Nullable<Scene>): LinesMesh;
  45265. /**
  45266. * Creates a line mesh
  45267. * 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
  45268. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45269. * * The parameter `points` is an array successive Vector3
  45270. * * 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
  45271. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45272. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45273. * * When updating an instance, remember that only point positions can change, not the number of points
  45274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45276. * @param name defines the name of the new line system
  45277. * @param options defines the options used to create the line system
  45278. * @param scene defines the hosting scene
  45279. * @returns a new line mesh
  45280. */
  45281. static CreateLines(name: string, options: {
  45282. points: Vector3[];
  45283. updatable?: boolean;
  45284. instance?: Nullable<LinesMesh>;
  45285. colors?: Color4[];
  45286. useVertexAlpha?: boolean;
  45287. }, scene?: Nullable<Scene>): LinesMesh;
  45288. /**
  45289. * Creates a dashed line mesh
  45290. * * 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
  45291. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45292. * * The parameter `points` is an array successive Vector3
  45293. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45294. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45295. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45296. * * 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
  45297. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45298. * * When updating an instance, remember that only point positions can change, not the number of points
  45299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45300. * @param name defines the name of the mesh
  45301. * @param options defines the options used to create the mesh
  45302. * @param scene defines the hosting scene
  45303. * @returns the dashed line mesh
  45304. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45305. */
  45306. static CreateDashedLines(name: string, options: {
  45307. points: Vector3[];
  45308. dashSize?: number;
  45309. gapSize?: number;
  45310. dashNb?: number;
  45311. updatable?: boolean;
  45312. instance?: LinesMesh;
  45313. useVertexAlpha?: boolean;
  45314. }, scene?: Nullable<Scene>): LinesMesh;
  45315. }
  45316. }
  45317. declare module BABYLON {
  45318. /**
  45319. * The options container for the teleportation module
  45320. */
  45321. export interface IWebXRTeleportationOptions {
  45322. /**
  45323. * if provided, this scene will be used to render meshes.
  45324. */
  45325. customUtilityLayerScene?: Scene;
  45326. /**
  45327. * Values to configure the default target mesh
  45328. */
  45329. defaultTargetMeshOptions?: {
  45330. /**
  45331. * Fill color of the teleportation area
  45332. */
  45333. teleportationFillColor?: string;
  45334. /**
  45335. * Border color for the teleportation area
  45336. */
  45337. teleportationBorderColor?: string;
  45338. /**
  45339. * Disable the mesh's animation sequence
  45340. */
  45341. disableAnimation?: boolean;
  45342. /**
  45343. * Disable lighting on the material or the ring and arrow
  45344. */
  45345. disableLighting?: boolean;
  45346. /**
  45347. * Override the default material of the torus and arrow
  45348. */
  45349. torusArrowMaterial?: Material;
  45350. };
  45351. /**
  45352. * A list of meshes to use as floor meshes.
  45353. * Meshes can be added and removed after initializing the feature using the
  45354. * addFloorMesh and removeFloorMesh functions
  45355. * If empty, rotation will still work
  45356. */
  45357. floorMeshes?: AbstractMesh[];
  45358. /**
  45359. * use this rendering group id for the meshes (optional)
  45360. */
  45361. renderingGroupId?: number;
  45362. /**
  45363. * Should teleportation move only to snap points
  45364. */
  45365. snapPointsOnly?: boolean;
  45366. /**
  45367. * An array of points to which the teleportation will snap to.
  45368. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45369. */
  45370. snapPositions?: Vector3[];
  45371. /**
  45372. * How close should the teleportation ray be in order to snap to position.
  45373. * Default to 0.8 units (meters)
  45374. */
  45375. snapToPositionRadius?: number;
  45376. /**
  45377. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45378. * If you want to support rotation, make sure your mesh has a direction indicator.
  45379. *
  45380. * When left untouched, the default mesh will be initialized.
  45381. */
  45382. teleportationTargetMesh?: AbstractMesh;
  45383. /**
  45384. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45385. */
  45386. timeToTeleport?: number;
  45387. /**
  45388. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45389. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45390. */
  45391. useMainComponentOnly?: boolean;
  45392. /**
  45393. * Should meshes created here be added to a utility layer or the main scene
  45394. */
  45395. useUtilityLayer?: boolean;
  45396. /**
  45397. * Babylon XR Input class for controller
  45398. */
  45399. xrInput: WebXRInput;
  45400. }
  45401. /**
  45402. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45403. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45404. * the input of the attached controllers.
  45405. */
  45406. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45407. private _options;
  45408. private _controllers;
  45409. private _currentTeleportationControllerId;
  45410. private _floorMeshes;
  45411. private _quadraticBezierCurve;
  45412. private _selectionFeature;
  45413. private _snapToPositions;
  45414. private _snappedToPoint;
  45415. private _teleportationRingMaterial?;
  45416. private _tmpRay;
  45417. private _tmpVector;
  45418. /**
  45419. * The module's name
  45420. */
  45421. static readonly Name: string;
  45422. /**
  45423. * The (Babylon) version of this module.
  45424. * This is an integer representing the implementation version.
  45425. * This number does not correspond to the webxr specs version
  45426. */
  45427. static readonly Version: number;
  45428. /**
  45429. * Is movement backwards enabled
  45430. */
  45431. backwardsMovementEnabled: boolean;
  45432. /**
  45433. * Distance to travel when moving backwards
  45434. */
  45435. backwardsTeleportationDistance: number;
  45436. /**
  45437. * The distance from the user to the inspection point in the direction of the controller
  45438. * A higher number will allow the user to move further
  45439. * defaults to 5 (meters, in xr units)
  45440. */
  45441. parabolicCheckRadius: number;
  45442. /**
  45443. * Should the module support parabolic ray on top of direct ray
  45444. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45445. * Very helpful when moving between floors / different heights
  45446. */
  45447. parabolicRayEnabled: boolean;
  45448. /**
  45449. * How much rotation should be applied when rotating right and left
  45450. */
  45451. rotationAngle: number;
  45452. /**
  45453. * Is rotation enabled when moving forward?
  45454. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45455. */
  45456. rotationEnabled: boolean;
  45457. /**
  45458. * constructs a new anchor system
  45459. * @param _xrSessionManager an instance of WebXRSessionManager
  45460. * @param _options configuration object for this feature
  45461. */
  45462. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45463. /**
  45464. * Get the snapPointsOnly flag
  45465. */
  45466. get snapPointsOnly(): boolean;
  45467. /**
  45468. * Sets the snapPointsOnly flag
  45469. * @param snapToPoints should teleportation be exclusively to snap points
  45470. */
  45471. set snapPointsOnly(snapToPoints: boolean);
  45472. /**
  45473. * Add a new mesh to the floor meshes array
  45474. * @param mesh the mesh to use as floor mesh
  45475. */
  45476. addFloorMesh(mesh: AbstractMesh): void;
  45477. /**
  45478. * Add a new snap-to point to fix teleportation to this position
  45479. * @param newSnapPoint The new Snap-To point
  45480. */
  45481. addSnapPoint(newSnapPoint: Vector3): void;
  45482. attach(): boolean;
  45483. detach(): boolean;
  45484. dispose(): void;
  45485. /**
  45486. * Remove a mesh from the floor meshes array
  45487. * @param mesh the mesh to remove
  45488. */
  45489. removeFloorMesh(mesh: AbstractMesh): void;
  45490. /**
  45491. * Remove a mesh from the floor meshes array using its name
  45492. * @param name the mesh name to remove
  45493. */
  45494. removeFloorMeshByName(name: string): void;
  45495. /**
  45496. * 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
  45497. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45498. * @returns was the point found and removed or not
  45499. */
  45500. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45501. /**
  45502. * This function sets a selection feature that will be disabled when
  45503. * the forward ray is shown and will be reattached when hidden.
  45504. * This is used to remove the selection rays when moving.
  45505. * @param selectionFeature the feature to disable when forward movement is enabled
  45506. */
  45507. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45508. protected _onXRFrame(_xrFrame: XRFrame): void;
  45509. private _attachController;
  45510. private _createDefaultTargetMesh;
  45511. private _detachController;
  45512. private _findClosestSnapPointWithRadius;
  45513. private _setTargetMeshPosition;
  45514. private _setTargetMeshVisibility;
  45515. private _showParabolicPath;
  45516. private _teleportForward;
  45517. }
  45518. }
  45519. declare module BABYLON {
  45520. /**
  45521. * Options for the default xr helper
  45522. */
  45523. export class WebXRDefaultExperienceOptions {
  45524. /**
  45525. * Enable or disable default UI to enter XR
  45526. */
  45527. disableDefaultUI?: boolean;
  45528. /**
  45529. * Should teleportation not initialize. defaults to false.
  45530. */
  45531. disableTeleportation?: boolean;
  45532. /**
  45533. * Floor meshes that will be used for teleport
  45534. */
  45535. floorMeshes?: Array<AbstractMesh>;
  45536. /**
  45537. * If set to true, the first frame will not be used to reset position
  45538. * The first frame is mainly used when copying transformation from the old camera
  45539. * Mainly used in AR
  45540. */
  45541. ignoreNativeCameraTransformation?: boolean;
  45542. /**
  45543. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45544. */
  45545. inputOptions?: IWebXRInputOptions;
  45546. /**
  45547. * optional configuration for the output canvas
  45548. */
  45549. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45550. /**
  45551. * optional UI options. This can be used among other to change session mode and reference space type
  45552. */
  45553. uiOptions?: WebXREnterExitUIOptions;
  45554. /**
  45555. * When loading teleportation and pointer select, use stable versions instead of latest.
  45556. */
  45557. useStablePlugins?: boolean;
  45558. }
  45559. /**
  45560. * Default experience which provides a similar setup to the previous webVRExperience
  45561. */
  45562. export class WebXRDefaultExperience {
  45563. /**
  45564. * Base experience
  45565. */
  45566. baseExperience: WebXRExperienceHelper;
  45567. /**
  45568. * Enables ui for entering/exiting xr
  45569. */
  45570. enterExitUI: WebXREnterExitUI;
  45571. /**
  45572. * Input experience extension
  45573. */
  45574. input: WebXRInput;
  45575. /**
  45576. * Enables laser pointer and selection
  45577. */
  45578. pointerSelection: WebXRControllerPointerSelection;
  45579. /**
  45580. * Default target xr should render to
  45581. */
  45582. renderTarget: WebXRRenderTarget;
  45583. /**
  45584. * Enables teleportation
  45585. */
  45586. teleportation: WebXRMotionControllerTeleportation;
  45587. private constructor();
  45588. /**
  45589. * Creates the default xr experience
  45590. * @param scene scene
  45591. * @param options options for basic configuration
  45592. * @returns resulting WebXRDefaultExperience
  45593. */
  45594. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45595. /**
  45596. * DIsposes of the experience helper
  45597. */
  45598. dispose(): void;
  45599. }
  45600. }
  45601. declare module BABYLON {
  45602. /**
  45603. * Options to modify the vr teleportation behavior.
  45604. */
  45605. export interface VRTeleportationOptions {
  45606. /**
  45607. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45608. */
  45609. floorMeshName?: string;
  45610. /**
  45611. * A list of meshes to be used as the teleportation floor. (default: empty)
  45612. */
  45613. floorMeshes?: Mesh[];
  45614. /**
  45615. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45616. */
  45617. teleportationMode?: number;
  45618. /**
  45619. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45620. */
  45621. teleportationTime?: number;
  45622. /**
  45623. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45624. */
  45625. teleportationSpeed?: number;
  45626. /**
  45627. * The easing function used in the animation or null for Linear. (default CircleEase)
  45628. */
  45629. easingFunction?: EasingFunction;
  45630. }
  45631. /**
  45632. * Options to modify the vr experience helper's behavior.
  45633. */
  45634. export interface VRExperienceHelperOptions extends WebVROptions {
  45635. /**
  45636. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45637. */
  45638. createDeviceOrientationCamera?: boolean;
  45639. /**
  45640. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45641. */
  45642. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45643. /**
  45644. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45645. */
  45646. laserToggle?: boolean;
  45647. /**
  45648. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45649. */
  45650. floorMeshes?: Mesh[];
  45651. /**
  45652. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45653. */
  45654. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45655. /**
  45656. * Defines if WebXR should be used instead of WebVR (if available)
  45657. */
  45658. useXR?: boolean;
  45659. }
  45660. /**
  45661. * Event containing information after VR has been entered
  45662. */
  45663. export class OnAfterEnteringVRObservableEvent {
  45664. /**
  45665. * If entering vr was successful
  45666. */
  45667. success: boolean;
  45668. }
  45669. /**
  45670. * Helps to quickly add VR support to an existing scene.
  45671. * See http://doc.babylonjs.com/how_to/webvr_helper
  45672. */
  45673. export class VRExperienceHelper {
  45674. /** Options to modify the vr experience helper's behavior. */
  45675. webVROptions: VRExperienceHelperOptions;
  45676. private _scene;
  45677. private _position;
  45678. private _btnVR;
  45679. private _btnVRDisplayed;
  45680. private _webVRsupported;
  45681. private _webVRready;
  45682. private _webVRrequesting;
  45683. private _webVRpresenting;
  45684. private _hasEnteredVR;
  45685. private _fullscreenVRpresenting;
  45686. private _inputElement;
  45687. private _webVRCamera;
  45688. private _vrDeviceOrientationCamera;
  45689. private _deviceOrientationCamera;
  45690. private _existingCamera;
  45691. private _onKeyDown;
  45692. private _onVrDisplayPresentChange;
  45693. private _onVRDisplayChanged;
  45694. private _onVRRequestPresentStart;
  45695. private _onVRRequestPresentComplete;
  45696. /**
  45697. * 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)
  45698. */
  45699. enableGazeEvenWhenNoPointerLock: boolean;
  45700. /**
  45701. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45702. */
  45703. exitVROnDoubleTap: boolean;
  45704. /**
  45705. * Observable raised right before entering VR.
  45706. */
  45707. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45708. /**
  45709. * Observable raised when entering VR has completed.
  45710. */
  45711. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45712. /**
  45713. * Observable raised when exiting VR.
  45714. */
  45715. onExitingVRObservable: Observable<VRExperienceHelper>;
  45716. /**
  45717. * Observable raised when controller mesh is loaded.
  45718. */
  45719. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45720. /** Return this.onEnteringVRObservable
  45721. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45722. */
  45723. get onEnteringVR(): Observable<VRExperienceHelper>;
  45724. /** Return this.onExitingVRObservable
  45725. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45726. */
  45727. get onExitingVR(): Observable<VRExperienceHelper>;
  45728. /** Return this.onControllerMeshLoadedObservable
  45729. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45730. */
  45731. get onControllerMeshLoaded(): Observable<WebVRController>;
  45732. private _rayLength;
  45733. private _useCustomVRButton;
  45734. private _teleportationRequested;
  45735. private _teleportActive;
  45736. private _floorMeshName;
  45737. private _floorMeshesCollection;
  45738. private _teleportationMode;
  45739. private _teleportationTime;
  45740. private _teleportationSpeed;
  45741. private _teleportationEasing;
  45742. private _rotationAllowed;
  45743. private _teleportBackwardsVector;
  45744. private _teleportationTarget;
  45745. private _isDefaultTeleportationTarget;
  45746. private _postProcessMove;
  45747. private _teleportationFillColor;
  45748. private _teleportationBorderColor;
  45749. private _rotationAngle;
  45750. private _haloCenter;
  45751. private _cameraGazer;
  45752. private _padSensibilityUp;
  45753. private _padSensibilityDown;
  45754. private _leftController;
  45755. private _rightController;
  45756. private _gazeColor;
  45757. private _laserColor;
  45758. private _pickedLaserColor;
  45759. private _pickedGazeColor;
  45760. /**
  45761. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45762. */
  45763. onNewMeshSelected: Observable<AbstractMesh>;
  45764. /**
  45765. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45766. * This observable will provide the mesh and the controller used to select the mesh
  45767. */
  45768. onMeshSelectedWithController: Observable<{
  45769. mesh: AbstractMesh;
  45770. controller: WebVRController;
  45771. }>;
  45772. /**
  45773. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45774. */
  45775. onNewMeshPicked: Observable<PickingInfo>;
  45776. private _circleEase;
  45777. /**
  45778. * Observable raised before camera teleportation
  45779. */
  45780. onBeforeCameraTeleport: Observable<Vector3>;
  45781. /**
  45782. * Observable raised after camera teleportation
  45783. */
  45784. onAfterCameraTeleport: Observable<Vector3>;
  45785. /**
  45786. * Observable raised when current selected mesh gets unselected
  45787. */
  45788. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45789. private _raySelectionPredicate;
  45790. /**
  45791. * To be optionaly changed by user to define custom ray selection
  45792. */
  45793. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45794. /**
  45795. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45796. */
  45797. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45798. /**
  45799. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45800. */
  45801. teleportationEnabled: boolean;
  45802. private _defaultHeight;
  45803. private _teleportationInitialized;
  45804. private _interactionsEnabled;
  45805. private _interactionsRequested;
  45806. private _displayGaze;
  45807. private _displayLaserPointer;
  45808. /**
  45809. * The mesh used to display where the user is going to teleport.
  45810. */
  45811. get teleportationTarget(): Mesh;
  45812. /**
  45813. * Sets the mesh to be used to display where the user is going to teleport.
  45814. */
  45815. set teleportationTarget(value: Mesh);
  45816. /**
  45817. * 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
  45818. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45819. * See http://doc.babylonjs.com/resources/baking_transformations
  45820. */
  45821. get gazeTrackerMesh(): Mesh;
  45822. set gazeTrackerMesh(value: Mesh);
  45823. /**
  45824. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45825. */
  45826. updateGazeTrackerScale: boolean;
  45827. /**
  45828. * If the gaze trackers color should be updated when selecting meshes
  45829. */
  45830. updateGazeTrackerColor: boolean;
  45831. /**
  45832. * If the controller laser color should be updated when selecting meshes
  45833. */
  45834. updateControllerLaserColor: boolean;
  45835. /**
  45836. * The gaze tracking mesh corresponding to the left controller
  45837. */
  45838. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45839. /**
  45840. * The gaze tracking mesh corresponding to the right controller
  45841. */
  45842. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45843. /**
  45844. * If the ray of the gaze should be displayed.
  45845. */
  45846. get displayGaze(): boolean;
  45847. /**
  45848. * Sets if the ray of the gaze should be displayed.
  45849. */
  45850. set displayGaze(value: boolean);
  45851. /**
  45852. * If the ray of the LaserPointer should be displayed.
  45853. */
  45854. get displayLaserPointer(): boolean;
  45855. /**
  45856. * Sets if the ray of the LaserPointer should be displayed.
  45857. */
  45858. set displayLaserPointer(value: boolean);
  45859. /**
  45860. * The deviceOrientationCamera used as the camera when not in VR.
  45861. */
  45862. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45863. /**
  45864. * Based on the current WebVR support, returns the current VR camera used.
  45865. */
  45866. get currentVRCamera(): Nullable<Camera>;
  45867. /**
  45868. * The webVRCamera which is used when in VR.
  45869. */
  45870. get webVRCamera(): WebVRFreeCamera;
  45871. /**
  45872. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45873. */
  45874. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45875. /**
  45876. * The html button that is used to trigger entering into VR.
  45877. */
  45878. get vrButton(): Nullable<HTMLButtonElement>;
  45879. private get _teleportationRequestInitiated();
  45880. /**
  45881. * Defines whether or not Pointer lock should be requested when switching to
  45882. * full screen.
  45883. */
  45884. requestPointerLockOnFullScreen: boolean;
  45885. /**
  45886. * If asking to force XR, this will be populated with the default xr experience
  45887. */
  45888. xr: WebXRDefaultExperience;
  45889. /**
  45890. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45891. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45892. */
  45893. xrTestDone: boolean;
  45894. /**
  45895. * Instantiates a VRExperienceHelper.
  45896. * Helps to quickly add VR support to an existing scene.
  45897. * @param scene The scene the VRExperienceHelper belongs to.
  45898. * @param webVROptions Options to modify the vr experience helper's behavior.
  45899. */
  45900. constructor(scene: Scene,
  45901. /** Options to modify the vr experience helper's behavior. */
  45902. webVROptions?: VRExperienceHelperOptions);
  45903. private completeVRInit;
  45904. private _onDefaultMeshLoaded;
  45905. private _onResize;
  45906. private _onFullscreenChange;
  45907. /**
  45908. * Gets a value indicating if we are currently in VR mode.
  45909. */
  45910. get isInVRMode(): boolean;
  45911. private onVrDisplayPresentChange;
  45912. private onVRDisplayChanged;
  45913. private moveButtonToBottomRight;
  45914. private displayVRButton;
  45915. private updateButtonVisibility;
  45916. private _cachedAngularSensibility;
  45917. /**
  45918. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45919. * Otherwise, will use the fullscreen API.
  45920. */
  45921. enterVR(): void;
  45922. /**
  45923. * Attempt to exit VR, or fullscreen.
  45924. */
  45925. exitVR(): void;
  45926. /**
  45927. * The position of the vr experience helper.
  45928. */
  45929. get position(): Vector3;
  45930. /**
  45931. * Sets the position of the vr experience helper.
  45932. */
  45933. set position(value: Vector3);
  45934. /**
  45935. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45936. */
  45937. enableInteractions(): void;
  45938. private get _noControllerIsActive();
  45939. private beforeRender;
  45940. private _isTeleportationFloor;
  45941. /**
  45942. * Adds a floor mesh to be used for teleportation.
  45943. * @param floorMesh the mesh to be used for teleportation.
  45944. */
  45945. addFloorMesh(floorMesh: Mesh): void;
  45946. /**
  45947. * Removes a floor mesh from being used for teleportation.
  45948. * @param floorMesh the mesh to be removed.
  45949. */
  45950. removeFloorMesh(floorMesh: Mesh): void;
  45951. /**
  45952. * Enables interactions and teleportation using the VR controllers and gaze.
  45953. * @param vrTeleportationOptions options to modify teleportation behavior.
  45954. */
  45955. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45956. private _onNewGamepadConnected;
  45957. private _tryEnableInteractionOnController;
  45958. private _onNewGamepadDisconnected;
  45959. private _enableInteractionOnController;
  45960. private _checkTeleportWithRay;
  45961. private _checkRotate;
  45962. private _checkTeleportBackwards;
  45963. private _enableTeleportationOnController;
  45964. private _createTeleportationCircles;
  45965. private _displayTeleportationTarget;
  45966. private _hideTeleportationTarget;
  45967. private _rotateCamera;
  45968. private _moveTeleportationSelectorTo;
  45969. private _workingVector;
  45970. private _workingQuaternion;
  45971. private _workingMatrix;
  45972. /**
  45973. * Time Constant Teleportation Mode
  45974. */
  45975. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45976. /**
  45977. * Speed Constant Teleportation Mode
  45978. */
  45979. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45980. /**
  45981. * Teleports the users feet to the desired location
  45982. * @param location The location where the user's feet should be placed
  45983. */
  45984. teleportCamera(location: Vector3): void;
  45985. private _convertNormalToDirectionOfRay;
  45986. private _castRayAndSelectObject;
  45987. private _notifySelectedMeshUnselected;
  45988. /**
  45989. * Permanently set new colors for the laser pointer
  45990. * @param color the new laser color
  45991. * @param pickedColor the new laser color when picked mesh detected
  45992. */
  45993. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45994. /**
  45995. * Set lighting enabled / disabled on the laser pointer of both controllers
  45996. * @param enabled should the lighting be enabled on the laser pointer
  45997. */
  45998. setLaserLightingState(enabled?: boolean): void;
  45999. /**
  46000. * Permanently set new colors for the gaze pointer
  46001. * @param color the new gaze color
  46002. * @param pickedColor the new gaze color when picked mesh detected
  46003. */
  46004. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46005. /**
  46006. * Sets the color of the laser ray from the vr controllers.
  46007. * @param color new color for the ray.
  46008. */
  46009. changeLaserColor(color: Color3): void;
  46010. /**
  46011. * Sets the color of the ray from the vr headsets gaze.
  46012. * @param color new color for the ray.
  46013. */
  46014. changeGazeColor(color: Color3): void;
  46015. /**
  46016. * Exits VR and disposes of the vr experience helper
  46017. */
  46018. dispose(): void;
  46019. /**
  46020. * Gets the name of the VRExperienceHelper class
  46021. * @returns "VRExperienceHelper"
  46022. */
  46023. getClassName(): string;
  46024. }
  46025. }
  46026. declare module BABYLON {
  46027. /**
  46028. * Contains an array of blocks representing the octree
  46029. */
  46030. export interface IOctreeContainer<T> {
  46031. /**
  46032. * Blocks within the octree
  46033. */
  46034. blocks: Array<OctreeBlock<T>>;
  46035. }
  46036. /**
  46037. * Class used to store a cell in an octree
  46038. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46039. */
  46040. export class OctreeBlock<T> {
  46041. /**
  46042. * Gets the content of the current block
  46043. */
  46044. entries: T[];
  46045. /**
  46046. * Gets the list of block children
  46047. */
  46048. blocks: Array<OctreeBlock<T>>;
  46049. private _depth;
  46050. private _maxDepth;
  46051. private _capacity;
  46052. private _minPoint;
  46053. private _maxPoint;
  46054. private _boundingVectors;
  46055. private _creationFunc;
  46056. /**
  46057. * Creates a new block
  46058. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46059. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46060. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46061. * @param depth defines the current depth of this block in the octree
  46062. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46063. * @param creationFunc defines a callback to call when an element is added to the block
  46064. */
  46065. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46066. /**
  46067. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46068. */
  46069. get capacity(): number;
  46070. /**
  46071. * Gets the minimum vector (in world space) of the block's bounding box
  46072. */
  46073. get minPoint(): Vector3;
  46074. /**
  46075. * Gets the maximum vector (in world space) of the block's bounding box
  46076. */
  46077. get maxPoint(): Vector3;
  46078. /**
  46079. * Add a new element to this block
  46080. * @param entry defines the element to add
  46081. */
  46082. addEntry(entry: T): void;
  46083. /**
  46084. * Remove an element from this block
  46085. * @param entry defines the element to remove
  46086. */
  46087. removeEntry(entry: T): void;
  46088. /**
  46089. * Add an array of elements to this block
  46090. * @param entries defines the array of elements to add
  46091. */
  46092. addEntries(entries: T[]): void;
  46093. /**
  46094. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46095. * @param frustumPlanes defines the frustum planes to test
  46096. * @param selection defines the array to store current content if selection is positive
  46097. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46098. */
  46099. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46100. /**
  46101. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46102. * @param sphereCenter defines the bounding sphere center
  46103. * @param sphereRadius defines the bounding sphere radius
  46104. * @param selection defines the array to store current content if selection is positive
  46105. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46106. */
  46107. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46108. /**
  46109. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46110. * @param ray defines the ray to test with
  46111. * @param selection defines the array to store current content if selection is positive
  46112. */
  46113. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46114. /**
  46115. * Subdivide the content into child blocks (this block will then be empty)
  46116. */
  46117. createInnerBlocks(): void;
  46118. /**
  46119. * @hidden
  46120. */
  46121. 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;
  46122. }
  46123. }
  46124. declare module BABYLON {
  46125. /**
  46126. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46127. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46128. */
  46129. export class Octree<T> {
  46130. /** 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.) */
  46131. maxDepth: number;
  46132. /**
  46133. * Blocks within the octree containing objects
  46134. */
  46135. blocks: Array<OctreeBlock<T>>;
  46136. /**
  46137. * Content stored in the octree
  46138. */
  46139. dynamicContent: T[];
  46140. private _maxBlockCapacity;
  46141. private _selectionContent;
  46142. private _creationFunc;
  46143. /**
  46144. * Creates a octree
  46145. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46146. * @param creationFunc function to be used to instatiate the octree
  46147. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46148. * @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.)
  46149. */
  46150. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46151. /** 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.) */
  46152. maxDepth?: number);
  46153. /**
  46154. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46155. * @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);
  46156. * @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);
  46157. * @param entries meshes to be added to the octree blocks
  46158. */
  46159. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46160. /**
  46161. * Adds a mesh to the octree
  46162. * @param entry Mesh to add to the octree
  46163. */
  46164. addMesh(entry: T): void;
  46165. /**
  46166. * Remove an element from the octree
  46167. * @param entry defines the element to remove
  46168. */
  46169. removeMesh(entry: T): void;
  46170. /**
  46171. * Selects an array of meshes within the frustum
  46172. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46173. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46174. * @returns array of meshes within the frustum
  46175. */
  46176. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46177. /**
  46178. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46179. * @param sphereCenter defines the bounding sphere center
  46180. * @param sphereRadius defines the bounding sphere radius
  46181. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46182. * @returns an array of objects that intersect the sphere
  46183. */
  46184. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46185. /**
  46186. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46187. * @param ray defines the ray to test with
  46188. * @returns array of intersected objects
  46189. */
  46190. intersectsRay(ray: Ray): SmartArray<T>;
  46191. /**
  46192. * Adds a mesh into the octree block if it intersects the block
  46193. */
  46194. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46195. /**
  46196. * Adds a submesh into the octree block if it intersects the block
  46197. */
  46198. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46199. }
  46200. }
  46201. declare module BABYLON {
  46202. interface Scene {
  46203. /**
  46204. * @hidden
  46205. * Backing Filed
  46206. */
  46207. _selectionOctree: Octree<AbstractMesh>;
  46208. /**
  46209. * Gets the octree used to boost mesh selection (picking)
  46210. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46211. */
  46212. selectionOctree: Octree<AbstractMesh>;
  46213. /**
  46214. * Creates or updates the octree used to boost selection (picking)
  46215. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46216. * @param maxCapacity defines the maximum capacity per leaf
  46217. * @param maxDepth defines the maximum depth of the octree
  46218. * @returns an octree of AbstractMesh
  46219. */
  46220. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46221. }
  46222. interface AbstractMesh {
  46223. /**
  46224. * @hidden
  46225. * Backing Field
  46226. */
  46227. _submeshesOctree: Octree<SubMesh>;
  46228. /**
  46229. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46230. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46231. * @param maxCapacity defines the maximum size of each block (64 by default)
  46232. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46233. * @returns the new octree
  46234. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46235. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46236. */
  46237. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46238. }
  46239. /**
  46240. * Defines the octree scene component responsible to manage any octrees
  46241. * in a given scene.
  46242. */
  46243. export class OctreeSceneComponent {
  46244. /**
  46245. * The component name help to identify the component in the list of scene components.
  46246. */
  46247. readonly name: string;
  46248. /**
  46249. * The scene the component belongs to.
  46250. */
  46251. scene: Scene;
  46252. /**
  46253. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46254. */
  46255. readonly checksIsEnabled: boolean;
  46256. /**
  46257. * Creates a new instance of the component for the given scene
  46258. * @param scene Defines the scene to register the component in
  46259. */
  46260. constructor(scene: Scene);
  46261. /**
  46262. * Registers the component in a given scene
  46263. */
  46264. register(): void;
  46265. /**
  46266. * Return the list of active meshes
  46267. * @returns the list of active meshes
  46268. */
  46269. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46270. /**
  46271. * Return the list of active sub meshes
  46272. * @param mesh The mesh to get the candidates sub meshes from
  46273. * @returns the list of active sub meshes
  46274. */
  46275. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46276. private _tempRay;
  46277. /**
  46278. * Return the list of sub meshes intersecting with a given local ray
  46279. * @param mesh defines the mesh to find the submesh for
  46280. * @param localRay defines the ray in local space
  46281. * @returns the list of intersecting sub meshes
  46282. */
  46283. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46284. /**
  46285. * Return the list of sub meshes colliding with a collider
  46286. * @param mesh defines the mesh to find the submesh for
  46287. * @param collider defines the collider to evaluate the collision against
  46288. * @returns the list of colliding sub meshes
  46289. */
  46290. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46291. /**
  46292. * Rebuilds the elements related to this component in case of
  46293. * context lost for instance.
  46294. */
  46295. rebuild(): void;
  46296. /**
  46297. * Disposes the component and the associated ressources.
  46298. */
  46299. dispose(): void;
  46300. }
  46301. }
  46302. declare module BABYLON {
  46303. /**
  46304. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46305. */
  46306. export class Gizmo implements IDisposable {
  46307. /** The utility layer the gizmo will be added to */
  46308. gizmoLayer: UtilityLayerRenderer;
  46309. /**
  46310. * The root mesh of the gizmo
  46311. */
  46312. _rootMesh: Mesh;
  46313. private _attachedMesh;
  46314. /**
  46315. * Ratio for the scale of the gizmo (Default: 1)
  46316. */
  46317. scaleRatio: number;
  46318. /**
  46319. * If a custom mesh has been set (Default: false)
  46320. */
  46321. protected _customMeshSet: boolean;
  46322. /**
  46323. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46324. * * When set, interactions will be enabled
  46325. */
  46326. get attachedMesh(): Nullable<AbstractMesh>;
  46327. set attachedMesh(value: Nullable<AbstractMesh>);
  46328. /**
  46329. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46330. * @param mesh The mesh to replace the default mesh of the gizmo
  46331. */
  46332. setCustomMesh(mesh: Mesh): void;
  46333. /**
  46334. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46335. */
  46336. updateGizmoRotationToMatchAttachedMesh: boolean;
  46337. /**
  46338. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46339. */
  46340. updateGizmoPositionToMatchAttachedMesh: boolean;
  46341. /**
  46342. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46343. */
  46344. updateScale: boolean;
  46345. protected _interactionsEnabled: boolean;
  46346. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46347. private _beforeRenderObserver;
  46348. private _tempVector;
  46349. /**
  46350. * Creates a gizmo
  46351. * @param gizmoLayer The utility layer the gizmo will be added to
  46352. */
  46353. constructor(
  46354. /** The utility layer the gizmo will be added to */
  46355. gizmoLayer?: UtilityLayerRenderer);
  46356. /**
  46357. * Updates the gizmo to match the attached mesh's position/rotation
  46358. */
  46359. protected _update(): void;
  46360. /**
  46361. * Disposes of the gizmo
  46362. */
  46363. dispose(): void;
  46364. }
  46365. }
  46366. declare module BABYLON {
  46367. /**
  46368. * Single plane drag gizmo
  46369. */
  46370. export class PlaneDragGizmo extends Gizmo {
  46371. /**
  46372. * Drag behavior responsible for the gizmos dragging interactions
  46373. */
  46374. dragBehavior: PointerDragBehavior;
  46375. private _pointerObserver;
  46376. /**
  46377. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46378. */
  46379. snapDistance: number;
  46380. /**
  46381. * Event that fires each time the gizmo snaps to a new location.
  46382. * * snapDistance is the the change in distance
  46383. */
  46384. onSnapObservable: Observable<{
  46385. snapDistance: number;
  46386. }>;
  46387. private _plane;
  46388. private _coloredMaterial;
  46389. private _hoverMaterial;
  46390. private _isEnabled;
  46391. private _parent;
  46392. /** @hidden */
  46393. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46394. /** @hidden */
  46395. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46396. /**
  46397. * Creates a PlaneDragGizmo
  46398. * @param gizmoLayer The utility layer the gizmo will be added to
  46399. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46400. * @param color The color of the gizmo
  46401. */
  46402. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46403. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46404. /**
  46405. * If the gizmo is enabled
  46406. */
  46407. set isEnabled(value: boolean);
  46408. get isEnabled(): boolean;
  46409. /**
  46410. * Disposes of the gizmo
  46411. */
  46412. dispose(): void;
  46413. }
  46414. }
  46415. declare module BABYLON {
  46416. /**
  46417. * Gizmo that enables dragging a mesh along 3 axis
  46418. */
  46419. export class PositionGizmo extends Gizmo {
  46420. /**
  46421. * Internal gizmo used for interactions on the x axis
  46422. */
  46423. xGizmo: AxisDragGizmo;
  46424. /**
  46425. * Internal gizmo used for interactions on the y axis
  46426. */
  46427. yGizmo: AxisDragGizmo;
  46428. /**
  46429. * Internal gizmo used for interactions on the z axis
  46430. */
  46431. zGizmo: AxisDragGizmo;
  46432. /**
  46433. * Internal gizmo used for interactions on the yz plane
  46434. */
  46435. xPlaneGizmo: PlaneDragGizmo;
  46436. /**
  46437. * Internal gizmo used for interactions on the xz plane
  46438. */
  46439. yPlaneGizmo: PlaneDragGizmo;
  46440. /**
  46441. * Internal gizmo used for interactions on the xy plane
  46442. */
  46443. zPlaneGizmo: PlaneDragGizmo;
  46444. /**
  46445. * private variables
  46446. */
  46447. private _meshAttached;
  46448. private _updateGizmoRotationToMatchAttachedMesh;
  46449. private _snapDistance;
  46450. private _scaleRatio;
  46451. /** Fires an event when any of it's sub gizmos are dragged */
  46452. onDragStartObservable: Observable<unknown>;
  46453. /** Fires an event when any of it's sub gizmos are released from dragging */
  46454. onDragEndObservable: Observable<unknown>;
  46455. /**
  46456. * If set to true, planar drag is enabled
  46457. */
  46458. private _planarGizmoEnabled;
  46459. get attachedMesh(): Nullable<AbstractMesh>;
  46460. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46461. /**
  46462. * Creates a PositionGizmo
  46463. * @param gizmoLayer The utility layer the gizmo will be added to
  46464. */
  46465. constructor(gizmoLayer?: UtilityLayerRenderer);
  46466. /**
  46467. * If the planar drag gizmo is enabled
  46468. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46469. */
  46470. set planarGizmoEnabled(value: boolean);
  46471. get planarGizmoEnabled(): boolean;
  46472. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46473. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46474. /**
  46475. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46476. */
  46477. set snapDistance(value: number);
  46478. get snapDistance(): number;
  46479. /**
  46480. * Ratio for the scale of the gizmo (Default: 1)
  46481. */
  46482. set scaleRatio(value: number);
  46483. get scaleRatio(): number;
  46484. /**
  46485. * Disposes of the gizmo
  46486. */
  46487. dispose(): void;
  46488. /**
  46489. * CustomMeshes are not supported by this gizmo
  46490. * @param mesh The mesh to replace the default mesh of the gizmo
  46491. */
  46492. setCustomMesh(mesh: Mesh): void;
  46493. }
  46494. }
  46495. declare module BABYLON {
  46496. /**
  46497. * Single axis drag gizmo
  46498. */
  46499. export class AxisDragGizmo extends Gizmo {
  46500. /**
  46501. * Drag behavior responsible for the gizmos dragging interactions
  46502. */
  46503. dragBehavior: PointerDragBehavior;
  46504. private _pointerObserver;
  46505. /**
  46506. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46507. */
  46508. snapDistance: number;
  46509. /**
  46510. * Event that fires each time the gizmo snaps to a new location.
  46511. * * snapDistance is the the change in distance
  46512. */
  46513. onSnapObservable: Observable<{
  46514. snapDistance: number;
  46515. }>;
  46516. private _isEnabled;
  46517. private _parent;
  46518. private _arrow;
  46519. private _coloredMaterial;
  46520. private _hoverMaterial;
  46521. /** @hidden */
  46522. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46523. /** @hidden */
  46524. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46525. /**
  46526. * Creates an AxisDragGizmo
  46527. * @param gizmoLayer The utility layer the gizmo will be added to
  46528. * @param dragAxis The axis which the gizmo will be able to drag on
  46529. * @param color The color of the gizmo
  46530. */
  46531. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46532. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46533. /**
  46534. * If the gizmo is enabled
  46535. */
  46536. set isEnabled(value: boolean);
  46537. get isEnabled(): boolean;
  46538. /**
  46539. * Disposes of the gizmo
  46540. */
  46541. dispose(): void;
  46542. }
  46543. }
  46544. declare module BABYLON.Debug {
  46545. /**
  46546. * The Axes viewer will show 3 axes in a specific point in space
  46547. */
  46548. export class AxesViewer {
  46549. private _xAxis;
  46550. private _yAxis;
  46551. private _zAxis;
  46552. private _scaleLinesFactor;
  46553. private _instanced;
  46554. /**
  46555. * Gets the hosting scene
  46556. */
  46557. scene: Scene;
  46558. /**
  46559. * Gets or sets a number used to scale line length
  46560. */
  46561. scaleLines: number;
  46562. /** Gets the node hierarchy used to render x-axis */
  46563. get xAxis(): TransformNode;
  46564. /** Gets the node hierarchy used to render y-axis */
  46565. get yAxis(): TransformNode;
  46566. /** Gets the node hierarchy used to render z-axis */
  46567. get zAxis(): TransformNode;
  46568. /**
  46569. * Creates a new AxesViewer
  46570. * @param scene defines the hosting scene
  46571. * @param scaleLines defines a number used to scale line length (1 by default)
  46572. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46573. * @param xAxis defines the node hierarchy used to render the x-axis
  46574. * @param yAxis defines the node hierarchy used to render the y-axis
  46575. * @param zAxis defines the node hierarchy used to render the z-axis
  46576. */
  46577. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46578. /**
  46579. * Force the viewer to update
  46580. * @param position defines the position of the viewer
  46581. * @param xaxis defines the x axis of the viewer
  46582. * @param yaxis defines the y axis of the viewer
  46583. * @param zaxis defines the z axis of the viewer
  46584. */
  46585. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46586. /**
  46587. * Creates an instance of this axes viewer.
  46588. * @returns a new axes viewer with instanced meshes
  46589. */
  46590. createInstance(): AxesViewer;
  46591. /** Releases resources */
  46592. dispose(): void;
  46593. private static _SetRenderingGroupId;
  46594. }
  46595. }
  46596. declare module BABYLON.Debug {
  46597. /**
  46598. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46599. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46600. */
  46601. export class BoneAxesViewer extends AxesViewer {
  46602. /**
  46603. * Gets or sets the target mesh where to display the axes viewer
  46604. */
  46605. mesh: Nullable<Mesh>;
  46606. /**
  46607. * Gets or sets the target bone where to display the axes viewer
  46608. */
  46609. bone: Nullable<Bone>;
  46610. /** Gets current position */
  46611. pos: Vector3;
  46612. /** Gets direction of X axis */
  46613. xaxis: Vector3;
  46614. /** Gets direction of Y axis */
  46615. yaxis: Vector3;
  46616. /** Gets direction of Z axis */
  46617. zaxis: Vector3;
  46618. /**
  46619. * Creates a new BoneAxesViewer
  46620. * @param scene defines the hosting scene
  46621. * @param bone defines the target bone
  46622. * @param mesh defines the target mesh
  46623. * @param scaleLines defines a scaling factor for line length (1 by default)
  46624. */
  46625. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46626. /**
  46627. * Force the viewer to update
  46628. */
  46629. update(): void;
  46630. /** Releases resources */
  46631. dispose(): void;
  46632. }
  46633. }
  46634. declare module BABYLON {
  46635. /**
  46636. * Interface used to define scene explorer extensibility option
  46637. */
  46638. export interface IExplorerExtensibilityOption {
  46639. /**
  46640. * Define the option label
  46641. */
  46642. label: string;
  46643. /**
  46644. * Defines the action to execute on click
  46645. */
  46646. action: (entity: any) => void;
  46647. }
  46648. /**
  46649. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46650. */
  46651. export interface IExplorerExtensibilityGroup {
  46652. /**
  46653. * Defines a predicate to test if a given type mut be extended
  46654. */
  46655. predicate: (entity: any) => boolean;
  46656. /**
  46657. * Gets the list of options added to a type
  46658. */
  46659. entries: IExplorerExtensibilityOption[];
  46660. }
  46661. /**
  46662. * Interface used to define the options to use to create the Inspector
  46663. */
  46664. export interface IInspectorOptions {
  46665. /**
  46666. * Display in overlay mode (default: false)
  46667. */
  46668. overlay?: boolean;
  46669. /**
  46670. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46671. */
  46672. globalRoot?: HTMLElement;
  46673. /**
  46674. * Display the Scene explorer
  46675. */
  46676. showExplorer?: boolean;
  46677. /**
  46678. * Display the property inspector
  46679. */
  46680. showInspector?: boolean;
  46681. /**
  46682. * Display in embed mode (both panes on the right)
  46683. */
  46684. embedMode?: boolean;
  46685. /**
  46686. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46687. */
  46688. handleResize?: boolean;
  46689. /**
  46690. * Allow the panes to popup (default: true)
  46691. */
  46692. enablePopup?: boolean;
  46693. /**
  46694. * Allow the panes to be closed by users (default: true)
  46695. */
  46696. enableClose?: boolean;
  46697. /**
  46698. * Optional list of extensibility entries
  46699. */
  46700. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46701. /**
  46702. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46703. */
  46704. inspectorURL?: string;
  46705. /**
  46706. * Optional initial tab (default to DebugLayerTab.Properties)
  46707. */
  46708. initialTab?: DebugLayerTab;
  46709. }
  46710. interface Scene {
  46711. /**
  46712. * @hidden
  46713. * Backing field
  46714. */
  46715. _debugLayer: DebugLayer;
  46716. /**
  46717. * Gets the debug layer (aka Inspector) associated with the scene
  46718. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46719. */
  46720. debugLayer: DebugLayer;
  46721. }
  46722. /**
  46723. * Enum of inspector action tab
  46724. */
  46725. export enum DebugLayerTab {
  46726. /**
  46727. * Properties tag (default)
  46728. */
  46729. Properties = 0,
  46730. /**
  46731. * Debug tab
  46732. */
  46733. Debug = 1,
  46734. /**
  46735. * Statistics tab
  46736. */
  46737. Statistics = 2,
  46738. /**
  46739. * Tools tab
  46740. */
  46741. Tools = 3,
  46742. /**
  46743. * Settings tab
  46744. */
  46745. Settings = 4
  46746. }
  46747. /**
  46748. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46749. * what is happening in your scene
  46750. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46751. */
  46752. export class DebugLayer {
  46753. /**
  46754. * Define the url to get the inspector script from.
  46755. * By default it uses the babylonjs CDN.
  46756. * @ignoreNaming
  46757. */
  46758. static InspectorURL: string;
  46759. private _scene;
  46760. private BJSINSPECTOR;
  46761. private _onPropertyChangedObservable?;
  46762. /**
  46763. * Observable triggered when a property is changed through the inspector.
  46764. */
  46765. get onPropertyChangedObservable(): any;
  46766. /**
  46767. * Instantiates a new debug layer.
  46768. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46769. * what is happening in your scene
  46770. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46771. * @param scene Defines the scene to inspect
  46772. */
  46773. constructor(scene: Scene);
  46774. /** Creates the inspector window. */
  46775. private _createInspector;
  46776. /**
  46777. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46778. * @param entity defines the entity to select
  46779. * @param lineContainerTitle defines the specific block to highlight
  46780. */
  46781. select(entity: any, lineContainerTitle?: string): void;
  46782. /** Get the inspector from bundle or global */
  46783. private _getGlobalInspector;
  46784. /**
  46785. * Get if the inspector is visible or not.
  46786. * @returns true if visible otherwise, false
  46787. */
  46788. isVisible(): boolean;
  46789. /**
  46790. * Hide the inspector and close its window.
  46791. */
  46792. hide(): void;
  46793. /**
  46794. * Launch the debugLayer.
  46795. * @param config Define the configuration of the inspector
  46796. * @return a promise fulfilled when the debug layer is visible
  46797. */
  46798. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46799. }
  46800. }
  46801. declare module BABYLON {
  46802. /**
  46803. * Class containing static functions to help procedurally build meshes
  46804. */
  46805. export class BoxBuilder {
  46806. /**
  46807. * Creates a box mesh
  46808. * * The parameter `size` sets the size (float) of each box side (default 1)
  46809. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46810. * * 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)
  46811. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46813. * * 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
  46814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46815. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46816. * @param name defines the name of the mesh
  46817. * @param options defines the options used to create the mesh
  46818. * @param scene defines the hosting scene
  46819. * @returns the box mesh
  46820. */
  46821. static CreateBox(name: string, options: {
  46822. size?: number;
  46823. width?: number;
  46824. height?: number;
  46825. depth?: number;
  46826. faceUV?: Vector4[];
  46827. faceColors?: Color4[];
  46828. sideOrientation?: number;
  46829. frontUVs?: Vector4;
  46830. backUVs?: Vector4;
  46831. wrap?: boolean;
  46832. topBaseAt?: number;
  46833. bottomBaseAt?: number;
  46834. updatable?: boolean;
  46835. }, scene?: Nullable<Scene>): Mesh;
  46836. }
  46837. }
  46838. declare module BABYLON.Debug {
  46839. /**
  46840. * Used to show the physics impostor around the specific mesh
  46841. */
  46842. export class PhysicsViewer {
  46843. /** @hidden */
  46844. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46845. /** @hidden */
  46846. protected _meshes: Array<Nullable<AbstractMesh>>;
  46847. /** @hidden */
  46848. protected _scene: Nullable<Scene>;
  46849. /** @hidden */
  46850. protected _numMeshes: number;
  46851. /** @hidden */
  46852. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46853. private _renderFunction;
  46854. private _utilityLayer;
  46855. private _debugBoxMesh;
  46856. private _debugSphereMesh;
  46857. private _debugCylinderMesh;
  46858. private _debugMaterial;
  46859. private _debugMeshMeshes;
  46860. /**
  46861. * Creates a new PhysicsViewer
  46862. * @param scene defines the hosting scene
  46863. */
  46864. constructor(scene: Scene);
  46865. /** @hidden */
  46866. protected _updateDebugMeshes(): void;
  46867. /**
  46868. * Renders a specified physic impostor
  46869. * @param impostor defines the impostor to render
  46870. * @param targetMesh defines the mesh represented by the impostor
  46871. * @returns the new debug mesh used to render the impostor
  46872. */
  46873. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46874. /**
  46875. * Hides a specified physic impostor
  46876. * @param impostor defines the impostor to hide
  46877. */
  46878. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46879. private _getDebugMaterial;
  46880. private _getDebugBoxMesh;
  46881. private _getDebugSphereMesh;
  46882. private _getDebugCylinderMesh;
  46883. private _getDebugMeshMesh;
  46884. private _getDebugMesh;
  46885. /** Releases all resources */
  46886. dispose(): void;
  46887. }
  46888. }
  46889. declare module BABYLON {
  46890. /**
  46891. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46892. * in order to better appreciate the issue one might have.
  46893. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46894. */
  46895. export class RayHelper {
  46896. /**
  46897. * Defines the ray we are currently tryin to visualize.
  46898. */
  46899. ray: Nullable<Ray>;
  46900. private _renderPoints;
  46901. private _renderLine;
  46902. private _renderFunction;
  46903. private _scene;
  46904. private _updateToMeshFunction;
  46905. private _attachedToMesh;
  46906. private _meshSpaceDirection;
  46907. private _meshSpaceOrigin;
  46908. /**
  46909. * Helper function to create a colored helper in a scene in one line.
  46910. * @param ray Defines the ray we are currently tryin to visualize
  46911. * @param scene Defines the scene the ray is used in
  46912. * @param color Defines the color we want to see the ray in
  46913. * @returns The newly created ray helper.
  46914. */
  46915. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46916. /**
  46917. * Instantiate a new ray helper.
  46918. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46919. * in order to better appreciate the issue one might have.
  46920. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46921. * @param ray Defines the ray we are currently tryin to visualize
  46922. */
  46923. constructor(ray: Ray);
  46924. /**
  46925. * Shows the ray we are willing to debug.
  46926. * @param scene Defines the scene the ray needs to be rendered in
  46927. * @param color Defines the color the ray needs to be rendered in
  46928. */
  46929. show(scene: Scene, color?: Color3): void;
  46930. /**
  46931. * Hides the ray we are debugging.
  46932. */
  46933. hide(): void;
  46934. private _render;
  46935. /**
  46936. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46937. * @param mesh Defines the mesh we want the helper attached to
  46938. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46939. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46940. * @param length Defines the length of the ray
  46941. */
  46942. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46943. /**
  46944. * Detach the ray helper from the mesh it has previously been attached to.
  46945. */
  46946. detachFromMesh(): void;
  46947. private _updateToMesh;
  46948. /**
  46949. * Dispose the helper and release its associated resources.
  46950. */
  46951. dispose(): void;
  46952. }
  46953. }
  46954. declare module BABYLON.Debug {
  46955. /**
  46956. * Class used to render a debug view of a given skeleton
  46957. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46958. */
  46959. export class SkeletonViewer {
  46960. /** defines the skeleton to render */
  46961. skeleton: Skeleton;
  46962. /** defines the mesh attached to the skeleton */
  46963. mesh: AbstractMesh;
  46964. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46965. autoUpdateBonesMatrices: boolean;
  46966. /** defines the rendering group id to use with the viewer */
  46967. renderingGroupId: number;
  46968. /** Gets or sets the color used to render the skeleton */
  46969. color: Color3;
  46970. private _scene;
  46971. private _debugLines;
  46972. private _debugMesh;
  46973. private _isEnabled;
  46974. private _renderFunction;
  46975. private _utilityLayer;
  46976. /**
  46977. * Returns the mesh used to render the bones
  46978. */
  46979. get debugMesh(): Nullable<LinesMesh>;
  46980. /**
  46981. * Creates a new SkeletonViewer
  46982. * @param skeleton defines the skeleton to render
  46983. * @param mesh defines the mesh attached to the skeleton
  46984. * @param scene defines the hosting scene
  46985. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46986. * @param renderingGroupId defines the rendering group id to use with the viewer
  46987. */
  46988. constructor(
  46989. /** defines the skeleton to render */
  46990. skeleton: Skeleton,
  46991. /** defines the mesh attached to the skeleton */
  46992. mesh: AbstractMesh, scene: Scene,
  46993. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46994. autoUpdateBonesMatrices?: boolean,
  46995. /** defines the rendering group id to use with the viewer */
  46996. renderingGroupId?: number);
  46997. /** Gets or sets a boolean indicating if the viewer is enabled */
  46998. set isEnabled(value: boolean);
  46999. get isEnabled(): boolean;
  47000. private _getBonePosition;
  47001. private _getLinesForBonesWithLength;
  47002. private _getLinesForBonesNoLength;
  47003. /** Update the viewer to sync with current skeleton state */
  47004. update(): void;
  47005. /** Release associated resources */
  47006. dispose(): void;
  47007. }
  47008. }
  47009. declare module BABYLON {
  47010. /**
  47011. * Options to create the null engine
  47012. */
  47013. export class NullEngineOptions {
  47014. /**
  47015. * Render width (Default: 512)
  47016. */
  47017. renderWidth: number;
  47018. /**
  47019. * Render height (Default: 256)
  47020. */
  47021. renderHeight: number;
  47022. /**
  47023. * Texture size (Default: 512)
  47024. */
  47025. textureSize: number;
  47026. /**
  47027. * If delta time between frames should be constant
  47028. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47029. */
  47030. deterministicLockstep: boolean;
  47031. /**
  47032. * Maximum about of steps between frames (Default: 4)
  47033. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47034. */
  47035. lockstepMaxSteps: number;
  47036. }
  47037. /**
  47038. * The null engine class provides support for headless version of babylon.js.
  47039. * This can be used in server side scenario or for testing purposes
  47040. */
  47041. export class NullEngine extends Engine {
  47042. private _options;
  47043. /**
  47044. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47045. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47046. * @returns true if engine is in deterministic lock step mode
  47047. */
  47048. isDeterministicLockStep(): boolean;
  47049. /**
  47050. * Gets the max steps when engine is running in deterministic lock step
  47051. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47052. * @returns the max steps
  47053. */
  47054. getLockstepMaxSteps(): number;
  47055. /**
  47056. * Gets the current hardware scaling level.
  47057. * By default the hardware scaling level is computed from the window device ratio.
  47058. * 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.
  47059. * @returns a number indicating the current hardware scaling level
  47060. */
  47061. getHardwareScalingLevel(): number;
  47062. constructor(options?: NullEngineOptions);
  47063. /**
  47064. * Creates a vertex buffer
  47065. * @param vertices the data for the vertex buffer
  47066. * @returns the new WebGL static buffer
  47067. */
  47068. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47069. /**
  47070. * Creates a new index buffer
  47071. * @param indices defines the content of the index buffer
  47072. * @param updatable defines if the index buffer must be updatable
  47073. * @returns a new webGL buffer
  47074. */
  47075. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47076. /**
  47077. * Clear the current render buffer or the current render target (if any is set up)
  47078. * @param color defines the color to use
  47079. * @param backBuffer defines if the back buffer must be cleared
  47080. * @param depth defines if the depth buffer must be cleared
  47081. * @param stencil defines if the stencil buffer must be cleared
  47082. */
  47083. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47084. /**
  47085. * Gets the current render width
  47086. * @param useScreen defines if screen size must be used (or the current render target if any)
  47087. * @returns a number defining the current render width
  47088. */
  47089. getRenderWidth(useScreen?: boolean): number;
  47090. /**
  47091. * Gets the current render height
  47092. * @param useScreen defines if screen size must be used (or the current render target if any)
  47093. * @returns a number defining the current render height
  47094. */
  47095. getRenderHeight(useScreen?: boolean): number;
  47096. /**
  47097. * Set the WebGL's viewport
  47098. * @param viewport defines the viewport element to be used
  47099. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47100. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47101. */
  47102. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47103. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47104. /**
  47105. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47106. * @param pipelineContext defines the pipeline context to use
  47107. * @param uniformsNames defines the list of uniform names
  47108. * @returns an array of webGL uniform locations
  47109. */
  47110. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47111. /**
  47112. * Gets the lsit of active attributes for a given webGL program
  47113. * @param pipelineContext defines the pipeline context to use
  47114. * @param attributesNames defines the list of attribute names to get
  47115. * @returns an array of indices indicating the offset of each attribute
  47116. */
  47117. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47118. /**
  47119. * Binds an effect to the webGL context
  47120. * @param effect defines the effect to bind
  47121. */
  47122. bindSamplers(effect: Effect): void;
  47123. /**
  47124. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47125. * @param effect defines the effect to activate
  47126. */
  47127. enableEffect(effect: Effect): void;
  47128. /**
  47129. * Set various states to the webGL context
  47130. * @param culling defines backface culling state
  47131. * @param zOffset defines the value to apply to zOffset (0 by default)
  47132. * @param force defines if states must be applied even if cache is up to date
  47133. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47134. */
  47135. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47136. /**
  47137. * Set the value of an uniform to an array of int32
  47138. * @param uniform defines the webGL uniform location where to store the value
  47139. * @param array defines the array of int32 to store
  47140. */
  47141. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47142. /**
  47143. * Set the value of an uniform to an array of int32 (stored as vec2)
  47144. * @param uniform defines the webGL uniform location where to store the value
  47145. * @param array defines the array of int32 to store
  47146. */
  47147. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47148. /**
  47149. * Set the value of an uniform to an array of int32 (stored as vec3)
  47150. * @param uniform defines the webGL uniform location where to store the value
  47151. * @param array defines the array of int32 to store
  47152. */
  47153. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47154. /**
  47155. * Set the value of an uniform to an array of int32 (stored as vec4)
  47156. * @param uniform defines the webGL uniform location where to store the value
  47157. * @param array defines the array of int32 to store
  47158. */
  47159. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47160. /**
  47161. * Set the value of an uniform to an array of float32
  47162. * @param uniform defines the webGL uniform location where to store the value
  47163. * @param array defines the array of float32 to store
  47164. */
  47165. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47166. /**
  47167. * Set the value of an uniform to an array of float32 (stored as vec2)
  47168. * @param uniform defines the webGL uniform location where to store the value
  47169. * @param array defines the array of float32 to store
  47170. */
  47171. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47172. /**
  47173. * Set the value of an uniform to an array of float32 (stored as vec3)
  47174. * @param uniform defines the webGL uniform location where to store the value
  47175. * @param array defines the array of float32 to store
  47176. */
  47177. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47178. /**
  47179. * Set the value of an uniform to an array of float32 (stored as vec4)
  47180. * @param uniform defines the webGL uniform location where to store the value
  47181. * @param array defines the array of float32 to store
  47182. */
  47183. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47184. /**
  47185. * Set the value of an uniform to an array of number
  47186. * @param uniform defines the webGL uniform location where to store the value
  47187. * @param array defines the array of number to store
  47188. */
  47189. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47190. /**
  47191. * Set the value of an uniform to an array of number (stored as vec2)
  47192. * @param uniform defines the webGL uniform location where to store the value
  47193. * @param array defines the array of number to store
  47194. */
  47195. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47196. /**
  47197. * Set the value of an uniform to an array of number (stored as vec3)
  47198. * @param uniform defines the webGL uniform location where to store the value
  47199. * @param array defines the array of number to store
  47200. */
  47201. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47202. /**
  47203. * Set the value of an uniform to an array of number (stored as vec4)
  47204. * @param uniform defines the webGL uniform location where to store the value
  47205. * @param array defines the array of number to store
  47206. */
  47207. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47208. /**
  47209. * Set the value of an uniform to an array of float32 (stored as matrices)
  47210. * @param uniform defines the webGL uniform location where to store the value
  47211. * @param matrices defines the array of float32 to store
  47212. */
  47213. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47214. /**
  47215. * Set the value of an uniform to a matrix (3x3)
  47216. * @param uniform defines the webGL uniform location where to store the value
  47217. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47218. */
  47219. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47220. /**
  47221. * Set the value of an uniform to a matrix (2x2)
  47222. * @param uniform defines the webGL uniform location where to store the value
  47223. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47224. */
  47225. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47226. /**
  47227. * Set the value of an uniform to a number (float)
  47228. * @param uniform defines the webGL uniform location where to store the value
  47229. * @param value defines the float number to store
  47230. */
  47231. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47232. /**
  47233. * Set the value of an uniform to a vec2
  47234. * @param uniform defines the webGL uniform location where to store the value
  47235. * @param x defines the 1st component of the value
  47236. * @param y defines the 2nd component of the value
  47237. */
  47238. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47239. /**
  47240. * Set the value of an uniform to a vec3
  47241. * @param uniform defines the webGL uniform location where to store the value
  47242. * @param x defines the 1st component of the value
  47243. * @param y defines the 2nd component of the value
  47244. * @param z defines the 3rd component of the value
  47245. */
  47246. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47247. /**
  47248. * Set the value of an uniform to a boolean
  47249. * @param uniform defines the webGL uniform location where to store the value
  47250. * @param bool defines the boolean to store
  47251. */
  47252. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47253. /**
  47254. * Set the value of an uniform to a vec4
  47255. * @param uniform defines the webGL uniform location where to store the value
  47256. * @param x defines the 1st component of the value
  47257. * @param y defines the 2nd component of the value
  47258. * @param z defines the 3rd component of the value
  47259. * @param w defines the 4th component of the value
  47260. */
  47261. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47262. /**
  47263. * Sets the current alpha mode
  47264. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47265. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47266. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47267. */
  47268. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47269. /**
  47270. * Bind webGl buffers directly to the webGL context
  47271. * @param vertexBuffers defines the vertex buffer to bind
  47272. * @param indexBuffer defines the index buffer to bind
  47273. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47274. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47275. * @param effect defines the effect associated with the vertex buffer
  47276. */
  47277. bindBuffers(vertexBuffers: {
  47278. [key: string]: VertexBuffer;
  47279. }, indexBuffer: DataBuffer, effect: Effect): void;
  47280. /**
  47281. * Force the entire cache to be cleared
  47282. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47283. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47284. */
  47285. wipeCaches(bruteForce?: boolean): void;
  47286. /**
  47287. * Send a draw order
  47288. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47289. * @param indexStart defines the starting index
  47290. * @param indexCount defines the number of index to draw
  47291. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47292. */
  47293. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47294. /**
  47295. * Draw a list of indexed primitives
  47296. * @param fillMode defines the primitive to use
  47297. * @param indexStart defines the starting index
  47298. * @param indexCount defines the number of index to draw
  47299. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47300. */
  47301. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47302. /**
  47303. * Draw a list of unindexed primitives
  47304. * @param fillMode defines the primitive to use
  47305. * @param verticesStart defines the index of first vertex to draw
  47306. * @param verticesCount defines the count of vertices to draw
  47307. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47308. */
  47309. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47310. /** @hidden */
  47311. _createTexture(): WebGLTexture;
  47312. /** @hidden */
  47313. _releaseTexture(texture: InternalTexture): void;
  47314. /**
  47315. * Usually called from Texture.ts.
  47316. * Passed information to create a WebGLTexture
  47317. * @param urlArg defines a value which contains one of the following:
  47318. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47319. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47320. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47321. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47322. * @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)
  47323. * @param scene needed for loading to the correct scene
  47324. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47325. * @param onLoad optional callback to be called upon successful completion
  47326. * @param onError optional callback to be called upon failure
  47327. * @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
  47328. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47329. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47330. * @param forcedExtension defines the extension to use to pick the right loader
  47331. * @param mimeType defines an optional mime type
  47332. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47333. */
  47334. 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;
  47335. /**
  47336. * Creates a new render target texture
  47337. * @param size defines the size of the texture
  47338. * @param options defines the options used to create the texture
  47339. * @returns a new render target texture stored in an InternalTexture
  47340. */
  47341. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47342. /**
  47343. * Update the sampling mode of a given texture
  47344. * @param samplingMode defines the required sampling mode
  47345. * @param texture defines the texture to update
  47346. */
  47347. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47348. /**
  47349. * Binds the frame buffer to the specified texture.
  47350. * @param texture The texture to render to or null for the default canvas
  47351. * @param faceIndex The face of the texture to render to in case of cube texture
  47352. * @param requiredWidth The width of the target to render to
  47353. * @param requiredHeight The height of the target to render to
  47354. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47355. * @param lodLevel defines le lod level to bind to the frame buffer
  47356. */
  47357. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47358. /**
  47359. * Unbind the current render target texture from the webGL context
  47360. * @param texture defines the render target texture to unbind
  47361. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47362. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47363. */
  47364. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47365. /**
  47366. * Creates a dynamic vertex buffer
  47367. * @param vertices the data for the dynamic vertex buffer
  47368. * @returns the new WebGL dynamic buffer
  47369. */
  47370. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47371. /**
  47372. * Update the content of a dynamic texture
  47373. * @param texture defines the texture to update
  47374. * @param canvas defines the canvas containing the source
  47375. * @param invertY defines if data must be stored with Y axis inverted
  47376. * @param premulAlpha defines if alpha is stored as premultiplied
  47377. * @param format defines the format of the data
  47378. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47379. */
  47380. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47381. /**
  47382. * Gets a boolean indicating if all created effects are ready
  47383. * @returns true if all effects are ready
  47384. */
  47385. areAllEffectsReady(): boolean;
  47386. /**
  47387. * @hidden
  47388. * Get the current error code of the webGL context
  47389. * @returns the error code
  47390. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47391. */
  47392. getError(): number;
  47393. /** @hidden */
  47394. _getUnpackAlignement(): number;
  47395. /** @hidden */
  47396. _unpackFlipY(value: boolean): void;
  47397. /**
  47398. * Update a dynamic index buffer
  47399. * @param indexBuffer defines the target index buffer
  47400. * @param indices defines the data to update
  47401. * @param offset defines the offset in the target index buffer where update should start
  47402. */
  47403. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47404. /**
  47405. * Updates a dynamic vertex buffer.
  47406. * @param vertexBuffer the vertex buffer to update
  47407. * @param vertices the data used to update the vertex buffer
  47408. * @param byteOffset the byte offset of the data (optional)
  47409. * @param byteLength the byte length of the data (optional)
  47410. */
  47411. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47412. /** @hidden */
  47413. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47414. /** @hidden */
  47415. _bindTexture(channel: number, texture: InternalTexture): void;
  47416. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47417. /**
  47418. * 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
  47419. */
  47420. releaseEffects(): void;
  47421. displayLoadingUI(): void;
  47422. hideLoadingUI(): void;
  47423. /** @hidden */
  47424. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47425. /** @hidden */
  47426. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47427. /** @hidden */
  47428. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47429. /** @hidden */
  47430. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47431. }
  47432. }
  47433. declare module BABYLON {
  47434. /**
  47435. * @hidden
  47436. **/
  47437. export class _TimeToken {
  47438. _startTimeQuery: Nullable<WebGLQuery>;
  47439. _endTimeQuery: Nullable<WebGLQuery>;
  47440. _timeElapsedQuery: Nullable<WebGLQuery>;
  47441. _timeElapsedQueryEnded: boolean;
  47442. }
  47443. }
  47444. declare module BABYLON {
  47445. /** @hidden */
  47446. export class _OcclusionDataStorage {
  47447. /** @hidden */
  47448. occlusionInternalRetryCounter: number;
  47449. /** @hidden */
  47450. isOcclusionQueryInProgress: boolean;
  47451. /** @hidden */
  47452. isOccluded: boolean;
  47453. /** @hidden */
  47454. occlusionRetryCount: number;
  47455. /** @hidden */
  47456. occlusionType: number;
  47457. /** @hidden */
  47458. occlusionQueryAlgorithmType: number;
  47459. }
  47460. interface Engine {
  47461. /**
  47462. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47463. * @return the new query
  47464. */
  47465. createQuery(): WebGLQuery;
  47466. /**
  47467. * Delete and release a webGL query
  47468. * @param query defines the query to delete
  47469. * @return the current engine
  47470. */
  47471. deleteQuery(query: WebGLQuery): Engine;
  47472. /**
  47473. * Check if a given query has resolved and got its value
  47474. * @param query defines the query to check
  47475. * @returns true if the query got its value
  47476. */
  47477. isQueryResultAvailable(query: WebGLQuery): boolean;
  47478. /**
  47479. * Gets the value of a given query
  47480. * @param query defines the query to check
  47481. * @returns the value of the query
  47482. */
  47483. getQueryResult(query: WebGLQuery): number;
  47484. /**
  47485. * Initiates an occlusion query
  47486. * @param algorithmType defines the algorithm to use
  47487. * @param query defines the query to use
  47488. * @returns the current engine
  47489. * @see http://doc.babylonjs.com/features/occlusionquery
  47490. */
  47491. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47492. /**
  47493. * Ends an occlusion query
  47494. * @see http://doc.babylonjs.com/features/occlusionquery
  47495. * @param algorithmType defines the algorithm to use
  47496. * @returns the current engine
  47497. */
  47498. endOcclusionQuery(algorithmType: number): Engine;
  47499. /**
  47500. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47501. * Please note that only one query can be issued at a time
  47502. * @returns a time token used to track the time span
  47503. */
  47504. startTimeQuery(): Nullable<_TimeToken>;
  47505. /**
  47506. * Ends a time query
  47507. * @param token defines the token used to measure the time span
  47508. * @returns the time spent (in ns)
  47509. */
  47510. endTimeQuery(token: _TimeToken): int;
  47511. /** @hidden */
  47512. _currentNonTimestampToken: Nullable<_TimeToken>;
  47513. /** @hidden */
  47514. _createTimeQuery(): WebGLQuery;
  47515. /** @hidden */
  47516. _deleteTimeQuery(query: WebGLQuery): void;
  47517. /** @hidden */
  47518. _getGlAlgorithmType(algorithmType: number): number;
  47519. /** @hidden */
  47520. _getTimeQueryResult(query: WebGLQuery): any;
  47521. /** @hidden */
  47522. _getTimeQueryAvailability(query: WebGLQuery): any;
  47523. }
  47524. interface AbstractMesh {
  47525. /**
  47526. * Backing filed
  47527. * @hidden
  47528. */
  47529. __occlusionDataStorage: _OcclusionDataStorage;
  47530. /**
  47531. * Access property
  47532. * @hidden
  47533. */
  47534. _occlusionDataStorage: _OcclusionDataStorage;
  47535. /**
  47536. * 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.
  47537. * The default value is -1 which means don't break the query and wait till the result
  47538. * @see http://doc.babylonjs.com/features/occlusionquery
  47539. */
  47540. occlusionRetryCount: number;
  47541. /**
  47542. * 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:
  47543. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47544. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47545. * * 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.
  47546. * @see http://doc.babylonjs.com/features/occlusionquery
  47547. */
  47548. occlusionType: number;
  47549. /**
  47550. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47551. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47552. * * 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.
  47553. * @see http://doc.babylonjs.com/features/occlusionquery
  47554. */
  47555. occlusionQueryAlgorithmType: number;
  47556. /**
  47557. * 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
  47558. * @see http://doc.babylonjs.com/features/occlusionquery
  47559. */
  47560. isOccluded: boolean;
  47561. /**
  47562. * Flag to check the progress status of the query
  47563. * @see http://doc.babylonjs.com/features/occlusionquery
  47564. */
  47565. isOcclusionQueryInProgress: boolean;
  47566. }
  47567. }
  47568. declare module BABYLON {
  47569. /** @hidden */
  47570. export var _forceTransformFeedbackToBundle: boolean;
  47571. interface Engine {
  47572. /**
  47573. * Creates a webGL transform feedback object
  47574. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47575. * @returns the webGL transform feedback object
  47576. */
  47577. createTransformFeedback(): WebGLTransformFeedback;
  47578. /**
  47579. * Delete a webGL transform feedback object
  47580. * @param value defines the webGL transform feedback object to delete
  47581. */
  47582. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47583. /**
  47584. * Bind a webGL transform feedback object to the webgl context
  47585. * @param value defines the webGL transform feedback object to bind
  47586. */
  47587. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47588. /**
  47589. * Begins a transform feedback operation
  47590. * @param usePoints defines if points or triangles must be used
  47591. */
  47592. beginTransformFeedback(usePoints: boolean): void;
  47593. /**
  47594. * Ends a transform feedback operation
  47595. */
  47596. endTransformFeedback(): void;
  47597. /**
  47598. * Specify the varyings to use with transform feedback
  47599. * @param program defines the associated webGL program
  47600. * @param value defines the list of strings representing the varying names
  47601. */
  47602. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47603. /**
  47604. * Bind a webGL buffer for a transform feedback operation
  47605. * @param value defines the webGL buffer to bind
  47606. */
  47607. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47608. }
  47609. }
  47610. declare module BABYLON {
  47611. /**
  47612. * Creation options of the multi render target texture.
  47613. */
  47614. export interface IMultiRenderTargetOptions {
  47615. /**
  47616. * Define if the texture needs to create mip maps after render.
  47617. */
  47618. generateMipMaps?: boolean;
  47619. /**
  47620. * Define the types of all the draw buffers we want to create
  47621. */
  47622. types?: number[];
  47623. /**
  47624. * Define the sampling modes of all the draw buffers we want to create
  47625. */
  47626. samplingModes?: number[];
  47627. /**
  47628. * Define if a depth buffer is required
  47629. */
  47630. generateDepthBuffer?: boolean;
  47631. /**
  47632. * Define if a stencil buffer is required
  47633. */
  47634. generateStencilBuffer?: boolean;
  47635. /**
  47636. * Define if a depth texture is required instead of a depth buffer
  47637. */
  47638. generateDepthTexture?: boolean;
  47639. /**
  47640. * Define the number of desired draw buffers
  47641. */
  47642. textureCount?: number;
  47643. /**
  47644. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47645. */
  47646. doNotChangeAspectRatio?: boolean;
  47647. /**
  47648. * Define the default type of the buffers we are creating
  47649. */
  47650. defaultType?: number;
  47651. }
  47652. /**
  47653. * A multi render target, like a render target provides the ability to render to a texture.
  47654. * Unlike the render target, it can render to several draw buffers in one draw.
  47655. * This is specially interesting in deferred rendering or for any effects requiring more than
  47656. * just one color from a single pass.
  47657. */
  47658. export class MultiRenderTarget extends RenderTargetTexture {
  47659. private _internalTextures;
  47660. private _textures;
  47661. private _multiRenderTargetOptions;
  47662. /**
  47663. * Get if draw buffers are currently supported by the used hardware and browser.
  47664. */
  47665. get isSupported(): boolean;
  47666. /**
  47667. * Get the list of textures generated by the multi render target.
  47668. */
  47669. get textures(): Texture[];
  47670. /**
  47671. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47672. */
  47673. get depthTexture(): Texture;
  47674. /**
  47675. * Set the wrapping mode on U of all the textures we are rendering to.
  47676. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47677. */
  47678. set wrapU(wrap: number);
  47679. /**
  47680. * Set the wrapping mode on V of all the textures we are rendering to.
  47681. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47682. */
  47683. set wrapV(wrap: number);
  47684. /**
  47685. * Instantiate a new multi render target texture.
  47686. * A multi render target, like a render target provides the ability to render to a texture.
  47687. * Unlike the render target, it can render to several draw buffers in one draw.
  47688. * This is specially interesting in deferred rendering or for any effects requiring more than
  47689. * just one color from a single pass.
  47690. * @param name Define the name of the texture
  47691. * @param size Define the size of the buffers to render to
  47692. * @param count Define the number of target we are rendering into
  47693. * @param scene Define the scene the texture belongs to
  47694. * @param options Define the options used to create the multi render target
  47695. */
  47696. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47697. /** @hidden */
  47698. _rebuild(): void;
  47699. private _createInternalTextures;
  47700. private _createTextures;
  47701. /**
  47702. * Define the number of samples used if MSAA is enabled.
  47703. */
  47704. get samples(): number;
  47705. set samples(value: number);
  47706. /**
  47707. * Resize all the textures in the multi render target.
  47708. * Be carrefull as it will recreate all the data in the new texture.
  47709. * @param size Define the new size
  47710. */
  47711. resize(size: any): void;
  47712. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47713. /**
  47714. * Dispose the render targets and their associated resources
  47715. */
  47716. dispose(): void;
  47717. /**
  47718. * Release all the underlying texture used as draw buffers.
  47719. */
  47720. releaseInternalTextures(): void;
  47721. }
  47722. }
  47723. declare module BABYLON {
  47724. interface ThinEngine {
  47725. /**
  47726. * Unbind a list of render target textures from the webGL context
  47727. * This is used only when drawBuffer extension or webGL2 are active
  47728. * @param textures defines the render target textures to unbind
  47729. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47730. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47731. */
  47732. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47733. /**
  47734. * Create a multi render target texture
  47735. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47736. * @param size defines the size of the texture
  47737. * @param options defines the creation options
  47738. * @returns the cube texture as an InternalTexture
  47739. */
  47740. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47741. /**
  47742. * Update the sample count for a given multiple render target texture
  47743. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47744. * @param textures defines the textures to update
  47745. * @param samples defines the sample count to set
  47746. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47747. */
  47748. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47749. }
  47750. }
  47751. declare module BABYLON {
  47752. /**
  47753. * Class used to define an additional view for the engine
  47754. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47755. */
  47756. export class EngineView {
  47757. /** Defines the canvas where to render the view */
  47758. target: HTMLCanvasElement;
  47759. /** Defines an optional camera used to render the view (will use active camera else) */
  47760. camera?: Camera;
  47761. }
  47762. interface Engine {
  47763. /**
  47764. * Gets or sets the HTML element to use for attaching events
  47765. */
  47766. inputElement: Nullable<HTMLElement>;
  47767. /**
  47768. * Gets the current engine view
  47769. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47770. */
  47771. activeView: Nullable<EngineView>;
  47772. /** Gets or sets the list of views */
  47773. views: EngineView[];
  47774. /**
  47775. * Register a new child canvas
  47776. * @param canvas defines the canvas to register
  47777. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47778. * @returns the associated view
  47779. */
  47780. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47781. /**
  47782. * Remove a registered child canvas
  47783. * @param canvas defines the canvas to remove
  47784. * @returns the current engine
  47785. */
  47786. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47787. }
  47788. }
  47789. declare module BABYLON {
  47790. interface Engine {
  47791. /** @hidden */
  47792. _excludedCompressedTextures: string[];
  47793. /** @hidden */
  47794. _textureFormatInUse: string;
  47795. /**
  47796. * Gets the list of texture formats supported
  47797. */
  47798. readonly texturesSupported: Array<string>;
  47799. /**
  47800. * Gets the texture format in use
  47801. */
  47802. readonly textureFormatInUse: Nullable<string>;
  47803. /**
  47804. * Set the compressed texture extensions or file names to skip.
  47805. *
  47806. * @param skippedFiles defines the list of those texture files you want to skip
  47807. * Example: [".dds", ".env", "myfile.png"]
  47808. */
  47809. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47810. /**
  47811. * Set the compressed texture format to use, based on the formats you have, and the formats
  47812. * supported by the hardware / browser.
  47813. *
  47814. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47815. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47816. * to API arguments needed to compressed textures. This puts the burden on the container
  47817. * generator to house the arcane code for determining these for current & future formats.
  47818. *
  47819. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47820. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47821. *
  47822. * Note: The result of this call is not taken into account when a texture is base64.
  47823. *
  47824. * @param formatsAvailable defines the list of those format families you have created
  47825. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47826. *
  47827. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47828. * @returns The extension selected.
  47829. */
  47830. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47831. }
  47832. }
  47833. declare module BABYLON {
  47834. /**
  47835. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47836. */
  47837. export interface CubeMapInfo {
  47838. /**
  47839. * The pixel array for the front face.
  47840. * This is stored in format, left to right, up to down format.
  47841. */
  47842. front: Nullable<ArrayBufferView>;
  47843. /**
  47844. * The pixel array for the back face.
  47845. * This is stored in format, left to right, up to down format.
  47846. */
  47847. back: Nullable<ArrayBufferView>;
  47848. /**
  47849. * The pixel array for the left face.
  47850. * This is stored in format, left to right, up to down format.
  47851. */
  47852. left: Nullable<ArrayBufferView>;
  47853. /**
  47854. * The pixel array for the right face.
  47855. * This is stored in format, left to right, up to down format.
  47856. */
  47857. right: Nullable<ArrayBufferView>;
  47858. /**
  47859. * The pixel array for the up face.
  47860. * This is stored in format, left to right, up to down format.
  47861. */
  47862. up: Nullable<ArrayBufferView>;
  47863. /**
  47864. * The pixel array for the down face.
  47865. * This is stored in format, left to right, up to down format.
  47866. */
  47867. down: Nullable<ArrayBufferView>;
  47868. /**
  47869. * The size of the cubemap stored.
  47870. *
  47871. * Each faces will be size * size pixels.
  47872. */
  47873. size: number;
  47874. /**
  47875. * The format of the texture.
  47876. *
  47877. * RGBA, RGB.
  47878. */
  47879. format: number;
  47880. /**
  47881. * The type of the texture data.
  47882. *
  47883. * UNSIGNED_INT, FLOAT.
  47884. */
  47885. type: number;
  47886. /**
  47887. * Specifies whether the texture is in gamma space.
  47888. */
  47889. gammaSpace: boolean;
  47890. }
  47891. /**
  47892. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47893. */
  47894. export class PanoramaToCubeMapTools {
  47895. private static FACE_FRONT;
  47896. private static FACE_BACK;
  47897. private static FACE_RIGHT;
  47898. private static FACE_LEFT;
  47899. private static FACE_DOWN;
  47900. private static FACE_UP;
  47901. /**
  47902. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47903. *
  47904. * @param float32Array The source data.
  47905. * @param inputWidth The width of the input panorama.
  47906. * @param inputHeight The height of the input panorama.
  47907. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47908. * @return The cubemap data
  47909. */
  47910. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47911. private static CreateCubemapTexture;
  47912. private static CalcProjectionSpherical;
  47913. }
  47914. }
  47915. declare module BABYLON {
  47916. /**
  47917. * Helper class dealing with the extraction of spherical polynomial dataArray
  47918. * from a cube map.
  47919. */
  47920. export class CubeMapToSphericalPolynomialTools {
  47921. private static FileFaces;
  47922. /**
  47923. * Converts a texture to the according Spherical Polynomial data.
  47924. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47925. *
  47926. * @param texture The texture to extract the information from.
  47927. * @return The Spherical Polynomial data.
  47928. */
  47929. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47930. /**
  47931. * Converts a cubemap to the according Spherical Polynomial data.
  47932. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47933. *
  47934. * @param cubeInfo The Cube map to extract the information from.
  47935. * @return The Spherical Polynomial data.
  47936. */
  47937. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47938. }
  47939. }
  47940. declare module BABYLON {
  47941. interface BaseTexture {
  47942. /**
  47943. * Get the polynomial representation of the texture data.
  47944. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47945. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47946. */
  47947. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47948. }
  47949. }
  47950. declare module BABYLON {
  47951. /** @hidden */
  47952. export var rgbdEncodePixelShader: {
  47953. name: string;
  47954. shader: string;
  47955. };
  47956. }
  47957. declare module BABYLON {
  47958. /** @hidden */
  47959. export var rgbdDecodePixelShader: {
  47960. name: string;
  47961. shader: string;
  47962. };
  47963. }
  47964. declare module BABYLON {
  47965. /**
  47966. * Raw texture data and descriptor sufficient for WebGL texture upload
  47967. */
  47968. export interface EnvironmentTextureInfo {
  47969. /**
  47970. * Version of the environment map
  47971. */
  47972. version: number;
  47973. /**
  47974. * Width of image
  47975. */
  47976. width: number;
  47977. /**
  47978. * Irradiance information stored in the file.
  47979. */
  47980. irradiance: any;
  47981. /**
  47982. * Specular information stored in the file.
  47983. */
  47984. specular: any;
  47985. }
  47986. /**
  47987. * Defines One Image in the file. It requires only the position in the file
  47988. * as well as the length.
  47989. */
  47990. interface BufferImageData {
  47991. /**
  47992. * Length of the image data.
  47993. */
  47994. length: number;
  47995. /**
  47996. * Position of the data from the null terminator delimiting the end of the JSON.
  47997. */
  47998. position: number;
  47999. }
  48000. /**
  48001. * Defines the specular data enclosed in the file.
  48002. * This corresponds to the version 1 of the data.
  48003. */
  48004. export interface EnvironmentTextureSpecularInfoV1 {
  48005. /**
  48006. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48007. */
  48008. specularDataPosition?: number;
  48009. /**
  48010. * This contains all the images data needed to reconstruct the cubemap.
  48011. */
  48012. mipmaps: Array<BufferImageData>;
  48013. /**
  48014. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48015. */
  48016. lodGenerationScale: number;
  48017. }
  48018. /**
  48019. * Sets of helpers addressing the serialization and deserialization of environment texture
  48020. * stored in a BabylonJS env file.
  48021. * Those files are usually stored as .env files.
  48022. */
  48023. export class EnvironmentTextureTools {
  48024. /**
  48025. * Magic number identifying the env file.
  48026. */
  48027. private static _MagicBytes;
  48028. /**
  48029. * Gets the environment info from an env file.
  48030. * @param data The array buffer containing the .env bytes.
  48031. * @returns the environment file info (the json header) if successfully parsed.
  48032. */
  48033. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  48034. /**
  48035. * Creates an environment texture from a loaded cube texture.
  48036. * @param texture defines the cube texture to convert in env file
  48037. * @return a promise containing the environment data if succesfull.
  48038. */
  48039. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48040. /**
  48041. * Creates a JSON representation of the spherical data.
  48042. * @param texture defines the texture containing the polynomials
  48043. * @return the JSON representation of the spherical info
  48044. */
  48045. private static _CreateEnvTextureIrradiance;
  48046. /**
  48047. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48048. * @param data the image data
  48049. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48050. * @return the views described by info providing access to the underlying buffer
  48051. */
  48052. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48053. /**
  48054. * Uploads the texture info contained in the env file to the GPU.
  48055. * @param texture defines the internal texture to upload to
  48056. * @param data defines the data to load
  48057. * @param info defines the texture info retrieved through the GetEnvInfo method
  48058. * @returns a promise
  48059. */
  48060. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  48061. private static _OnImageReadyAsync;
  48062. /**
  48063. * Uploads the levels of image data to the GPU.
  48064. * @param texture defines the internal texture to upload to
  48065. * @param imageData defines the array buffer views of image data [mipmap][face]
  48066. * @returns a promise
  48067. */
  48068. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48069. /**
  48070. * Uploads spherical polynomials information to the texture.
  48071. * @param texture defines the texture we are trying to upload the information to
  48072. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48073. */
  48074. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48075. /** @hidden */
  48076. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48077. }
  48078. }
  48079. declare module BABYLON {
  48080. /**
  48081. * Contains position and normal vectors for a vertex
  48082. */
  48083. export class PositionNormalVertex {
  48084. /** the position of the vertex (defaut: 0,0,0) */
  48085. position: Vector3;
  48086. /** the normal of the vertex (defaut: 0,1,0) */
  48087. normal: Vector3;
  48088. /**
  48089. * Creates a PositionNormalVertex
  48090. * @param position the position of the vertex (defaut: 0,0,0)
  48091. * @param normal the normal of the vertex (defaut: 0,1,0)
  48092. */
  48093. constructor(
  48094. /** the position of the vertex (defaut: 0,0,0) */
  48095. position?: Vector3,
  48096. /** the normal of the vertex (defaut: 0,1,0) */
  48097. normal?: Vector3);
  48098. /**
  48099. * Clones the PositionNormalVertex
  48100. * @returns the cloned PositionNormalVertex
  48101. */
  48102. clone(): PositionNormalVertex;
  48103. }
  48104. /**
  48105. * Contains position, normal and uv vectors for a vertex
  48106. */
  48107. export class PositionNormalTextureVertex {
  48108. /** the position of the vertex (defaut: 0,0,0) */
  48109. position: Vector3;
  48110. /** the normal of the vertex (defaut: 0,1,0) */
  48111. normal: Vector3;
  48112. /** the uv of the vertex (default: 0,0) */
  48113. uv: Vector2;
  48114. /**
  48115. * Creates a PositionNormalTextureVertex
  48116. * @param position the position of the vertex (defaut: 0,0,0)
  48117. * @param normal the normal of the vertex (defaut: 0,1,0)
  48118. * @param uv the uv of the vertex (default: 0,0)
  48119. */
  48120. constructor(
  48121. /** the position of the vertex (defaut: 0,0,0) */
  48122. position?: Vector3,
  48123. /** the normal of the vertex (defaut: 0,1,0) */
  48124. normal?: Vector3,
  48125. /** the uv of the vertex (default: 0,0) */
  48126. uv?: Vector2);
  48127. /**
  48128. * Clones the PositionNormalTextureVertex
  48129. * @returns the cloned PositionNormalTextureVertex
  48130. */
  48131. clone(): PositionNormalTextureVertex;
  48132. }
  48133. }
  48134. declare module BABYLON {
  48135. /** @hidden */
  48136. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48137. private _genericAttributeLocation;
  48138. private _varyingLocationCount;
  48139. private _varyingLocationMap;
  48140. private _replacements;
  48141. private _textureCount;
  48142. private _uniforms;
  48143. lineProcessor(line: string): string;
  48144. attributeProcessor(attribute: string): string;
  48145. varyingProcessor(varying: string, isFragment: boolean): string;
  48146. uniformProcessor(uniform: string): string;
  48147. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48148. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48149. }
  48150. }
  48151. declare module BABYLON {
  48152. /**
  48153. * Container for accessors for natively-stored mesh data buffers.
  48154. */
  48155. class NativeDataBuffer extends DataBuffer {
  48156. /**
  48157. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48158. */
  48159. nativeIndexBuffer?: any;
  48160. /**
  48161. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48162. */
  48163. nativeVertexBuffer?: any;
  48164. }
  48165. /** @hidden */
  48166. class NativeTexture extends InternalTexture {
  48167. getInternalTexture(): InternalTexture;
  48168. getViewCount(): number;
  48169. }
  48170. /** @hidden */
  48171. export class NativeEngine extends Engine {
  48172. private readonly _native;
  48173. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48174. private readonly INVALID_HANDLE;
  48175. getHardwareScalingLevel(): number;
  48176. constructor();
  48177. dispose(): void;
  48178. /**
  48179. * Can be used to override the current requestAnimationFrame requester.
  48180. * @hidden
  48181. */
  48182. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48183. /**
  48184. * Override default engine behavior.
  48185. * @param color
  48186. * @param backBuffer
  48187. * @param depth
  48188. * @param stencil
  48189. */
  48190. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48191. /**
  48192. * Gets host document
  48193. * @returns the host document object
  48194. */
  48195. getHostDocument(): Nullable<Document>;
  48196. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48197. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48198. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48199. recordVertexArrayObject(vertexBuffers: {
  48200. [key: string]: VertexBuffer;
  48201. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48202. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48203. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48204. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48205. /**
  48206. * Draw a list of indexed primitives
  48207. * @param fillMode defines the primitive to use
  48208. * @param indexStart defines the starting index
  48209. * @param indexCount defines the number of index to draw
  48210. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48211. */
  48212. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48213. /**
  48214. * Draw a list of unindexed primitives
  48215. * @param fillMode defines the primitive to use
  48216. * @param verticesStart defines the index of first vertex to draw
  48217. * @param verticesCount defines the count of vertices to draw
  48218. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48219. */
  48220. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48221. createPipelineContext(): IPipelineContext;
  48222. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48223. /** @hidden */
  48224. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48225. /** @hidden */
  48226. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48227. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48228. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48229. protected _setProgram(program: WebGLProgram): void;
  48230. _releaseEffect(effect: Effect): void;
  48231. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48232. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48233. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48234. bindSamplers(effect: Effect): void;
  48235. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48236. getRenderWidth(useScreen?: boolean): number;
  48237. getRenderHeight(useScreen?: boolean): number;
  48238. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48239. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48240. /**
  48241. * Set the z offset to apply to current rendering
  48242. * @param value defines the offset to apply
  48243. */
  48244. setZOffset(value: number): void;
  48245. /**
  48246. * Gets the current value of the zOffset
  48247. * @returns the current zOffset state
  48248. */
  48249. getZOffset(): number;
  48250. /**
  48251. * Enable or disable depth buffering
  48252. * @param enable defines the state to set
  48253. */
  48254. setDepthBuffer(enable: boolean): void;
  48255. /**
  48256. * Gets a boolean indicating if depth writing is enabled
  48257. * @returns the current depth writing state
  48258. */
  48259. getDepthWrite(): boolean;
  48260. /**
  48261. * Enable or disable depth writing
  48262. * @param enable defines the state to set
  48263. */
  48264. setDepthWrite(enable: boolean): void;
  48265. /**
  48266. * Enable or disable color writing
  48267. * @param enable defines the state to set
  48268. */
  48269. setColorWrite(enable: boolean): void;
  48270. /**
  48271. * Gets a boolean indicating if color writing is enabled
  48272. * @returns the current color writing state
  48273. */
  48274. getColorWrite(): boolean;
  48275. /**
  48276. * Sets alpha constants used by some alpha blending modes
  48277. * @param r defines the red component
  48278. * @param g defines the green component
  48279. * @param b defines the blue component
  48280. * @param a defines the alpha component
  48281. */
  48282. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48283. /**
  48284. * Sets the current alpha mode
  48285. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48286. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48287. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48288. */
  48289. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48290. /**
  48291. * Gets the current alpha mode
  48292. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48293. * @returns the current alpha mode
  48294. */
  48295. getAlphaMode(): number;
  48296. setInt(uniform: WebGLUniformLocation, int: number): void;
  48297. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48298. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48299. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48300. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48301. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48302. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48303. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48304. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48305. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48306. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48307. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48308. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48309. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48310. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48311. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48312. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48313. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48314. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48315. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48316. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48317. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48318. wipeCaches(bruteForce?: boolean): void;
  48319. _createTexture(): WebGLTexture;
  48320. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48321. /**
  48322. * Usually called from Texture.ts.
  48323. * Passed information to create a WebGLTexture
  48324. * @param url defines a value which contains one of the following:
  48325. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48326. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48327. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48328. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48329. * @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)
  48330. * @param scene needed for loading to the correct scene
  48331. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48332. * @param onLoad optional callback to be called upon successful completion
  48333. * @param onError optional callback to be called upon failure
  48334. * @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
  48335. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48336. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48337. * @param forcedExtension defines the extension to use to pick the right loader
  48338. * @param mimeType defines an optional mime type
  48339. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48340. */
  48341. 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;
  48342. /**
  48343. * Creates a cube texture
  48344. * @param rootUrl defines the url where the files to load is located
  48345. * @param scene defines the current scene
  48346. * @param files defines the list of files to load (1 per face)
  48347. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48348. * @param onLoad defines an optional callback raised when the texture is loaded
  48349. * @param onError defines an optional callback raised if there is an issue to load the texture
  48350. * @param format defines the format of the data
  48351. * @param forcedExtension defines the extension to use to pick the right loader
  48352. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48353. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48354. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48355. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48356. * @returns the cube texture as an InternalTexture
  48357. */
  48358. 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;
  48359. private _getSamplingFilter;
  48360. private static _GetNativeTextureFormat;
  48361. createRenderTargetTexture(size: number | {
  48362. width: number;
  48363. height: number;
  48364. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48365. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48366. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48367. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48368. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48369. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48370. /**
  48371. * Updates a dynamic vertex buffer.
  48372. * @param vertexBuffer the vertex buffer to update
  48373. * @param data the data used to update the vertex buffer
  48374. * @param byteOffset the byte offset of the data (optional)
  48375. * @param byteLength the byte length of the data (optional)
  48376. */
  48377. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48378. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48379. private _updateAnisotropicLevel;
  48380. private _getAddressMode;
  48381. /** @hidden */
  48382. _bindTexture(channel: number, texture: InternalTexture): void;
  48383. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48384. releaseEffects(): void;
  48385. /** @hidden */
  48386. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48387. /** @hidden */
  48388. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48389. /** @hidden */
  48390. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48391. /** @hidden */
  48392. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48393. }
  48394. }
  48395. declare module BABYLON {
  48396. /**
  48397. * Gather the list of clipboard event types as constants.
  48398. */
  48399. export class ClipboardEventTypes {
  48400. /**
  48401. * The clipboard event is fired when a copy command is active (pressed).
  48402. */
  48403. static readonly COPY: number;
  48404. /**
  48405. * The clipboard event is fired when a cut command is active (pressed).
  48406. */
  48407. static readonly CUT: number;
  48408. /**
  48409. * The clipboard event is fired when a paste command is active (pressed).
  48410. */
  48411. static readonly PASTE: number;
  48412. }
  48413. /**
  48414. * This class is used to store clipboard related info for the onClipboardObservable event.
  48415. */
  48416. export class ClipboardInfo {
  48417. /**
  48418. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48419. */
  48420. type: number;
  48421. /**
  48422. * Defines the related dom event
  48423. */
  48424. event: ClipboardEvent;
  48425. /**
  48426. *Creates an instance of ClipboardInfo.
  48427. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48428. * @param event Defines the related dom event
  48429. */
  48430. constructor(
  48431. /**
  48432. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48433. */
  48434. type: number,
  48435. /**
  48436. * Defines the related dom event
  48437. */
  48438. event: ClipboardEvent);
  48439. /**
  48440. * Get the clipboard event's type from the keycode.
  48441. * @param keyCode Defines the keyCode for the current keyboard event.
  48442. * @return {number}
  48443. */
  48444. static GetTypeFromCharacter(keyCode: number): number;
  48445. }
  48446. }
  48447. declare module BABYLON {
  48448. /**
  48449. * Google Daydream controller
  48450. */
  48451. export class DaydreamController extends WebVRController {
  48452. /**
  48453. * Base Url for the controller model.
  48454. */
  48455. static MODEL_BASE_URL: string;
  48456. /**
  48457. * File name for the controller model.
  48458. */
  48459. static MODEL_FILENAME: string;
  48460. /**
  48461. * Gamepad Id prefix used to identify Daydream Controller.
  48462. */
  48463. static readonly GAMEPAD_ID_PREFIX: string;
  48464. /**
  48465. * Creates a new DaydreamController from a gamepad
  48466. * @param vrGamepad the gamepad that the controller should be created from
  48467. */
  48468. constructor(vrGamepad: any);
  48469. /**
  48470. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48471. * @param scene scene in which to add meshes
  48472. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48473. */
  48474. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48475. /**
  48476. * Called once for each button that changed state since the last frame
  48477. * @param buttonIdx Which button index changed
  48478. * @param state New state of the button
  48479. * @param changes Which properties on the state changed since last frame
  48480. */
  48481. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48482. }
  48483. }
  48484. declare module BABYLON {
  48485. /**
  48486. * Gear VR Controller
  48487. */
  48488. export class GearVRController extends WebVRController {
  48489. /**
  48490. * Base Url for the controller model.
  48491. */
  48492. static MODEL_BASE_URL: string;
  48493. /**
  48494. * File name for the controller model.
  48495. */
  48496. static MODEL_FILENAME: string;
  48497. /**
  48498. * Gamepad Id prefix used to identify this controller.
  48499. */
  48500. static readonly GAMEPAD_ID_PREFIX: string;
  48501. private readonly _buttonIndexToObservableNameMap;
  48502. /**
  48503. * Creates a new GearVRController from a gamepad
  48504. * @param vrGamepad the gamepad that the controller should be created from
  48505. */
  48506. constructor(vrGamepad: any);
  48507. /**
  48508. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48509. * @param scene scene in which to add meshes
  48510. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48511. */
  48512. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48513. /**
  48514. * Called once for each button that changed state since the last frame
  48515. * @param buttonIdx Which button index changed
  48516. * @param state New state of the button
  48517. * @param changes Which properties on the state changed since last frame
  48518. */
  48519. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48520. }
  48521. }
  48522. declare module BABYLON {
  48523. /**
  48524. * Generic Controller
  48525. */
  48526. export class GenericController extends WebVRController {
  48527. /**
  48528. * Base Url for the controller model.
  48529. */
  48530. static readonly MODEL_BASE_URL: string;
  48531. /**
  48532. * File name for the controller model.
  48533. */
  48534. static readonly MODEL_FILENAME: string;
  48535. /**
  48536. * Creates a new GenericController from a gamepad
  48537. * @param vrGamepad the gamepad that the controller should be created from
  48538. */
  48539. constructor(vrGamepad: any);
  48540. /**
  48541. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48542. * @param scene scene in which to add meshes
  48543. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48544. */
  48545. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48546. /**
  48547. * Called once for each button that changed state since the last frame
  48548. * @param buttonIdx Which button index changed
  48549. * @param state New state of the button
  48550. * @param changes Which properties on the state changed since last frame
  48551. */
  48552. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48553. }
  48554. }
  48555. declare module BABYLON {
  48556. /**
  48557. * Oculus Touch Controller
  48558. */
  48559. export class OculusTouchController extends WebVRController {
  48560. /**
  48561. * Base Url for the controller model.
  48562. */
  48563. static MODEL_BASE_URL: string;
  48564. /**
  48565. * File name for the left controller model.
  48566. */
  48567. static MODEL_LEFT_FILENAME: string;
  48568. /**
  48569. * File name for the right controller model.
  48570. */
  48571. static MODEL_RIGHT_FILENAME: string;
  48572. /**
  48573. * Base Url for the Quest controller model.
  48574. */
  48575. static QUEST_MODEL_BASE_URL: string;
  48576. /**
  48577. * @hidden
  48578. * If the controllers are running on a device that needs the updated Quest controller models
  48579. */
  48580. static _IsQuest: boolean;
  48581. /**
  48582. * Fired when the secondary trigger on this controller is modified
  48583. */
  48584. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48585. /**
  48586. * Fired when the thumb rest on this controller is modified
  48587. */
  48588. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48589. /**
  48590. * Creates a new OculusTouchController from a gamepad
  48591. * @param vrGamepad the gamepad that the controller should be created from
  48592. */
  48593. constructor(vrGamepad: any);
  48594. /**
  48595. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48596. * @param scene scene in which to add meshes
  48597. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48598. */
  48599. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48600. /**
  48601. * Fired when the A button on this controller is modified
  48602. */
  48603. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48604. /**
  48605. * Fired when the B button on this controller is modified
  48606. */
  48607. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48608. /**
  48609. * Fired when the X button on this controller is modified
  48610. */
  48611. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48612. /**
  48613. * Fired when the Y button on this controller is modified
  48614. */
  48615. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48616. /**
  48617. * Called once for each button that changed state since the last frame
  48618. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48619. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48620. * 2) secondary trigger (same)
  48621. * 3) A (right) X (left), touch, pressed = value
  48622. * 4) B / Y
  48623. * 5) thumb rest
  48624. * @param buttonIdx Which button index changed
  48625. * @param state New state of the button
  48626. * @param changes Which properties on the state changed since last frame
  48627. */
  48628. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48629. }
  48630. }
  48631. declare module BABYLON {
  48632. /**
  48633. * Vive Controller
  48634. */
  48635. export class ViveController extends WebVRController {
  48636. /**
  48637. * Base Url for the controller model.
  48638. */
  48639. static MODEL_BASE_URL: string;
  48640. /**
  48641. * File name for the controller model.
  48642. */
  48643. static MODEL_FILENAME: string;
  48644. /**
  48645. * Creates a new ViveController from a gamepad
  48646. * @param vrGamepad the gamepad that the controller should be created from
  48647. */
  48648. constructor(vrGamepad: any);
  48649. /**
  48650. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48651. * @param scene scene in which to add meshes
  48652. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48653. */
  48654. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48655. /**
  48656. * Fired when the left button on this controller is modified
  48657. */
  48658. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48659. /**
  48660. * Fired when the right button on this controller is modified
  48661. */
  48662. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48663. /**
  48664. * Fired when the menu button on this controller is modified
  48665. */
  48666. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48667. /**
  48668. * Called once for each button that changed state since the last frame
  48669. * Vive mapping:
  48670. * 0: touchpad
  48671. * 1: trigger
  48672. * 2: left AND right buttons
  48673. * 3: menu button
  48674. * @param buttonIdx Which button index changed
  48675. * @param state New state of the button
  48676. * @param changes Which properties on the state changed since last frame
  48677. */
  48678. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48679. }
  48680. }
  48681. declare module BABYLON {
  48682. /**
  48683. * Defines the WindowsMotionController object that the state of the windows motion controller
  48684. */
  48685. export class WindowsMotionController extends WebVRController {
  48686. /**
  48687. * The base url used to load the left and right controller models
  48688. */
  48689. static MODEL_BASE_URL: string;
  48690. /**
  48691. * The name of the left controller model file
  48692. */
  48693. static MODEL_LEFT_FILENAME: string;
  48694. /**
  48695. * The name of the right controller model file
  48696. */
  48697. static MODEL_RIGHT_FILENAME: string;
  48698. /**
  48699. * The controller name prefix for this controller type
  48700. */
  48701. static readonly GAMEPAD_ID_PREFIX: string;
  48702. /**
  48703. * The controller id pattern for this controller type
  48704. */
  48705. private static readonly GAMEPAD_ID_PATTERN;
  48706. private _loadedMeshInfo;
  48707. protected readonly _mapping: {
  48708. buttons: string[];
  48709. buttonMeshNames: {
  48710. trigger: string;
  48711. menu: string;
  48712. grip: string;
  48713. thumbstick: string;
  48714. trackpad: string;
  48715. };
  48716. buttonObservableNames: {
  48717. trigger: string;
  48718. menu: string;
  48719. grip: string;
  48720. thumbstick: string;
  48721. trackpad: string;
  48722. };
  48723. axisMeshNames: string[];
  48724. pointingPoseMeshName: string;
  48725. };
  48726. /**
  48727. * Fired when the trackpad on this controller is clicked
  48728. */
  48729. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48730. /**
  48731. * Fired when the trackpad on this controller is modified
  48732. */
  48733. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48734. /**
  48735. * The current x and y values of this controller's trackpad
  48736. */
  48737. trackpad: StickValues;
  48738. /**
  48739. * Creates a new WindowsMotionController from a gamepad
  48740. * @param vrGamepad the gamepad that the controller should be created from
  48741. */
  48742. constructor(vrGamepad: any);
  48743. /**
  48744. * Fired when the trigger on this controller is modified
  48745. */
  48746. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48747. /**
  48748. * Fired when the menu button on this controller is modified
  48749. */
  48750. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48751. /**
  48752. * Fired when the grip button on this controller is modified
  48753. */
  48754. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48755. /**
  48756. * Fired when the thumbstick button on this controller is modified
  48757. */
  48758. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48759. /**
  48760. * Fired when the touchpad button on this controller is modified
  48761. */
  48762. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48763. /**
  48764. * Fired when the touchpad values on this controller are modified
  48765. */
  48766. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48767. protected _updateTrackpad(): void;
  48768. /**
  48769. * Called once per frame by the engine.
  48770. */
  48771. update(): void;
  48772. /**
  48773. * Called once for each button that changed state since the last frame
  48774. * @param buttonIdx Which button index changed
  48775. * @param state New state of the button
  48776. * @param changes Which properties on the state changed since last frame
  48777. */
  48778. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48779. /**
  48780. * Moves the buttons on the controller mesh based on their current state
  48781. * @param buttonName the name of the button to move
  48782. * @param buttonValue the value of the button which determines the buttons new position
  48783. */
  48784. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48785. /**
  48786. * Moves the axis on the controller mesh based on its current state
  48787. * @param axis the index of the axis
  48788. * @param axisValue the value of the axis which determines the meshes new position
  48789. * @hidden
  48790. */
  48791. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48792. /**
  48793. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48794. * @param scene scene in which to add meshes
  48795. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48796. */
  48797. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48798. /**
  48799. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48800. * can be transformed by button presses and axes values, based on this._mapping.
  48801. *
  48802. * @param scene scene in which the meshes exist
  48803. * @param meshes list of meshes that make up the controller model to process
  48804. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48805. */
  48806. private processModel;
  48807. private createMeshInfo;
  48808. /**
  48809. * Gets the ray of the controller in the direction the controller is pointing
  48810. * @param length the length the resulting ray should be
  48811. * @returns a ray in the direction the controller is pointing
  48812. */
  48813. getForwardRay(length?: number): Ray;
  48814. /**
  48815. * Disposes of the controller
  48816. */
  48817. dispose(): void;
  48818. }
  48819. /**
  48820. * This class represents a new windows motion controller in XR.
  48821. */
  48822. export class XRWindowsMotionController extends WindowsMotionController {
  48823. /**
  48824. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48825. */
  48826. protected readonly _mapping: {
  48827. buttons: string[];
  48828. buttonMeshNames: {
  48829. trigger: string;
  48830. menu: string;
  48831. grip: string;
  48832. thumbstick: string;
  48833. trackpad: string;
  48834. };
  48835. buttonObservableNames: {
  48836. trigger: string;
  48837. menu: string;
  48838. grip: string;
  48839. thumbstick: string;
  48840. trackpad: string;
  48841. };
  48842. axisMeshNames: string[];
  48843. pointingPoseMeshName: string;
  48844. };
  48845. /**
  48846. * Construct a new XR-Based windows motion controller
  48847. *
  48848. * @param gamepadInfo the gamepad object from the browser
  48849. */
  48850. constructor(gamepadInfo: any);
  48851. /**
  48852. * holds the thumbstick values (X,Y)
  48853. */
  48854. thumbstickValues: StickValues;
  48855. /**
  48856. * Fired when the thumbstick on this controller is clicked
  48857. */
  48858. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48859. /**
  48860. * Fired when the thumbstick on this controller is modified
  48861. */
  48862. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48863. /**
  48864. * Fired when the touchpad button on this controller is modified
  48865. */
  48866. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48867. /**
  48868. * Fired when the touchpad values on this controller are modified
  48869. */
  48870. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48871. /**
  48872. * Fired when the thumbstick button on this controller is modified
  48873. * here to prevent breaking changes
  48874. */
  48875. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48876. /**
  48877. * updating the thumbstick(!) and not the trackpad.
  48878. * This is named this way due to the difference between WebVR and XR and to avoid
  48879. * changing the parent class.
  48880. */
  48881. protected _updateTrackpad(): void;
  48882. /**
  48883. * Disposes the class with joy
  48884. */
  48885. dispose(): void;
  48886. }
  48887. }
  48888. declare module BABYLON {
  48889. /**
  48890. * Class containing static functions to help procedurally build meshes
  48891. */
  48892. export class PolyhedronBuilder {
  48893. /**
  48894. * Creates a polyhedron mesh
  48895. * * 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
  48896. * * The parameter `size` (positive float, default 1) sets the polygon size
  48897. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48898. * * 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`
  48899. * * 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
  48900. * * 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)`)
  48901. * * 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
  48902. * * 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
  48903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48904. * * 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
  48905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48906. * @param name defines the name of the mesh
  48907. * @param options defines the options used to create the mesh
  48908. * @param scene defines the hosting scene
  48909. * @returns the polyhedron mesh
  48910. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48911. */
  48912. static CreatePolyhedron(name: string, options: {
  48913. type?: number;
  48914. size?: number;
  48915. sizeX?: number;
  48916. sizeY?: number;
  48917. sizeZ?: number;
  48918. custom?: any;
  48919. faceUV?: Vector4[];
  48920. faceColors?: Color4[];
  48921. flat?: boolean;
  48922. updatable?: boolean;
  48923. sideOrientation?: number;
  48924. frontUVs?: Vector4;
  48925. backUVs?: Vector4;
  48926. }, scene?: Nullable<Scene>): Mesh;
  48927. }
  48928. }
  48929. declare module BABYLON {
  48930. /**
  48931. * Gizmo that enables scaling a mesh along 3 axis
  48932. */
  48933. export class ScaleGizmo extends Gizmo {
  48934. /**
  48935. * Internal gizmo used for interactions on the x axis
  48936. */
  48937. xGizmo: AxisScaleGizmo;
  48938. /**
  48939. * Internal gizmo used for interactions on the y axis
  48940. */
  48941. yGizmo: AxisScaleGizmo;
  48942. /**
  48943. * Internal gizmo used for interactions on the z axis
  48944. */
  48945. zGizmo: AxisScaleGizmo;
  48946. /**
  48947. * Internal gizmo used to scale all axis equally
  48948. */
  48949. uniformScaleGizmo: AxisScaleGizmo;
  48950. private _meshAttached;
  48951. private _updateGizmoRotationToMatchAttachedMesh;
  48952. private _snapDistance;
  48953. private _scaleRatio;
  48954. private _uniformScalingMesh;
  48955. private _octahedron;
  48956. private _sensitivity;
  48957. /** Fires an event when any of it's sub gizmos are dragged */
  48958. onDragStartObservable: Observable<unknown>;
  48959. /** Fires an event when any of it's sub gizmos are released from dragging */
  48960. onDragEndObservable: Observable<unknown>;
  48961. get attachedMesh(): Nullable<AbstractMesh>;
  48962. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48963. /**
  48964. * Creates a ScaleGizmo
  48965. * @param gizmoLayer The utility layer the gizmo will be added to
  48966. */
  48967. constructor(gizmoLayer?: UtilityLayerRenderer);
  48968. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48969. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48970. /**
  48971. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48972. */
  48973. set snapDistance(value: number);
  48974. get snapDistance(): number;
  48975. /**
  48976. * Ratio for the scale of the gizmo (Default: 1)
  48977. */
  48978. set scaleRatio(value: number);
  48979. get scaleRatio(): number;
  48980. /**
  48981. * Sensitivity factor for dragging (Default: 1)
  48982. */
  48983. set sensitivity(value: number);
  48984. get sensitivity(): number;
  48985. /**
  48986. * Disposes of the gizmo
  48987. */
  48988. dispose(): void;
  48989. }
  48990. }
  48991. declare module BABYLON {
  48992. /**
  48993. * Single axis scale gizmo
  48994. */
  48995. export class AxisScaleGizmo extends Gizmo {
  48996. /**
  48997. * Drag behavior responsible for the gizmos dragging interactions
  48998. */
  48999. dragBehavior: PointerDragBehavior;
  49000. private _pointerObserver;
  49001. /**
  49002. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49003. */
  49004. snapDistance: number;
  49005. /**
  49006. * Event that fires each time the gizmo snaps to a new location.
  49007. * * snapDistance is the the change in distance
  49008. */
  49009. onSnapObservable: Observable<{
  49010. snapDistance: number;
  49011. }>;
  49012. /**
  49013. * If the scaling operation should be done on all axis (default: false)
  49014. */
  49015. uniformScaling: boolean;
  49016. /**
  49017. * Custom sensitivity value for the drag strength
  49018. */
  49019. sensitivity: number;
  49020. private _isEnabled;
  49021. private _parent;
  49022. private _arrow;
  49023. private _coloredMaterial;
  49024. private _hoverMaterial;
  49025. /**
  49026. * Creates an AxisScaleGizmo
  49027. * @param gizmoLayer The utility layer the gizmo will be added to
  49028. * @param dragAxis The axis which the gizmo will be able to scale on
  49029. * @param color The color of the gizmo
  49030. */
  49031. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49032. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49033. /**
  49034. * If the gizmo is enabled
  49035. */
  49036. set isEnabled(value: boolean);
  49037. get isEnabled(): boolean;
  49038. /**
  49039. * Disposes of the gizmo
  49040. */
  49041. dispose(): void;
  49042. /**
  49043. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49044. * @param mesh The mesh to replace the default mesh of the gizmo
  49045. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49046. */
  49047. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49048. }
  49049. }
  49050. declare module BABYLON {
  49051. /**
  49052. * Bounding box gizmo
  49053. */
  49054. export class BoundingBoxGizmo extends Gizmo {
  49055. private _lineBoundingBox;
  49056. private _rotateSpheresParent;
  49057. private _scaleBoxesParent;
  49058. private _boundingDimensions;
  49059. private _renderObserver;
  49060. private _pointerObserver;
  49061. private _scaleDragSpeed;
  49062. private _tmpQuaternion;
  49063. private _tmpVector;
  49064. private _tmpRotationMatrix;
  49065. /**
  49066. * 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)
  49067. */
  49068. ignoreChildren: boolean;
  49069. /**
  49070. * 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)
  49071. */
  49072. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49073. /**
  49074. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49075. */
  49076. rotationSphereSize: number;
  49077. /**
  49078. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49079. */
  49080. scaleBoxSize: number;
  49081. /**
  49082. * 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)
  49083. */
  49084. fixedDragMeshScreenSize: boolean;
  49085. /**
  49086. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49087. */
  49088. fixedDragMeshScreenSizeDistanceFactor: number;
  49089. /**
  49090. * Fired when a rotation sphere or scale box is dragged
  49091. */
  49092. onDragStartObservable: Observable<{}>;
  49093. /**
  49094. * Fired when a scale box is dragged
  49095. */
  49096. onScaleBoxDragObservable: Observable<{}>;
  49097. /**
  49098. * Fired when a scale box drag is ended
  49099. */
  49100. onScaleBoxDragEndObservable: Observable<{}>;
  49101. /**
  49102. * Fired when a rotation sphere is dragged
  49103. */
  49104. onRotationSphereDragObservable: Observable<{}>;
  49105. /**
  49106. * Fired when a rotation sphere drag is ended
  49107. */
  49108. onRotationSphereDragEndObservable: Observable<{}>;
  49109. /**
  49110. * 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)
  49111. */
  49112. scalePivot: Nullable<Vector3>;
  49113. /**
  49114. * Mesh used as a pivot to rotate the attached mesh
  49115. */
  49116. private _anchorMesh;
  49117. private _existingMeshScale;
  49118. private _dragMesh;
  49119. private pointerDragBehavior;
  49120. private coloredMaterial;
  49121. private hoverColoredMaterial;
  49122. /**
  49123. * Sets the color of the bounding box gizmo
  49124. * @param color the color to set
  49125. */
  49126. setColor(color: Color3): void;
  49127. /**
  49128. * Creates an BoundingBoxGizmo
  49129. * @param gizmoLayer The utility layer the gizmo will be added to
  49130. * @param color The color of the gizmo
  49131. */
  49132. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49133. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49134. private _selectNode;
  49135. /**
  49136. * Updates the bounding box information for the Gizmo
  49137. */
  49138. updateBoundingBox(): void;
  49139. private _updateRotationSpheres;
  49140. private _updateScaleBoxes;
  49141. /**
  49142. * Enables rotation on the specified axis and disables rotation on the others
  49143. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49144. */
  49145. setEnabledRotationAxis(axis: string): void;
  49146. /**
  49147. * Enables/disables scaling
  49148. * @param enable if scaling should be enabled
  49149. * @param homogeneousScaling defines if scaling should only be homogeneous
  49150. */
  49151. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49152. private _updateDummy;
  49153. /**
  49154. * Enables a pointer drag behavior on the bounding box of the gizmo
  49155. */
  49156. enableDragBehavior(): void;
  49157. /**
  49158. * Disposes of the gizmo
  49159. */
  49160. dispose(): void;
  49161. /**
  49162. * 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)
  49163. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49164. * @returns the bounding box mesh with the passed in mesh as a child
  49165. */
  49166. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49167. /**
  49168. * CustomMeshes are not supported by this gizmo
  49169. * @param mesh The mesh to replace the default mesh of the gizmo
  49170. */
  49171. setCustomMesh(mesh: Mesh): void;
  49172. }
  49173. }
  49174. declare module BABYLON {
  49175. /**
  49176. * Single plane rotation gizmo
  49177. */
  49178. export class PlaneRotationGizmo extends Gizmo {
  49179. /**
  49180. * Drag behavior responsible for the gizmos dragging interactions
  49181. */
  49182. dragBehavior: PointerDragBehavior;
  49183. private _pointerObserver;
  49184. /**
  49185. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49186. */
  49187. snapDistance: number;
  49188. /**
  49189. * Event that fires each time the gizmo snaps to a new location.
  49190. * * snapDistance is the the change in distance
  49191. */
  49192. onSnapObservable: Observable<{
  49193. snapDistance: number;
  49194. }>;
  49195. private _isEnabled;
  49196. private _parent;
  49197. /**
  49198. * Creates a PlaneRotationGizmo
  49199. * @param gizmoLayer The utility layer the gizmo will be added to
  49200. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49201. * @param color The color of the gizmo
  49202. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49203. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49204. */
  49205. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49206. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49207. /**
  49208. * If the gizmo is enabled
  49209. */
  49210. set isEnabled(value: boolean);
  49211. get isEnabled(): boolean;
  49212. /**
  49213. * Disposes of the gizmo
  49214. */
  49215. dispose(): void;
  49216. }
  49217. }
  49218. declare module BABYLON {
  49219. /**
  49220. * Gizmo that enables rotating a mesh along 3 axis
  49221. */
  49222. export class RotationGizmo extends Gizmo {
  49223. /**
  49224. * Internal gizmo used for interactions on the x axis
  49225. */
  49226. xGizmo: PlaneRotationGizmo;
  49227. /**
  49228. * Internal gizmo used for interactions on the y axis
  49229. */
  49230. yGizmo: PlaneRotationGizmo;
  49231. /**
  49232. * Internal gizmo used for interactions on the z axis
  49233. */
  49234. zGizmo: PlaneRotationGizmo;
  49235. /** Fires an event when any of it's sub gizmos are dragged */
  49236. onDragStartObservable: Observable<unknown>;
  49237. /** Fires an event when any of it's sub gizmos are released from dragging */
  49238. onDragEndObservable: Observable<unknown>;
  49239. private _meshAttached;
  49240. get attachedMesh(): Nullable<AbstractMesh>;
  49241. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49242. /**
  49243. * Creates a RotationGizmo
  49244. * @param gizmoLayer The utility layer the gizmo will be added to
  49245. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49246. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49247. */
  49248. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49249. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49250. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49251. /**
  49252. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49253. */
  49254. set snapDistance(value: number);
  49255. get snapDistance(): number;
  49256. /**
  49257. * Ratio for the scale of the gizmo (Default: 1)
  49258. */
  49259. set scaleRatio(value: number);
  49260. get scaleRatio(): number;
  49261. /**
  49262. * Disposes of the gizmo
  49263. */
  49264. dispose(): void;
  49265. /**
  49266. * CustomMeshes are not supported by this gizmo
  49267. * @param mesh The mesh to replace the default mesh of the gizmo
  49268. */
  49269. setCustomMesh(mesh: Mesh): void;
  49270. }
  49271. }
  49272. declare module BABYLON {
  49273. /**
  49274. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49275. */
  49276. export class GizmoManager implements IDisposable {
  49277. private scene;
  49278. /**
  49279. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49280. */
  49281. gizmos: {
  49282. positionGizmo: Nullable<PositionGizmo>;
  49283. rotationGizmo: Nullable<RotationGizmo>;
  49284. scaleGizmo: Nullable<ScaleGizmo>;
  49285. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49286. };
  49287. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49288. clearGizmoOnEmptyPointerEvent: boolean;
  49289. /** Fires an event when the manager is attached to a mesh */
  49290. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49291. private _gizmosEnabled;
  49292. private _pointerObserver;
  49293. private _attachedMesh;
  49294. private _boundingBoxColor;
  49295. private _defaultUtilityLayer;
  49296. private _defaultKeepDepthUtilityLayer;
  49297. /**
  49298. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49299. */
  49300. boundingBoxDragBehavior: SixDofDragBehavior;
  49301. /**
  49302. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49303. */
  49304. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49305. /**
  49306. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49307. */
  49308. usePointerToAttachGizmos: boolean;
  49309. /**
  49310. * Utility layer that the bounding box gizmo belongs to
  49311. */
  49312. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49313. /**
  49314. * Utility layer that all gizmos besides bounding box belong to
  49315. */
  49316. get utilityLayer(): UtilityLayerRenderer;
  49317. /**
  49318. * Instatiates a gizmo manager
  49319. * @param scene the scene to overlay the gizmos on top of
  49320. */
  49321. constructor(scene: Scene);
  49322. /**
  49323. * Attaches a set of gizmos to the specified mesh
  49324. * @param mesh The mesh the gizmo's should be attached to
  49325. */
  49326. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49327. /**
  49328. * If the position gizmo is enabled
  49329. */
  49330. set positionGizmoEnabled(value: boolean);
  49331. get positionGizmoEnabled(): boolean;
  49332. /**
  49333. * If the rotation gizmo is enabled
  49334. */
  49335. set rotationGizmoEnabled(value: boolean);
  49336. get rotationGizmoEnabled(): boolean;
  49337. /**
  49338. * If the scale gizmo is enabled
  49339. */
  49340. set scaleGizmoEnabled(value: boolean);
  49341. get scaleGizmoEnabled(): boolean;
  49342. /**
  49343. * If the boundingBox gizmo is enabled
  49344. */
  49345. set boundingBoxGizmoEnabled(value: boolean);
  49346. get boundingBoxGizmoEnabled(): boolean;
  49347. /**
  49348. * Disposes of the gizmo manager
  49349. */
  49350. dispose(): void;
  49351. }
  49352. }
  49353. declare module BABYLON {
  49354. /**
  49355. * A directional light is defined by a direction (what a surprise!).
  49356. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49357. * 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.
  49358. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49359. */
  49360. export class DirectionalLight extends ShadowLight {
  49361. private _shadowFrustumSize;
  49362. /**
  49363. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49364. */
  49365. get shadowFrustumSize(): number;
  49366. /**
  49367. * Specifies a fix frustum size for the shadow generation.
  49368. */
  49369. set shadowFrustumSize(value: number);
  49370. private _shadowOrthoScale;
  49371. /**
  49372. * Gets the shadow projection scale against the optimal computed one.
  49373. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49374. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49375. */
  49376. get shadowOrthoScale(): number;
  49377. /**
  49378. * Sets the shadow projection scale against the optimal computed one.
  49379. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49380. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49381. */
  49382. set shadowOrthoScale(value: number);
  49383. /**
  49384. * Automatically compute the projection matrix to best fit (including all the casters)
  49385. * on each frame.
  49386. */
  49387. autoUpdateExtends: boolean;
  49388. /**
  49389. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49390. * on each frame. autoUpdateExtends must be set to true for this to work
  49391. */
  49392. autoCalcShadowZBounds: boolean;
  49393. private _orthoLeft;
  49394. private _orthoRight;
  49395. private _orthoTop;
  49396. private _orthoBottom;
  49397. /**
  49398. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49399. * The directional light is emitted from everywhere in the given direction.
  49400. * It can cast shadows.
  49401. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49402. * @param name The friendly name of the light
  49403. * @param direction The direction of the light
  49404. * @param scene The scene the light belongs to
  49405. */
  49406. constructor(name: string, direction: Vector3, scene: Scene);
  49407. /**
  49408. * Returns the string "DirectionalLight".
  49409. * @return The class name
  49410. */
  49411. getClassName(): string;
  49412. /**
  49413. * Returns the integer 1.
  49414. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49415. */
  49416. getTypeID(): number;
  49417. /**
  49418. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49419. * Returns the DirectionalLight Shadow projection matrix.
  49420. */
  49421. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49422. /**
  49423. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49424. * Returns the DirectionalLight Shadow projection matrix.
  49425. */
  49426. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49427. /**
  49428. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49429. * Returns the DirectionalLight Shadow projection matrix.
  49430. */
  49431. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49432. protected _buildUniformLayout(): void;
  49433. /**
  49434. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49435. * @param effect The effect to update
  49436. * @param lightIndex The index of the light in the effect to update
  49437. * @returns The directional light
  49438. */
  49439. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49440. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49441. /**
  49442. * Gets the minZ used for shadow according to both the scene and the light.
  49443. *
  49444. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49445. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49446. * @param activeCamera The camera we are returning the min for
  49447. * @returns the depth min z
  49448. */
  49449. getDepthMinZ(activeCamera: Camera): number;
  49450. /**
  49451. * Gets the maxZ used for shadow according to both the scene and the light.
  49452. *
  49453. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49454. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49455. * @param activeCamera The camera we are returning the max for
  49456. * @returns the depth max z
  49457. */
  49458. getDepthMaxZ(activeCamera: Camera): number;
  49459. /**
  49460. * Prepares the list of defines specific to the light type.
  49461. * @param defines the list of defines
  49462. * @param lightIndex defines the index of the light for the effect
  49463. */
  49464. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49465. }
  49466. }
  49467. declare module BABYLON {
  49468. /**
  49469. * Class containing static functions to help procedurally build meshes
  49470. */
  49471. export class HemisphereBuilder {
  49472. /**
  49473. * Creates a hemisphere mesh
  49474. * @param name defines the name of the mesh
  49475. * @param options defines the options used to create the mesh
  49476. * @param scene defines the hosting scene
  49477. * @returns the hemisphere mesh
  49478. */
  49479. static CreateHemisphere(name: string, options: {
  49480. segments?: number;
  49481. diameter?: number;
  49482. sideOrientation?: number;
  49483. }, scene: any): Mesh;
  49484. }
  49485. }
  49486. declare module BABYLON {
  49487. /**
  49488. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49489. * These values define a cone of light starting from the position, emitting toward the direction.
  49490. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49491. * and the exponent defines the speed of the decay of the light with distance (reach).
  49492. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49493. */
  49494. export class SpotLight extends ShadowLight {
  49495. private _angle;
  49496. private _innerAngle;
  49497. private _cosHalfAngle;
  49498. private _lightAngleScale;
  49499. private _lightAngleOffset;
  49500. /**
  49501. * Gets the cone angle of the spot light in Radians.
  49502. */
  49503. get angle(): number;
  49504. /**
  49505. * Sets the cone angle of the spot light in Radians.
  49506. */
  49507. set angle(value: number);
  49508. /**
  49509. * Only used in gltf falloff mode, this defines the angle where
  49510. * the directional falloff will start before cutting at angle which could be seen
  49511. * as outer angle.
  49512. */
  49513. get innerAngle(): number;
  49514. /**
  49515. * Only used in gltf falloff mode, this defines the angle where
  49516. * the directional falloff will start before cutting at angle which could be seen
  49517. * as outer angle.
  49518. */
  49519. set innerAngle(value: number);
  49520. private _shadowAngleScale;
  49521. /**
  49522. * Allows scaling the angle of the light for shadow generation only.
  49523. */
  49524. get shadowAngleScale(): number;
  49525. /**
  49526. * Allows scaling the angle of the light for shadow generation only.
  49527. */
  49528. set shadowAngleScale(value: number);
  49529. /**
  49530. * The light decay speed with the distance from the emission spot.
  49531. */
  49532. exponent: number;
  49533. private _projectionTextureMatrix;
  49534. /**
  49535. * Allows reading the projecton texture
  49536. */
  49537. get projectionTextureMatrix(): Matrix;
  49538. protected _projectionTextureLightNear: number;
  49539. /**
  49540. * Gets the near clip of the Spotlight for texture projection.
  49541. */
  49542. get projectionTextureLightNear(): number;
  49543. /**
  49544. * Sets the near clip of the Spotlight for texture projection.
  49545. */
  49546. set projectionTextureLightNear(value: number);
  49547. protected _projectionTextureLightFar: number;
  49548. /**
  49549. * Gets the far clip of the Spotlight for texture projection.
  49550. */
  49551. get projectionTextureLightFar(): number;
  49552. /**
  49553. * Sets the far clip of the Spotlight for texture projection.
  49554. */
  49555. set projectionTextureLightFar(value: number);
  49556. protected _projectionTextureUpDirection: Vector3;
  49557. /**
  49558. * Gets the Up vector of the Spotlight for texture projection.
  49559. */
  49560. get projectionTextureUpDirection(): Vector3;
  49561. /**
  49562. * Sets the Up vector of the Spotlight for texture projection.
  49563. */
  49564. set projectionTextureUpDirection(value: Vector3);
  49565. private _projectionTexture;
  49566. /**
  49567. * Gets the projection texture of the light.
  49568. */
  49569. get projectionTexture(): Nullable<BaseTexture>;
  49570. /**
  49571. * Sets the projection texture of the light.
  49572. */
  49573. set projectionTexture(value: Nullable<BaseTexture>);
  49574. private _projectionTextureViewLightDirty;
  49575. private _projectionTextureProjectionLightDirty;
  49576. private _projectionTextureDirty;
  49577. private _projectionTextureViewTargetVector;
  49578. private _projectionTextureViewLightMatrix;
  49579. private _projectionTextureProjectionLightMatrix;
  49580. private _projectionTextureScalingMatrix;
  49581. /**
  49582. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49583. * It can cast shadows.
  49584. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49585. * @param name The light friendly name
  49586. * @param position The position of the spot light in the scene
  49587. * @param direction The direction of the light in the scene
  49588. * @param angle The cone angle of the light in Radians
  49589. * @param exponent The light decay speed with the distance from the emission spot
  49590. * @param scene The scene the lights belongs to
  49591. */
  49592. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49593. /**
  49594. * Returns the string "SpotLight".
  49595. * @returns the class name
  49596. */
  49597. getClassName(): string;
  49598. /**
  49599. * Returns the integer 2.
  49600. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49601. */
  49602. getTypeID(): number;
  49603. /**
  49604. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49605. */
  49606. protected _setDirection(value: Vector3): void;
  49607. /**
  49608. * Overrides the position setter to recompute the projection texture view light Matrix.
  49609. */
  49610. protected _setPosition(value: Vector3): void;
  49611. /**
  49612. * 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.
  49613. * Returns the SpotLight.
  49614. */
  49615. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49616. protected _computeProjectionTextureViewLightMatrix(): void;
  49617. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49618. /**
  49619. * Main function for light texture projection matrix computing.
  49620. */
  49621. protected _computeProjectionTextureMatrix(): void;
  49622. protected _buildUniformLayout(): void;
  49623. private _computeAngleValues;
  49624. /**
  49625. * Sets the passed Effect "effect" with the Light textures.
  49626. * @param effect The effect to update
  49627. * @param lightIndex The index of the light in the effect to update
  49628. * @returns The light
  49629. */
  49630. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49631. /**
  49632. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49633. * @param effect The effect to update
  49634. * @param lightIndex The index of the light in the effect to update
  49635. * @returns The spot light
  49636. */
  49637. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49638. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49639. /**
  49640. * Disposes the light and the associated resources.
  49641. */
  49642. dispose(): void;
  49643. /**
  49644. * Prepares the list of defines specific to the light type.
  49645. * @param defines the list of defines
  49646. * @param lightIndex defines the index of the light for the effect
  49647. */
  49648. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49649. }
  49650. }
  49651. declare module BABYLON {
  49652. /**
  49653. * Gizmo that enables viewing a light
  49654. */
  49655. export class LightGizmo extends Gizmo {
  49656. private _lightMesh;
  49657. private _material;
  49658. private _cachedPosition;
  49659. private _cachedForward;
  49660. private _attachedMeshParent;
  49661. /**
  49662. * Creates a LightGizmo
  49663. * @param gizmoLayer The utility layer the gizmo will be added to
  49664. */
  49665. constructor(gizmoLayer?: UtilityLayerRenderer);
  49666. private _light;
  49667. /**
  49668. * The light that the gizmo is attached to
  49669. */
  49670. set light(light: Nullable<Light>);
  49671. get light(): Nullable<Light>;
  49672. /**
  49673. * Gets the material used to render the light gizmo
  49674. */
  49675. get material(): StandardMaterial;
  49676. /**
  49677. * @hidden
  49678. * Updates the gizmo to match the attached mesh's position/rotation
  49679. */
  49680. protected _update(): void;
  49681. private static _Scale;
  49682. /**
  49683. * Creates the lines for a light mesh
  49684. */
  49685. private static _CreateLightLines;
  49686. /**
  49687. * Disposes of the light gizmo
  49688. */
  49689. dispose(): void;
  49690. private static _CreateHemisphericLightMesh;
  49691. private static _CreatePointLightMesh;
  49692. private static _CreateSpotLightMesh;
  49693. private static _CreateDirectionalLightMesh;
  49694. }
  49695. }
  49696. declare module BABYLON {
  49697. /** @hidden */
  49698. export var backgroundFragmentDeclaration: {
  49699. name: string;
  49700. shader: string;
  49701. };
  49702. }
  49703. declare module BABYLON {
  49704. /** @hidden */
  49705. export var backgroundUboDeclaration: {
  49706. name: string;
  49707. shader: string;
  49708. };
  49709. }
  49710. declare module BABYLON {
  49711. /** @hidden */
  49712. export var backgroundPixelShader: {
  49713. name: string;
  49714. shader: string;
  49715. };
  49716. }
  49717. declare module BABYLON {
  49718. /** @hidden */
  49719. export var backgroundVertexDeclaration: {
  49720. name: string;
  49721. shader: string;
  49722. };
  49723. }
  49724. declare module BABYLON {
  49725. /** @hidden */
  49726. export var backgroundVertexShader: {
  49727. name: string;
  49728. shader: string;
  49729. };
  49730. }
  49731. declare module BABYLON {
  49732. /**
  49733. * Background material used to create an efficient environement around your scene.
  49734. */
  49735. export class BackgroundMaterial extends PushMaterial {
  49736. /**
  49737. * Standard reflectance value at parallel view angle.
  49738. */
  49739. static StandardReflectance0: number;
  49740. /**
  49741. * Standard reflectance value at grazing angle.
  49742. */
  49743. static StandardReflectance90: number;
  49744. protected _primaryColor: Color3;
  49745. /**
  49746. * Key light Color (multiply against the environement texture)
  49747. */
  49748. primaryColor: Color3;
  49749. protected __perceptualColor: Nullable<Color3>;
  49750. /**
  49751. * Experimental Internal Use Only.
  49752. *
  49753. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49754. * This acts as a helper to set the primary color to a more "human friendly" value.
  49755. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49756. * output color as close as possible from the chosen value.
  49757. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49758. * part of lighting setup.)
  49759. */
  49760. get _perceptualColor(): Nullable<Color3>;
  49761. set _perceptualColor(value: Nullable<Color3>);
  49762. protected _primaryColorShadowLevel: float;
  49763. /**
  49764. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49765. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49766. */
  49767. get primaryColorShadowLevel(): float;
  49768. set primaryColorShadowLevel(value: float);
  49769. protected _primaryColorHighlightLevel: float;
  49770. /**
  49771. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49772. * The primary color is used at the level chosen to define what the white area would look.
  49773. */
  49774. get primaryColorHighlightLevel(): float;
  49775. set primaryColorHighlightLevel(value: float);
  49776. protected _reflectionTexture: Nullable<BaseTexture>;
  49777. /**
  49778. * Reflection Texture used in the material.
  49779. * Should be author in a specific way for the best result (refer to the documentation).
  49780. */
  49781. reflectionTexture: Nullable<BaseTexture>;
  49782. protected _reflectionBlur: float;
  49783. /**
  49784. * Reflection Texture level of blur.
  49785. *
  49786. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49787. * texture twice.
  49788. */
  49789. reflectionBlur: float;
  49790. protected _diffuseTexture: Nullable<BaseTexture>;
  49791. /**
  49792. * Diffuse Texture used in the material.
  49793. * Should be author in a specific way for the best result (refer to the documentation).
  49794. */
  49795. diffuseTexture: Nullable<BaseTexture>;
  49796. protected _shadowLights: Nullable<IShadowLight[]>;
  49797. /**
  49798. * Specify the list of lights casting shadow on the material.
  49799. * All scene shadow lights will be included if null.
  49800. */
  49801. shadowLights: Nullable<IShadowLight[]>;
  49802. protected _shadowLevel: float;
  49803. /**
  49804. * Helps adjusting the shadow to a softer level if required.
  49805. * 0 means black shadows and 1 means no shadows.
  49806. */
  49807. shadowLevel: float;
  49808. protected _sceneCenter: Vector3;
  49809. /**
  49810. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49811. * It is usually zero but might be interesting to modify according to your setup.
  49812. */
  49813. sceneCenter: Vector3;
  49814. protected _opacityFresnel: boolean;
  49815. /**
  49816. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49817. * This helps ensuring a nice transition when the camera goes under the ground.
  49818. */
  49819. opacityFresnel: boolean;
  49820. protected _reflectionFresnel: boolean;
  49821. /**
  49822. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49823. * This helps adding a mirror texture on the ground.
  49824. */
  49825. reflectionFresnel: boolean;
  49826. protected _reflectionFalloffDistance: number;
  49827. /**
  49828. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49829. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49830. */
  49831. reflectionFalloffDistance: number;
  49832. protected _reflectionAmount: number;
  49833. /**
  49834. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49835. */
  49836. reflectionAmount: number;
  49837. protected _reflectionReflectance0: number;
  49838. /**
  49839. * This specifies the weight of the reflection at grazing angle.
  49840. */
  49841. reflectionReflectance0: number;
  49842. protected _reflectionReflectance90: number;
  49843. /**
  49844. * This specifies the weight of the reflection at a perpendicular point of view.
  49845. */
  49846. reflectionReflectance90: number;
  49847. /**
  49848. * Sets the reflection reflectance fresnel values according to the default standard
  49849. * empirically know to work well :-)
  49850. */
  49851. set reflectionStandardFresnelWeight(value: number);
  49852. protected _useRGBColor: boolean;
  49853. /**
  49854. * Helps to directly use the maps channels instead of their level.
  49855. */
  49856. useRGBColor: boolean;
  49857. protected _enableNoise: boolean;
  49858. /**
  49859. * This helps reducing the banding effect that could occur on the background.
  49860. */
  49861. enableNoise: boolean;
  49862. /**
  49863. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49864. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49865. * Recommended to be keep at 1.0 except for special cases.
  49866. */
  49867. get fovMultiplier(): number;
  49868. set fovMultiplier(value: number);
  49869. private _fovMultiplier;
  49870. /**
  49871. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49872. */
  49873. useEquirectangularFOV: boolean;
  49874. private _maxSimultaneousLights;
  49875. /**
  49876. * Number of Simultaneous lights allowed on the material.
  49877. */
  49878. maxSimultaneousLights: int;
  49879. /**
  49880. * Default configuration related to image processing available in the Background Material.
  49881. */
  49882. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49883. /**
  49884. * Keep track of the image processing observer to allow dispose and replace.
  49885. */
  49886. private _imageProcessingObserver;
  49887. /**
  49888. * Attaches a new image processing configuration to the PBR Material.
  49889. * @param configuration (if null the scene configuration will be use)
  49890. */
  49891. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49892. /**
  49893. * Gets the image processing configuration used either in this material.
  49894. */
  49895. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49896. /**
  49897. * Sets the Default image processing configuration used either in the this material.
  49898. *
  49899. * If sets to null, the scene one is in use.
  49900. */
  49901. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49902. /**
  49903. * Gets wether the color curves effect is enabled.
  49904. */
  49905. get cameraColorCurvesEnabled(): boolean;
  49906. /**
  49907. * Sets wether the color curves effect is enabled.
  49908. */
  49909. set cameraColorCurvesEnabled(value: boolean);
  49910. /**
  49911. * Gets wether the color grading effect is enabled.
  49912. */
  49913. get cameraColorGradingEnabled(): boolean;
  49914. /**
  49915. * Gets wether the color grading effect is enabled.
  49916. */
  49917. set cameraColorGradingEnabled(value: boolean);
  49918. /**
  49919. * Gets wether tonemapping is enabled or not.
  49920. */
  49921. get cameraToneMappingEnabled(): boolean;
  49922. /**
  49923. * Sets wether tonemapping is enabled or not
  49924. */
  49925. set cameraToneMappingEnabled(value: boolean);
  49926. /**
  49927. * The camera exposure used on this material.
  49928. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49929. * This corresponds to a photographic exposure.
  49930. */
  49931. get cameraExposure(): float;
  49932. /**
  49933. * The camera exposure used on this material.
  49934. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49935. * This corresponds to a photographic exposure.
  49936. */
  49937. set cameraExposure(value: float);
  49938. /**
  49939. * Gets The camera contrast used on this material.
  49940. */
  49941. get cameraContrast(): float;
  49942. /**
  49943. * Sets The camera contrast used on this material.
  49944. */
  49945. set cameraContrast(value: float);
  49946. /**
  49947. * Gets the Color Grading 2D Lookup Texture.
  49948. */
  49949. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49950. /**
  49951. * Sets the Color Grading 2D Lookup Texture.
  49952. */
  49953. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49954. /**
  49955. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49956. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49957. * 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;
  49958. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49959. */
  49960. get cameraColorCurves(): Nullable<ColorCurves>;
  49961. /**
  49962. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49963. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49964. * 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;
  49965. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49966. */
  49967. set cameraColorCurves(value: Nullable<ColorCurves>);
  49968. /**
  49969. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49970. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49971. */
  49972. switchToBGR: boolean;
  49973. private _renderTargets;
  49974. private _reflectionControls;
  49975. private _white;
  49976. private _primaryShadowColor;
  49977. private _primaryHighlightColor;
  49978. /**
  49979. * Instantiates a Background Material in the given scene
  49980. * @param name The friendly name of the material
  49981. * @param scene The scene to add the material to
  49982. */
  49983. constructor(name: string, scene: Scene);
  49984. /**
  49985. * Gets a boolean indicating that current material needs to register RTT
  49986. */
  49987. get hasRenderTargetTextures(): boolean;
  49988. /**
  49989. * The entire material has been created in order to prevent overdraw.
  49990. * @returns false
  49991. */
  49992. needAlphaTesting(): boolean;
  49993. /**
  49994. * The entire material has been created in order to prevent overdraw.
  49995. * @returns true if blending is enable
  49996. */
  49997. needAlphaBlending(): boolean;
  49998. /**
  49999. * Checks wether the material is ready to be rendered for a given mesh.
  50000. * @param mesh The mesh to render
  50001. * @param subMesh The submesh to check against
  50002. * @param useInstances Specify wether or not the material is used with instances
  50003. * @returns true if all the dependencies are ready (Textures, Effects...)
  50004. */
  50005. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50006. /**
  50007. * Compute the primary color according to the chosen perceptual color.
  50008. */
  50009. private _computePrimaryColorFromPerceptualColor;
  50010. /**
  50011. * Compute the highlights and shadow colors according to their chosen levels.
  50012. */
  50013. private _computePrimaryColors;
  50014. /**
  50015. * Build the uniform buffer used in the material.
  50016. */
  50017. buildUniformLayout(): void;
  50018. /**
  50019. * Unbind the material.
  50020. */
  50021. unbind(): void;
  50022. /**
  50023. * Bind only the world matrix to the material.
  50024. * @param world The world matrix to bind.
  50025. */
  50026. bindOnlyWorldMatrix(world: Matrix): void;
  50027. /**
  50028. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50029. * @param world The world matrix to bind.
  50030. * @param subMesh The submesh to bind for.
  50031. */
  50032. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50033. /**
  50034. * Checks to see if a texture is used in the material.
  50035. * @param texture - Base texture to use.
  50036. * @returns - Boolean specifying if a texture is used in the material.
  50037. */
  50038. hasTexture(texture: BaseTexture): boolean;
  50039. /**
  50040. * Dispose the material.
  50041. * @param forceDisposeEffect Force disposal of the associated effect.
  50042. * @param forceDisposeTextures Force disposal of the associated textures.
  50043. */
  50044. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50045. /**
  50046. * Clones the material.
  50047. * @param name The cloned name.
  50048. * @returns The cloned material.
  50049. */
  50050. clone(name: string): BackgroundMaterial;
  50051. /**
  50052. * Serializes the current material to its JSON representation.
  50053. * @returns The JSON representation.
  50054. */
  50055. serialize(): any;
  50056. /**
  50057. * Gets the class name of the material
  50058. * @returns "BackgroundMaterial"
  50059. */
  50060. getClassName(): string;
  50061. /**
  50062. * Parse a JSON input to create back a background material.
  50063. * @param source The JSON data to parse
  50064. * @param scene The scene to create the parsed material in
  50065. * @param rootUrl The root url of the assets the material depends upon
  50066. * @returns the instantiated BackgroundMaterial.
  50067. */
  50068. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50069. }
  50070. }
  50071. declare module BABYLON {
  50072. /**
  50073. * Represents the different options available during the creation of
  50074. * a Environment helper.
  50075. *
  50076. * This can control the default ground, skybox and image processing setup of your scene.
  50077. */
  50078. export interface IEnvironmentHelperOptions {
  50079. /**
  50080. * Specifies whether or not to create a ground.
  50081. * True by default.
  50082. */
  50083. createGround: boolean;
  50084. /**
  50085. * Specifies the ground size.
  50086. * 15 by default.
  50087. */
  50088. groundSize: number;
  50089. /**
  50090. * The texture used on the ground for the main color.
  50091. * Comes from the BabylonJS CDN by default.
  50092. *
  50093. * Remarks: Can be either a texture or a url.
  50094. */
  50095. groundTexture: string | BaseTexture;
  50096. /**
  50097. * The color mixed in the ground texture by default.
  50098. * BabylonJS clearColor by default.
  50099. */
  50100. groundColor: Color3;
  50101. /**
  50102. * Specifies the ground opacity.
  50103. * 1 by default.
  50104. */
  50105. groundOpacity: number;
  50106. /**
  50107. * Enables the ground to receive shadows.
  50108. * True by default.
  50109. */
  50110. enableGroundShadow: boolean;
  50111. /**
  50112. * Helps preventing the shadow to be fully black on the ground.
  50113. * 0.5 by default.
  50114. */
  50115. groundShadowLevel: number;
  50116. /**
  50117. * Creates a mirror texture attach to the ground.
  50118. * false by default.
  50119. */
  50120. enableGroundMirror: boolean;
  50121. /**
  50122. * Specifies the ground mirror size ratio.
  50123. * 0.3 by default as the default kernel is 64.
  50124. */
  50125. groundMirrorSizeRatio: number;
  50126. /**
  50127. * Specifies the ground mirror blur kernel size.
  50128. * 64 by default.
  50129. */
  50130. groundMirrorBlurKernel: number;
  50131. /**
  50132. * Specifies the ground mirror visibility amount.
  50133. * 1 by default
  50134. */
  50135. groundMirrorAmount: number;
  50136. /**
  50137. * Specifies the ground mirror reflectance weight.
  50138. * This uses the standard weight of the background material to setup the fresnel effect
  50139. * of the mirror.
  50140. * 1 by default.
  50141. */
  50142. groundMirrorFresnelWeight: number;
  50143. /**
  50144. * Specifies the ground mirror Falloff distance.
  50145. * This can helps reducing the size of the reflection.
  50146. * 0 by Default.
  50147. */
  50148. groundMirrorFallOffDistance: number;
  50149. /**
  50150. * Specifies the ground mirror texture type.
  50151. * Unsigned Int by Default.
  50152. */
  50153. groundMirrorTextureType: number;
  50154. /**
  50155. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50156. * the shown objects.
  50157. */
  50158. groundYBias: number;
  50159. /**
  50160. * Specifies whether or not to create a skybox.
  50161. * True by default.
  50162. */
  50163. createSkybox: boolean;
  50164. /**
  50165. * Specifies the skybox size.
  50166. * 20 by default.
  50167. */
  50168. skyboxSize: number;
  50169. /**
  50170. * The texture used on the skybox for the main color.
  50171. * Comes from the BabylonJS CDN by default.
  50172. *
  50173. * Remarks: Can be either a texture or a url.
  50174. */
  50175. skyboxTexture: string | BaseTexture;
  50176. /**
  50177. * The color mixed in the skybox texture by default.
  50178. * BabylonJS clearColor by default.
  50179. */
  50180. skyboxColor: Color3;
  50181. /**
  50182. * The background rotation around the Y axis of the scene.
  50183. * This helps aligning the key lights of your scene with the background.
  50184. * 0 by default.
  50185. */
  50186. backgroundYRotation: number;
  50187. /**
  50188. * Compute automatically the size of the elements to best fit with the scene.
  50189. */
  50190. sizeAuto: boolean;
  50191. /**
  50192. * Default position of the rootMesh if autoSize is not true.
  50193. */
  50194. rootPosition: Vector3;
  50195. /**
  50196. * Sets up the image processing in the scene.
  50197. * true by default.
  50198. */
  50199. setupImageProcessing: boolean;
  50200. /**
  50201. * The texture used as your environment texture in the scene.
  50202. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50203. *
  50204. * Remarks: Can be either a texture or a url.
  50205. */
  50206. environmentTexture: string | BaseTexture;
  50207. /**
  50208. * The value of the exposure to apply to the scene.
  50209. * 0.6 by default if setupImageProcessing is true.
  50210. */
  50211. cameraExposure: number;
  50212. /**
  50213. * The value of the contrast to apply to the scene.
  50214. * 1.6 by default if setupImageProcessing is true.
  50215. */
  50216. cameraContrast: number;
  50217. /**
  50218. * Specifies whether or not tonemapping should be enabled in the scene.
  50219. * true by default if setupImageProcessing is true.
  50220. */
  50221. toneMappingEnabled: boolean;
  50222. }
  50223. /**
  50224. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50225. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50226. * It also helps with the default setup of your imageProcessing configuration.
  50227. */
  50228. export class EnvironmentHelper {
  50229. /**
  50230. * Default ground texture URL.
  50231. */
  50232. private static _groundTextureCDNUrl;
  50233. /**
  50234. * Default skybox texture URL.
  50235. */
  50236. private static _skyboxTextureCDNUrl;
  50237. /**
  50238. * Default environment texture URL.
  50239. */
  50240. private static _environmentTextureCDNUrl;
  50241. /**
  50242. * Creates the default options for the helper.
  50243. */
  50244. private static _getDefaultOptions;
  50245. private _rootMesh;
  50246. /**
  50247. * Gets the root mesh created by the helper.
  50248. */
  50249. get rootMesh(): Mesh;
  50250. private _skybox;
  50251. /**
  50252. * Gets the skybox created by the helper.
  50253. */
  50254. get skybox(): Nullable<Mesh>;
  50255. private _skyboxTexture;
  50256. /**
  50257. * Gets the skybox texture created by the helper.
  50258. */
  50259. get skyboxTexture(): Nullable<BaseTexture>;
  50260. private _skyboxMaterial;
  50261. /**
  50262. * Gets the skybox material created by the helper.
  50263. */
  50264. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50265. private _ground;
  50266. /**
  50267. * Gets the ground mesh created by the helper.
  50268. */
  50269. get ground(): Nullable<Mesh>;
  50270. private _groundTexture;
  50271. /**
  50272. * Gets the ground texture created by the helper.
  50273. */
  50274. get groundTexture(): Nullable<BaseTexture>;
  50275. private _groundMirror;
  50276. /**
  50277. * Gets the ground mirror created by the helper.
  50278. */
  50279. get groundMirror(): Nullable<MirrorTexture>;
  50280. /**
  50281. * Gets the ground mirror render list to helps pushing the meshes
  50282. * you wish in the ground reflection.
  50283. */
  50284. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50285. private _groundMaterial;
  50286. /**
  50287. * Gets the ground material created by the helper.
  50288. */
  50289. get groundMaterial(): Nullable<BackgroundMaterial>;
  50290. /**
  50291. * Stores the creation options.
  50292. */
  50293. private readonly _scene;
  50294. private _options;
  50295. /**
  50296. * This observable will be notified with any error during the creation of the environment,
  50297. * mainly texture creation errors.
  50298. */
  50299. onErrorObservable: Observable<{
  50300. message?: string;
  50301. exception?: any;
  50302. }>;
  50303. /**
  50304. * constructor
  50305. * @param options Defines the options we want to customize the helper
  50306. * @param scene The scene to add the material to
  50307. */
  50308. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50309. /**
  50310. * Updates the background according to the new options
  50311. * @param options
  50312. */
  50313. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50314. /**
  50315. * Sets the primary color of all the available elements.
  50316. * @param color the main color to affect to the ground and the background
  50317. */
  50318. setMainColor(color: Color3): void;
  50319. /**
  50320. * Setup the image processing according to the specified options.
  50321. */
  50322. private _setupImageProcessing;
  50323. /**
  50324. * Setup the environment texture according to the specified options.
  50325. */
  50326. private _setupEnvironmentTexture;
  50327. /**
  50328. * Setup the background according to the specified options.
  50329. */
  50330. private _setupBackground;
  50331. /**
  50332. * Get the scene sizes according to the setup.
  50333. */
  50334. private _getSceneSize;
  50335. /**
  50336. * Setup the ground according to the specified options.
  50337. */
  50338. private _setupGround;
  50339. /**
  50340. * Setup the ground material according to the specified options.
  50341. */
  50342. private _setupGroundMaterial;
  50343. /**
  50344. * Setup the ground diffuse texture according to the specified options.
  50345. */
  50346. private _setupGroundDiffuseTexture;
  50347. /**
  50348. * Setup the ground mirror texture according to the specified options.
  50349. */
  50350. private _setupGroundMirrorTexture;
  50351. /**
  50352. * Setup the ground to receive the mirror texture.
  50353. */
  50354. private _setupMirrorInGroundMaterial;
  50355. /**
  50356. * Setup the skybox according to the specified options.
  50357. */
  50358. private _setupSkybox;
  50359. /**
  50360. * Setup the skybox material according to the specified options.
  50361. */
  50362. private _setupSkyboxMaterial;
  50363. /**
  50364. * Setup the skybox reflection texture according to the specified options.
  50365. */
  50366. private _setupSkyboxReflectionTexture;
  50367. private _errorHandler;
  50368. /**
  50369. * Dispose all the elements created by the Helper.
  50370. */
  50371. dispose(): void;
  50372. }
  50373. }
  50374. declare module BABYLON {
  50375. /**
  50376. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50377. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50378. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50379. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50380. */
  50381. export class PhotoDome extends TransformNode {
  50382. /**
  50383. * Define the image as a Monoscopic panoramic 360 image.
  50384. */
  50385. static readonly MODE_MONOSCOPIC: number;
  50386. /**
  50387. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50388. */
  50389. static readonly MODE_TOPBOTTOM: number;
  50390. /**
  50391. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50392. */
  50393. static readonly MODE_SIDEBYSIDE: number;
  50394. private _useDirectMapping;
  50395. /**
  50396. * The texture being displayed on the sphere
  50397. */
  50398. protected _photoTexture: Texture;
  50399. /**
  50400. * Gets or sets the texture being displayed on the sphere
  50401. */
  50402. get photoTexture(): Texture;
  50403. set photoTexture(value: Texture);
  50404. /**
  50405. * Observable raised when an error occured while loading the 360 image
  50406. */
  50407. onLoadErrorObservable: Observable<string>;
  50408. /**
  50409. * The skybox material
  50410. */
  50411. protected _material: BackgroundMaterial;
  50412. /**
  50413. * The surface used for the skybox
  50414. */
  50415. protected _mesh: Mesh;
  50416. /**
  50417. * Gets the mesh used for the skybox.
  50418. */
  50419. get mesh(): Mesh;
  50420. /**
  50421. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50422. * Also see the options.resolution property.
  50423. */
  50424. get fovMultiplier(): number;
  50425. set fovMultiplier(value: number);
  50426. private _imageMode;
  50427. /**
  50428. * Gets or set the current video mode for the video. It can be:
  50429. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50430. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50431. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50432. */
  50433. get imageMode(): number;
  50434. set imageMode(value: number);
  50435. /**
  50436. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50437. * @param name Element's name, child elements will append suffixes for their own names.
  50438. * @param urlsOfPhoto defines the url of the photo to display
  50439. * @param options defines an object containing optional or exposed sub element properties
  50440. * @param onError defines a callback called when an error occured while loading the texture
  50441. */
  50442. constructor(name: string, urlOfPhoto: string, options: {
  50443. resolution?: number;
  50444. size?: number;
  50445. useDirectMapping?: boolean;
  50446. faceForward?: boolean;
  50447. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50448. private _onBeforeCameraRenderObserver;
  50449. private _changeImageMode;
  50450. /**
  50451. * Releases resources associated with this node.
  50452. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50453. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50454. */
  50455. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50456. }
  50457. }
  50458. declare module BABYLON {
  50459. /**
  50460. * Class used to host RGBD texture specific utilities
  50461. */
  50462. export class RGBDTextureTools {
  50463. /**
  50464. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50465. * @param texture the texture to expand.
  50466. */
  50467. static ExpandRGBDTexture(texture: Texture): void;
  50468. }
  50469. }
  50470. declare module BABYLON {
  50471. /**
  50472. * Class used to host texture specific utilities
  50473. */
  50474. export class BRDFTextureTools {
  50475. /**
  50476. * Prevents texture cache collision
  50477. */
  50478. private static _instanceNumber;
  50479. /**
  50480. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50481. * @param scene defines the hosting scene
  50482. * @returns the environment BRDF texture
  50483. */
  50484. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50485. private static _environmentBRDFBase64Texture;
  50486. }
  50487. }
  50488. declare module BABYLON {
  50489. /**
  50490. * @hidden
  50491. */
  50492. export interface IMaterialClearCoatDefines {
  50493. CLEARCOAT: boolean;
  50494. CLEARCOAT_DEFAULTIOR: boolean;
  50495. CLEARCOAT_TEXTURE: boolean;
  50496. CLEARCOAT_TEXTUREDIRECTUV: number;
  50497. CLEARCOAT_BUMP: boolean;
  50498. CLEARCOAT_BUMPDIRECTUV: number;
  50499. CLEARCOAT_TINT: boolean;
  50500. CLEARCOAT_TINT_TEXTURE: boolean;
  50501. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50502. /** @hidden */
  50503. _areTexturesDirty: boolean;
  50504. }
  50505. /**
  50506. * Define the code related to the clear coat parameters of the pbr material.
  50507. */
  50508. export class PBRClearCoatConfiguration {
  50509. /**
  50510. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50511. * The default fits with a polyurethane material.
  50512. */
  50513. private static readonly _DefaultIndexOfRefraction;
  50514. private _isEnabled;
  50515. /**
  50516. * Defines if the clear coat is enabled in the material.
  50517. */
  50518. isEnabled: boolean;
  50519. /**
  50520. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50521. */
  50522. intensity: number;
  50523. /**
  50524. * Defines the clear coat layer roughness.
  50525. */
  50526. roughness: number;
  50527. private _indexOfRefraction;
  50528. /**
  50529. * Defines the index of refraction of the clear coat.
  50530. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50531. * The default fits with a polyurethane material.
  50532. * Changing the default value is more performance intensive.
  50533. */
  50534. indexOfRefraction: number;
  50535. private _texture;
  50536. /**
  50537. * Stores the clear coat values in a texture.
  50538. */
  50539. texture: Nullable<BaseTexture>;
  50540. private _bumpTexture;
  50541. /**
  50542. * Define the clear coat specific bump texture.
  50543. */
  50544. bumpTexture: Nullable<BaseTexture>;
  50545. private _isTintEnabled;
  50546. /**
  50547. * Defines if the clear coat tint is enabled in the material.
  50548. */
  50549. isTintEnabled: boolean;
  50550. /**
  50551. * Defines the clear coat tint of the material.
  50552. * This is only use if tint is enabled
  50553. */
  50554. tintColor: Color3;
  50555. /**
  50556. * Defines the distance at which the tint color should be found in the
  50557. * clear coat media.
  50558. * This is only use if tint is enabled
  50559. */
  50560. tintColorAtDistance: number;
  50561. /**
  50562. * Defines the clear coat layer thickness.
  50563. * This is only use if tint is enabled
  50564. */
  50565. tintThickness: number;
  50566. private _tintTexture;
  50567. /**
  50568. * Stores the clear tint values in a texture.
  50569. * rgb is tint
  50570. * a is a thickness factor
  50571. */
  50572. tintTexture: Nullable<BaseTexture>;
  50573. /** @hidden */
  50574. private _internalMarkAllSubMeshesAsTexturesDirty;
  50575. /** @hidden */
  50576. _markAllSubMeshesAsTexturesDirty(): void;
  50577. /**
  50578. * Instantiate a new istance of clear coat configuration.
  50579. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50580. */
  50581. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50582. /**
  50583. * Gets wehter the submesh is ready to be used or not.
  50584. * @param defines the list of "defines" to update.
  50585. * @param scene defines the scene the material belongs to.
  50586. * @param engine defines the engine the material belongs to.
  50587. * @param disableBumpMap defines wether the material disables bump or not.
  50588. * @returns - boolean indicating that the submesh is ready or not.
  50589. */
  50590. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50591. /**
  50592. * Checks to see if a texture is used in the material.
  50593. * @param defines the list of "defines" to update.
  50594. * @param scene defines the scene to the material belongs to.
  50595. */
  50596. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50597. /**
  50598. * Binds the material data.
  50599. * @param uniformBuffer defines the Uniform buffer to fill in.
  50600. * @param scene defines the scene the material belongs to.
  50601. * @param engine defines the engine the material belongs to.
  50602. * @param disableBumpMap defines wether the material disables bump or not.
  50603. * @param isFrozen defines wether the material is frozen or not.
  50604. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50605. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50606. */
  50607. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50608. /**
  50609. * Checks to see if a texture is used in the material.
  50610. * @param texture - Base texture to use.
  50611. * @returns - Boolean specifying if a texture is used in the material.
  50612. */
  50613. hasTexture(texture: BaseTexture): boolean;
  50614. /**
  50615. * Returns an array of the actively used textures.
  50616. * @param activeTextures Array of BaseTextures
  50617. */
  50618. getActiveTextures(activeTextures: BaseTexture[]): void;
  50619. /**
  50620. * Returns the animatable textures.
  50621. * @param animatables Array of animatable textures.
  50622. */
  50623. getAnimatables(animatables: IAnimatable[]): void;
  50624. /**
  50625. * Disposes the resources of the material.
  50626. * @param forceDisposeTextures - Forces the disposal of all textures.
  50627. */
  50628. dispose(forceDisposeTextures?: boolean): void;
  50629. /**
  50630. * Get the current class name of the texture useful for serialization or dynamic coding.
  50631. * @returns "PBRClearCoatConfiguration"
  50632. */
  50633. getClassName(): string;
  50634. /**
  50635. * Add fallbacks to the effect fallbacks list.
  50636. * @param defines defines the Base texture to use.
  50637. * @param fallbacks defines the current fallback list.
  50638. * @param currentRank defines the current fallback rank.
  50639. * @returns the new fallback rank.
  50640. */
  50641. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50642. /**
  50643. * Add the required uniforms to the current list.
  50644. * @param uniforms defines the current uniform list.
  50645. */
  50646. static AddUniforms(uniforms: string[]): void;
  50647. /**
  50648. * Add the required samplers to the current list.
  50649. * @param samplers defines the current sampler list.
  50650. */
  50651. static AddSamplers(samplers: string[]): void;
  50652. /**
  50653. * Add the required uniforms to the current buffer.
  50654. * @param uniformBuffer defines the current uniform buffer.
  50655. */
  50656. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50657. /**
  50658. * Makes a duplicate of the current configuration into another one.
  50659. * @param clearCoatConfiguration define the config where to copy the info
  50660. */
  50661. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50662. /**
  50663. * Serializes this clear coat configuration.
  50664. * @returns - An object with the serialized config.
  50665. */
  50666. serialize(): any;
  50667. /**
  50668. * Parses a anisotropy Configuration from a serialized object.
  50669. * @param source - Serialized object.
  50670. * @param scene Defines the scene we are parsing for
  50671. * @param rootUrl Defines the rootUrl to load from
  50672. */
  50673. parse(source: any, scene: Scene, rootUrl: string): void;
  50674. }
  50675. }
  50676. declare module BABYLON {
  50677. /**
  50678. * @hidden
  50679. */
  50680. export interface IMaterialAnisotropicDefines {
  50681. ANISOTROPIC: boolean;
  50682. ANISOTROPIC_TEXTURE: boolean;
  50683. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50684. MAINUV1: boolean;
  50685. _areTexturesDirty: boolean;
  50686. _needUVs: boolean;
  50687. }
  50688. /**
  50689. * Define the code related to the anisotropic parameters of the pbr material.
  50690. */
  50691. export class PBRAnisotropicConfiguration {
  50692. private _isEnabled;
  50693. /**
  50694. * Defines if the anisotropy is enabled in the material.
  50695. */
  50696. isEnabled: boolean;
  50697. /**
  50698. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50699. */
  50700. intensity: number;
  50701. /**
  50702. * Defines if the effect is along the tangents, bitangents or in between.
  50703. * By default, the effect is "strectching" the highlights along the tangents.
  50704. */
  50705. direction: Vector2;
  50706. private _texture;
  50707. /**
  50708. * Stores the anisotropy values in a texture.
  50709. * rg is direction (like normal from -1 to 1)
  50710. * b is a intensity
  50711. */
  50712. texture: Nullable<BaseTexture>;
  50713. /** @hidden */
  50714. private _internalMarkAllSubMeshesAsTexturesDirty;
  50715. /** @hidden */
  50716. _markAllSubMeshesAsTexturesDirty(): void;
  50717. /**
  50718. * Instantiate a new istance of anisotropy configuration.
  50719. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50720. */
  50721. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50722. /**
  50723. * Specifies that the submesh is ready to be used.
  50724. * @param defines the list of "defines" to update.
  50725. * @param scene defines the scene the material belongs to.
  50726. * @returns - boolean indicating that the submesh is ready or not.
  50727. */
  50728. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50729. /**
  50730. * Checks to see if a texture is used in the material.
  50731. * @param defines the list of "defines" to update.
  50732. * @param mesh the mesh we are preparing the defines for.
  50733. * @param scene defines the scene the material belongs to.
  50734. */
  50735. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50736. /**
  50737. * Binds the material data.
  50738. * @param uniformBuffer defines the Uniform buffer to fill in.
  50739. * @param scene defines the scene the material belongs to.
  50740. * @param isFrozen defines wether the material is frozen or not.
  50741. */
  50742. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50743. /**
  50744. * Checks to see if a texture is used in the material.
  50745. * @param texture - Base texture to use.
  50746. * @returns - Boolean specifying if a texture is used in the material.
  50747. */
  50748. hasTexture(texture: BaseTexture): boolean;
  50749. /**
  50750. * Returns an array of the actively used textures.
  50751. * @param activeTextures Array of BaseTextures
  50752. */
  50753. getActiveTextures(activeTextures: BaseTexture[]): void;
  50754. /**
  50755. * Returns the animatable textures.
  50756. * @param animatables Array of animatable textures.
  50757. */
  50758. getAnimatables(animatables: IAnimatable[]): void;
  50759. /**
  50760. * Disposes the resources of the material.
  50761. * @param forceDisposeTextures - Forces the disposal of all textures.
  50762. */
  50763. dispose(forceDisposeTextures?: boolean): void;
  50764. /**
  50765. * Get the current class name of the texture useful for serialization or dynamic coding.
  50766. * @returns "PBRAnisotropicConfiguration"
  50767. */
  50768. getClassName(): string;
  50769. /**
  50770. * Add fallbacks to the effect fallbacks list.
  50771. * @param defines defines the Base texture to use.
  50772. * @param fallbacks defines the current fallback list.
  50773. * @param currentRank defines the current fallback rank.
  50774. * @returns the new fallback rank.
  50775. */
  50776. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50777. /**
  50778. * Add the required uniforms to the current list.
  50779. * @param uniforms defines the current uniform list.
  50780. */
  50781. static AddUniforms(uniforms: string[]): void;
  50782. /**
  50783. * Add the required uniforms to the current buffer.
  50784. * @param uniformBuffer defines the current uniform buffer.
  50785. */
  50786. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50787. /**
  50788. * Add the required samplers to the current list.
  50789. * @param samplers defines the current sampler list.
  50790. */
  50791. static AddSamplers(samplers: string[]): void;
  50792. /**
  50793. * Makes a duplicate of the current configuration into another one.
  50794. * @param anisotropicConfiguration define the config where to copy the info
  50795. */
  50796. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50797. /**
  50798. * Serializes this anisotropy configuration.
  50799. * @returns - An object with the serialized config.
  50800. */
  50801. serialize(): any;
  50802. /**
  50803. * Parses a anisotropy Configuration from a serialized object.
  50804. * @param source - Serialized object.
  50805. * @param scene Defines the scene we are parsing for
  50806. * @param rootUrl Defines the rootUrl to load from
  50807. */
  50808. parse(source: any, scene: Scene, rootUrl: string): void;
  50809. }
  50810. }
  50811. declare module BABYLON {
  50812. /**
  50813. * @hidden
  50814. */
  50815. export interface IMaterialBRDFDefines {
  50816. BRDF_V_HEIGHT_CORRELATED: boolean;
  50817. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50818. SPHERICAL_HARMONICS: boolean;
  50819. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50820. /** @hidden */
  50821. _areMiscDirty: boolean;
  50822. }
  50823. /**
  50824. * Define the code related to the BRDF parameters of the pbr material.
  50825. */
  50826. export class PBRBRDFConfiguration {
  50827. /**
  50828. * Default value used for the energy conservation.
  50829. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50830. */
  50831. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50832. /**
  50833. * Default value used for the Smith Visibility Height Correlated mode.
  50834. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50835. */
  50836. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50837. /**
  50838. * Default value used for the IBL diffuse part.
  50839. * This can help switching back to the polynomials mode globally which is a tiny bit
  50840. * less GPU intensive at the drawback of a lower quality.
  50841. */
  50842. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50843. /**
  50844. * Default value used for activating energy conservation for the specular workflow.
  50845. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50846. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50847. */
  50848. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50849. private _useEnergyConservation;
  50850. /**
  50851. * Defines if the material uses energy conservation.
  50852. */
  50853. useEnergyConservation: boolean;
  50854. private _useSmithVisibilityHeightCorrelated;
  50855. /**
  50856. * LEGACY Mode set to false
  50857. * Defines if the material uses height smith correlated visibility term.
  50858. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50859. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50860. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50861. * Not relying on height correlated will also disable energy conservation.
  50862. */
  50863. useSmithVisibilityHeightCorrelated: boolean;
  50864. private _useSphericalHarmonics;
  50865. /**
  50866. * LEGACY Mode set to false
  50867. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50868. * diffuse part of the IBL.
  50869. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50870. * to the ground truth.
  50871. */
  50872. useSphericalHarmonics: boolean;
  50873. private _useSpecularGlossinessInputEnergyConservation;
  50874. /**
  50875. * Defines if the material uses energy conservation, when the specular workflow is active.
  50876. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50877. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50878. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50879. */
  50880. useSpecularGlossinessInputEnergyConservation: boolean;
  50881. /** @hidden */
  50882. private _internalMarkAllSubMeshesAsMiscDirty;
  50883. /** @hidden */
  50884. _markAllSubMeshesAsMiscDirty(): void;
  50885. /**
  50886. * Instantiate a new istance of clear coat configuration.
  50887. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50888. */
  50889. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50890. /**
  50891. * Checks to see if a texture is used in the material.
  50892. * @param defines the list of "defines" to update.
  50893. */
  50894. prepareDefines(defines: IMaterialBRDFDefines): void;
  50895. /**
  50896. * Get the current class name of the texture useful for serialization or dynamic coding.
  50897. * @returns "PBRClearCoatConfiguration"
  50898. */
  50899. getClassName(): string;
  50900. /**
  50901. * Makes a duplicate of the current configuration into another one.
  50902. * @param brdfConfiguration define the config where to copy the info
  50903. */
  50904. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50905. /**
  50906. * Serializes this BRDF configuration.
  50907. * @returns - An object with the serialized config.
  50908. */
  50909. serialize(): any;
  50910. /**
  50911. * Parses a anisotropy Configuration from a serialized object.
  50912. * @param source - Serialized object.
  50913. * @param scene Defines the scene we are parsing for
  50914. * @param rootUrl Defines the rootUrl to load from
  50915. */
  50916. parse(source: any, scene: Scene, rootUrl: string): void;
  50917. }
  50918. }
  50919. declare module BABYLON {
  50920. /**
  50921. * @hidden
  50922. */
  50923. export interface IMaterialSheenDefines {
  50924. SHEEN: boolean;
  50925. SHEEN_TEXTURE: boolean;
  50926. SHEEN_TEXTUREDIRECTUV: number;
  50927. SHEEN_LINKWITHALBEDO: boolean;
  50928. SHEEN_ROUGHNESS: boolean;
  50929. SHEEN_ALBEDOSCALING: boolean;
  50930. /** @hidden */
  50931. _areTexturesDirty: boolean;
  50932. }
  50933. /**
  50934. * Define the code related to the Sheen parameters of the pbr material.
  50935. */
  50936. export class PBRSheenConfiguration {
  50937. private _isEnabled;
  50938. /**
  50939. * Defines if the material uses sheen.
  50940. */
  50941. isEnabled: boolean;
  50942. private _linkSheenWithAlbedo;
  50943. /**
  50944. * Defines if the sheen is linked to the sheen color.
  50945. */
  50946. linkSheenWithAlbedo: boolean;
  50947. /**
  50948. * Defines the sheen intensity.
  50949. */
  50950. intensity: number;
  50951. /**
  50952. * Defines the sheen color.
  50953. */
  50954. color: Color3;
  50955. private _texture;
  50956. /**
  50957. * Stores the sheen tint values in a texture.
  50958. * rgb is tint
  50959. * a is a intensity
  50960. */
  50961. texture: Nullable<BaseTexture>;
  50962. private _roughness;
  50963. /**
  50964. * Defines the sheen roughness.
  50965. * It is not taken into account if linkSheenWithAlbedo is true.
  50966. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50967. */
  50968. roughness: Nullable<number>;
  50969. private _albedoScaling;
  50970. /**
  50971. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50972. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50973. * making it easier to setup and tweak the effect
  50974. */
  50975. albedoScaling: boolean;
  50976. /** @hidden */
  50977. private _internalMarkAllSubMeshesAsTexturesDirty;
  50978. /** @hidden */
  50979. _markAllSubMeshesAsTexturesDirty(): void;
  50980. /**
  50981. * Instantiate a new istance of clear coat configuration.
  50982. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50983. */
  50984. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50985. /**
  50986. * Specifies that the submesh is ready to be used.
  50987. * @param defines the list of "defines" to update.
  50988. * @param scene defines the scene the material belongs to.
  50989. * @returns - boolean indicating that the submesh is ready or not.
  50990. */
  50991. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50992. /**
  50993. * Checks to see if a texture is used in the material.
  50994. * @param defines the list of "defines" to update.
  50995. * @param scene defines the scene the material belongs to.
  50996. */
  50997. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50998. /**
  50999. * Binds the material data.
  51000. * @param uniformBuffer defines the Uniform buffer to fill in.
  51001. * @param scene defines the scene the material belongs to.
  51002. * @param isFrozen defines wether the material is frozen or not.
  51003. */
  51004. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51005. /**
  51006. * Checks to see if a texture is used in the material.
  51007. * @param texture - Base texture to use.
  51008. * @returns - Boolean specifying if a texture is used in the material.
  51009. */
  51010. hasTexture(texture: BaseTexture): boolean;
  51011. /**
  51012. * Returns an array of the actively used textures.
  51013. * @param activeTextures Array of BaseTextures
  51014. */
  51015. getActiveTextures(activeTextures: BaseTexture[]): void;
  51016. /**
  51017. * Returns the animatable textures.
  51018. * @param animatables Array of animatable textures.
  51019. */
  51020. getAnimatables(animatables: IAnimatable[]): void;
  51021. /**
  51022. * Disposes the resources of the material.
  51023. * @param forceDisposeTextures - Forces the disposal of all textures.
  51024. */
  51025. dispose(forceDisposeTextures?: boolean): void;
  51026. /**
  51027. * Get the current class name of the texture useful for serialization or dynamic coding.
  51028. * @returns "PBRSheenConfiguration"
  51029. */
  51030. getClassName(): string;
  51031. /**
  51032. * Add fallbacks to the effect fallbacks list.
  51033. * @param defines defines the Base texture to use.
  51034. * @param fallbacks defines the current fallback list.
  51035. * @param currentRank defines the current fallback rank.
  51036. * @returns the new fallback rank.
  51037. */
  51038. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51039. /**
  51040. * Add the required uniforms to the current list.
  51041. * @param uniforms defines the current uniform list.
  51042. */
  51043. static AddUniforms(uniforms: string[]): void;
  51044. /**
  51045. * Add the required uniforms to the current buffer.
  51046. * @param uniformBuffer defines the current uniform buffer.
  51047. */
  51048. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51049. /**
  51050. * Add the required samplers to the current list.
  51051. * @param samplers defines the current sampler list.
  51052. */
  51053. static AddSamplers(samplers: string[]): void;
  51054. /**
  51055. * Makes a duplicate of the current configuration into another one.
  51056. * @param sheenConfiguration define the config where to copy the info
  51057. */
  51058. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51059. /**
  51060. * Serializes this BRDF configuration.
  51061. * @returns - An object with the serialized config.
  51062. */
  51063. serialize(): any;
  51064. /**
  51065. * Parses a anisotropy Configuration from a serialized object.
  51066. * @param source - Serialized object.
  51067. * @param scene Defines the scene we are parsing for
  51068. * @param rootUrl Defines the rootUrl to load from
  51069. */
  51070. parse(source: any, scene: Scene, rootUrl: string): void;
  51071. }
  51072. }
  51073. declare module BABYLON {
  51074. /**
  51075. * @hidden
  51076. */
  51077. export interface IMaterialSubSurfaceDefines {
  51078. SUBSURFACE: boolean;
  51079. SS_REFRACTION: boolean;
  51080. SS_TRANSLUCENCY: boolean;
  51081. SS_SCATERRING: boolean;
  51082. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51083. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51084. SS_REFRACTIONMAP_3D: boolean;
  51085. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51086. SS_LODINREFRACTIONALPHA: boolean;
  51087. SS_GAMMAREFRACTION: boolean;
  51088. SS_RGBDREFRACTION: boolean;
  51089. SS_LINEARSPECULARREFRACTION: boolean;
  51090. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51091. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51092. /** @hidden */
  51093. _areTexturesDirty: boolean;
  51094. }
  51095. /**
  51096. * Define the code related to the sub surface parameters of the pbr material.
  51097. */
  51098. export class PBRSubSurfaceConfiguration {
  51099. private _isRefractionEnabled;
  51100. /**
  51101. * Defines if the refraction is enabled in the material.
  51102. */
  51103. isRefractionEnabled: boolean;
  51104. private _isTranslucencyEnabled;
  51105. /**
  51106. * Defines if the translucency is enabled in the material.
  51107. */
  51108. isTranslucencyEnabled: boolean;
  51109. private _isScatteringEnabled;
  51110. /**
  51111. * Defines the refraction intensity of the material.
  51112. * The refraction when enabled replaces the Diffuse part of the material.
  51113. * The intensity helps transitionning between diffuse and refraction.
  51114. */
  51115. refractionIntensity: number;
  51116. /**
  51117. * Defines the translucency intensity of the material.
  51118. * When translucency has been enabled, this defines how much of the "translucency"
  51119. * is addded to the diffuse part of the material.
  51120. */
  51121. translucencyIntensity: number;
  51122. /**
  51123. * Defines the scattering intensity of the material.
  51124. * When scattering has been enabled, this defines how much of the "scattered light"
  51125. * is addded to the diffuse part of the material.
  51126. */
  51127. scatteringIntensity: number;
  51128. private _thicknessTexture;
  51129. /**
  51130. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51131. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51132. * 0 would mean minimumThickness
  51133. * 1 would mean maximumThickness
  51134. * The other channels might be use as a mask to vary the different effects intensity.
  51135. */
  51136. thicknessTexture: Nullable<BaseTexture>;
  51137. private _refractionTexture;
  51138. /**
  51139. * Defines the texture to use for refraction.
  51140. */
  51141. refractionTexture: Nullable<BaseTexture>;
  51142. private _indexOfRefraction;
  51143. /**
  51144. * Defines the index of refraction used in the material.
  51145. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51146. */
  51147. indexOfRefraction: number;
  51148. private _invertRefractionY;
  51149. /**
  51150. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51151. */
  51152. invertRefractionY: boolean;
  51153. private _linkRefractionWithTransparency;
  51154. /**
  51155. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51156. * Materials half opaque for instance using refraction could benefit from this control.
  51157. */
  51158. linkRefractionWithTransparency: boolean;
  51159. /**
  51160. * Defines the minimum thickness stored in the thickness map.
  51161. * If no thickness map is defined, this value will be used to simulate thickness.
  51162. */
  51163. minimumThickness: number;
  51164. /**
  51165. * Defines the maximum thickness stored in the thickness map.
  51166. */
  51167. maximumThickness: number;
  51168. /**
  51169. * Defines the volume tint of the material.
  51170. * This is used for both translucency and scattering.
  51171. */
  51172. tintColor: Color3;
  51173. /**
  51174. * Defines the distance at which the tint color should be found in the media.
  51175. * This is used for refraction only.
  51176. */
  51177. tintColorAtDistance: number;
  51178. /**
  51179. * Defines how far each channel transmit through the media.
  51180. * It is defined as a color to simplify it selection.
  51181. */
  51182. diffusionDistance: Color3;
  51183. private _useMaskFromThicknessTexture;
  51184. /**
  51185. * Stores the intensity of the different subsurface effects in the thickness texture.
  51186. * * the green channel is the translucency intensity.
  51187. * * the blue channel is the scattering intensity.
  51188. * * the alpha channel is the refraction intensity.
  51189. */
  51190. useMaskFromThicknessTexture: boolean;
  51191. /** @hidden */
  51192. private _internalMarkAllSubMeshesAsTexturesDirty;
  51193. /** @hidden */
  51194. _markAllSubMeshesAsTexturesDirty(): void;
  51195. /**
  51196. * Instantiate a new istance of sub surface configuration.
  51197. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51198. */
  51199. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51200. /**
  51201. * Gets wehter the submesh is ready to be used or not.
  51202. * @param defines the list of "defines" to update.
  51203. * @param scene defines the scene the material belongs to.
  51204. * @returns - boolean indicating that the submesh is ready or not.
  51205. */
  51206. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51207. /**
  51208. * Checks to see if a texture is used in the material.
  51209. * @param defines the list of "defines" to update.
  51210. * @param scene defines the scene to the material belongs to.
  51211. */
  51212. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51213. /**
  51214. * Binds the material data.
  51215. * @param uniformBuffer defines the Uniform buffer to fill in.
  51216. * @param scene defines the scene the material belongs to.
  51217. * @param engine defines the engine the material belongs to.
  51218. * @param isFrozen defines wether the material is frozen or not.
  51219. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51220. */
  51221. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51222. /**
  51223. * Unbinds the material from the mesh.
  51224. * @param activeEffect defines the effect that should be unbound from.
  51225. * @returns true if unbound, otherwise false
  51226. */
  51227. unbind(activeEffect: Effect): boolean;
  51228. /**
  51229. * Returns the texture used for refraction or null if none is used.
  51230. * @param scene defines the scene the material belongs to.
  51231. * @returns - Refraction texture if present. If no refraction texture and refraction
  51232. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51233. */
  51234. private _getRefractionTexture;
  51235. /**
  51236. * Returns true if alpha blending should be disabled.
  51237. */
  51238. get disableAlphaBlending(): boolean;
  51239. /**
  51240. * Fills the list of render target textures.
  51241. * @param renderTargets the list of render targets to update
  51242. */
  51243. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51244. /**
  51245. * Checks to see if a texture is used in the material.
  51246. * @param texture - Base texture to use.
  51247. * @returns - Boolean specifying if a texture is used in the material.
  51248. */
  51249. hasTexture(texture: BaseTexture): boolean;
  51250. /**
  51251. * Gets a boolean indicating that current material needs to register RTT
  51252. * @returns true if this uses a render target otherwise false.
  51253. */
  51254. hasRenderTargetTextures(): boolean;
  51255. /**
  51256. * Returns an array of the actively used textures.
  51257. * @param activeTextures Array of BaseTextures
  51258. */
  51259. getActiveTextures(activeTextures: BaseTexture[]): void;
  51260. /**
  51261. * Returns the animatable textures.
  51262. * @param animatables Array of animatable textures.
  51263. */
  51264. getAnimatables(animatables: IAnimatable[]): void;
  51265. /**
  51266. * Disposes the resources of the material.
  51267. * @param forceDisposeTextures - Forces the disposal of all textures.
  51268. */
  51269. dispose(forceDisposeTextures?: boolean): void;
  51270. /**
  51271. * Get the current class name of the texture useful for serialization or dynamic coding.
  51272. * @returns "PBRSubSurfaceConfiguration"
  51273. */
  51274. getClassName(): string;
  51275. /**
  51276. * Add fallbacks to the effect fallbacks list.
  51277. * @param defines defines the Base texture to use.
  51278. * @param fallbacks defines the current fallback list.
  51279. * @param currentRank defines the current fallback rank.
  51280. * @returns the new fallback rank.
  51281. */
  51282. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51283. /**
  51284. * Add the required uniforms to the current list.
  51285. * @param uniforms defines the current uniform list.
  51286. */
  51287. static AddUniforms(uniforms: string[]): void;
  51288. /**
  51289. * Add the required samplers to the current list.
  51290. * @param samplers defines the current sampler list.
  51291. */
  51292. static AddSamplers(samplers: string[]): void;
  51293. /**
  51294. * Add the required uniforms to the current buffer.
  51295. * @param uniformBuffer defines the current uniform buffer.
  51296. */
  51297. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51298. /**
  51299. * Makes a duplicate of the current configuration into another one.
  51300. * @param configuration define the config where to copy the info
  51301. */
  51302. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51303. /**
  51304. * Serializes this Sub Surface configuration.
  51305. * @returns - An object with the serialized config.
  51306. */
  51307. serialize(): any;
  51308. /**
  51309. * Parses a anisotropy Configuration from a serialized object.
  51310. * @param source - Serialized object.
  51311. * @param scene Defines the scene we are parsing for
  51312. * @param rootUrl Defines the rootUrl to load from
  51313. */
  51314. parse(source: any, scene: Scene, rootUrl: string): void;
  51315. }
  51316. }
  51317. declare module BABYLON {
  51318. /** @hidden */
  51319. export var pbrFragmentDeclaration: {
  51320. name: string;
  51321. shader: string;
  51322. };
  51323. }
  51324. declare module BABYLON {
  51325. /** @hidden */
  51326. export var pbrUboDeclaration: {
  51327. name: string;
  51328. shader: string;
  51329. };
  51330. }
  51331. declare module BABYLON {
  51332. /** @hidden */
  51333. export var pbrFragmentExtraDeclaration: {
  51334. name: string;
  51335. shader: string;
  51336. };
  51337. }
  51338. declare module BABYLON {
  51339. /** @hidden */
  51340. export var pbrFragmentSamplersDeclaration: {
  51341. name: string;
  51342. shader: string;
  51343. };
  51344. }
  51345. declare module BABYLON {
  51346. /** @hidden */
  51347. export var pbrHelperFunctions: {
  51348. name: string;
  51349. shader: string;
  51350. };
  51351. }
  51352. declare module BABYLON {
  51353. /** @hidden */
  51354. export var harmonicsFunctions: {
  51355. name: string;
  51356. shader: string;
  51357. };
  51358. }
  51359. declare module BABYLON {
  51360. /** @hidden */
  51361. export var pbrDirectLightingSetupFunctions: {
  51362. name: string;
  51363. shader: string;
  51364. };
  51365. }
  51366. declare module BABYLON {
  51367. /** @hidden */
  51368. export var pbrDirectLightingFalloffFunctions: {
  51369. name: string;
  51370. shader: string;
  51371. };
  51372. }
  51373. declare module BABYLON {
  51374. /** @hidden */
  51375. export var pbrBRDFFunctions: {
  51376. name: string;
  51377. shader: string;
  51378. };
  51379. }
  51380. declare module BABYLON {
  51381. /** @hidden */
  51382. export var pbrDirectLightingFunctions: {
  51383. name: string;
  51384. shader: string;
  51385. };
  51386. }
  51387. declare module BABYLON {
  51388. /** @hidden */
  51389. export var pbrIBLFunctions: {
  51390. name: string;
  51391. shader: string;
  51392. };
  51393. }
  51394. declare module BABYLON {
  51395. /** @hidden */
  51396. export var pbrBlockAlbedoOpacity: {
  51397. name: string;
  51398. shader: string;
  51399. };
  51400. }
  51401. declare module BABYLON {
  51402. /** @hidden */
  51403. export var pbrBlockReflectivity: {
  51404. name: string;
  51405. shader: string;
  51406. };
  51407. }
  51408. declare module BABYLON {
  51409. /** @hidden */
  51410. export var pbrBlockAmbientOcclusion: {
  51411. name: string;
  51412. shader: string;
  51413. };
  51414. }
  51415. declare module BABYLON {
  51416. /** @hidden */
  51417. export var pbrBlockAlphaFresnel: {
  51418. name: string;
  51419. shader: string;
  51420. };
  51421. }
  51422. declare module BABYLON {
  51423. /** @hidden */
  51424. export var pbrBlockAnisotropic: {
  51425. name: string;
  51426. shader: string;
  51427. };
  51428. }
  51429. declare module BABYLON {
  51430. /** @hidden */
  51431. export var pbrBlockReflection: {
  51432. name: string;
  51433. shader: string;
  51434. };
  51435. }
  51436. declare module BABYLON {
  51437. /** @hidden */
  51438. export var pbrBlockSheen: {
  51439. name: string;
  51440. shader: string;
  51441. };
  51442. }
  51443. declare module BABYLON {
  51444. /** @hidden */
  51445. export var pbrBlockClearcoat: {
  51446. name: string;
  51447. shader: string;
  51448. };
  51449. }
  51450. declare module BABYLON {
  51451. /** @hidden */
  51452. export var pbrBlockSubSurface: {
  51453. name: string;
  51454. shader: string;
  51455. };
  51456. }
  51457. declare module BABYLON {
  51458. /** @hidden */
  51459. export var pbrBlockNormalGeometric: {
  51460. name: string;
  51461. shader: string;
  51462. };
  51463. }
  51464. declare module BABYLON {
  51465. /** @hidden */
  51466. export var pbrBlockNormalFinal: {
  51467. name: string;
  51468. shader: string;
  51469. };
  51470. }
  51471. declare module BABYLON {
  51472. /** @hidden */
  51473. export var pbrBlockGeometryInfo: {
  51474. name: string;
  51475. shader: string;
  51476. };
  51477. }
  51478. declare module BABYLON {
  51479. /** @hidden */
  51480. export var pbrBlockReflectance0: {
  51481. name: string;
  51482. shader: string;
  51483. };
  51484. }
  51485. declare module BABYLON {
  51486. /** @hidden */
  51487. export var pbrBlockReflectance: {
  51488. name: string;
  51489. shader: string;
  51490. };
  51491. }
  51492. declare module BABYLON {
  51493. /** @hidden */
  51494. export var pbrBlockDirectLighting: {
  51495. name: string;
  51496. shader: string;
  51497. };
  51498. }
  51499. declare module BABYLON {
  51500. /** @hidden */
  51501. export var pbrBlockFinalLitComponents: {
  51502. name: string;
  51503. shader: string;
  51504. };
  51505. }
  51506. declare module BABYLON {
  51507. /** @hidden */
  51508. export var pbrBlockFinalUnlitComponents: {
  51509. name: string;
  51510. shader: string;
  51511. };
  51512. }
  51513. declare module BABYLON {
  51514. /** @hidden */
  51515. export var pbrBlockFinalColorComposition: {
  51516. name: string;
  51517. shader: string;
  51518. };
  51519. }
  51520. declare module BABYLON {
  51521. /** @hidden */
  51522. export var pbrBlockImageProcessing: {
  51523. name: string;
  51524. shader: string;
  51525. };
  51526. }
  51527. declare module BABYLON {
  51528. /** @hidden */
  51529. export var pbrDebug: {
  51530. name: string;
  51531. shader: string;
  51532. };
  51533. }
  51534. declare module BABYLON {
  51535. /** @hidden */
  51536. export var pbrPixelShader: {
  51537. name: string;
  51538. shader: string;
  51539. };
  51540. }
  51541. declare module BABYLON {
  51542. /** @hidden */
  51543. export var pbrVertexDeclaration: {
  51544. name: string;
  51545. shader: string;
  51546. };
  51547. }
  51548. declare module BABYLON {
  51549. /** @hidden */
  51550. export var pbrVertexShader: {
  51551. name: string;
  51552. shader: string;
  51553. };
  51554. }
  51555. declare module BABYLON {
  51556. /**
  51557. * Manages the defines for the PBR Material.
  51558. * @hidden
  51559. */
  51560. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51561. PBR: boolean;
  51562. MAINUV1: boolean;
  51563. MAINUV2: boolean;
  51564. UV1: boolean;
  51565. UV2: boolean;
  51566. ALBEDO: boolean;
  51567. GAMMAALBEDO: boolean;
  51568. ALBEDODIRECTUV: number;
  51569. VERTEXCOLOR: boolean;
  51570. AMBIENT: boolean;
  51571. AMBIENTDIRECTUV: number;
  51572. AMBIENTINGRAYSCALE: boolean;
  51573. OPACITY: boolean;
  51574. VERTEXALPHA: boolean;
  51575. OPACITYDIRECTUV: number;
  51576. OPACITYRGB: boolean;
  51577. ALPHATEST: boolean;
  51578. DEPTHPREPASS: boolean;
  51579. ALPHABLEND: boolean;
  51580. ALPHAFROMALBEDO: boolean;
  51581. ALPHATESTVALUE: string;
  51582. SPECULAROVERALPHA: boolean;
  51583. RADIANCEOVERALPHA: boolean;
  51584. ALPHAFRESNEL: boolean;
  51585. LINEARALPHAFRESNEL: boolean;
  51586. PREMULTIPLYALPHA: boolean;
  51587. EMISSIVE: boolean;
  51588. EMISSIVEDIRECTUV: number;
  51589. REFLECTIVITY: boolean;
  51590. REFLECTIVITYDIRECTUV: number;
  51591. SPECULARTERM: boolean;
  51592. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51593. MICROSURFACEAUTOMATIC: boolean;
  51594. LODBASEDMICROSFURACE: boolean;
  51595. MICROSURFACEMAP: boolean;
  51596. MICROSURFACEMAPDIRECTUV: number;
  51597. METALLICWORKFLOW: boolean;
  51598. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51599. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51600. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51601. AOSTOREINMETALMAPRED: boolean;
  51602. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51603. ENVIRONMENTBRDF: boolean;
  51604. ENVIRONMENTBRDF_RGBD: boolean;
  51605. NORMAL: boolean;
  51606. TANGENT: boolean;
  51607. BUMP: boolean;
  51608. BUMPDIRECTUV: number;
  51609. OBJECTSPACE_NORMALMAP: boolean;
  51610. PARALLAX: boolean;
  51611. PARALLAXOCCLUSION: boolean;
  51612. NORMALXYSCALE: boolean;
  51613. LIGHTMAP: boolean;
  51614. LIGHTMAPDIRECTUV: number;
  51615. USELIGHTMAPASSHADOWMAP: boolean;
  51616. GAMMALIGHTMAP: boolean;
  51617. RGBDLIGHTMAP: boolean;
  51618. REFLECTION: boolean;
  51619. REFLECTIONMAP_3D: boolean;
  51620. REFLECTIONMAP_SPHERICAL: boolean;
  51621. REFLECTIONMAP_PLANAR: boolean;
  51622. REFLECTIONMAP_CUBIC: boolean;
  51623. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51624. REFLECTIONMAP_PROJECTION: boolean;
  51625. REFLECTIONMAP_SKYBOX: boolean;
  51626. REFLECTIONMAP_EXPLICIT: boolean;
  51627. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51628. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51629. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51630. INVERTCUBICMAP: boolean;
  51631. USESPHERICALFROMREFLECTIONMAP: boolean;
  51632. USEIRRADIANCEMAP: boolean;
  51633. SPHERICAL_HARMONICS: boolean;
  51634. USESPHERICALINVERTEX: boolean;
  51635. REFLECTIONMAP_OPPOSITEZ: boolean;
  51636. LODINREFLECTIONALPHA: boolean;
  51637. GAMMAREFLECTION: boolean;
  51638. RGBDREFLECTION: boolean;
  51639. LINEARSPECULARREFLECTION: boolean;
  51640. RADIANCEOCCLUSION: boolean;
  51641. HORIZONOCCLUSION: boolean;
  51642. INSTANCES: boolean;
  51643. NUM_BONE_INFLUENCERS: number;
  51644. BonesPerMesh: number;
  51645. BONETEXTURE: boolean;
  51646. NONUNIFORMSCALING: boolean;
  51647. MORPHTARGETS: boolean;
  51648. MORPHTARGETS_NORMAL: boolean;
  51649. MORPHTARGETS_TANGENT: boolean;
  51650. MORPHTARGETS_UV: boolean;
  51651. NUM_MORPH_INFLUENCERS: number;
  51652. IMAGEPROCESSING: boolean;
  51653. VIGNETTE: boolean;
  51654. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51655. VIGNETTEBLENDMODEOPAQUE: boolean;
  51656. TONEMAPPING: boolean;
  51657. TONEMAPPING_ACES: boolean;
  51658. CONTRAST: boolean;
  51659. COLORCURVES: boolean;
  51660. COLORGRADING: boolean;
  51661. COLORGRADING3D: boolean;
  51662. SAMPLER3DGREENDEPTH: boolean;
  51663. SAMPLER3DBGRMAP: boolean;
  51664. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51665. EXPOSURE: boolean;
  51666. MULTIVIEW: boolean;
  51667. USEPHYSICALLIGHTFALLOFF: boolean;
  51668. USEGLTFLIGHTFALLOFF: boolean;
  51669. TWOSIDEDLIGHTING: boolean;
  51670. SHADOWFLOAT: boolean;
  51671. CLIPPLANE: boolean;
  51672. CLIPPLANE2: boolean;
  51673. CLIPPLANE3: boolean;
  51674. CLIPPLANE4: boolean;
  51675. CLIPPLANE5: boolean;
  51676. CLIPPLANE6: boolean;
  51677. POINTSIZE: boolean;
  51678. FOG: boolean;
  51679. LOGARITHMICDEPTH: boolean;
  51680. FORCENORMALFORWARD: boolean;
  51681. SPECULARAA: boolean;
  51682. CLEARCOAT: boolean;
  51683. CLEARCOAT_DEFAULTIOR: boolean;
  51684. CLEARCOAT_TEXTURE: boolean;
  51685. CLEARCOAT_TEXTUREDIRECTUV: number;
  51686. CLEARCOAT_BUMP: boolean;
  51687. CLEARCOAT_BUMPDIRECTUV: number;
  51688. CLEARCOAT_TINT: boolean;
  51689. CLEARCOAT_TINT_TEXTURE: boolean;
  51690. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51691. ANISOTROPIC: boolean;
  51692. ANISOTROPIC_TEXTURE: boolean;
  51693. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51694. BRDF_V_HEIGHT_CORRELATED: boolean;
  51695. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51696. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51697. SHEEN: boolean;
  51698. SHEEN_TEXTURE: boolean;
  51699. SHEEN_TEXTUREDIRECTUV: number;
  51700. SHEEN_LINKWITHALBEDO: boolean;
  51701. SHEEN_ROUGHNESS: boolean;
  51702. SHEEN_ALBEDOSCALING: boolean;
  51703. SUBSURFACE: boolean;
  51704. SS_REFRACTION: boolean;
  51705. SS_TRANSLUCENCY: boolean;
  51706. SS_SCATERRING: boolean;
  51707. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51708. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51709. SS_REFRACTIONMAP_3D: boolean;
  51710. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51711. SS_LODINREFRACTIONALPHA: boolean;
  51712. SS_GAMMAREFRACTION: boolean;
  51713. SS_RGBDREFRACTION: boolean;
  51714. SS_LINEARSPECULARREFRACTION: boolean;
  51715. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51716. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51717. UNLIT: boolean;
  51718. DEBUGMODE: number;
  51719. /**
  51720. * Initializes the PBR Material defines.
  51721. */
  51722. constructor();
  51723. /**
  51724. * Resets the PBR Material defines.
  51725. */
  51726. reset(): void;
  51727. }
  51728. /**
  51729. * The Physically based material base class of BJS.
  51730. *
  51731. * This offers the main features of a standard PBR material.
  51732. * For more information, please refer to the documentation :
  51733. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51734. */
  51735. export abstract class PBRBaseMaterial extends PushMaterial {
  51736. /**
  51737. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51738. */
  51739. static readonly PBRMATERIAL_OPAQUE: number;
  51740. /**
  51741. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51742. */
  51743. static readonly PBRMATERIAL_ALPHATEST: number;
  51744. /**
  51745. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51746. */
  51747. static readonly PBRMATERIAL_ALPHABLEND: number;
  51748. /**
  51749. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51750. * They are also discarded below the alpha cutoff threshold to improve performances.
  51751. */
  51752. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51753. /**
  51754. * Defines the default value of how much AO map is occluding the analytical lights
  51755. * (point spot...).
  51756. */
  51757. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51758. /**
  51759. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51760. */
  51761. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51762. /**
  51763. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51764. * to enhance interoperability with other engines.
  51765. */
  51766. static readonly LIGHTFALLOFF_GLTF: number;
  51767. /**
  51768. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51769. * to enhance interoperability with other materials.
  51770. */
  51771. static readonly LIGHTFALLOFF_STANDARD: number;
  51772. /**
  51773. * Intensity of the direct lights e.g. the four lights available in your scene.
  51774. * This impacts both the direct diffuse and specular highlights.
  51775. */
  51776. protected _directIntensity: number;
  51777. /**
  51778. * Intensity of the emissive part of the material.
  51779. * This helps controlling the emissive effect without modifying the emissive color.
  51780. */
  51781. protected _emissiveIntensity: number;
  51782. /**
  51783. * Intensity of the environment e.g. how much the environment will light the object
  51784. * either through harmonics for rough material or through the refelction for shiny ones.
  51785. */
  51786. protected _environmentIntensity: number;
  51787. /**
  51788. * This is a special control allowing the reduction of the specular highlights coming from the
  51789. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51790. */
  51791. protected _specularIntensity: number;
  51792. /**
  51793. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51794. */
  51795. private _lightingInfos;
  51796. /**
  51797. * Debug Control allowing disabling the bump map on this material.
  51798. */
  51799. protected _disableBumpMap: boolean;
  51800. /**
  51801. * AKA Diffuse Texture in standard nomenclature.
  51802. */
  51803. protected _albedoTexture: Nullable<BaseTexture>;
  51804. /**
  51805. * AKA Occlusion Texture in other nomenclature.
  51806. */
  51807. protected _ambientTexture: Nullable<BaseTexture>;
  51808. /**
  51809. * AKA Occlusion Texture Intensity in other nomenclature.
  51810. */
  51811. protected _ambientTextureStrength: number;
  51812. /**
  51813. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51814. * 1 means it completely occludes it
  51815. * 0 mean it has no impact
  51816. */
  51817. protected _ambientTextureImpactOnAnalyticalLights: number;
  51818. /**
  51819. * Stores the alpha values in a texture.
  51820. */
  51821. protected _opacityTexture: Nullable<BaseTexture>;
  51822. /**
  51823. * Stores the reflection values in a texture.
  51824. */
  51825. protected _reflectionTexture: Nullable<BaseTexture>;
  51826. /**
  51827. * Stores the emissive values in a texture.
  51828. */
  51829. protected _emissiveTexture: Nullable<BaseTexture>;
  51830. /**
  51831. * AKA Specular texture in other nomenclature.
  51832. */
  51833. protected _reflectivityTexture: Nullable<BaseTexture>;
  51834. /**
  51835. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51836. */
  51837. protected _metallicTexture: Nullable<BaseTexture>;
  51838. /**
  51839. * Specifies the metallic scalar of the metallic/roughness workflow.
  51840. * Can also be used to scale the metalness values of the metallic texture.
  51841. */
  51842. protected _metallic: Nullable<number>;
  51843. /**
  51844. * Specifies the roughness scalar of the metallic/roughness workflow.
  51845. * Can also be used to scale the roughness values of the metallic texture.
  51846. */
  51847. protected _roughness: Nullable<number>;
  51848. /**
  51849. * Specifies the an F0 factor to help configuring the material F0.
  51850. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51851. * to 0.5 the previously hard coded value stays the same.
  51852. * Can also be used to scale the F0 values of the metallic texture.
  51853. */
  51854. protected _metallicF0Factor: number;
  51855. /**
  51856. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51857. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51858. * your expectation as it multiplies with the texture data.
  51859. */
  51860. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51861. /**
  51862. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51863. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51864. */
  51865. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51866. /**
  51867. * Stores surface normal data used to displace a mesh in a texture.
  51868. */
  51869. protected _bumpTexture: Nullable<BaseTexture>;
  51870. /**
  51871. * Stores the pre-calculated light information of a mesh in a texture.
  51872. */
  51873. protected _lightmapTexture: Nullable<BaseTexture>;
  51874. /**
  51875. * The color of a material in ambient lighting.
  51876. */
  51877. protected _ambientColor: Color3;
  51878. /**
  51879. * AKA Diffuse Color in other nomenclature.
  51880. */
  51881. protected _albedoColor: Color3;
  51882. /**
  51883. * AKA Specular Color in other nomenclature.
  51884. */
  51885. protected _reflectivityColor: Color3;
  51886. /**
  51887. * The color applied when light is reflected from a material.
  51888. */
  51889. protected _reflectionColor: Color3;
  51890. /**
  51891. * The color applied when light is emitted from a material.
  51892. */
  51893. protected _emissiveColor: Color3;
  51894. /**
  51895. * AKA Glossiness in other nomenclature.
  51896. */
  51897. protected _microSurface: number;
  51898. /**
  51899. * Specifies that the material will use the light map as a show map.
  51900. */
  51901. protected _useLightmapAsShadowmap: boolean;
  51902. /**
  51903. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51904. * makes the reflect vector face the model (under horizon).
  51905. */
  51906. protected _useHorizonOcclusion: boolean;
  51907. /**
  51908. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51909. * too much the area relying on ambient texture to define their ambient occlusion.
  51910. */
  51911. protected _useRadianceOcclusion: boolean;
  51912. /**
  51913. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51914. */
  51915. protected _useAlphaFromAlbedoTexture: boolean;
  51916. /**
  51917. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51918. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51919. */
  51920. protected _useSpecularOverAlpha: boolean;
  51921. /**
  51922. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51923. */
  51924. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51925. /**
  51926. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51927. */
  51928. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51929. /**
  51930. * Specifies if the metallic texture contains the roughness information in its green channel.
  51931. */
  51932. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51933. /**
  51934. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51935. */
  51936. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51937. /**
  51938. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51939. */
  51940. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51941. /**
  51942. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51943. */
  51944. protected _useAmbientInGrayScale: boolean;
  51945. /**
  51946. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51947. * The material will try to infer what glossiness each pixel should be.
  51948. */
  51949. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51950. /**
  51951. * Defines the falloff type used in this material.
  51952. * It by default is Physical.
  51953. */
  51954. protected _lightFalloff: number;
  51955. /**
  51956. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51957. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51958. */
  51959. protected _useRadianceOverAlpha: boolean;
  51960. /**
  51961. * Allows using an object space normal map (instead of tangent space).
  51962. */
  51963. protected _useObjectSpaceNormalMap: boolean;
  51964. /**
  51965. * Allows using the bump map in parallax mode.
  51966. */
  51967. protected _useParallax: boolean;
  51968. /**
  51969. * Allows using the bump map in parallax occlusion mode.
  51970. */
  51971. protected _useParallaxOcclusion: boolean;
  51972. /**
  51973. * Controls the scale bias of the parallax mode.
  51974. */
  51975. protected _parallaxScaleBias: number;
  51976. /**
  51977. * If sets to true, disables all the lights affecting the material.
  51978. */
  51979. protected _disableLighting: boolean;
  51980. /**
  51981. * Number of Simultaneous lights allowed on the material.
  51982. */
  51983. protected _maxSimultaneousLights: number;
  51984. /**
  51985. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51986. */
  51987. protected _invertNormalMapX: boolean;
  51988. /**
  51989. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51990. */
  51991. protected _invertNormalMapY: boolean;
  51992. /**
  51993. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51994. */
  51995. protected _twoSidedLighting: boolean;
  51996. /**
  51997. * Defines the alpha limits in alpha test mode.
  51998. */
  51999. protected _alphaCutOff: number;
  52000. /**
  52001. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52002. */
  52003. protected _forceAlphaTest: boolean;
  52004. /**
  52005. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52006. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52007. */
  52008. protected _useAlphaFresnel: boolean;
  52009. /**
  52010. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52011. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52012. */
  52013. protected _useLinearAlphaFresnel: boolean;
  52014. /**
  52015. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52016. * from cos thetav and roughness:
  52017. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52018. */
  52019. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52020. /**
  52021. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52022. */
  52023. protected _forceIrradianceInFragment: boolean;
  52024. /**
  52025. * Force normal to face away from face.
  52026. */
  52027. protected _forceNormalForward: boolean;
  52028. /**
  52029. * Enables specular anti aliasing in the PBR shader.
  52030. * It will both interacts on the Geometry for analytical and IBL lighting.
  52031. * It also prefilter the roughness map based on the bump values.
  52032. */
  52033. protected _enableSpecularAntiAliasing: boolean;
  52034. /**
  52035. * Default configuration related to image processing available in the PBR Material.
  52036. */
  52037. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52038. /**
  52039. * Keep track of the image processing observer to allow dispose and replace.
  52040. */
  52041. private _imageProcessingObserver;
  52042. /**
  52043. * Attaches a new image processing configuration to the PBR Material.
  52044. * @param configuration
  52045. */
  52046. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52047. /**
  52048. * Stores the available render targets.
  52049. */
  52050. private _renderTargets;
  52051. /**
  52052. * Sets the global ambient color for the material used in lighting calculations.
  52053. */
  52054. private _globalAmbientColor;
  52055. /**
  52056. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52057. */
  52058. private _useLogarithmicDepth;
  52059. /**
  52060. * If set to true, no lighting calculations will be applied.
  52061. */
  52062. private _unlit;
  52063. private _debugMode;
  52064. /**
  52065. * @hidden
  52066. * This is reserved for the inspector.
  52067. * Defines the material debug mode.
  52068. * It helps seeing only some components of the material while troubleshooting.
  52069. */
  52070. debugMode: number;
  52071. /**
  52072. * @hidden
  52073. * This is reserved for the inspector.
  52074. * Specify from where on screen the debug mode should start.
  52075. * The value goes from -1 (full screen) to 1 (not visible)
  52076. * It helps with side by side comparison against the final render
  52077. * This defaults to -1
  52078. */
  52079. private debugLimit;
  52080. /**
  52081. * @hidden
  52082. * This is reserved for the inspector.
  52083. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52084. * You can use the factor to better multiply the final value.
  52085. */
  52086. private debugFactor;
  52087. /**
  52088. * Defines the clear coat layer parameters for the material.
  52089. */
  52090. readonly clearCoat: PBRClearCoatConfiguration;
  52091. /**
  52092. * Defines the anisotropic parameters for the material.
  52093. */
  52094. readonly anisotropy: PBRAnisotropicConfiguration;
  52095. /**
  52096. * Defines the BRDF parameters for the material.
  52097. */
  52098. readonly brdf: PBRBRDFConfiguration;
  52099. /**
  52100. * Defines the Sheen parameters for the material.
  52101. */
  52102. readonly sheen: PBRSheenConfiguration;
  52103. /**
  52104. * Defines the SubSurface parameters for the material.
  52105. */
  52106. readonly subSurface: PBRSubSurfaceConfiguration;
  52107. protected _rebuildInParallel: boolean;
  52108. /**
  52109. * Instantiates a new PBRMaterial instance.
  52110. *
  52111. * @param name The material name
  52112. * @param scene The scene the material will be use in.
  52113. */
  52114. constructor(name: string, scene: Scene);
  52115. /**
  52116. * Gets a boolean indicating that current material needs to register RTT
  52117. */
  52118. get hasRenderTargetTextures(): boolean;
  52119. /**
  52120. * Gets the name of the material class.
  52121. */
  52122. getClassName(): string;
  52123. /**
  52124. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52125. */
  52126. get useLogarithmicDepth(): boolean;
  52127. /**
  52128. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52129. */
  52130. set useLogarithmicDepth(value: boolean);
  52131. /**
  52132. * Returns true if alpha blending should be disabled.
  52133. */
  52134. protected get _disableAlphaBlending(): boolean;
  52135. /**
  52136. * Specifies whether or not this material should be rendered in alpha blend mode.
  52137. */
  52138. needAlphaBlending(): boolean;
  52139. /**
  52140. * Specifies whether or not this material should be rendered in alpha test mode.
  52141. */
  52142. needAlphaTesting(): boolean;
  52143. /**
  52144. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52145. */
  52146. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52147. /**
  52148. * Gets the texture used for the alpha test.
  52149. */
  52150. getAlphaTestTexture(): Nullable<BaseTexture>;
  52151. /**
  52152. * Specifies that the submesh is ready to be used.
  52153. * @param mesh - BJS mesh.
  52154. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52155. * @param useInstances - Specifies that instances should be used.
  52156. * @returns - boolean indicating that the submesh is ready or not.
  52157. */
  52158. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52159. /**
  52160. * Specifies if the material uses metallic roughness workflow.
  52161. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52162. */
  52163. isMetallicWorkflow(): boolean;
  52164. private _prepareEffect;
  52165. private _prepareDefines;
  52166. /**
  52167. * Force shader compilation
  52168. */
  52169. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52170. /**
  52171. * Initializes the uniform buffer layout for the shader.
  52172. */
  52173. buildUniformLayout(): void;
  52174. /**
  52175. * Unbinds the material from the mesh
  52176. */
  52177. unbind(): void;
  52178. /**
  52179. * Binds the submesh data.
  52180. * @param world - The world matrix.
  52181. * @param mesh - The BJS mesh.
  52182. * @param subMesh - A submesh of the BJS mesh.
  52183. */
  52184. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52185. /**
  52186. * Returns the animatable textures.
  52187. * @returns - Array of animatable textures.
  52188. */
  52189. getAnimatables(): IAnimatable[];
  52190. /**
  52191. * Returns the texture used for reflections.
  52192. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52193. */
  52194. private _getReflectionTexture;
  52195. /**
  52196. * Returns an array of the actively used textures.
  52197. * @returns - Array of BaseTextures
  52198. */
  52199. getActiveTextures(): BaseTexture[];
  52200. /**
  52201. * Checks to see if a texture is used in the material.
  52202. * @param texture - Base texture to use.
  52203. * @returns - Boolean specifying if a texture is used in the material.
  52204. */
  52205. hasTexture(texture: BaseTexture): boolean;
  52206. /**
  52207. * Disposes the resources of the material.
  52208. * @param forceDisposeEffect - Forces the disposal of effects.
  52209. * @param forceDisposeTextures - Forces the disposal of all textures.
  52210. */
  52211. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52212. }
  52213. }
  52214. declare module BABYLON {
  52215. /**
  52216. * The Physically based material of BJS.
  52217. *
  52218. * This offers the main features of a standard PBR material.
  52219. * For more information, please refer to the documentation :
  52220. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52221. */
  52222. export class PBRMaterial extends PBRBaseMaterial {
  52223. /**
  52224. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52225. */
  52226. static readonly PBRMATERIAL_OPAQUE: number;
  52227. /**
  52228. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52229. */
  52230. static readonly PBRMATERIAL_ALPHATEST: number;
  52231. /**
  52232. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52233. */
  52234. static readonly PBRMATERIAL_ALPHABLEND: number;
  52235. /**
  52236. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52237. * They are also discarded below the alpha cutoff threshold to improve performances.
  52238. */
  52239. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52240. /**
  52241. * Defines the default value of how much AO map is occluding the analytical lights
  52242. * (point spot...).
  52243. */
  52244. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52245. /**
  52246. * Intensity of the direct lights e.g. the four lights available in your scene.
  52247. * This impacts both the direct diffuse and specular highlights.
  52248. */
  52249. directIntensity: number;
  52250. /**
  52251. * Intensity of the emissive part of the material.
  52252. * This helps controlling the emissive effect without modifying the emissive color.
  52253. */
  52254. emissiveIntensity: number;
  52255. /**
  52256. * Intensity of the environment e.g. how much the environment will light the object
  52257. * either through harmonics for rough material or through the refelction for shiny ones.
  52258. */
  52259. environmentIntensity: number;
  52260. /**
  52261. * This is a special control allowing the reduction of the specular highlights coming from the
  52262. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52263. */
  52264. specularIntensity: number;
  52265. /**
  52266. * Debug Control allowing disabling the bump map on this material.
  52267. */
  52268. disableBumpMap: boolean;
  52269. /**
  52270. * AKA Diffuse Texture in standard nomenclature.
  52271. */
  52272. albedoTexture: BaseTexture;
  52273. /**
  52274. * AKA Occlusion Texture in other nomenclature.
  52275. */
  52276. ambientTexture: BaseTexture;
  52277. /**
  52278. * AKA Occlusion Texture Intensity in other nomenclature.
  52279. */
  52280. ambientTextureStrength: number;
  52281. /**
  52282. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52283. * 1 means it completely occludes it
  52284. * 0 mean it has no impact
  52285. */
  52286. ambientTextureImpactOnAnalyticalLights: number;
  52287. /**
  52288. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52289. */
  52290. opacityTexture: BaseTexture;
  52291. /**
  52292. * Stores the reflection values in a texture.
  52293. */
  52294. reflectionTexture: Nullable<BaseTexture>;
  52295. /**
  52296. * Stores the emissive values in a texture.
  52297. */
  52298. emissiveTexture: BaseTexture;
  52299. /**
  52300. * AKA Specular texture in other nomenclature.
  52301. */
  52302. reflectivityTexture: BaseTexture;
  52303. /**
  52304. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52305. */
  52306. metallicTexture: BaseTexture;
  52307. /**
  52308. * Specifies the metallic scalar of the metallic/roughness workflow.
  52309. * Can also be used to scale the metalness values of the metallic texture.
  52310. */
  52311. metallic: Nullable<number>;
  52312. /**
  52313. * Specifies the roughness scalar of the metallic/roughness workflow.
  52314. * Can also be used to scale the roughness values of the metallic texture.
  52315. */
  52316. roughness: Nullable<number>;
  52317. /**
  52318. * Specifies the an F0 factor to help configuring the material F0.
  52319. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52320. * to 0.5 the previously hard coded value stays the same.
  52321. * Can also be used to scale the F0 values of the metallic texture.
  52322. */
  52323. metallicF0Factor: number;
  52324. /**
  52325. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52326. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52327. * your expectation as it multiplies with the texture data.
  52328. */
  52329. useMetallicF0FactorFromMetallicTexture: boolean;
  52330. /**
  52331. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52332. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52333. */
  52334. microSurfaceTexture: BaseTexture;
  52335. /**
  52336. * Stores surface normal data used to displace a mesh in a texture.
  52337. */
  52338. bumpTexture: BaseTexture;
  52339. /**
  52340. * Stores the pre-calculated light information of a mesh in a texture.
  52341. */
  52342. lightmapTexture: BaseTexture;
  52343. /**
  52344. * Stores the refracted light information in a texture.
  52345. */
  52346. get refractionTexture(): Nullable<BaseTexture>;
  52347. set refractionTexture(value: Nullable<BaseTexture>);
  52348. /**
  52349. * The color of a material in ambient lighting.
  52350. */
  52351. ambientColor: Color3;
  52352. /**
  52353. * AKA Diffuse Color in other nomenclature.
  52354. */
  52355. albedoColor: Color3;
  52356. /**
  52357. * AKA Specular Color in other nomenclature.
  52358. */
  52359. reflectivityColor: Color3;
  52360. /**
  52361. * The color reflected from the material.
  52362. */
  52363. reflectionColor: Color3;
  52364. /**
  52365. * The color emitted from the material.
  52366. */
  52367. emissiveColor: Color3;
  52368. /**
  52369. * AKA Glossiness in other nomenclature.
  52370. */
  52371. microSurface: number;
  52372. /**
  52373. * source material index of refraction (IOR)' / 'destination material IOR.
  52374. */
  52375. get indexOfRefraction(): number;
  52376. set indexOfRefraction(value: number);
  52377. /**
  52378. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52379. */
  52380. get invertRefractionY(): boolean;
  52381. set invertRefractionY(value: boolean);
  52382. /**
  52383. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52384. * Materials half opaque for instance using refraction could benefit from this control.
  52385. */
  52386. get linkRefractionWithTransparency(): boolean;
  52387. set linkRefractionWithTransparency(value: boolean);
  52388. /**
  52389. * If true, the light map contains occlusion information instead of lighting info.
  52390. */
  52391. useLightmapAsShadowmap: boolean;
  52392. /**
  52393. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52394. */
  52395. useAlphaFromAlbedoTexture: boolean;
  52396. /**
  52397. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52398. */
  52399. forceAlphaTest: boolean;
  52400. /**
  52401. * Defines the alpha limits in alpha test mode.
  52402. */
  52403. alphaCutOff: number;
  52404. /**
  52405. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52406. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52407. */
  52408. useSpecularOverAlpha: boolean;
  52409. /**
  52410. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52411. */
  52412. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52413. /**
  52414. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52415. */
  52416. useRoughnessFromMetallicTextureAlpha: boolean;
  52417. /**
  52418. * Specifies if the metallic texture contains the roughness information in its green channel.
  52419. */
  52420. useRoughnessFromMetallicTextureGreen: boolean;
  52421. /**
  52422. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52423. */
  52424. useMetallnessFromMetallicTextureBlue: boolean;
  52425. /**
  52426. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52427. */
  52428. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52429. /**
  52430. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52431. */
  52432. useAmbientInGrayScale: boolean;
  52433. /**
  52434. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52435. * The material will try to infer what glossiness each pixel should be.
  52436. */
  52437. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52438. /**
  52439. * BJS is using an harcoded light falloff based on a manually sets up range.
  52440. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52441. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52442. */
  52443. get usePhysicalLightFalloff(): boolean;
  52444. /**
  52445. * BJS is using an harcoded light falloff based on a manually sets up range.
  52446. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52447. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52448. */
  52449. set usePhysicalLightFalloff(value: boolean);
  52450. /**
  52451. * In order to support the falloff compatibility with gltf, a special mode has been added
  52452. * to reproduce the gltf light falloff.
  52453. */
  52454. get useGLTFLightFalloff(): boolean;
  52455. /**
  52456. * In order to support the falloff compatibility with gltf, a special mode has been added
  52457. * to reproduce the gltf light falloff.
  52458. */
  52459. set useGLTFLightFalloff(value: boolean);
  52460. /**
  52461. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52462. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52463. */
  52464. useRadianceOverAlpha: boolean;
  52465. /**
  52466. * Allows using an object space normal map (instead of tangent space).
  52467. */
  52468. useObjectSpaceNormalMap: boolean;
  52469. /**
  52470. * Allows using the bump map in parallax mode.
  52471. */
  52472. useParallax: boolean;
  52473. /**
  52474. * Allows using the bump map in parallax occlusion mode.
  52475. */
  52476. useParallaxOcclusion: boolean;
  52477. /**
  52478. * Controls the scale bias of the parallax mode.
  52479. */
  52480. parallaxScaleBias: number;
  52481. /**
  52482. * If sets to true, disables all the lights affecting the material.
  52483. */
  52484. disableLighting: boolean;
  52485. /**
  52486. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52487. */
  52488. forceIrradianceInFragment: boolean;
  52489. /**
  52490. * Number of Simultaneous lights allowed on the material.
  52491. */
  52492. maxSimultaneousLights: number;
  52493. /**
  52494. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52495. */
  52496. invertNormalMapX: boolean;
  52497. /**
  52498. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52499. */
  52500. invertNormalMapY: boolean;
  52501. /**
  52502. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52503. */
  52504. twoSidedLighting: boolean;
  52505. /**
  52506. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52507. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52508. */
  52509. useAlphaFresnel: boolean;
  52510. /**
  52511. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52512. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52513. */
  52514. useLinearAlphaFresnel: boolean;
  52515. /**
  52516. * Let user defines the brdf lookup texture used for IBL.
  52517. * A default 8bit version is embedded but you could point at :
  52518. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52519. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52520. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52521. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52522. */
  52523. environmentBRDFTexture: Nullable<BaseTexture>;
  52524. /**
  52525. * Force normal to face away from face.
  52526. */
  52527. forceNormalForward: boolean;
  52528. /**
  52529. * Enables specular anti aliasing in the PBR shader.
  52530. * It will both interacts on the Geometry for analytical and IBL lighting.
  52531. * It also prefilter the roughness map based on the bump values.
  52532. */
  52533. enableSpecularAntiAliasing: boolean;
  52534. /**
  52535. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52536. * makes the reflect vector face the model (under horizon).
  52537. */
  52538. useHorizonOcclusion: boolean;
  52539. /**
  52540. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52541. * too much the area relying on ambient texture to define their ambient occlusion.
  52542. */
  52543. useRadianceOcclusion: boolean;
  52544. /**
  52545. * If set to true, no lighting calculations will be applied.
  52546. */
  52547. unlit: boolean;
  52548. /**
  52549. * Gets the image processing configuration used either in this material.
  52550. */
  52551. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52552. /**
  52553. * Sets the Default image processing configuration used either in the this material.
  52554. *
  52555. * If sets to null, the scene one is in use.
  52556. */
  52557. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52558. /**
  52559. * Gets wether the color curves effect is enabled.
  52560. */
  52561. get cameraColorCurvesEnabled(): boolean;
  52562. /**
  52563. * Sets wether the color curves effect is enabled.
  52564. */
  52565. set cameraColorCurvesEnabled(value: boolean);
  52566. /**
  52567. * Gets wether the color grading effect is enabled.
  52568. */
  52569. get cameraColorGradingEnabled(): boolean;
  52570. /**
  52571. * Gets wether the color grading effect is enabled.
  52572. */
  52573. set cameraColorGradingEnabled(value: boolean);
  52574. /**
  52575. * Gets wether tonemapping is enabled or not.
  52576. */
  52577. get cameraToneMappingEnabled(): boolean;
  52578. /**
  52579. * Sets wether tonemapping is enabled or not
  52580. */
  52581. set cameraToneMappingEnabled(value: boolean);
  52582. /**
  52583. * The camera exposure used on this material.
  52584. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52585. * This corresponds to a photographic exposure.
  52586. */
  52587. get cameraExposure(): number;
  52588. /**
  52589. * The camera exposure used on this material.
  52590. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52591. * This corresponds to a photographic exposure.
  52592. */
  52593. set cameraExposure(value: number);
  52594. /**
  52595. * Gets The camera contrast used on this material.
  52596. */
  52597. get cameraContrast(): number;
  52598. /**
  52599. * Sets The camera contrast used on this material.
  52600. */
  52601. set cameraContrast(value: number);
  52602. /**
  52603. * Gets the Color Grading 2D Lookup Texture.
  52604. */
  52605. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52606. /**
  52607. * Sets the Color Grading 2D Lookup Texture.
  52608. */
  52609. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52610. /**
  52611. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52612. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52613. * 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;
  52614. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52615. */
  52616. get cameraColorCurves(): Nullable<ColorCurves>;
  52617. /**
  52618. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52619. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52620. * 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;
  52621. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52622. */
  52623. set cameraColorCurves(value: Nullable<ColorCurves>);
  52624. /**
  52625. * Instantiates a new PBRMaterial instance.
  52626. *
  52627. * @param name The material name
  52628. * @param scene The scene the material will be use in.
  52629. */
  52630. constructor(name: string, scene: Scene);
  52631. /**
  52632. * Returns the name of this material class.
  52633. */
  52634. getClassName(): string;
  52635. /**
  52636. * Makes a duplicate of the current material.
  52637. * @param name - name to use for the new material.
  52638. */
  52639. clone(name: string): PBRMaterial;
  52640. /**
  52641. * Serializes this PBR Material.
  52642. * @returns - An object with the serialized material.
  52643. */
  52644. serialize(): any;
  52645. /**
  52646. * Parses a PBR Material from a serialized object.
  52647. * @param source - Serialized object.
  52648. * @param scene - BJS scene instance.
  52649. * @param rootUrl - url for the scene object
  52650. * @returns - PBRMaterial
  52651. */
  52652. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52653. }
  52654. }
  52655. declare module BABYLON {
  52656. /**
  52657. * Direct draw surface info
  52658. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52659. */
  52660. export interface DDSInfo {
  52661. /**
  52662. * Width of the texture
  52663. */
  52664. width: number;
  52665. /**
  52666. * Width of the texture
  52667. */
  52668. height: number;
  52669. /**
  52670. * Number of Mipmaps for the texture
  52671. * @see https://en.wikipedia.org/wiki/Mipmap
  52672. */
  52673. mipmapCount: number;
  52674. /**
  52675. * If the textures format is a known fourCC format
  52676. * @see https://www.fourcc.org/
  52677. */
  52678. isFourCC: boolean;
  52679. /**
  52680. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52681. */
  52682. isRGB: boolean;
  52683. /**
  52684. * If the texture is a lumincance format
  52685. */
  52686. isLuminance: boolean;
  52687. /**
  52688. * If this is a cube texture
  52689. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52690. */
  52691. isCube: boolean;
  52692. /**
  52693. * If the texture is a compressed format eg. FOURCC_DXT1
  52694. */
  52695. isCompressed: boolean;
  52696. /**
  52697. * The dxgiFormat of the texture
  52698. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52699. */
  52700. dxgiFormat: number;
  52701. /**
  52702. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52703. */
  52704. textureType: number;
  52705. /**
  52706. * Sphericle polynomial created for the dds texture
  52707. */
  52708. sphericalPolynomial?: SphericalPolynomial;
  52709. }
  52710. /**
  52711. * Class used to provide DDS decompression tools
  52712. */
  52713. export class DDSTools {
  52714. /**
  52715. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52716. */
  52717. static StoreLODInAlphaChannel: boolean;
  52718. /**
  52719. * Gets DDS information from an array buffer
  52720. * @param data defines the array buffer view to read data from
  52721. * @returns the DDS information
  52722. */
  52723. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52724. private static _FloatView;
  52725. private static _Int32View;
  52726. private static _ToHalfFloat;
  52727. private static _FromHalfFloat;
  52728. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52729. private static _GetHalfFloatRGBAArrayBuffer;
  52730. private static _GetFloatRGBAArrayBuffer;
  52731. private static _GetFloatAsUIntRGBAArrayBuffer;
  52732. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52733. private static _GetRGBAArrayBuffer;
  52734. private static _ExtractLongWordOrder;
  52735. private static _GetRGBArrayBuffer;
  52736. private static _GetLuminanceArrayBuffer;
  52737. /**
  52738. * Uploads DDS Levels to a Babylon Texture
  52739. * @hidden
  52740. */
  52741. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52742. }
  52743. interface ThinEngine {
  52744. /**
  52745. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52746. * @param rootUrl defines the url where the file to load is located
  52747. * @param scene defines the current scene
  52748. * @param lodScale defines scale to apply to the mip map selection
  52749. * @param lodOffset defines offset to apply to the mip map selection
  52750. * @param onLoad defines an optional callback raised when the texture is loaded
  52751. * @param onError defines an optional callback raised if there is an issue to load the texture
  52752. * @param format defines the format of the data
  52753. * @param forcedExtension defines the extension to use to pick the right loader
  52754. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52755. * @returns the cube texture as an InternalTexture
  52756. */
  52757. 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;
  52758. }
  52759. }
  52760. declare module BABYLON {
  52761. /**
  52762. * Implementation of the DDS Texture Loader.
  52763. * @hidden
  52764. */
  52765. export class _DDSTextureLoader implements IInternalTextureLoader {
  52766. /**
  52767. * Defines wether the loader supports cascade loading the different faces.
  52768. */
  52769. readonly supportCascades: boolean;
  52770. /**
  52771. * This returns if the loader support the current file information.
  52772. * @param extension defines the file extension of the file being loaded
  52773. * @returns true if the loader can load the specified file
  52774. */
  52775. canLoad(extension: string): boolean;
  52776. /**
  52777. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52778. * @param data contains the texture data
  52779. * @param texture defines the BabylonJS internal texture
  52780. * @param createPolynomials will be true if polynomials have been requested
  52781. * @param onLoad defines the callback to trigger once the texture is ready
  52782. * @param onError defines the callback to trigger in case of error
  52783. */
  52784. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52785. /**
  52786. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52787. * @param data contains the texture data
  52788. * @param texture defines the BabylonJS internal texture
  52789. * @param callback defines the method to call once ready to upload
  52790. */
  52791. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52792. }
  52793. }
  52794. declare module BABYLON {
  52795. /**
  52796. * Implementation of the ENV Texture Loader.
  52797. * @hidden
  52798. */
  52799. export class _ENVTextureLoader implements IInternalTextureLoader {
  52800. /**
  52801. * Defines wether the loader supports cascade loading the different faces.
  52802. */
  52803. readonly supportCascades: boolean;
  52804. /**
  52805. * This returns if the loader support the current file information.
  52806. * @param extension defines the file extension of the file being loaded
  52807. * @returns true if the loader can load the specified file
  52808. */
  52809. canLoad(extension: string): boolean;
  52810. /**
  52811. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52812. * @param data contains the texture data
  52813. * @param texture defines the BabylonJS internal texture
  52814. * @param createPolynomials will be true if polynomials have been requested
  52815. * @param onLoad defines the callback to trigger once the texture is ready
  52816. * @param onError defines the callback to trigger in case of error
  52817. */
  52818. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52819. /**
  52820. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52821. * @param data contains the texture data
  52822. * @param texture defines the BabylonJS internal texture
  52823. * @param callback defines the method to call once ready to upload
  52824. */
  52825. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52826. }
  52827. }
  52828. declare module BABYLON {
  52829. /**
  52830. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52831. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52832. */
  52833. export class KhronosTextureContainer {
  52834. /** contents of the KTX container file */
  52835. data: ArrayBufferView;
  52836. private static HEADER_LEN;
  52837. private static COMPRESSED_2D;
  52838. private static COMPRESSED_3D;
  52839. private static TEX_2D;
  52840. private static TEX_3D;
  52841. /**
  52842. * Gets the openGL type
  52843. */
  52844. glType: number;
  52845. /**
  52846. * Gets the openGL type size
  52847. */
  52848. glTypeSize: number;
  52849. /**
  52850. * Gets the openGL format
  52851. */
  52852. glFormat: number;
  52853. /**
  52854. * Gets the openGL internal format
  52855. */
  52856. glInternalFormat: number;
  52857. /**
  52858. * Gets the base internal format
  52859. */
  52860. glBaseInternalFormat: number;
  52861. /**
  52862. * Gets image width in pixel
  52863. */
  52864. pixelWidth: number;
  52865. /**
  52866. * Gets image height in pixel
  52867. */
  52868. pixelHeight: number;
  52869. /**
  52870. * Gets image depth in pixels
  52871. */
  52872. pixelDepth: number;
  52873. /**
  52874. * Gets the number of array elements
  52875. */
  52876. numberOfArrayElements: number;
  52877. /**
  52878. * Gets the number of faces
  52879. */
  52880. numberOfFaces: number;
  52881. /**
  52882. * Gets the number of mipmap levels
  52883. */
  52884. numberOfMipmapLevels: number;
  52885. /**
  52886. * Gets the bytes of key value data
  52887. */
  52888. bytesOfKeyValueData: number;
  52889. /**
  52890. * Gets the load type
  52891. */
  52892. loadType: number;
  52893. /**
  52894. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52895. */
  52896. isInvalid: boolean;
  52897. /**
  52898. * Creates a new KhronosTextureContainer
  52899. * @param data contents of the KTX container file
  52900. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52901. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52902. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52903. */
  52904. constructor(
  52905. /** contents of the KTX container file */
  52906. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52907. /**
  52908. * Uploads KTX content to a Babylon Texture.
  52909. * It is assumed that the texture has already been created & is currently bound
  52910. * @hidden
  52911. */
  52912. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52913. private _upload2DCompressedLevels;
  52914. /**
  52915. * Checks if the given data starts with a KTX file identifier.
  52916. * @param data the data to check
  52917. * @returns true if the data is a KTX file or false otherwise
  52918. */
  52919. static IsValid(data: ArrayBufferView): boolean;
  52920. }
  52921. }
  52922. declare module BABYLON {
  52923. /**
  52924. * Class for loading KTX2 files
  52925. * !!! Experimental Extension Subject to Changes !!!
  52926. * @hidden
  52927. */
  52928. export class KhronosTextureContainer2 {
  52929. private static _ModulePromise;
  52930. private static _TranscodeFormat;
  52931. constructor(engine: ThinEngine);
  52932. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52933. private _determineTranscodeFormat;
  52934. /**
  52935. * Checks if the given data starts with a KTX2 file identifier.
  52936. * @param data the data to check
  52937. * @returns true if the data is a KTX2 file or false otherwise
  52938. */
  52939. static IsValid(data: ArrayBufferView): boolean;
  52940. }
  52941. }
  52942. declare module BABYLON {
  52943. /**
  52944. * Implementation of the KTX Texture Loader.
  52945. * @hidden
  52946. */
  52947. export class _KTXTextureLoader implements IInternalTextureLoader {
  52948. /**
  52949. * Defines wether the loader supports cascade loading the different faces.
  52950. */
  52951. readonly supportCascades: boolean;
  52952. /**
  52953. * This returns if the loader support the current file information.
  52954. * @param extension defines the file extension of the file being loaded
  52955. * @returns true if the loader can load the specified file
  52956. */
  52957. canLoad(extension: string): boolean;
  52958. /**
  52959. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52960. * @param data contains the texture data
  52961. * @param texture defines the BabylonJS internal texture
  52962. * @param createPolynomials will be true if polynomials have been requested
  52963. * @param onLoad defines the callback to trigger once the texture is ready
  52964. * @param onError defines the callback to trigger in case of error
  52965. */
  52966. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52967. /**
  52968. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52969. * @param data contains the texture data
  52970. * @param texture defines the BabylonJS internal texture
  52971. * @param callback defines the method to call once ready to upload
  52972. */
  52973. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52974. }
  52975. }
  52976. declare module BABYLON {
  52977. /** @hidden */
  52978. export var _forceSceneHelpersToBundle: boolean;
  52979. interface Scene {
  52980. /**
  52981. * Creates a default light for the scene.
  52982. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52983. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52984. */
  52985. createDefaultLight(replace?: boolean): void;
  52986. /**
  52987. * Creates a default camera for the scene.
  52988. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52989. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52990. * @param replace has default false, when true replaces the active camera in the scene
  52991. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52992. */
  52993. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52994. /**
  52995. * Creates a default camera and a default light.
  52996. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52997. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52998. * @param replace has the default false, when true replaces the active camera/light in the scene
  52999. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53000. */
  53001. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53002. /**
  53003. * Creates a new sky box
  53004. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53005. * @param environmentTexture defines the texture to use as environment texture
  53006. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53007. * @param scale defines the overall scale of the skybox
  53008. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53009. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53010. * @returns a new mesh holding the sky box
  53011. */
  53012. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53013. /**
  53014. * Creates a new environment
  53015. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53016. * @param options defines the options you can use to configure the environment
  53017. * @returns the new EnvironmentHelper
  53018. */
  53019. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53020. /**
  53021. * Creates a new VREXperienceHelper
  53022. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53023. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53024. * @returns a new VREXperienceHelper
  53025. */
  53026. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53027. /**
  53028. * Creates a new WebXRDefaultExperience
  53029. * @see http://doc.babylonjs.com/how_to/webxr
  53030. * @param options experience options
  53031. * @returns a promise for a new WebXRDefaultExperience
  53032. */
  53033. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53034. }
  53035. }
  53036. declare module BABYLON {
  53037. /**
  53038. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53039. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53040. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53041. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53042. */
  53043. export class VideoDome extends TransformNode {
  53044. /**
  53045. * Define the video source as a Monoscopic panoramic 360 video.
  53046. */
  53047. static readonly MODE_MONOSCOPIC: number;
  53048. /**
  53049. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53050. */
  53051. static readonly MODE_TOPBOTTOM: number;
  53052. /**
  53053. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53054. */
  53055. static readonly MODE_SIDEBYSIDE: number;
  53056. private _halfDome;
  53057. private _useDirectMapping;
  53058. /**
  53059. * The video texture being displayed on the sphere
  53060. */
  53061. protected _videoTexture: VideoTexture;
  53062. /**
  53063. * Gets the video texture being displayed on the sphere
  53064. */
  53065. get videoTexture(): VideoTexture;
  53066. /**
  53067. * The skybox material
  53068. */
  53069. protected _material: BackgroundMaterial;
  53070. /**
  53071. * The surface used for the skybox
  53072. */
  53073. protected _mesh: Mesh;
  53074. /**
  53075. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53076. */
  53077. private _halfDomeMask;
  53078. /**
  53079. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53080. * Also see the options.resolution property.
  53081. */
  53082. get fovMultiplier(): number;
  53083. set fovMultiplier(value: number);
  53084. private _videoMode;
  53085. /**
  53086. * Gets or set the current video mode for the video. It can be:
  53087. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53088. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53089. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53090. */
  53091. get videoMode(): number;
  53092. set videoMode(value: number);
  53093. /**
  53094. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53095. *
  53096. */
  53097. get halfDome(): boolean;
  53098. /**
  53099. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53100. */
  53101. set halfDome(enabled: boolean);
  53102. /**
  53103. * Oberserver used in Stereoscopic VR Mode.
  53104. */
  53105. private _onBeforeCameraRenderObserver;
  53106. /**
  53107. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53108. * @param name Element's name, child elements will append suffixes for their own names.
  53109. * @param urlsOrVideo defines the url(s) or the video element to use
  53110. * @param options An object containing optional or exposed sub element properties
  53111. */
  53112. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53113. resolution?: number;
  53114. clickToPlay?: boolean;
  53115. autoPlay?: boolean;
  53116. loop?: boolean;
  53117. size?: number;
  53118. poster?: string;
  53119. faceForward?: boolean;
  53120. useDirectMapping?: boolean;
  53121. halfDomeMode?: boolean;
  53122. }, scene: Scene);
  53123. private _changeVideoMode;
  53124. /**
  53125. * Releases resources associated with this node.
  53126. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53127. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53128. */
  53129. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53130. }
  53131. }
  53132. declare module BABYLON {
  53133. /**
  53134. * This class can be used to get instrumentation data from a Babylon engine
  53135. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53136. */
  53137. export class EngineInstrumentation implements IDisposable {
  53138. /**
  53139. * Define the instrumented engine.
  53140. */
  53141. engine: Engine;
  53142. private _captureGPUFrameTime;
  53143. private _gpuFrameTimeToken;
  53144. private _gpuFrameTime;
  53145. private _captureShaderCompilationTime;
  53146. private _shaderCompilationTime;
  53147. private _onBeginFrameObserver;
  53148. private _onEndFrameObserver;
  53149. private _onBeforeShaderCompilationObserver;
  53150. private _onAfterShaderCompilationObserver;
  53151. /**
  53152. * Gets the perf counter used for GPU frame time
  53153. */
  53154. get gpuFrameTimeCounter(): PerfCounter;
  53155. /**
  53156. * Gets the GPU frame time capture status
  53157. */
  53158. get captureGPUFrameTime(): boolean;
  53159. /**
  53160. * Enable or disable the GPU frame time capture
  53161. */
  53162. set captureGPUFrameTime(value: boolean);
  53163. /**
  53164. * Gets the perf counter used for shader compilation time
  53165. */
  53166. get shaderCompilationTimeCounter(): PerfCounter;
  53167. /**
  53168. * Gets the shader compilation time capture status
  53169. */
  53170. get captureShaderCompilationTime(): boolean;
  53171. /**
  53172. * Enable or disable the shader compilation time capture
  53173. */
  53174. set captureShaderCompilationTime(value: boolean);
  53175. /**
  53176. * Instantiates a new engine instrumentation.
  53177. * This class can be used to get instrumentation data from a Babylon engine
  53178. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53179. * @param engine Defines the engine to instrument
  53180. */
  53181. constructor(
  53182. /**
  53183. * Define the instrumented engine.
  53184. */
  53185. engine: Engine);
  53186. /**
  53187. * Dispose and release associated resources.
  53188. */
  53189. dispose(): void;
  53190. }
  53191. }
  53192. declare module BABYLON {
  53193. /**
  53194. * This class can be used to get instrumentation data from a Babylon engine
  53195. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53196. */
  53197. export class SceneInstrumentation implements IDisposable {
  53198. /**
  53199. * Defines the scene to instrument
  53200. */
  53201. scene: Scene;
  53202. private _captureActiveMeshesEvaluationTime;
  53203. private _activeMeshesEvaluationTime;
  53204. private _captureRenderTargetsRenderTime;
  53205. private _renderTargetsRenderTime;
  53206. private _captureFrameTime;
  53207. private _frameTime;
  53208. private _captureRenderTime;
  53209. private _renderTime;
  53210. private _captureInterFrameTime;
  53211. private _interFrameTime;
  53212. private _captureParticlesRenderTime;
  53213. private _particlesRenderTime;
  53214. private _captureSpritesRenderTime;
  53215. private _spritesRenderTime;
  53216. private _capturePhysicsTime;
  53217. private _physicsTime;
  53218. private _captureAnimationsTime;
  53219. private _animationsTime;
  53220. private _captureCameraRenderTime;
  53221. private _cameraRenderTime;
  53222. private _onBeforeActiveMeshesEvaluationObserver;
  53223. private _onAfterActiveMeshesEvaluationObserver;
  53224. private _onBeforeRenderTargetsRenderObserver;
  53225. private _onAfterRenderTargetsRenderObserver;
  53226. private _onAfterRenderObserver;
  53227. private _onBeforeDrawPhaseObserver;
  53228. private _onAfterDrawPhaseObserver;
  53229. private _onBeforeAnimationsObserver;
  53230. private _onBeforeParticlesRenderingObserver;
  53231. private _onAfterParticlesRenderingObserver;
  53232. private _onBeforeSpritesRenderingObserver;
  53233. private _onAfterSpritesRenderingObserver;
  53234. private _onBeforePhysicsObserver;
  53235. private _onAfterPhysicsObserver;
  53236. private _onAfterAnimationsObserver;
  53237. private _onBeforeCameraRenderObserver;
  53238. private _onAfterCameraRenderObserver;
  53239. /**
  53240. * Gets the perf counter used for active meshes evaluation time
  53241. */
  53242. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53243. /**
  53244. * Gets the active meshes evaluation time capture status
  53245. */
  53246. get captureActiveMeshesEvaluationTime(): boolean;
  53247. /**
  53248. * Enable or disable the active meshes evaluation time capture
  53249. */
  53250. set captureActiveMeshesEvaluationTime(value: boolean);
  53251. /**
  53252. * Gets the perf counter used for render targets render time
  53253. */
  53254. get renderTargetsRenderTimeCounter(): PerfCounter;
  53255. /**
  53256. * Gets the render targets render time capture status
  53257. */
  53258. get captureRenderTargetsRenderTime(): boolean;
  53259. /**
  53260. * Enable or disable the render targets render time capture
  53261. */
  53262. set captureRenderTargetsRenderTime(value: boolean);
  53263. /**
  53264. * Gets the perf counter used for particles render time
  53265. */
  53266. get particlesRenderTimeCounter(): PerfCounter;
  53267. /**
  53268. * Gets the particles render time capture status
  53269. */
  53270. get captureParticlesRenderTime(): boolean;
  53271. /**
  53272. * Enable or disable the particles render time capture
  53273. */
  53274. set captureParticlesRenderTime(value: boolean);
  53275. /**
  53276. * Gets the perf counter used for sprites render time
  53277. */
  53278. get spritesRenderTimeCounter(): PerfCounter;
  53279. /**
  53280. * Gets the sprites render time capture status
  53281. */
  53282. get captureSpritesRenderTime(): boolean;
  53283. /**
  53284. * Enable or disable the sprites render time capture
  53285. */
  53286. set captureSpritesRenderTime(value: boolean);
  53287. /**
  53288. * Gets the perf counter used for physics time
  53289. */
  53290. get physicsTimeCounter(): PerfCounter;
  53291. /**
  53292. * Gets the physics time capture status
  53293. */
  53294. get capturePhysicsTime(): boolean;
  53295. /**
  53296. * Enable or disable the physics time capture
  53297. */
  53298. set capturePhysicsTime(value: boolean);
  53299. /**
  53300. * Gets the perf counter used for animations time
  53301. */
  53302. get animationsTimeCounter(): PerfCounter;
  53303. /**
  53304. * Gets the animations time capture status
  53305. */
  53306. get captureAnimationsTime(): boolean;
  53307. /**
  53308. * Enable or disable the animations time capture
  53309. */
  53310. set captureAnimationsTime(value: boolean);
  53311. /**
  53312. * Gets the perf counter used for frame time capture
  53313. */
  53314. get frameTimeCounter(): PerfCounter;
  53315. /**
  53316. * Gets the frame time capture status
  53317. */
  53318. get captureFrameTime(): boolean;
  53319. /**
  53320. * Enable or disable the frame time capture
  53321. */
  53322. set captureFrameTime(value: boolean);
  53323. /**
  53324. * Gets the perf counter used for inter-frames time capture
  53325. */
  53326. get interFrameTimeCounter(): PerfCounter;
  53327. /**
  53328. * Gets the inter-frames time capture status
  53329. */
  53330. get captureInterFrameTime(): boolean;
  53331. /**
  53332. * Enable or disable the inter-frames time capture
  53333. */
  53334. set captureInterFrameTime(value: boolean);
  53335. /**
  53336. * Gets the perf counter used for render time capture
  53337. */
  53338. get renderTimeCounter(): PerfCounter;
  53339. /**
  53340. * Gets the render time capture status
  53341. */
  53342. get captureRenderTime(): boolean;
  53343. /**
  53344. * Enable or disable the render time capture
  53345. */
  53346. set captureRenderTime(value: boolean);
  53347. /**
  53348. * Gets the perf counter used for camera render time capture
  53349. */
  53350. get cameraRenderTimeCounter(): PerfCounter;
  53351. /**
  53352. * Gets the camera render time capture status
  53353. */
  53354. get captureCameraRenderTime(): boolean;
  53355. /**
  53356. * Enable or disable the camera render time capture
  53357. */
  53358. set captureCameraRenderTime(value: boolean);
  53359. /**
  53360. * Gets the perf counter used for draw calls
  53361. */
  53362. get drawCallsCounter(): PerfCounter;
  53363. /**
  53364. * Instantiates a new scene instrumentation.
  53365. * This class can be used to get instrumentation data from a Babylon engine
  53366. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53367. * @param scene Defines the scene to instrument
  53368. */
  53369. constructor(
  53370. /**
  53371. * Defines the scene to instrument
  53372. */
  53373. scene: Scene);
  53374. /**
  53375. * Dispose and release associated resources.
  53376. */
  53377. dispose(): void;
  53378. }
  53379. }
  53380. declare module BABYLON {
  53381. /** @hidden */
  53382. export var glowMapGenerationPixelShader: {
  53383. name: string;
  53384. shader: string;
  53385. };
  53386. }
  53387. declare module BABYLON {
  53388. /** @hidden */
  53389. export var glowMapGenerationVertexShader: {
  53390. name: string;
  53391. shader: string;
  53392. };
  53393. }
  53394. declare module BABYLON {
  53395. /**
  53396. * Effect layer options. This helps customizing the behaviour
  53397. * of the effect layer.
  53398. */
  53399. export interface IEffectLayerOptions {
  53400. /**
  53401. * Multiplication factor apply to the canvas size to compute the render target size
  53402. * used to generated the objects (the smaller the faster).
  53403. */
  53404. mainTextureRatio: number;
  53405. /**
  53406. * Enforces a fixed size texture to ensure effect stability across devices.
  53407. */
  53408. mainTextureFixedSize?: number;
  53409. /**
  53410. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53411. */
  53412. alphaBlendingMode: number;
  53413. /**
  53414. * The camera attached to the layer.
  53415. */
  53416. camera: Nullable<Camera>;
  53417. /**
  53418. * The rendering group to draw the layer in.
  53419. */
  53420. renderingGroupId: number;
  53421. }
  53422. /**
  53423. * The effect layer Helps adding post process effect blended with the main pass.
  53424. *
  53425. * This can be for instance use to generate glow or higlight effects on the scene.
  53426. *
  53427. * The effect layer class can not be used directly and is intented to inherited from to be
  53428. * customized per effects.
  53429. */
  53430. export abstract class EffectLayer {
  53431. private _vertexBuffers;
  53432. private _indexBuffer;
  53433. private _cachedDefines;
  53434. private _effectLayerMapGenerationEffect;
  53435. private _effectLayerOptions;
  53436. private _mergeEffect;
  53437. protected _scene: Scene;
  53438. protected _engine: Engine;
  53439. protected _maxSize: number;
  53440. protected _mainTextureDesiredSize: ISize;
  53441. protected _mainTexture: RenderTargetTexture;
  53442. protected _shouldRender: boolean;
  53443. protected _postProcesses: PostProcess[];
  53444. protected _textures: BaseTexture[];
  53445. protected _emissiveTextureAndColor: {
  53446. texture: Nullable<BaseTexture>;
  53447. color: Color4;
  53448. };
  53449. /**
  53450. * The name of the layer
  53451. */
  53452. name: string;
  53453. /**
  53454. * The clear color of the texture used to generate the glow map.
  53455. */
  53456. neutralColor: Color4;
  53457. /**
  53458. * Specifies whether the highlight layer is enabled or not.
  53459. */
  53460. isEnabled: boolean;
  53461. /**
  53462. * Gets the camera attached to the layer.
  53463. */
  53464. get camera(): Nullable<Camera>;
  53465. /**
  53466. * Gets the rendering group id the layer should render in.
  53467. */
  53468. get renderingGroupId(): number;
  53469. set renderingGroupId(renderingGroupId: number);
  53470. /**
  53471. * An event triggered when the effect layer has been disposed.
  53472. */
  53473. onDisposeObservable: Observable<EffectLayer>;
  53474. /**
  53475. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53476. */
  53477. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53478. /**
  53479. * An event triggered when the generated texture is being merged in the scene.
  53480. */
  53481. onBeforeComposeObservable: Observable<EffectLayer>;
  53482. /**
  53483. * An event triggered when the mesh is rendered into the effect render target.
  53484. */
  53485. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53486. /**
  53487. * An event triggered after the mesh has been rendered into the effect render target.
  53488. */
  53489. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53490. /**
  53491. * An event triggered when the generated texture has been merged in the scene.
  53492. */
  53493. onAfterComposeObservable: Observable<EffectLayer>;
  53494. /**
  53495. * An event triggered when the efffect layer changes its size.
  53496. */
  53497. onSizeChangedObservable: Observable<EffectLayer>;
  53498. /** @hidden */
  53499. static _SceneComponentInitialization: (scene: Scene) => void;
  53500. /**
  53501. * Instantiates a new effect Layer and references it in the scene.
  53502. * @param name The name of the layer
  53503. * @param scene The scene to use the layer in
  53504. */
  53505. constructor(
  53506. /** The Friendly of the effect in the scene */
  53507. name: string, scene: Scene);
  53508. /**
  53509. * Get the effect name of the layer.
  53510. * @return The effect name
  53511. */
  53512. abstract getEffectName(): string;
  53513. /**
  53514. * Checks for the readiness of the element composing the layer.
  53515. * @param subMesh the mesh to check for
  53516. * @param useInstances specify whether or not to use instances to render the mesh
  53517. * @return true if ready otherwise, false
  53518. */
  53519. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53520. /**
  53521. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53522. * @returns true if the effect requires stencil during the main canvas render pass.
  53523. */
  53524. abstract needStencil(): boolean;
  53525. /**
  53526. * Create the merge effect. This is the shader use to blit the information back
  53527. * to the main canvas at the end of the scene rendering.
  53528. * @returns The effect containing the shader used to merge the effect on the main canvas
  53529. */
  53530. protected abstract _createMergeEffect(): Effect;
  53531. /**
  53532. * Creates the render target textures and post processes used in the effect layer.
  53533. */
  53534. protected abstract _createTextureAndPostProcesses(): void;
  53535. /**
  53536. * Implementation specific of rendering the generating effect on the main canvas.
  53537. * @param effect The effect used to render through
  53538. */
  53539. protected abstract _internalRender(effect: Effect): void;
  53540. /**
  53541. * Sets the required values for both the emissive texture and and the main color.
  53542. */
  53543. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53544. /**
  53545. * Free any resources and references associated to a mesh.
  53546. * Internal use
  53547. * @param mesh The mesh to free.
  53548. */
  53549. abstract _disposeMesh(mesh: Mesh): void;
  53550. /**
  53551. * Serializes this layer (Glow or Highlight for example)
  53552. * @returns a serialized layer object
  53553. */
  53554. abstract serialize?(): any;
  53555. /**
  53556. * Initializes the effect layer with the required options.
  53557. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53558. */
  53559. protected _init(options: Partial<IEffectLayerOptions>): void;
  53560. /**
  53561. * Generates the index buffer of the full screen quad blending to the main canvas.
  53562. */
  53563. private _generateIndexBuffer;
  53564. /**
  53565. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53566. */
  53567. private _generateVertexBuffer;
  53568. /**
  53569. * Sets the main texture desired size which is the closest power of two
  53570. * of the engine canvas size.
  53571. */
  53572. private _setMainTextureSize;
  53573. /**
  53574. * Creates the main texture for the effect layer.
  53575. */
  53576. protected _createMainTexture(): void;
  53577. /**
  53578. * Adds specific effects defines.
  53579. * @param defines The defines to add specifics to.
  53580. */
  53581. protected _addCustomEffectDefines(defines: string[]): void;
  53582. /**
  53583. * Checks for the readiness of the element composing the layer.
  53584. * @param subMesh the mesh to check for
  53585. * @param useInstances specify whether or not to use instances to render the mesh
  53586. * @param emissiveTexture the associated emissive texture used to generate the glow
  53587. * @return true if ready otherwise, false
  53588. */
  53589. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53590. /**
  53591. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53592. */
  53593. render(): void;
  53594. /**
  53595. * Determine if a given mesh will be used in the current effect.
  53596. * @param mesh mesh to test
  53597. * @returns true if the mesh will be used
  53598. */
  53599. hasMesh(mesh: AbstractMesh): boolean;
  53600. /**
  53601. * Returns true if the layer contains information to display, otherwise false.
  53602. * @returns true if the glow layer should be rendered
  53603. */
  53604. shouldRender(): boolean;
  53605. /**
  53606. * Returns true if the mesh should render, otherwise false.
  53607. * @param mesh The mesh to render
  53608. * @returns true if it should render otherwise false
  53609. */
  53610. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53611. /**
  53612. * Returns true if the mesh can be rendered, otherwise false.
  53613. * @param mesh The mesh to render
  53614. * @param material The material used on the mesh
  53615. * @returns true if it can be rendered otherwise false
  53616. */
  53617. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53618. /**
  53619. * Returns true if the mesh should render, otherwise false.
  53620. * @param mesh The mesh to render
  53621. * @returns true if it should render otherwise false
  53622. */
  53623. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53624. /**
  53625. * Renders the submesh passed in parameter to the generation map.
  53626. */
  53627. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53628. /**
  53629. * Defines whether the current material of the mesh should be use to render the effect.
  53630. * @param mesh defines the current mesh to render
  53631. */
  53632. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53633. /**
  53634. * Rebuild the required buffers.
  53635. * @hidden Internal use only.
  53636. */
  53637. _rebuild(): void;
  53638. /**
  53639. * Dispose only the render target textures and post process.
  53640. */
  53641. private _disposeTextureAndPostProcesses;
  53642. /**
  53643. * Dispose the highlight layer and free resources.
  53644. */
  53645. dispose(): void;
  53646. /**
  53647. * Gets the class name of the effect layer
  53648. * @returns the string with the class name of the effect layer
  53649. */
  53650. getClassName(): string;
  53651. /**
  53652. * Creates an effect layer from parsed effect layer data
  53653. * @param parsedEffectLayer defines effect layer data
  53654. * @param scene defines the current scene
  53655. * @param rootUrl defines the root URL containing the effect layer information
  53656. * @returns a parsed effect Layer
  53657. */
  53658. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53659. }
  53660. }
  53661. declare module BABYLON {
  53662. interface AbstractScene {
  53663. /**
  53664. * The list of effect layers (highlights/glow) added to the scene
  53665. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53666. * @see http://doc.babylonjs.com/how_to/glow_layer
  53667. */
  53668. effectLayers: Array<EffectLayer>;
  53669. /**
  53670. * Removes the given effect layer from this scene.
  53671. * @param toRemove defines the effect layer to remove
  53672. * @returns the index of the removed effect layer
  53673. */
  53674. removeEffectLayer(toRemove: EffectLayer): number;
  53675. /**
  53676. * Adds the given effect layer to this scene
  53677. * @param newEffectLayer defines the effect layer to add
  53678. */
  53679. addEffectLayer(newEffectLayer: EffectLayer): void;
  53680. }
  53681. /**
  53682. * Defines the layer scene component responsible to manage any effect layers
  53683. * in a given scene.
  53684. */
  53685. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53686. /**
  53687. * The component name helpfull to identify the component in the list of scene components.
  53688. */
  53689. readonly name: string;
  53690. /**
  53691. * The scene the component belongs to.
  53692. */
  53693. scene: Scene;
  53694. private _engine;
  53695. private _renderEffects;
  53696. private _needStencil;
  53697. private _previousStencilState;
  53698. /**
  53699. * Creates a new instance of the component for the given scene
  53700. * @param scene Defines the scene to register the component in
  53701. */
  53702. constructor(scene: Scene);
  53703. /**
  53704. * Registers the component in a given scene
  53705. */
  53706. register(): void;
  53707. /**
  53708. * Rebuilds the elements related to this component in case of
  53709. * context lost for instance.
  53710. */
  53711. rebuild(): void;
  53712. /**
  53713. * Serializes the component data to the specified json object
  53714. * @param serializationObject The object to serialize to
  53715. */
  53716. serialize(serializationObject: any): void;
  53717. /**
  53718. * Adds all the elements from the container to the scene
  53719. * @param container the container holding the elements
  53720. */
  53721. addFromContainer(container: AbstractScene): void;
  53722. /**
  53723. * Removes all the elements in the container from the scene
  53724. * @param container contains the elements to remove
  53725. * @param dispose if the removed element should be disposed (default: false)
  53726. */
  53727. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53728. /**
  53729. * Disposes the component and the associated ressources.
  53730. */
  53731. dispose(): void;
  53732. private _isReadyForMesh;
  53733. private _renderMainTexture;
  53734. private _setStencil;
  53735. private _setStencilBack;
  53736. private _draw;
  53737. private _drawCamera;
  53738. private _drawRenderingGroup;
  53739. }
  53740. }
  53741. declare module BABYLON {
  53742. /** @hidden */
  53743. export var glowMapMergePixelShader: {
  53744. name: string;
  53745. shader: string;
  53746. };
  53747. }
  53748. declare module BABYLON {
  53749. /** @hidden */
  53750. export var glowMapMergeVertexShader: {
  53751. name: string;
  53752. shader: string;
  53753. };
  53754. }
  53755. declare module BABYLON {
  53756. interface AbstractScene {
  53757. /**
  53758. * Return a the first highlight layer of the scene with a given name.
  53759. * @param name The name of the highlight layer to look for.
  53760. * @return The highlight layer if found otherwise null.
  53761. */
  53762. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53763. }
  53764. /**
  53765. * Glow layer options. This helps customizing the behaviour
  53766. * of the glow layer.
  53767. */
  53768. export interface IGlowLayerOptions {
  53769. /**
  53770. * Multiplication factor apply to the canvas size to compute the render target size
  53771. * used to generated the glowing objects (the smaller the faster).
  53772. */
  53773. mainTextureRatio: number;
  53774. /**
  53775. * Enforces a fixed size texture to ensure resize independant blur.
  53776. */
  53777. mainTextureFixedSize?: number;
  53778. /**
  53779. * How big is the kernel of the blur texture.
  53780. */
  53781. blurKernelSize: number;
  53782. /**
  53783. * The camera attached to the layer.
  53784. */
  53785. camera: Nullable<Camera>;
  53786. /**
  53787. * Enable MSAA by chosing the number of samples.
  53788. */
  53789. mainTextureSamples?: number;
  53790. /**
  53791. * The rendering group to draw the layer in.
  53792. */
  53793. renderingGroupId: number;
  53794. }
  53795. /**
  53796. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53797. *
  53798. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53799. *
  53800. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53801. */
  53802. export class GlowLayer extends EffectLayer {
  53803. /**
  53804. * Effect Name of the layer.
  53805. */
  53806. static readonly EffectName: string;
  53807. /**
  53808. * The default blur kernel size used for the glow.
  53809. */
  53810. static DefaultBlurKernelSize: number;
  53811. /**
  53812. * The default texture size ratio used for the glow.
  53813. */
  53814. static DefaultTextureRatio: number;
  53815. /**
  53816. * Sets the kernel size of the blur.
  53817. */
  53818. set blurKernelSize(value: number);
  53819. /**
  53820. * Gets the kernel size of the blur.
  53821. */
  53822. get blurKernelSize(): number;
  53823. /**
  53824. * Sets the glow intensity.
  53825. */
  53826. set intensity(value: number);
  53827. /**
  53828. * Gets the glow intensity.
  53829. */
  53830. get intensity(): number;
  53831. private _options;
  53832. private _intensity;
  53833. private _horizontalBlurPostprocess1;
  53834. private _verticalBlurPostprocess1;
  53835. private _horizontalBlurPostprocess2;
  53836. private _verticalBlurPostprocess2;
  53837. private _blurTexture1;
  53838. private _blurTexture2;
  53839. private _postProcesses1;
  53840. private _postProcesses2;
  53841. private _includedOnlyMeshes;
  53842. private _excludedMeshes;
  53843. private _meshesUsingTheirOwnMaterials;
  53844. /**
  53845. * Callback used to let the user override the color selection on a per mesh basis
  53846. */
  53847. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53848. /**
  53849. * Callback used to let the user override the texture selection on a per mesh basis
  53850. */
  53851. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53852. /**
  53853. * Instantiates a new glow Layer and references it to the scene.
  53854. * @param name The name of the layer
  53855. * @param scene The scene to use the layer in
  53856. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53857. */
  53858. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53859. /**
  53860. * Get the effect name of the layer.
  53861. * @return The effect name
  53862. */
  53863. getEffectName(): string;
  53864. /**
  53865. * Create the merge effect. This is the shader use to blit the information back
  53866. * to the main canvas at the end of the scene rendering.
  53867. */
  53868. protected _createMergeEffect(): Effect;
  53869. /**
  53870. * Creates the render target textures and post processes used in the glow layer.
  53871. */
  53872. protected _createTextureAndPostProcesses(): void;
  53873. /**
  53874. * Checks for the readiness of the element composing the layer.
  53875. * @param subMesh the mesh to check for
  53876. * @param useInstances specify wether or not to use instances to render the mesh
  53877. * @param emissiveTexture the associated emissive texture used to generate the glow
  53878. * @return true if ready otherwise, false
  53879. */
  53880. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53881. /**
  53882. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53883. */
  53884. needStencil(): boolean;
  53885. /**
  53886. * Returns true if the mesh can be rendered, otherwise false.
  53887. * @param mesh The mesh to render
  53888. * @param material The material used on the mesh
  53889. * @returns true if it can be rendered otherwise false
  53890. */
  53891. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53892. /**
  53893. * Implementation specific of rendering the generating effect on the main canvas.
  53894. * @param effect The effect used to render through
  53895. */
  53896. protected _internalRender(effect: Effect): void;
  53897. /**
  53898. * Sets the required values for both the emissive texture and and the main color.
  53899. */
  53900. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53901. /**
  53902. * Returns true if the mesh should render, otherwise false.
  53903. * @param mesh The mesh to render
  53904. * @returns true if it should render otherwise false
  53905. */
  53906. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53907. /**
  53908. * Adds specific effects defines.
  53909. * @param defines The defines to add specifics to.
  53910. */
  53911. protected _addCustomEffectDefines(defines: string[]): void;
  53912. /**
  53913. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53914. * @param mesh The mesh to exclude from the glow layer
  53915. */
  53916. addExcludedMesh(mesh: Mesh): void;
  53917. /**
  53918. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53919. * @param mesh The mesh to remove
  53920. */
  53921. removeExcludedMesh(mesh: Mesh): void;
  53922. /**
  53923. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53924. * @param mesh The mesh to include in the glow layer
  53925. */
  53926. addIncludedOnlyMesh(mesh: Mesh): void;
  53927. /**
  53928. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53929. * @param mesh The mesh to remove
  53930. */
  53931. removeIncludedOnlyMesh(mesh: Mesh): void;
  53932. /**
  53933. * Determine if a given mesh will be used in the glow layer
  53934. * @param mesh The mesh to test
  53935. * @returns true if the mesh will be highlighted by the current glow layer
  53936. */
  53937. hasMesh(mesh: AbstractMesh): boolean;
  53938. /**
  53939. * Defines whether the current material of the mesh should be use to render the effect.
  53940. * @param mesh defines the current mesh to render
  53941. */
  53942. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53943. /**
  53944. * Add a mesh to be rendered through its own material and not with emissive only.
  53945. * @param mesh The mesh for which we need to use its material
  53946. */
  53947. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53948. /**
  53949. * Remove a mesh from being rendered through its own material and not with emissive only.
  53950. * @param mesh The mesh for which we need to not use its material
  53951. */
  53952. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53953. /**
  53954. * Free any resources and references associated to a mesh.
  53955. * Internal use
  53956. * @param mesh The mesh to free.
  53957. * @hidden
  53958. */
  53959. _disposeMesh(mesh: Mesh): void;
  53960. /**
  53961. * Gets the class name of the effect layer
  53962. * @returns the string with the class name of the effect layer
  53963. */
  53964. getClassName(): string;
  53965. /**
  53966. * Serializes this glow layer
  53967. * @returns a serialized glow layer object
  53968. */
  53969. serialize(): any;
  53970. /**
  53971. * Creates a Glow Layer from parsed glow layer data
  53972. * @param parsedGlowLayer defines glow layer data
  53973. * @param scene defines the current scene
  53974. * @param rootUrl defines the root URL containing the glow layer information
  53975. * @returns a parsed Glow Layer
  53976. */
  53977. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53978. }
  53979. }
  53980. declare module BABYLON {
  53981. /** @hidden */
  53982. export var glowBlurPostProcessPixelShader: {
  53983. name: string;
  53984. shader: string;
  53985. };
  53986. }
  53987. declare module BABYLON {
  53988. interface AbstractScene {
  53989. /**
  53990. * Return a the first highlight layer of the scene with a given name.
  53991. * @param name The name of the highlight layer to look for.
  53992. * @return The highlight layer if found otherwise null.
  53993. */
  53994. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53995. }
  53996. /**
  53997. * Highlight layer options. This helps customizing the behaviour
  53998. * of the highlight layer.
  53999. */
  54000. export interface IHighlightLayerOptions {
  54001. /**
  54002. * Multiplication factor apply to the canvas size to compute the render target size
  54003. * used to generated the glowing objects (the smaller the faster).
  54004. */
  54005. mainTextureRatio: number;
  54006. /**
  54007. * Enforces a fixed size texture to ensure resize independant blur.
  54008. */
  54009. mainTextureFixedSize?: number;
  54010. /**
  54011. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54012. * of the picture to blur (the smaller the faster).
  54013. */
  54014. blurTextureSizeRatio: number;
  54015. /**
  54016. * How big in texel of the blur texture is the vertical blur.
  54017. */
  54018. blurVerticalSize: number;
  54019. /**
  54020. * How big in texel of the blur texture is the horizontal blur.
  54021. */
  54022. blurHorizontalSize: number;
  54023. /**
  54024. * Alpha blending mode used to apply the blur. Default is combine.
  54025. */
  54026. alphaBlendingMode: number;
  54027. /**
  54028. * The camera attached to the layer.
  54029. */
  54030. camera: Nullable<Camera>;
  54031. /**
  54032. * Should we display highlight as a solid stroke?
  54033. */
  54034. isStroke?: boolean;
  54035. /**
  54036. * The rendering group to draw the layer in.
  54037. */
  54038. renderingGroupId: number;
  54039. }
  54040. /**
  54041. * The highlight layer Helps adding a glow effect around a mesh.
  54042. *
  54043. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54044. * glowy meshes to your scene.
  54045. *
  54046. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54047. */
  54048. export class HighlightLayer extends EffectLayer {
  54049. name: string;
  54050. /**
  54051. * Effect Name of the highlight layer.
  54052. */
  54053. static readonly EffectName: string;
  54054. /**
  54055. * The neutral color used during the preparation of the glow effect.
  54056. * This is black by default as the blend operation is a blend operation.
  54057. */
  54058. static NeutralColor: Color4;
  54059. /**
  54060. * Stencil value used for glowing meshes.
  54061. */
  54062. static GlowingMeshStencilReference: number;
  54063. /**
  54064. * Stencil value used for the other meshes in the scene.
  54065. */
  54066. static NormalMeshStencilReference: number;
  54067. /**
  54068. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54069. */
  54070. innerGlow: boolean;
  54071. /**
  54072. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54073. */
  54074. outerGlow: boolean;
  54075. /**
  54076. * Specifies the horizontal size of the blur.
  54077. */
  54078. set blurHorizontalSize(value: number);
  54079. /**
  54080. * Specifies the vertical size of the blur.
  54081. */
  54082. set blurVerticalSize(value: number);
  54083. /**
  54084. * Gets the horizontal size of the blur.
  54085. */
  54086. get blurHorizontalSize(): number;
  54087. /**
  54088. * Gets the vertical size of the blur.
  54089. */
  54090. get blurVerticalSize(): number;
  54091. /**
  54092. * An event triggered when the highlight layer is being blurred.
  54093. */
  54094. onBeforeBlurObservable: Observable<HighlightLayer>;
  54095. /**
  54096. * An event triggered when the highlight layer has been blurred.
  54097. */
  54098. onAfterBlurObservable: Observable<HighlightLayer>;
  54099. private _instanceGlowingMeshStencilReference;
  54100. private _options;
  54101. private _downSamplePostprocess;
  54102. private _horizontalBlurPostprocess;
  54103. private _verticalBlurPostprocess;
  54104. private _blurTexture;
  54105. private _meshes;
  54106. private _excludedMeshes;
  54107. /**
  54108. * Instantiates a new highlight Layer and references it to the scene..
  54109. * @param name The name of the layer
  54110. * @param scene The scene to use the layer in
  54111. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54112. */
  54113. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54114. /**
  54115. * Get the effect name of the layer.
  54116. * @return The effect name
  54117. */
  54118. getEffectName(): string;
  54119. /**
  54120. * Create the merge effect. This is the shader use to blit the information back
  54121. * to the main canvas at the end of the scene rendering.
  54122. */
  54123. protected _createMergeEffect(): Effect;
  54124. /**
  54125. * Creates the render target textures and post processes used in the highlight layer.
  54126. */
  54127. protected _createTextureAndPostProcesses(): void;
  54128. /**
  54129. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54130. */
  54131. needStencil(): boolean;
  54132. /**
  54133. * Checks for the readiness of the element composing the layer.
  54134. * @param subMesh the mesh to check for
  54135. * @param useInstances specify wether or not to use instances to render the mesh
  54136. * @param emissiveTexture the associated emissive texture used to generate the glow
  54137. * @return true if ready otherwise, false
  54138. */
  54139. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54140. /**
  54141. * Implementation specific of rendering the generating effect on the main canvas.
  54142. * @param effect The effect used to render through
  54143. */
  54144. protected _internalRender(effect: Effect): void;
  54145. /**
  54146. * Returns true if the layer contains information to display, otherwise false.
  54147. */
  54148. shouldRender(): boolean;
  54149. /**
  54150. * Returns true if the mesh should render, otherwise false.
  54151. * @param mesh The mesh to render
  54152. * @returns true if it should render otherwise false
  54153. */
  54154. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54155. /**
  54156. * Adds specific effects defines.
  54157. * @param defines The defines to add specifics to.
  54158. */
  54159. protected _addCustomEffectDefines(defines: string[]): void;
  54160. /**
  54161. * Sets the required values for both the emissive texture and and the main color.
  54162. */
  54163. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54164. /**
  54165. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54166. * @param mesh The mesh to exclude from the highlight layer
  54167. */
  54168. addExcludedMesh(mesh: Mesh): void;
  54169. /**
  54170. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54171. * @param mesh The mesh to highlight
  54172. */
  54173. removeExcludedMesh(mesh: Mesh): void;
  54174. /**
  54175. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54176. * @param mesh mesh to test
  54177. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54178. */
  54179. hasMesh(mesh: AbstractMesh): boolean;
  54180. /**
  54181. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54182. * @param mesh The mesh to highlight
  54183. * @param color The color of the highlight
  54184. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54185. */
  54186. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54187. /**
  54188. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54189. * @param mesh The mesh to highlight
  54190. */
  54191. removeMesh(mesh: Mesh): void;
  54192. /**
  54193. * Remove all the meshes currently referenced in the highlight layer
  54194. */
  54195. removeAllMeshes(): void;
  54196. /**
  54197. * Force the stencil to the normal expected value for none glowing parts
  54198. */
  54199. private _defaultStencilReference;
  54200. /**
  54201. * Free any resources and references associated to a mesh.
  54202. * Internal use
  54203. * @param mesh The mesh to free.
  54204. * @hidden
  54205. */
  54206. _disposeMesh(mesh: Mesh): void;
  54207. /**
  54208. * Dispose the highlight layer and free resources.
  54209. */
  54210. dispose(): void;
  54211. /**
  54212. * Gets the class name of the effect layer
  54213. * @returns the string with the class name of the effect layer
  54214. */
  54215. getClassName(): string;
  54216. /**
  54217. * Serializes this Highlight layer
  54218. * @returns a serialized Highlight layer object
  54219. */
  54220. serialize(): any;
  54221. /**
  54222. * Creates a Highlight layer from parsed Highlight layer data
  54223. * @param parsedHightlightLayer defines the Highlight layer data
  54224. * @param scene defines the current scene
  54225. * @param rootUrl defines the root URL containing the Highlight layer information
  54226. * @returns a parsed Highlight layer
  54227. */
  54228. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54229. }
  54230. }
  54231. declare module BABYLON {
  54232. interface AbstractScene {
  54233. /**
  54234. * The list of layers (background and foreground) of the scene
  54235. */
  54236. layers: Array<Layer>;
  54237. }
  54238. /**
  54239. * Defines the layer scene component responsible to manage any layers
  54240. * in a given scene.
  54241. */
  54242. export class LayerSceneComponent implements ISceneComponent {
  54243. /**
  54244. * The component name helpfull to identify the component in the list of scene components.
  54245. */
  54246. readonly name: string;
  54247. /**
  54248. * The scene the component belongs to.
  54249. */
  54250. scene: Scene;
  54251. private _engine;
  54252. /**
  54253. * Creates a new instance of the component for the given scene
  54254. * @param scene Defines the scene to register the component in
  54255. */
  54256. constructor(scene: Scene);
  54257. /**
  54258. * Registers the component in a given scene
  54259. */
  54260. register(): void;
  54261. /**
  54262. * Rebuilds the elements related to this component in case of
  54263. * context lost for instance.
  54264. */
  54265. rebuild(): void;
  54266. /**
  54267. * Disposes the component and the associated ressources.
  54268. */
  54269. dispose(): void;
  54270. private _draw;
  54271. private _drawCameraPredicate;
  54272. private _drawCameraBackground;
  54273. private _drawCameraForeground;
  54274. private _drawRenderTargetPredicate;
  54275. private _drawRenderTargetBackground;
  54276. private _drawRenderTargetForeground;
  54277. /**
  54278. * Adds all the elements from the container to the scene
  54279. * @param container the container holding the elements
  54280. */
  54281. addFromContainer(container: AbstractScene): void;
  54282. /**
  54283. * Removes all the elements in the container from the scene
  54284. * @param container contains the elements to remove
  54285. * @param dispose if the removed element should be disposed (default: false)
  54286. */
  54287. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54288. }
  54289. }
  54290. declare module BABYLON {
  54291. /** @hidden */
  54292. export var layerPixelShader: {
  54293. name: string;
  54294. shader: string;
  54295. };
  54296. }
  54297. declare module BABYLON {
  54298. /** @hidden */
  54299. export var layerVertexShader: {
  54300. name: string;
  54301. shader: string;
  54302. };
  54303. }
  54304. declare module BABYLON {
  54305. /**
  54306. * This represents a full screen 2d layer.
  54307. * This can be useful to display a picture in the background of your scene for instance.
  54308. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54309. */
  54310. export class Layer {
  54311. /**
  54312. * Define the name of the layer.
  54313. */
  54314. name: string;
  54315. /**
  54316. * Define the texture the layer should display.
  54317. */
  54318. texture: Nullable<Texture>;
  54319. /**
  54320. * Is the layer in background or foreground.
  54321. */
  54322. isBackground: boolean;
  54323. /**
  54324. * Define the color of the layer (instead of texture).
  54325. */
  54326. color: Color4;
  54327. /**
  54328. * Define the scale of the layer in order to zoom in out of the texture.
  54329. */
  54330. scale: Vector2;
  54331. /**
  54332. * Define an offset for the layer in order to shift the texture.
  54333. */
  54334. offset: Vector2;
  54335. /**
  54336. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54337. */
  54338. alphaBlendingMode: number;
  54339. /**
  54340. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54341. * Alpha test will not mix with the background color in case of transparency.
  54342. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54343. */
  54344. alphaTest: boolean;
  54345. /**
  54346. * Define a mask to restrict the layer to only some of the scene cameras.
  54347. */
  54348. layerMask: number;
  54349. /**
  54350. * Define the list of render target the layer is visible into.
  54351. */
  54352. renderTargetTextures: RenderTargetTexture[];
  54353. /**
  54354. * Define if the layer is only used in renderTarget or if it also
  54355. * renders in the main frame buffer of the canvas.
  54356. */
  54357. renderOnlyInRenderTargetTextures: boolean;
  54358. private _scene;
  54359. private _vertexBuffers;
  54360. private _indexBuffer;
  54361. private _effect;
  54362. private _previousDefines;
  54363. /**
  54364. * An event triggered when the layer is disposed.
  54365. */
  54366. onDisposeObservable: Observable<Layer>;
  54367. private _onDisposeObserver;
  54368. /**
  54369. * Back compatibility with callback before the onDisposeObservable existed.
  54370. * The set callback will be triggered when the layer has been disposed.
  54371. */
  54372. set onDispose(callback: () => void);
  54373. /**
  54374. * An event triggered before rendering the scene
  54375. */
  54376. onBeforeRenderObservable: Observable<Layer>;
  54377. private _onBeforeRenderObserver;
  54378. /**
  54379. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54380. * The set callback will be triggered just before rendering the layer.
  54381. */
  54382. set onBeforeRender(callback: () => void);
  54383. /**
  54384. * An event triggered after rendering the scene
  54385. */
  54386. onAfterRenderObservable: Observable<Layer>;
  54387. private _onAfterRenderObserver;
  54388. /**
  54389. * Back compatibility with callback before the onAfterRenderObservable existed.
  54390. * The set callback will be triggered just after rendering the layer.
  54391. */
  54392. set onAfterRender(callback: () => void);
  54393. /**
  54394. * Instantiates a new layer.
  54395. * This represents a full screen 2d layer.
  54396. * This can be useful to display a picture in the background of your scene for instance.
  54397. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54398. * @param name Define the name of the layer in the scene
  54399. * @param imgUrl Define the url of the texture to display in the layer
  54400. * @param scene Define the scene the layer belongs to
  54401. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54402. * @param color Defines a color for the layer
  54403. */
  54404. constructor(
  54405. /**
  54406. * Define the name of the layer.
  54407. */
  54408. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54409. private _createIndexBuffer;
  54410. /** @hidden */
  54411. _rebuild(): void;
  54412. /**
  54413. * Renders the layer in the scene.
  54414. */
  54415. render(): void;
  54416. /**
  54417. * Disposes and releases the associated ressources.
  54418. */
  54419. dispose(): void;
  54420. }
  54421. }
  54422. declare module BABYLON {
  54423. /** @hidden */
  54424. export var lensFlarePixelShader: {
  54425. name: string;
  54426. shader: string;
  54427. };
  54428. }
  54429. declare module BABYLON {
  54430. /** @hidden */
  54431. export var lensFlareVertexShader: {
  54432. name: string;
  54433. shader: string;
  54434. };
  54435. }
  54436. declare module BABYLON {
  54437. /**
  54438. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54439. * It is usually composed of several `lensFlare`.
  54440. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54441. */
  54442. export class LensFlareSystem {
  54443. /**
  54444. * Define the name of the lens flare system
  54445. */
  54446. name: string;
  54447. /**
  54448. * List of lens flares used in this system.
  54449. */
  54450. lensFlares: LensFlare[];
  54451. /**
  54452. * Define a limit from the border the lens flare can be visible.
  54453. */
  54454. borderLimit: number;
  54455. /**
  54456. * Define a viewport border we do not want to see the lens flare in.
  54457. */
  54458. viewportBorder: number;
  54459. /**
  54460. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54461. */
  54462. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54463. /**
  54464. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54465. */
  54466. layerMask: number;
  54467. /**
  54468. * Define the id of the lens flare system in the scene.
  54469. * (equal to name by default)
  54470. */
  54471. id: string;
  54472. private _scene;
  54473. private _emitter;
  54474. private _vertexBuffers;
  54475. private _indexBuffer;
  54476. private _effect;
  54477. private _positionX;
  54478. private _positionY;
  54479. private _isEnabled;
  54480. /** @hidden */
  54481. static _SceneComponentInitialization: (scene: Scene) => void;
  54482. /**
  54483. * Instantiates a lens flare system.
  54484. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54485. * It is usually composed of several `lensFlare`.
  54486. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54487. * @param name Define the name of the lens flare system in the scene
  54488. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54489. * @param scene Define the scene the lens flare system belongs to
  54490. */
  54491. constructor(
  54492. /**
  54493. * Define the name of the lens flare system
  54494. */
  54495. name: string, emitter: any, scene: Scene);
  54496. /**
  54497. * Define if the lens flare system is enabled.
  54498. */
  54499. get isEnabled(): boolean;
  54500. set isEnabled(value: boolean);
  54501. /**
  54502. * Get the scene the effects belongs to.
  54503. * @returns the scene holding the lens flare system
  54504. */
  54505. getScene(): Scene;
  54506. /**
  54507. * Get the emitter of the lens flare system.
  54508. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54509. * @returns the emitter of the lens flare system
  54510. */
  54511. getEmitter(): any;
  54512. /**
  54513. * Set the emitter of the lens flare system.
  54514. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54515. * @param newEmitter Define the new emitter of the system
  54516. */
  54517. setEmitter(newEmitter: any): void;
  54518. /**
  54519. * Get the lens flare system emitter position.
  54520. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54521. * @returns the position
  54522. */
  54523. getEmitterPosition(): Vector3;
  54524. /**
  54525. * @hidden
  54526. */
  54527. computeEffectivePosition(globalViewport: Viewport): boolean;
  54528. /** @hidden */
  54529. _isVisible(): boolean;
  54530. /**
  54531. * @hidden
  54532. */
  54533. render(): boolean;
  54534. /**
  54535. * Dispose and release the lens flare with its associated resources.
  54536. */
  54537. dispose(): void;
  54538. /**
  54539. * Parse a lens flare system from a JSON repressentation
  54540. * @param parsedLensFlareSystem Define the JSON to parse
  54541. * @param scene Define the scene the parsed system should be instantiated in
  54542. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54543. * @returns the parsed system
  54544. */
  54545. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54546. /**
  54547. * Serialize the current Lens Flare System into a JSON representation.
  54548. * @returns the serialized JSON
  54549. */
  54550. serialize(): any;
  54551. }
  54552. }
  54553. declare module BABYLON {
  54554. /**
  54555. * This represents one of the lens effect in a `lensFlareSystem`.
  54556. * It controls one of the indiviual texture used in the effect.
  54557. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54558. */
  54559. export class LensFlare {
  54560. /**
  54561. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54562. */
  54563. size: number;
  54564. /**
  54565. * 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.
  54566. */
  54567. position: number;
  54568. /**
  54569. * Define the lens color.
  54570. */
  54571. color: Color3;
  54572. /**
  54573. * Define the lens texture.
  54574. */
  54575. texture: Nullable<Texture>;
  54576. /**
  54577. * Define the alpha mode to render this particular lens.
  54578. */
  54579. alphaMode: number;
  54580. private _system;
  54581. /**
  54582. * Creates a new Lens Flare.
  54583. * This represents one of the lens effect in a `lensFlareSystem`.
  54584. * It controls one of the indiviual texture used in the effect.
  54585. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54586. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54587. * @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.
  54588. * @param color Define the lens color
  54589. * @param imgUrl Define the lens texture url
  54590. * @param system Define the `lensFlareSystem` this flare is part of
  54591. * @returns The newly created Lens Flare
  54592. */
  54593. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54594. /**
  54595. * Instantiates a new Lens Flare.
  54596. * This represents one of the lens effect in a `lensFlareSystem`.
  54597. * It controls one of the indiviual texture used in the effect.
  54598. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54599. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54600. * @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.
  54601. * @param color Define the lens color
  54602. * @param imgUrl Define the lens texture url
  54603. * @param system Define the `lensFlareSystem` this flare is part of
  54604. */
  54605. constructor(
  54606. /**
  54607. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54608. */
  54609. size: number,
  54610. /**
  54611. * 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.
  54612. */
  54613. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54614. /**
  54615. * Dispose and release the lens flare with its associated resources.
  54616. */
  54617. dispose(): void;
  54618. }
  54619. }
  54620. declare module BABYLON {
  54621. interface AbstractScene {
  54622. /**
  54623. * The list of lens flare system added to the scene
  54624. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54625. */
  54626. lensFlareSystems: Array<LensFlareSystem>;
  54627. /**
  54628. * Removes the given lens flare system from this scene.
  54629. * @param toRemove The lens flare system to remove
  54630. * @returns The index of the removed lens flare system
  54631. */
  54632. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54633. /**
  54634. * Adds the given lens flare system to this scene
  54635. * @param newLensFlareSystem The lens flare system to add
  54636. */
  54637. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54638. /**
  54639. * Gets a lens flare system using its name
  54640. * @param name defines the name to look for
  54641. * @returns the lens flare system or null if not found
  54642. */
  54643. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54644. /**
  54645. * Gets a lens flare system using its id
  54646. * @param id defines the id to look for
  54647. * @returns the lens flare system or null if not found
  54648. */
  54649. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54650. }
  54651. /**
  54652. * Defines the lens flare scene component responsible to manage any lens flares
  54653. * in a given scene.
  54654. */
  54655. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54656. /**
  54657. * The component name helpfull to identify the component in the list of scene components.
  54658. */
  54659. readonly name: string;
  54660. /**
  54661. * The scene the component belongs to.
  54662. */
  54663. scene: Scene;
  54664. /**
  54665. * Creates a new instance of the component for the given scene
  54666. * @param scene Defines the scene to register the component in
  54667. */
  54668. constructor(scene: Scene);
  54669. /**
  54670. * Registers the component in a given scene
  54671. */
  54672. register(): void;
  54673. /**
  54674. * Rebuilds the elements related to this component in case of
  54675. * context lost for instance.
  54676. */
  54677. rebuild(): void;
  54678. /**
  54679. * Adds all the elements from the container to the scene
  54680. * @param container the container holding the elements
  54681. */
  54682. addFromContainer(container: AbstractScene): void;
  54683. /**
  54684. * Removes all the elements in the container from the scene
  54685. * @param container contains the elements to remove
  54686. * @param dispose if the removed element should be disposed (default: false)
  54687. */
  54688. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54689. /**
  54690. * Serializes the component data to the specified json object
  54691. * @param serializationObject The object to serialize to
  54692. */
  54693. serialize(serializationObject: any): void;
  54694. /**
  54695. * Disposes the component and the associated ressources.
  54696. */
  54697. dispose(): void;
  54698. private _draw;
  54699. }
  54700. }
  54701. declare module BABYLON {
  54702. /** @hidden */
  54703. export var depthPixelShader: {
  54704. name: string;
  54705. shader: string;
  54706. };
  54707. }
  54708. declare module BABYLON {
  54709. /** @hidden */
  54710. export var depthVertexShader: {
  54711. name: string;
  54712. shader: string;
  54713. };
  54714. }
  54715. declare module BABYLON {
  54716. /**
  54717. * This represents a depth renderer in Babylon.
  54718. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54719. */
  54720. export class DepthRenderer {
  54721. private _scene;
  54722. private _depthMap;
  54723. private _effect;
  54724. private readonly _storeNonLinearDepth;
  54725. private readonly _clearColor;
  54726. /** Get if the depth renderer is using packed depth or not */
  54727. readonly isPacked: boolean;
  54728. private _cachedDefines;
  54729. private _camera;
  54730. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54731. enabled: boolean;
  54732. /**
  54733. * Specifiess that the depth renderer will only be used within
  54734. * the camera it is created for.
  54735. * This can help forcing its rendering during the camera processing.
  54736. */
  54737. useOnlyInActiveCamera: boolean;
  54738. /** @hidden */
  54739. static _SceneComponentInitialization: (scene: Scene) => void;
  54740. /**
  54741. * Instantiates a depth renderer
  54742. * @param scene The scene the renderer belongs to
  54743. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54744. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54745. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54746. */
  54747. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54748. /**
  54749. * Creates the depth rendering effect and checks if the effect is ready.
  54750. * @param subMesh The submesh to be used to render the depth map of
  54751. * @param useInstances If multiple world instances should be used
  54752. * @returns if the depth renderer is ready to render the depth map
  54753. */
  54754. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54755. /**
  54756. * Gets the texture which the depth map will be written to.
  54757. * @returns The depth map texture
  54758. */
  54759. getDepthMap(): RenderTargetTexture;
  54760. /**
  54761. * Disposes of the depth renderer.
  54762. */
  54763. dispose(): void;
  54764. }
  54765. }
  54766. declare module BABYLON {
  54767. /** @hidden */
  54768. export var minmaxReduxPixelShader: {
  54769. name: string;
  54770. shader: string;
  54771. };
  54772. }
  54773. declare module BABYLON {
  54774. /**
  54775. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54776. * and maximum values from all values of the texture.
  54777. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54778. * The source values are read from the red channel of the texture.
  54779. */
  54780. export class MinMaxReducer {
  54781. /**
  54782. * Observable triggered when the computation has been performed
  54783. */
  54784. onAfterReductionPerformed: Observable<{
  54785. min: number;
  54786. max: number;
  54787. }>;
  54788. protected _camera: Camera;
  54789. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54790. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54791. protected _postProcessManager: PostProcessManager;
  54792. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54793. protected _forceFullscreenViewport: boolean;
  54794. /**
  54795. * Creates a min/max reducer
  54796. * @param camera The camera to use for the post processes
  54797. */
  54798. constructor(camera: Camera);
  54799. /**
  54800. * Gets the texture used to read the values from.
  54801. */
  54802. get sourceTexture(): Nullable<RenderTargetTexture>;
  54803. /**
  54804. * Sets the source texture to read the values from.
  54805. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54806. * because in such textures '1' value must not be taken into account to compute the maximum
  54807. * as this value is used to clear the texture.
  54808. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54809. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54810. * @param depthRedux Indicates if the texture is a depth texture or not
  54811. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54812. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54813. */
  54814. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54815. /**
  54816. * Defines the refresh rate of the computation.
  54817. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54818. */
  54819. get refreshRate(): number;
  54820. set refreshRate(value: number);
  54821. protected _activated: boolean;
  54822. /**
  54823. * Gets the activation status of the reducer
  54824. */
  54825. get activated(): boolean;
  54826. /**
  54827. * Activates the reduction computation.
  54828. * When activated, the observers registered in onAfterReductionPerformed are
  54829. * called after the compuation is performed
  54830. */
  54831. activate(): void;
  54832. /**
  54833. * Deactivates the reduction computation.
  54834. */
  54835. deactivate(): void;
  54836. /**
  54837. * Disposes the min/max reducer
  54838. * @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.
  54839. */
  54840. dispose(disposeAll?: boolean): void;
  54841. }
  54842. }
  54843. declare module BABYLON {
  54844. /**
  54845. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54846. */
  54847. export class DepthReducer extends MinMaxReducer {
  54848. private _depthRenderer;
  54849. private _depthRendererId;
  54850. /**
  54851. * Gets the depth renderer used for the computation.
  54852. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54853. */
  54854. get depthRenderer(): Nullable<DepthRenderer>;
  54855. /**
  54856. * Creates a depth reducer
  54857. * @param camera The camera used to render the depth texture
  54858. */
  54859. constructor(camera: Camera);
  54860. /**
  54861. * Sets the depth renderer to use to generate the depth map
  54862. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54863. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54864. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54865. */
  54866. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54867. /** @hidden */
  54868. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54869. /**
  54870. * Activates the reduction computation.
  54871. * When activated, the observers registered in onAfterReductionPerformed are
  54872. * called after the compuation is performed
  54873. */
  54874. activate(): void;
  54875. /**
  54876. * Deactivates the reduction computation.
  54877. */
  54878. deactivate(): void;
  54879. /**
  54880. * Disposes the depth reducer
  54881. * @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.
  54882. */
  54883. dispose(disposeAll?: boolean): void;
  54884. }
  54885. }
  54886. declare module BABYLON {
  54887. /**
  54888. * A CSM implementation allowing casting shadows on large scenes.
  54889. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54890. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54891. */
  54892. export class CascadedShadowGenerator extends ShadowGenerator {
  54893. private static readonly frustumCornersNDCSpace;
  54894. /**
  54895. * Name of the CSM class
  54896. */
  54897. static CLASSNAME: string;
  54898. /**
  54899. * Defines the default number of cascades used by the CSM.
  54900. */
  54901. static readonly DEFAULT_CASCADES_COUNT: number;
  54902. /**
  54903. * Defines the minimum number of cascades used by the CSM.
  54904. */
  54905. static readonly MIN_CASCADES_COUNT: number;
  54906. /**
  54907. * Defines the maximum number of cascades used by the CSM.
  54908. */
  54909. static readonly MAX_CASCADES_COUNT: number;
  54910. protected _validateFilter(filter: number): number;
  54911. /**
  54912. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54913. */
  54914. penumbraDarkness: number;
  54915. private _numCascades;
  54916. /**
  54917. * Gets or set the number of cascades used by the CSM.
  54918. */
  54919. get numCascades(): number;
  54920. set numCascades(value: number);
  54921. /**
  54922. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54923. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54924. */
  54925. stabilizeCascades: boolean;
  54926. private _freezeShadowCastersBoundingInfo;
  54927. private _freezeShadowCastersBoundingInfoObservable;
  54928. /**
  54929. * Enables or disables the shadow casters bounding info computation.
  54930. * If your shadow casters don't move, you can disable this feature.
  54931. * If it is enabled, the bounding box computation is done every frame.
  54932. */
  54933. get freezeShadowCastersBoundingInfo(): boolean;
  54934. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54935. private _scbiMin;
  54936. private _scbiMax;
  54937. protected _computeShadowCastersBoundingInfo(): void;
  54938. protected _shadowCastersBoundingInfo: BoundingInfo;
  54939. /**
  54940. * Gets or sets the shadow casters bounding info.
  54941. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54942. * so that the system won't overwrite the bounds you provide
  54943. */
  54944. get shadowCastersBoundingInfo(): BoundingInfo;
  54945. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54946. protected _breaksAreDirty: boolean;
  54947. protected _minDistance: number;
  54948. protected _maxDistance: number;
  54949. /**
  54950. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54951. *
  54952. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54953. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54954. * @param min minimal distance for the breaks (default to 0.)
  54955. * @param max maximal distance for the breaks (default to 1.)
  54956. */
  54957. setMinMaxDistance(min: number, max: number): void;
  54958. /** Gets the minimal distance used in the cascade break computation */
  54959. get minDistance(): number;
  54960. /** Gets the maximal distance used in the cascade break computation */
  54961. get maxDistance(): number;
  54962. /**
  54963. * Gets the class name of that object
  54964. * @returns "CascadedShadowGenerator"
  54965. */
  54966. getClassName(): string;
  54967. private _cascadeMinExtents;
  54968. private _cascadeMaxExtents;
  54969. /**
  54970. * Gets a cascade minimum extents
  54971. * @param cascadeIndex index of the cascade
  54972. * @returns the minimum cascade extents
  54973. */
  54974. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54975. /**
  54976. * Gets a cascade maximum extents
  54977. * @param cascadeIndex index of the cascade
  54978. * @returns the maximum cascade extents
  54979. */
  54980. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54981. private _cascades;
  54982. private _currentLayer;
  54983. private _viewSpaceFrustumsZ;
  54984. private _viewMatrices;
  54985. private _projectionMatrices;
  54986. private _transformMatrices;
  54987. private _transformMatricesAsArray;
  54988. private _frustumLengths;
  54989. private _lightSizeUVCorrection;
  54990. private _depthCorrection;
  54991. private _frustumCornersWorldSpace;
  54992. private _frustumCenter;
  54993. private _shadowCameraPos;
  54994. private _shadowMaxZ;
  54995. /**
  54996. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54997. * It defaults to camera.maxZ
  54998. */
  54999. get shadowMaxZ(): number;
  55000. /**
  55001. * Sets the shadow max z distance.
  55002. */
  55003. set shadowMaxZ(value: number);
  55004. protected _debug: boolean;
  55005. /**
  55006. * Gets or sets the debug flag.
  55007. * When enabled, the cascades are materialized by different colors on the screen.
  55008. */
  55009. get debug(): boolean;
  55010. set debug(dbg: boolean);
  55011. private _depthClamp;
  55012. /**
  55013. * Gets or sets the depth clamping value.
  55014. *
  55015. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  55016. * to account for the shadow casters far away.
  55017. *
  55018. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  55019. */
  55020. get depthClamp(): boolean;
  55021. set depthClamp(value: boolean);
  55022. private _cascadeBlendPercentage;
  55023. /**
  55024. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  55025. * It defaults to 0.1 (10% blending).
  55026. */
  55027. get cascadeBlendPercentage(): number;
  55028. set cascadeBlendPercentage(value: number);
  55029. private _lambda;
  55030. /**
  55031. * Gets or set the lambda parameter.
  55032. * This parameter is used to split the camera frustum and create the cascades.
  55033. * 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.
  55034. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  55035. */
  55036. get lambda(): number;
  55037. set lambda(value: number);
  55038. /**
  55039. * Gets the view matrix corresponding to a given cascade
  55040. * @param cascadeNum cascade to retrieve the view matrix from
  55041. * @returns the cascade view matrix
  55042. */
  55043. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  55044. /**
  55045. * Gets the projection matrix corresponding to a given cascade
  55046. * @param cascadeNum cascade to retrieve the projection matrix from
  55047. * @returns the cascade projection matrix
  55048. */
  55049. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  55050. /**
  55051. * Gets the transformation matrix corresponding to a given cascade
  55052. * @param cascadeNum cascade to retrieve the transformation matrix from
  55053. * @returns the cascade transformation matrix
  55054. */
  55055. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  55056. private _depthRenderer;
  55057. /**
  55058. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  55059. *
  55060. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  55061. *
  55062. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  55063. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  55064. * @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
  55065. */
  55066. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  55067. private _depthReducer;
  55068. private _autoCalcDepthBounds;
  55069. /**
  55070. * Gets or sets the autoCalcDepthBounds property.
  55071. *
  55072. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  55073. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  55074. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  55075. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  55076. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  55077. */
  55078. get autoCalcDepthBounds(): boolean;
  55079. set autoCalcDepthBounds(value: boolean);
  55080. /**
  55081. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  55082. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55083. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  55084. * for setting the refresh rate on the renderer yourself!
  55085. */
  55086. get autoCalcDepthBoundsRefreshRate(): number;
  55087. set autoCalcDepthBoundsRefreshRate(value: number);
  55088. /**
  55089. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  55090. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  55091. * you change the camera near/far planes!
  55092. */
  55093. splitFrustum(): void;
  55094. private _splitFrustum;
  55095. private _computeMatrices;
  55096. private _computeFrustumInWorldSpace;
  55097. private _computeCascadeFrustum;
  55098. /**
  55099. * Support test.
  55100. */
  55101. static get IsSupported(): boolean;
  55102. /** @hidden */
  55103. static _SceneComponentInitialization: (scene: Scene) => void;
  55104. /**
  55105. * Creates a Cascaded Shadow Generator object.
  55106. * A ShadowGenerator is the required tool to use the shadows.
  55107. * Each directional light casting shadows needs to use its own ShadowGenerator.
  55108. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55109. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  55110. * @param light The directional light object generating the shadows.
  55111. * @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.
  55112. */
  55113. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  55114. protected _initializeGenerator(): void;
  55115. protected _createTargetRenderTexture(): void;
  55116. protected _initializeShadowMap(): void;
  55117. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any): void;
  55118. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  55119. /**
  55120. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  55121. * @param defines Defines of the material we want to update
  55122. * @param lightIndex Index of the light in the enabled light list of the material
  55123. */
  55124. prepareDefines(defines: any, lightIndex: number): void;
  55125. /**
  55126. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  55127. * defined in the generator but impacting the effect).
  55128. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  55129. * @param effect The effect we are binfing the information for
  55130. */
  55131. bindShadowLight(lightIndex: string, effect: Effect): void;
  55132. /**
  55133. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  55134. * (eq to view projection * shadow projection matrices)
  55135. * @returns The transform matrix used to create the shadow map
  55136. */
  55137. getTransformMatrix(): Matrix;
  55138. /**
  55139. * Disposes the ShadowGenerator.
  55140. * Returns nothing.
  55141. */
  55142. dispose(): void;
  55143. /**
  55144. * Serializes the shadow generator setup to a json object.
  55145. * @returns The serialized JSON object
  55146. */
  55147. serialize(): any;
  55148. /**
  55149. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55150. * @param parsedShadowGenerator The JSON object to parse
  55151. * @param scene The scene to create the shadow map for
  55152. * @returns The parsed shadow generator
  55153. */
  55154. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55155. }
  55156. }
  55157. declare module BABYLON {
  55158. /**
  55159. * Defines the shadow generator component responsible to manage any shadow generators
  55160. * in a given scene.
  55161. */
  55162. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55163. /**
  55164. * The component name helpfull to identify the component in the list of scene components.
  55165. */
  55166. readonly name: string;
  55167. /**
  55168. * The scene the component belongs to.
  55169. */
  55170. scene: Scene;
  55171. /**
  55172. * Creates a new instance of the component for the given scene
  55173. * @param scene Defines the scene to register the component in
  55174. */
  55175. constructor(scene: Scene);
  55176. /**
  55177. * Registers the component in a given scene
  55178. */
  55179. register(): void;
  55180. /**
  55181. * Rebuilds the elements related to this component in case of
  55182. * context lost for instance.
  55183. */
  55184. rebuild(): void;
  55185. /**
  55186. * Serializes the component data to the specified json object
  55187. * @param serializationObject The object to serialize to
  55188. */
  55189. serialize(serializationObject: any): void;
  55190. /**
  55191. * Adds all the elements from the container to the scene
  55192. * @param container the container holding the elements
  55193. */
  55194. addFromContainer(container: AbstractScene): void;
  55195. /**
  55196. * Removes all the elements in the container from the scene
  55197. * @param container contains the elements to remove
  55198. * @param dispose if the removed element should be disposed (default: false)
  55199. */
  55200. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55201. /**
  55202. * Rebuilds the elements related to this component in case of
  55203. * context lost for instance.
  55204. */
  55205. dispose(): void;
  55206. private _gatherRenderTargets;
  55207. }
  55208. }
  55209. declare module BABYLON {
  55210. /**
  55211. * A point light is a light defined by an unique point in world space.
  55212. * The light is emitted in every direction from this point.
  55213. * A good example of a point light is a standard light bulb.
  55214. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55215. */
  55216. export class PointLight extends ShadowLight {
  55217. private _shadowAngle;
  55218. /**
  55219. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55220. * This specifies what angle the shadow will use to be created.
  55221. *
  55222. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55223. */
  55224. get shadowAngle(): number;
  55225. /**
  55226. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55227. * This specifies what angle the shadow will use to be created.
  55228. *
  55229. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55230. */
  55231. set shadowAngle(value: number);
  55232. /**
  55233. * Gets the direction if it has been set.
  55234. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55235. */
  55236. get direction(): Vector3;
  55237. /**
  55238. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55239. */
  55240. set direction(value: Vector3);
  55241. /**
  55242. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55243. * A PointLight emits the light in every direction.
  55244. * It can cast shadows.
  55245. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55246. * ```javascript
  55247. * var pointLight = new PointLight("pl", camera.position, scene);
  55248. * ```
  55249. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55250. * @param name The light friendly name
  55251. * @param position The position of the point light in the scene
  55252. * @param scene The scene the lights belongs to
  55253. */
  55254. constructor(name: string, position: Vector3, scene: Scene);
  55255. /**
  55256. * Returns the string "PointLight"
  55257. * @returns the class name
  55258. */
  55259. getClassName(): string;
  55260. /**
  55261. * Returns the integer 0.
  55262. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55263. */
  55264. getTypeID(): number;
  55265. /**
  55266. * Specifies wether or not the shadowmap should be a cube texture.
  55267. * @returns true if the shadowmap needs to be a cube texture.
  55268. */
  55269. needCube(): boolean;
  55270. /**
  55271. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55272. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55273. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55274. */
  55275. getShadowDirection(faceIndex?: number): Vector3;
  55276. /**
  55277. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55278. * - fov = PI / 2
  55279. * - aspect ratio : 1.0
  55280. * - z-near and far equal to the active camera minZ and maxZ.
  55281. * Returns the PointLight.
  55282. */
  55283. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55284. protected _buildUniformLayout(): void;
  55285. /**
  55286. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55287. * @param effect The effect to update
  55288. * @param lightIndex The index of the light in the effect to update
  55289. * @returns The point light
  55290. */
  55291. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55292. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55293. /**
  55294. * Prepares the list of defines specific to the light type.
  55295. * @param defines the list of defines
  55296. * @param lightIndex defines the index of the light for the effect
  55297. */
  55298. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55299. }
  55300. }
  55301. declare module BABYLON {
  55302. /**
  55303. * Header information of HDR texture files.
  55304. */
  55305. export interface HDRInfo {
  55306. /**
  55307. * The height of the texture in pixels.
  55308. */
  55309. height: number;
  55310. /**
  55311. * The width of the texture in pixels.
  55312. */
  55313. width: number;
  55314. /**
  55315. * The index of the beginning of the data in the binary file.
  55316. */
  55317. dataPosition: number;
  55318. }
  55319. /**
  55320. * This groups tools to convert HDR texture to native colors array.
  55321. */
  55322. export class HDRTools {
  55323. private static Ldexp;
  55324. private static Rgbe2float;
  55325. private static readStringLine;
  55326. /**
  55327. * Reads header information from an RGBE texture stored in a native array.
  55328. * More information on this format are available here:
  55329. * https://en.wikipedia.org/wiki/RGBE_image_format
  55330. *
  55331. * @param uint8array The binary file stored in native array.
  55332. * @return The header information.
  55333. */
  55334. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55335. /**
  55336. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55337. * This RGBE texture needs to store the information as a panorama.
  55338. *
  55339. * More information on this format are available here:
  55340. * https://en.wikipedia.org/wiki/RGBE_image_format
  55341. *
  55342. * @param buffer The binary file stored in an array buffer.
  55343. * @param size The expected size of the extracted cubemap.
  55344. * @return The Cube Map information.
  55345. */
  55346. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55347. /**
  55348. * Returns the pixels data extracted from an RGBE texture.
  55349. * This pixels will be stored left to right up to down in the R G B order in one array.
  55350. *
  55351. * More information on this format are available here:
  55352. * https://en.wikipedia.org/wiki/RGBE_image_format
  55353. *
  55354. * @param uint8array The binary file stored in an array buffer.
  55355. * @param hdrInfo The header information of the file.
  55356. * @return The pixels data in RGB right to left up to down order.
  55357. */
  55358. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55359. private static RGBE_ReadPixels_RLE;
  55360. }
  55361. }
  55362. declare module BABYLON {
  55363. /**
  55364. * This represents a texture coming from an HDR input.
  55365. *
  55366. * The only supported format is currently panorama picture stored in RGBE format.
  55367. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55368. */
  55369. export class HDRCubeTexture extends BaseTexture {
  55370. private static _facesMapping;
  55371. private _generateHarmonics;
  55372. private _noMipmap;
  55373. private _textureMatrix;
  55374. private _size;
  55375. private _onLoad;
  55376. private _onError;
  55377. /**
  55378. * The texture URL.
  55379. */
  55380. url: string;
  55381. /**
  55382. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55383. */
  55384. coordinatesMode: number;
  55385. protected _isBlocking: boolean;
  55386. /**
  55387. * Sets wether or not the texture is blocking during loading.
  55388. */
  55389. set isBlocking(value: boolean);
  55390. /**
  55391. * Gets wether or not the texture is blocking during loading.
  55392. */
  55393. get isBlocking(): boolean;
  55394. protected _rotationY: number;
  55395. /**
  55396. * Sets texture matrix rotation angle around Y axis in radians.
  55397. */
  55398. set rotationY(value: number);
  55399. /**
  55400. * Gets texture matrix rotation angle around Y axis radians.
  55401. */
  55402. get rotationY(): number;
  55403. /**
  55404. * Gets or sets the center of the bounding box associated with the cube texture
  55405. * It must define where the camera used to render the texture was set
  55406. */
  55407. boundingBoxPosition: Vector3;
  55408. private _boundingBoxSize;
  55409. /**
  55410. * Gets or sets the size of the bounding box associated with the cube texture
  55411. * When defined, the cubemap will switch to local mode
  55412. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55413. * @example https://www.babylonjs-playground.com/#RNASML
  55414. */
  55415. set boundingBoxSize(value: Vector3);
  55416. get boundingBoxSize(): Vector3;
  55417. /**
  55418. * Instantiates an HDRTexture from the following parameters.
  55419. *
  55420. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55421. * @param scene The scene the texture will be used in
  55422. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55423. * @param noMipmap Forces to not generate the mipmap if true
  55424. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55425. * @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)
  55426. * @param reserved Reserved flag for internal use.
  55427. */
  55428. 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>);
  55429. /**
  55430. * Get the current class name of the texture useful for serialization or dynamic coding.
  55431. * @returns "HDRCubeTexture"
  55432. */
  55433. getClassName(): string;
  55434. /**
  55435. * Occurs when the file is raw .hdr file.
  55436. */
  55437. private loadTexture;
  55438. clone(): HDRCubeTexture;
  55439. delayLoad(): void;
  55440. /**
  55441. * Get the texture reflection matrix used to rotate/transform the reflection.
  55442. * @returns the reflection matrix
  55443. */
  55444. getReflectionTextureMatrix(): Matrix;
  55445. /**
  55446. * Set the texture reflection matrix used to rotate/transform the reflection.
  55447. * @param value Define the reflection matrix to set
  55448. */
  55449. setReflectionTextureMatrix(value: Matrix): void;
  55450. /**
  55451. * Parses a JSON representation of an HDR Texture in order to create the texture
  55452. * @param parsedTexture Define the JSON representation
  55453. * @param scene Define the scene the texture should be created in
  55454. * @param rootUrl Define the root url in case we need to load relative dependencies
  55455. * @returns the newly created texture after parsing
  55456. */
  55457. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55458. serialize(): any;
  55459. }
  55460. }
  55461. declare module BABYLON {
  55462. /**
  55463. * Class used to control physics engine
  55464. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55465. */
  55466. export class PhysicsEngine implements IPhysicsEngine {
  55467. private _physicsPlugin;
  55468. /**
  55469. * Global value used to control the smallest number supported by the simulation
  55470. */
  55471. static Epsilon: number;
  55472. private _impostors;
  55473. private _joints;
  55474. private _subTimeStep;
  55475. /**
  55476. * Gets the gravity vector used by the simulation
  55477. */
  55478. gravity: Vector3;
  55479. /**
  55480. * Factory used to create the default physics plugin.
  55481. * @returns The default physics plugin
  55482. */
  55483. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55484. /**
  55485. * Creates a new Physics Engine
  55486. * @param gravity defines the gravity vector used by the simulation
  55487. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55488. */
  55489. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55490. /**
  55491. * Sets the gravity vector used by the simulation
  55492. * @param gravity defines the gravity vector to use
  55493. */
  55494. setGravity(gravity: Vector3): void;
  55495. /**
  55496. * Set the time step of the physics engine.
  55497. * Default is 1/60.
  55498. * To slow it down, enter 1/600 for example.
  55499. * To speed it up, 1/30
  55500. * @param newTimeStep defines the new timestep to apply to this world.
  55501. */
  55502. setTimeStep(newTimeStep?: number): void;
  55503. /**
  55504. * Get the time step of the physics engine.
  55505. * @returns the current time step
  55506. */
  55507. getTimeStep(): number;
  55508. /**
  55509. * Set the sub time step of the physics engine.
  55510. * Default is 0 meaning there is no sub steps
  55511. * To increase physics resolution precision, set a small value (like 1 ms)
  55512. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55513. */
  55514. setSubTimeStep(subTimeStep?: number): void;
  55515. /**
  55516. * Get the sub time step of the physics engine.
  55517. * @returns the current sub time step
  55518. */
  55519. getSubTimeStep(): number;
  55520. /**
  55521. * Release all resources
  55522. */
  55523. dispose(): void;
  55524. /**
  55525. * Gets the name of the current physics plugin
  55526. * @returns the name of the plugin
  55527. */
  55528. getPhysicsPluginName(): string;
  55529. /**
  55530. * Adding a new impostor for the impostor tracking.
  55531. * This will be done by the impostor itself.
  55532. * @param impostor the impostor to add
  55533. */
  55534. addImpostor(impostor: PhysicsImpostor): void;
  55535. /**
  55536. * Remove an impostor from the engine.
  55537. * This impostor and its mesh will not longer be updated by the physics engine.
  55538. * @param impostor the impostor to remove
  55539. */
  55540. removeImpostor(impostor: PhysicsImpostor): void;
  55541. /**
  55542. * Add a joint to the physics engine
  55543. * @param mainImpostor defines the main impostor to which the joint is added.
  55544. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55545. * @param joint defines the joint that will connect both impostors.
  55546. */
  55547. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55548. /**
  55549. * Removes a joint from the simulation
  55550. * @param mainImpostor defines the impostor used with the joint
  55551. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55552. * @param joint defines the joint to remove
  55553. */
  55554. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55555. /**
  55556. * Called by the scene. No need to call it.
  55557. * @param delta defines the timespam between frames
  55558. */
  55559. _step(delta: number): void;
  55560. /**
  55561. * Gets the current plugin used to run the simulation
  55562. * @returns current plugin
  55563. */
  55564. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55565. /**
  55566. * Gets the list of physic impostors
  55567. * @returns an array of PhysicsImpostor
  55568. */
  55569. getImpostors(): Array<PhysicsImpostor>;
  55570. /**
  55571. * Gets the impostor for a physics enabled object
  55572. * @param object defines the object impersonated by the impostor
  55573. * @returns the PhysicsImpostor or null if not found
  55574. */
  55575. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55576. /**
  55577. * Gets the impostor for a physics body object
  55578. * @param body defines physics body used by the impostor
  55579. * @returns the PhysicsImpostor or null if not found
  55580. */
  55581. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55582. /**
  55583. * Does a raycast in the physics world
  55584. * @param from when should the ray start?
  55585. * @param to when should the ray end?
  55586. * @returns PhysicsRaycastResult
  55587. */
  55588. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55589. }
  55590. }
  55591. declare module BABYLON {
  55592. /** @hidden */
  55593. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55594. private _useDeltaForWorldStep;
  55595. world: any;
  55596. name: string;
  55597. private _physicsMaterials;
  55598. private _fixedTimeStep;
  55599. private _cannonRaycastResult;
  55600. private _raycastResult;
  55601. private _physicsBodysToRemoveAfterStep;
  55602. BJSCANNON: any;
  55603. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55604. setGravity(gravity: Vector3): void;
  55605. setTimeStep(timeStep: number): void;
  55606. getTimeStep(): number;
  55607. executeStep(delta: number): void;
  55608. private _removeMarkedPhysicsBodiesFromWorld;
  55609. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55610. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55611. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55612. private _processChildMeshes;
  55613. removePhysicsBody(impostor: PhysicsImpostor): void;
  55614. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55615. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55616. private _addMaterial;
  55617. private _checkWithEpsilon;
  55618. private _createShape;
  55619. private _createHeightmap;
  55620. private _minus90X;
  55621. private _plus90X;
  55622. private _tmpPosition;
  55623. private _tmpDeltaPosition;
  55624. private _tmpUnityRotation;
  55625. private _updatePhysicsBodyTransformation;
  55626. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55627. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55628. isSupported(): boolean;
  55629. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55630. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55631. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55632. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55633. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55634. getBodyMass(impostor: PhysicsImpostor): number;
  55635. getBodyFriction(impostor: PhysicsImpostor): number;
  55636. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55637. getBodyRestitution(impostor: PhysicsImpostor): number;
  55638. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55639. sleepBody(impostor: PhysicsImpostor): void;
  55640. wakeUpBody(impostor: PhysicsImpostor): void;
  55641. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55642. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55643. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55644. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55645. getRadius(impostor: PhysicsImpostor): number;
  55646. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55647. dispose(): void;
  55648. private _extendNamespace;
  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. /** @hidden */
  55660. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55661. world: any;
  55662. name: string;
  55663. BJSOIMO: any;
  55664. private _raycastResult;
  55665. constructor(iterations?: number, oimoInjection?: any);
  55666. setGravity(gravity: Vector3): void;
  55667. setTimeStep(timeStep: number): void;
  55668. getTimeStep(): number;
  55669. private _tmpImpostorsArray;
  55670. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55671. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55672. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55673. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55674. private _tmpPositionVector;
  55675. removePhysicsBody(impostor: PhysicsImpostor): void;
  55676. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55677. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55678. isSupported(): boolean;
  55679. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55680. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55681. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55682. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55683. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55684. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55685. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55686. getBodyMass(impostor: PhysicsImpostor): number;
  55687. getBodyFriction(impostor: PhysicsImpostor): number;
  55688. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55689. getBodyRestitution(impostor: PhysicsImpostor): number;
  55690. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55691. sleepBody(impostor: PhysicsImpostor): void;
  55692. wakeUpBody(impostor: PhysicsImpostor): void;
  55693. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55694. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55695. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55696. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55697. getRadius(impostor: PhysicsImpostor): number;
  55698. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55699. dispose(): void;
  55700. /**
  55701. * Does a raycast in the physics world
  55702. * @param from when should the ray start?
  55703. * @param to when should the ray end?
  55704. * @returns PhysicsRaycastResult
  55705. */
  55706. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55707. }
  55708. }
  55709. declare module BABYLON {
  55710. /**
  55711. * Class containing static functions to help procedurally build meshes
  55712. */
  55713. export class RibbonBuilder {
  55714. /**
  55715. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55716. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55717. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55718. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55719. * * 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
  55720. * * 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
  55721. * * 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
  55722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55723. * * 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
  55724. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55725. * * 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
  55726. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55727. * * 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
  55728. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55730. * @param name defines the name of the mesh
  55731. * @param options defines the options used to create the mesh
  55732. * @param scene defines the hosting scene
  55733. * @returns the ribbon mesh
  55734. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55735. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55736. */
  55737. static CreateRibbon(name: string, options: {
  55738. pathArray: Vector3[][];
  55739. closeArray?: boolean;
  55740. closePath?: boolean;
  55741. offset?: number;
  55742. updatable?: boolean;
  55743. sideOrientation?: number;
  55744. frontUVs?: Vector4;
  55745. backUVs?: Vector4;
  55746. instance?: Mesh;
  55747. invertUV?: boolean;
  55748. uvs?: Vector2[];
  55749. colors?: Color4[];
  55750. }, scene?: Nullable<Scene>): Mesh;
  55751. }
  55752. }
  55753. declare module BABYLON {
  55754. /**
  55755. * Class containing static functions to help procedurally build meshes
  55756. */
  55757. export class ShapeBuilder {
  55758. /**
  55759. * 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.
  55760. * * 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.
  55761. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55762. * * 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.
  55763. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55764. * * 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
  55765. * * 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
  55766. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55768. * * 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
  55769. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55771. * @param name defines the name of the mesh
  55772. * @param options defines the options used to create the mesh
  55773. * @param scene defines the hosting scene
  55774. * @returns the extruded shape mesh
  55775. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55776. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55777. */
  55778. static ExtrudeShape(name: string, options: {
  55779. shape: Vector3[];
  55780. path: Vector3[];
  55781. scale?: number;
  55782. rotation?: number;
  55783. cap?: number;
  55784. updatable?: boolean;
  55785. sideOrientation?: number;
  55786. frontUVs?: Vector4;
  55787. backUVs?: Vector4;
  55788. instance?: Mesh;
  55789. invertUV?: boolean;
  55790. }, scene?: Nullable<Scene>): Mesh;
  55791. /**
  55792. * Creates an custom extruded shape mesh.
  55793. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55794. * * 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.
  55795. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55796. * * 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
  55797. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55798. * * 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
  55799. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55800. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55801. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55802. * * 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
  55803. * * 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
  55804. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55806. * * 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
  55807. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55809. * @param name defines the name of the mesh
  55810. * @param options defines the options used to create the mesh
  55811. * @param scene defines the hosting scene
  55812. * @returns the custom extruded shape mesh
  55813. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55814. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55815. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55816. */
  55817. static ExtrudeShapeCustom(name: string, options: {
  55818. shape: Vector3[];
  55819. path: Vector3[];
  55820. scaleFunction?: any;
  55821. rotationFunction?: any;
  55822. ribbonCloseArray?: boolean;
  55823. ribbonClosePath?: boolean;
  55824. cap?: number;
  55825. updatable?: boolean;
  55826. sideOrientation?: number;
  55827. frontUVs?: Vector4;
  55828. backUVs?: Vector4;
  55829. instance?: Mesh;
  55830. invertUV?: boolean;
  55831. }, scene?: Nullable<Scene>): Mesh;
  55832. private static _ExtrudeShapeGeneric;
  55833. }
  55834. }
  55835. declare module BABYLON {
  55836. /**
  55837. * AmmoJS Physics plugin
  55838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55839. * @see https://github.com/kripken/ammo.js/
  55840. */
  55841. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55842. private _useDeltaForWorldStep;
  55843. /**
  55844. * Reference to the Ammo library
  55845. */
  55846. bjsAMMO: any;
  55847. /**
  55848. * Created ammoJS world which physics bodies are added to
  55849. */
  55850. world: any;
  55851. /**
  55852. * Name of the plugin
  55853. */
  55854. name: string;
  55855. private _timeStep;
  55856. private _fixedTimeStep;
  55857. private _maxSteps;
  55858. private _tmpQuaternion;
  55859. private _tmpAmmoTransform;
  55860. private _tmpAmmoQuaternion;
  55861. private _tmpAmmoConcreteContactResultCallback;
  55862. private _collisionConfiguration;
  55863. private _dispatcher;
  55864. private _overlappingPairCache;
  55865. private _solver;
  55866. private _softBodySolver;
  55867. private _tmpAmmoVectorA;
  55868. private _tmpAmmoVectorB;
  55869. private _tmpAmmoVectorC;
  55870. private _tmpAmmoVectorD;
  55871. private _tmpContactCallbackResult;
  55872. private _tmpAmmoVectorRCA;
  55873. private _tmpAmmoVectorRCB;
  55874. private _raycastResult;
  55875. private static readonly DISABLE_COLLISION_FLAG;
  55876. private static readonly KINEMATIC_FLAG;
  55877. private static readonly DISABLE_DEACTIVATION_FLAG;
  55878. /**
  55879. * Initializes the ammoJS plugin
  55880. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55881. * @param ammoInjection can be used to inject your own ammo reference
  55882. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55883. */
  55884. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55885. /**
  55886. * Sets the gravity of the physics world (m/(s^2))
  55887. * @param gravity Gravity to set
  55888. */
  55889. setGravity(gravity: Vector3): void;
  55890. /**
  55891. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55892. * @param timeStep timestep to use in seconds
  55893. */
  55894. setTimeStep(timeStep: number): void;
  55895. /**
  55896. * 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)
  55897. * @param fixedTimeStep fixedTimeStep to use in seconds
  55898. */
  55899. setFixedTimeStep(fixedTimeStep: number): void;
  55900. /**
  55901. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55902. * @param maxSteps the maximum number of steps by the physics engine per frame
  55903. */
  55904. setMaxSteps(maxSteps: number): void;
  55905. /**
  55906. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55907. * @returns the current timestep in seconds
  55908. */
  55909. getTimeStep(): number;
  55910. /**
  55911. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55912. */
  55913. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55914. private _isImpostorInContact;
  55915. private _isImpostorPairInContact;
  55916. private _stepSimulation;
  55917. /**
  55918. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55919. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55920. * After the step the babylon meshes are set to the position of the physics imposters
  55921. * @param delta amount of time to step forward
  55922. * @param impostors array of imposters to update before/after the step
  55923. */
  55924. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55925. /**
  55926. * Update babylon mesh to match physics world object
  55927. * @param impostor imposter to match
  55928. */
  55929. private _afterSoftStep;
  55930. /**
  55931. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55932. * @param impostor imposter to match
  55933. */
  55934. private _ropeStep;
  55935. /**
  55936. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55937. * @param impostor imposter to match
  55938. */
  55939. private _softbodyOrClothStep;
  55940. private _tmpMatrix;
  55941. /**
  55942. * Applies an impulse on the imposter
  55943. * @param impostor imposter to apply impulse to
  55944. * @param force amount of force to be applied to the imposter
  55945. * @param contactPoint the location to apply the impulse on the imposter
  55946. */
  55947. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55948. /**
  55949. * Applies a force on the imposter
  55950. * @param impostor imposter to apply force
  55951. * @param force amount of force to be applied to the imposter
  55952. * @param contactPoint the location to apply the force on the imposter
  55953. */
  55954. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55955. /**
  55956. * Creates a physics body using the plugin
  55957. * @param impostor the imposter to create the physics body on
  55958. */
  55959. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55960. /**
  55961. * Removes the physics body from the imposter and disposes of the body's memory
  55962. * @param impostor imposter to remove the physics body from
  55963. */
  55964. removePhysicsBody(impostor: PhysicsImpostor): void;
  55965. /**
  55966. * Generates a joint
  55967. * @param impostorJoint the imposter joint to create the joint with
  55968. */
  55969. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55970. /**
  55971. * Removes a joint
  55972. * @param impostorJoint the imposter joint to remove the joint from
  55973. */
  55974. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55975. private _addMeshVerts;
  55976. /**
  55977. * Initialise the soft body vertices to match its object's (mesh) vertices
  55978. * Softbody vertices (nodes) are in world space and to match this
  55979. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55980. * @param impostor to create the softbody for
  55981. */
  55982. private _softVertexData;
  55983. /**
  55984. * Create an impostor's soft body
  55985. * @param impostor to create the softbody for
  55986. */
  55987. private _createSoftbody;
  55988. /**
  55989. * Create cloth for an impostor
  55990. * @param impostor to create the softbody for
  55991. */
  55992. private _createCloth;
  55993. /**
  55994. * Create rope for an impostor
  55995. * @param impostor to create the softbody for
  55996. */
  55997. private _createRope;
  55998. /**
  55999. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56000. * @param impostor to create the custom physics shape for
  56001. */
  56002. private _createCustom;
  56003. private _addHullVerts;
  56004. private _createShape;
  56005. /**
  56006. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56007. * @param impostor imposter containing the physics body and babylon object
  56008. */
  56009. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56010. /**
  56011. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56012. * @param impostor imposter containing the physics body and babylon object
  56013. * @param newPosition new position
  56014. * @param newRotation new rotation
  56015. */
  56016. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56017. /**
  56018. * If this plugin is supported
  56019. * @returns true if its supported
  56020. */
  56021. isSupported(): boolean;
  56022. /**
  56023. * Sets the linear velocity of the physics body
  56024. * @param impostor imposter to set the velocity on
  56025. * @param velocity velocity to set
  56026. */
  56027. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56028. /**
  56029. * Sets the angular velocity of the physics body
  56030. * @param impostor imposter to set the velocity on
  56031. * @param velocity velocity to set
  56032. */
  56033. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56034. /**
  56035. * gets the linear velocity
  56036. * @param impostor imposter to get linear velocity from
  56037. * @returns linear velocity
  56038. */
  56039. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56040. /**
  56041. * gets the angular velocity
  56042. * @param impostor imposter to get angular velocity from
  56043. * @returns angular velocity
  56044. */
  56045. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56046. /**
  56047. * Sets the mass of physics body
  56048. * @param impostor imposter to set the mass on
  56049. * @param mass mass to set
  56050. */
  56051. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56052. /**
  56053. * Gets the mass of the physics body
  56054. * @param impostor imposter to get the mass from
  56055. * @returns mass
  56056. */
  56057. getBodyMass(impostor: PhysicsImpostor): number;
  56058. /**
  56059. * Gets friction of the impostor
  56060. * @param impostor impostor to get friction from
  56061. * @returns friction value
  56062. */
  56063. getBodyFriction(impostor: PhysicsImpostor): number;
  56064. /**
  56065. * Sets friction of the impostor
  56066. * @param impostor impostor to set friction on
  56067. * @param friction friction value
  56068. */
  56069. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56070. /**
  56071. * Gets restitution of the impostor
  56072. * @param impostor impostor to get restitution from
  56073. * @returns restitution value
  56074. */
  56075. getBodyRestitution(impostor: PhysicsImpostor): number;
  56076. /**
  56077. * Sets resitution of the impostor
  56078. * @param impostor impostor to set resitution on
  56079. * @param restitution resitution value
  56080. */
  56081. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56082. /**
  56083. * Gets pressure inside the impostor
  56084. * @param impostor impostor to get pressure from
  56085. * @returns pressure value
  56086. */
  56087. getBodyPressure(impostor: PhysicsImpostor): number;
  56088. /**
  56089. * Sets pressure inside a soft body impostor
  56090. * Cloth and rope must remain 0 pressure
  56091. * @param impostor impostor to set pressure on
  56092. * @param pressure pressure value
  56093. */
  56094. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56095. /**
  56096. * Gets stiffness of the impostor
  56097. * @param impostor impostor to get stiffness from
  56098. * @returns pressure value
  56099. */
  56100. getBodyStiffness(impostor: PhysicsImpostor): number;
  56101. /**
  56102. * Sets stiffness of the impostor
  56103. * @param impostor impostor to set stiffness on
  56104. * @param stiffness stiffness value from 0 to 1
  56105. */
  56106. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56107. /**
  56108. * Gets velocityIterations of the impostor
  56109. * @param impostor impostor to get velocity iterations from
  56110. * @returns velocityIterations value
  56111. */
  56112. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56113. /**
  56114. * Sets velocityIterations of the impostor
  56115. * @param impostor impostor to set velocity iterations on
  56116. * @param velocityIterations velocityIterations value
  56117. */
  56118. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56119. /**
  56120. * Gets positionIterations of the impostor
  56121. * @param impostor impostor to get position iterations from
  56122. * @returns positionIterations value
  56123. */
  56124. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56125. /**
  56126. * Sets positionIterations of the impostor
  56127. * @param impostor impostor to set position on
  56128. * @param positionIterations positionIterations value
  56129. */
  56130. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56131. /**
  56132. * Append an anchor to a cloth object
  56133. * @param impostor is the cloth impostor to add anchor to
  56134. * @param otherImpostor is the rigid impostor to anchor to
  56135. * @param width ratio across width from 0 to 1
  56136. * @param height ratio up height from 0 to 1
  56137. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56138. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56139. */
  56140. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56141. /**
  56142. * Append an hook to a rope object
  56143. * @param impostor is the rope impostor to add hook to
  56144. * @param otherImpostor is the rigid impostor to hook to
  56145. * @param length ratio along the rope from 0 to 1
  56146. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56147. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56148. */
  56149. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56150. /**
  56151. * Sleeps the physics body and stops it from being active
  56152. * @param impostor impostor to sleep
  56153. */
  56154. sleepBody(impostor: PhysicsImpostor): void;
  56155. /**
  56156. * Activates the physics body
  56157. * @param impostor impostor to activate
  56158. */
  56159. wakeUpBody(impostor: PhysicsImpostor): void;
  56160. /**
  56161. * Updates the distance parameters of the joint
  56162. * @param joint joint to update
  56163. * @param maxDistance maximum distance of the joint
  56164. * @param minDistance minimum distance of the joint
  56165. */
  56166. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56167. /**
  56168. * Sets a motor on the joint
  56169. * @param joint joint to set motor on
  56170. * @param speed speed of the motor
  56171. * @param maxForce maximum force of the motor
  56172. * @param motorIndex index of the motor
  56173. */
  56174. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56175. /**
  56176. * Sets the motors limit
  56177. * @param joint joint to set limit on
  56178. * @param upperLimit upper limit
  56179. * @param lowerLimit lower limit
  56180. */
  56181. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56182. /**
  56183. * Syncs the position and rotation of a mesh with the impostor
  56184. * @param mesh mesh to sync
  56185. * @param impostor impostor to update the mesh with
  56186. */
  56187. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56188. /**
  56189. * Gets the radius of the impostor
  56190. * @param impostor impostor to get radius from
  56191. * @returns the radius
  56192. */
  56193. getRadius(impostor: PhysicsImpostor): number;
  56194. /**
  56195. * Gets the box size of the impostor
  56196. * @param impostor impostor to get box size from
  56197. * @param result the resulting box size
  56198. */
  56199. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56200. /**
  56201. * Disposes of the impostor
  56202. */
  56203. dispose(): void;
  56204. /**
  56205. * Does a raycast in the physics world
  56206. * @param from when should the ray start?
  56207. * @param to when should the ray end?
  56208. * @returns PhysicsRaycastResult
  56209. */
  56210. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56211. }
  56212. }
  56213. declare module BABYLON {
  56214. interface AbstractScene {
  56215. /**
  56216. * The list of reflection probes added to the scene
  56217. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56218. */
  56219. reflectionProbes: Array<ReflectionProbe>;
  56220. /**
  56221. * Removes the given reflection probe from this scene.
  56222. * @param toRemove The reflection probe to remove
  56223. * @returns The index of the removed reflection probe
  56224. */
  56225. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56226. /**
  56227. * Adds the given reflection probe to this scene.
  56228. * @param newReflectionProbe The reflection probe to add
  56229. */
  56230. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56231. }
  56232. /**
  56233. * Class used to generate realtime reflection / refraction cube textures
  56234. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56235. */
  56236. export class ReflectionProbe {
  56237. /** defines the name of the probe */
  56238. name: string;
  56239. private _scene;
  56240. private _renderTargetTexture;
  56241. private _projectionMatrix;
  56242. private _viewMatrix;
  56243. private _target;
  56244. private _add;
  56245. private _attachedMesh;
  56246. private _invertYAxis;
  56247. /** Gets or sets probe position (center of the cube map) */
  56248. position: Vector3;
  56249. /**
  56250. * Creates a new reflection probe
  56251. * @param name defines the name of the probe
  56252. * @param size defines the texture resolution (for each face)
  56253. * @param scene defines the hosting scene
  56254. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56255. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56256. */
  56257. constructor(
  56258. /** defines the name of the probe */
  56259. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56260. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56261. get samples(): number;
  56262. set samples(value: number);
  56263. /** Gets or sets the refresh rate to use (on every frame by default) */
  56264. get refreshRate(): number;
  56265. set refreshRate(value: number);
  56266. /**
  56267. * Gets the hosting scene
  56268. * @returns a Scene
  56269. */
  56270. getScene(): Scene;
  56271. /** Gets the internal CubeTexture used to render to */
  56272. get cubeTexture(): RenderTargetTexture;
  56273. /** Gets the list of meshes to render */
  56274. get renderList(): Nullable<AbstractMesh[]>;
  56275. /**
  56276. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56277. * @param mesh defines the mesh to attach to
  56278. */
  56279. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56280. /**
  56281. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56282. * @param renderingGroupId The rendering group id corresponding to its index
  56283. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56284. */
  56285. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56286. /**
  56287. * Clean all associated resources
  56288. */
  56289. dispose(): void;
  56290. /**
  56291. * Converts the reflection probe information to a readable string for debug purpose.
  56292. * @param fullDetails Supports for multiple levels of logging within scene loading
  56293. * @returns the human readable reflection probe info
  56294. */
  56295. toString(fullDetails?: boolean): string;
  56296. /**
  56297. * Get the class name of the relfection probe.
  56298. * @returns "ReflectionProbe"
  56299. */
  56300. getClassName(): string;
  56301. /**
  56302. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56303. * @returns The JSON representation of the texture
  56304. */
  56305. serialize(): any;
  56306. /**
  56307. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56308. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56309. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56310. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56311. * @returns The parsed reflection probe if successful
  56312. */
  56313. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56314. }
  56315. }
  56316. declare module BABYLON {
  56317. /** @hidden */
  56318. export var _BabylonLoaderRegistered: boolean;
  56319. /**
  56320. * Helps setting up some configuration for the babylon file loader.
  56321. */
  56322. export class BabylonFileLoaderConfiguration {
  56323. /**
  56324. * The loader does not allow injecting custom physix engine into the plugins.
  56325. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56326. * So you could set this variable to your engine import to make it work.
  56327. */
  56328. static LoaderInjectedPhysicsEngine: any;
  56329. }
  56330. }
  56331. declare module BABYLON {
  56332. /**
  56333. * The Physically based simple base material of BJS.
  56334. *
  56335. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56336. * It is used as the base class for both the specGloss and metalRough conventions.
  56337. */
  56338. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56339. /**
  56340. * Number of Simultaneous lights allowed on the material.
  56341. */
  56342. maxSimultaneousLights: number;
  56343. /**
  56344. * If sets to true, disables all the lights affecting the material.
  56345. */
  56346. disableLighting: boolean;
  56347. /**
  56348. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56349. */
  56350. environmentTexture: BaseTexture;
  56351. /**
  56352. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56353. */
  56354. invertNormalMapX: boolean;
  56355. /**
  56356. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56357. */
  56358. invertNormalMapY: boolean;
  56359. /**
  56360. * Normal map used in the model.
  56361. */
  56362. normalTexture: BaseTexture;
  56363. /**
  56364. * Emissivie color used to self-illuminate the model.
  56365. */
  56366. emissiveColor: Color3;
  56367. /**
  56368. * Emissivie texture used to self-illuminate the model.
  56369. */
  56370. emissiveTexture: BaseTexture;
  56371. /**
  56372. * Occlusion Channel Strenght.
  56373. */
  56374. occlusionStrength: number;
  56375. /**
  56376. * Occlusion Texture of the material (adding extra occlusion effects).
  56377. */
  56378. occlusionTexture: BaseTexture;
  56379. /**
  56380. * Defines the alpha limits in alpha test mode.
  56381. */
  56382. alphaCutOff: number;
  56383. /**
  56384. * Gets the current double sided mode.
  56385. */
  56386. get doubleSided(): boolean;
  56387. /**
  56388. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56389. */
  56390. set doubleSided(value: boolean);
  56391. /**
  56392. * Stores the pre-calculated light information of a mesh in a texture.
  56393. */
  56394. lightmapTexture: BaseTexture;
  56395. /**
  56396. * If true, the light map contains occlusion information instead of lighting info.
  56397. */
  56398. useLightmapAsShadowmap: boolean;
  56399. /**
  56400. * Instantiates a new PBRMaterial instance.
  56401. *
  56402. * @param name The material name
  56403. * @param scene The scene the material will be use in.
  56404. */
  56405. constructor(name: string, scene: Scene);
  56406. getClassName(): string;
  56407. }
  56408. }
  56409. declare module BABYLON {
  56410. /**
  56411. * The PBR material of BJS following the metal roughness convention.
  56412. *
  56413. * This fits to the PBR convention in the GLTF definition:
  56414. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56415. */
  56416. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56417. /**
  56418. * The base color has two different interpretations depending on the value of metalness.
  56419. * When the material is a metal, the base color is the specific measured reflectance value
  56420. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56421. * of the material.
  56422. */
  56423. baseColor: Color3;
  56424. /**
  56425. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56426. * well as opacity information in the alpha channel.
  56427. */
  56428. baseTexture: BaseTexture;
  56429. /**
  56430. * Specifies the metallic scalar value of the material.
  56431. * Can also be used to scale the metalness values of the metallic texture.
  56432. */
  56433. metallic: number;
  56434. /**
  56435. * Specifies the roughness scalar value of the material.
  56436. * Can also be used to scale the roughness values of the metallic texture.
  56437. */
  56438. roughness: number;
  56439. /**
  56440. * Texture containing both the metallic value in the B channel and the
  56441. * roughness value in the G channel to keep better precision.
  56442. */
  56443. metallicRoughnessTexture: BaseTexture;
  56444. /**
  56445. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56446. *
  56447. * @param name The material name
  56448. * @param scene The scene the material will be use in.
  56449. */
  56450. constructor(name: string, scene: Scene);
  56451. /**
  56452. * Return the currrent class name of the material.
  56453. */
  56454. getClassName(): string;
  56455. /**
  56456. * Makes a duplicate of the current material.
  56457. * @param name - name to use for the new material.
  56458. */
  56459. clone(name: string): PBRMetallicRoughnessMaterial;
  56460. /**
  56461. * Serialize the material to a parsable JSON object.
  56462. */
  56463. serialize(): any;
  56464. /**
  56465. * Parses a JSON object correponding to the serialize function.
  56466. */
  56467. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56468. }
  56469. }
  56470. declare module BABYLON {
  56471. /**
  56472. * The PBR material of BJS following the specular glossiness convention.
  56473. *
  56474. * This fits to the PBR convention in the GLTF definition:
  56475. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56476. */
  56477. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56478. /**
  56479. * Specifies the diffuse color of the material.
  56480. */
  56481. diffuseColor: Color3;
  56482. /**
  56483. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56484. * channel.
  56485. */
  56486. diffuseTexture: BaseTexture;
  56487. /**
  56488. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56489. */
  56490. specularColor: Color3;
  56491. /**
  56492. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56493. */
  56494. glossiness: number;
  56495. /**
  56496. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56497. */
  56498. specularGlossinessTexture: BaseTexture;
  56499. /**
  56500. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56501. *
  56502. * @param name The material name
  56503. * @param scene The scene the material will be use in.
  56504. */
  56505. constructor(name: string, scene: Scene);
  56506. /**
  56507. * Return the currrent class name of the material.
  56508. */
  56509. getClassName(): string;
  56510. /**
  56511. * Makes a duplicate of the current material.
  56512. * @param name - name to use for the new material.
  56513. */
  56514. clone(name: string): PBRSpecularGlossinessMaterial;
  56515. /**
  56516. * Serialize the material to a parsable JSON object.
  56517. */
  56518. serialize(): any;
  56519. /**
  56520. * Parses a JSON object correponding to the serialize function.
  56521. */
  56522. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56523. }
  56524. }
  56525. declare module BABYLON {
  56526. /**
  56527. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56528. * It can help converting any input color in a desired output one. This can then be used to create effects
  56529. * from sepia, black and white to sixties or futuristic rendering...
  56530. *
  56531. * The only supported format is currently 3dl.
  56532. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56533. */
  56534. export class ColorGradingTexture extends BaseTexture {
  56535. /**
  56536. * The current texture matrix. (will always be identity in color grading texture)
  56537. */
  56538. private _textureMatrix;
  56539. /**
  56540. * The texture URL.
  56541. */
  56542. url: string;
  56543. /**
  56544. * Empty line regex stored for GC.
  56545. */
  56546. private static _noneEmptyLineRegex;
  56547. private _engine;
  56548. /**
  56549. * Instantiates a ColorGradingTexture from the following parameters.
  56550. *
  56551. * @param url The location of the color gradind data (currently only supporting 3dl)
  56552. * @param scene The scene the texture will be used in
  56553. */
  56554. constructor(url: string, scene: Scene);
  56555. /**
  56556. * Returns the texture matrix used in most of the material.
  56557. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56558. */
  56559. getTextureMatrix(): Matrix;
  56560. /**
  56561. * Occurs when the file being loaded is a .3dl LUT file.
  56562. */
  56563. private load3dlTexture;
  56564. /**
  56565. * Starts the loading process of the texture.
  56566. */
  56567. private loadTexture;
  56568. /**
  56569. * Clones the color gradind texture.
  56570. */
  56571. clone(): ColorGradingTexture;
  56572. /**
  56573. * Called during delayed load for textures.
  56574. */
  56575. delayLoad(): void;
  56576. /**
  56577. * Parses a color grading texture serialized by Babylon.
  56578. * @param parsedTexture The texture information being parsedTexture
  56579. * @param scene The scene to load the texture in
  56580. * @param rootUrl The root url of the data assets to load
  56581. * @return A color gradind texture
  56582. */
  56583. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56584. /**
  56585. * Serializes the LUT texture to json format.
  56586. */
  56587. serialize(): any;
  56588. }
  56589. }
  56590. declare module BABYLON {
  56591. /**
  56592. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56593. */
  56594. export class EquiRectangularCubeTexture extends BaseTexture {
  56595. /** The six faces of the cube. */
  56596. private static _FacesMapping;
  56597. private _noMipmap;
  56598. private _onLoad;
  56599. private _onError;
  56600. /** The size of the cubemap. */
  56601. private _size;
  56602. /** The buffer of the image. */
  56603. private _buffer;
  56604. /** The width of the input image. */
  56605. private _width;
  56606. /** The height of the input image. */
  56607. private _height;
  56608. /** The URL to the image. */
  56609. url: string;
  56610. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56611. coordinatesMode: number;
  56612. /**
  56613. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56614. * @param url The location of the image
  56615. * @param scene The scene the texture will be used in
  56616. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56617. * @param noMipmap Forces to not generate the mipmap if true
  56618. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56619. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56620. * @param onLoad — defines a callback called when texture is loaded
  56621. * @param onError — defines a callback called if there is an error
  56622. */
  56623. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56624. /**
  56625. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56626. */
  56627. private loadImage;
  56628. /**
  56629. * Convert the image buffer into a cubemap and create a CubeTexture.
  56630. */
  56631. private loadTexture;
  56632. /**
  56633. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56634. * @param buffer The ArrayBuffer that should be converted.
  56635. * @returns The buffer as Float32Array.
  56636. */
  56637. private getFloat32ArrayFromArrayBuffer;
  56638. /**
  56639. * Get the current class name of the texture useful for serialization or dynamic coding.
  56640. * @returns "EquiRectangularCubeTexture"
  56641. */
  56642. getClassName(): string;
  56643. /**
  56644. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56645. * @returns A clone of the current EquiRectangularCubeTexture.
  56646. */
  56647. clone(): EquiRectangularCubeTexture;
  56648. }
  56649. }
  56650. declare module BABYLON {
  56651. /**
  56652. * Based on jsTGALoader - Javascript loader for TGA file
  56653. * By Vincent Thibault
  56654. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56655. */
  56656. export class TGATools {
  56657. private static _TYPE_INDEXED;
  56658. private static _TYPE_RGB;
  56659. private static _TYPE_GREY;
  56660. private static _TYPE_RLE_INDEXED;
  56661. private static _TYPE_RLE_RGB;
  56662. private static _TYPE_RLE_GREY;
  56663. private static _ORIGIN_MASK;
  56664. private static _ORIGIN_SHIFT;
  56665. private static _ORIGIN_BL;
  56666. private static _ORIGIN_BR;
  56667. private static _ORIGIN_UL;
  56668. private static _ORIGIN_UR;
  56669. /**
  56670. * Gets the header of a TGA file
  56671. * @param data defines the TGA data
  56672. * @returns the header
  56673. */
  56674. static GetTGAHeader(data: Uint8Array): any;
  56675. /**
  56676. * Uploads TGA content to a Babylon Texture
  56677. * @hidden
  56678. */
  56679. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56680. /** @hidden */
  56681. 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;
  56682. /** @hidden */
  56683. 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;
  56684. /** @hidden */
  56685. 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;
  56686. /** @hidden */
  56687. 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;
  56688. /** @hidden */
  56689. 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;
  56690. /** @hidden */
  56691. 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;
  56692. }
  56693. }
  56694. declare module BABYLON {
  56695. /**
  56696. * Implementation of the TGA Texture Loader.
  56697. * @hidden
  56698. */
  56699. export class _TGATextureLoader implements IInternalTextureLoader {
  56700. /**
  56701. * Defines wether the loader supports cascade loading the different faces.
  56702. */
  56703. readonly supportCascades: boolean;
  56704. /**
  56705. * This returns if the loader support the current file information.
  56706. * @param extension defines the file extension of the file being loaded
  56707. * @returns true if the loader can load the specified file
  56708. */
  56709. canLoad(extension: string): boolean;
  56710. /**
  56711. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56712. * @param data contains the texture data
  56713. * @param texture defines the BabylonJS internal texture
  56714. * @param createPolynomials will be true if polynomials have been requested
  56715. * @param onLoad defines the callback to trigger once the texture is ready
  56716. * @param onError defines the callback to trigger in case of error
  56717. */
  56718. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56719. /**
  56720. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56721. * @param data contains the texture data
  56722. * @param texture defines the BabylonJS internal texture
  56723. * @param callback defines the method to call once ready to upload
  56724. */
  56725. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56726. }
  56727. }
  56728. declare module BABYLON {
  56729. /**
  56730. * Info about the .basis files
  56731. */
  56732. class BasisFileInfo {
  56733. /**
  56734. * If the file has alpha
  56735. */
  56736. hasAlpha: boolean;
  56737. /**
  56738. * Info about each image of the basis file
  56739. */
  56740. images: Array<{
  56741. levels: Array<{
  56742. width: number;
  56743. height: number;
  56744. transcodedPixels: ArrayBufferView;
  56745. }>;
  56746. }>;
  56747. }
  56748. /**
  56749. * Result of transcoding a basis file
  56750. */
  56751. class TranscodeResult {
  56752. /**
  56753. * Info about the .basis file
  56754. */
  56755. fileInfo: BasisFileInfo;
  56756. /**
  56757. * Format to use when loading the file
  56758. */
  56759. format: number;
  56760. }
  56761. /**
  56762. * Configuration options for the Basis transcoder
  56763. */
  56764. export class BasisTranscodeConfiguration {
  56765. /**
  56766. * Supported compression formats used to determine the supported output format of the transcoder
  56767. */
  56768. supportedCompressionFormats?: {
  56769. /**
  56770. * etc1 compression format
  56771. */
  56772. etc1?: boolean;
  56773. /**
  56774. * s3tc compression format
  56775. */
  56776. s3tc?: boolean;
  56777. /**
  56778. * pvrtc compression format
  56779. */
  56780. pvrtc?: boolean;
  56781. /**
  56782. * etc2 compression format
  56783. */
  56784. etc2?: boolean;
  56785. };
  56786. /**
  56787. * If mipmap levels should be loaded for transcoded images (Default: true)
  56788. */
  56789. loadMipmapLevels?: boolean;
  56790. /**
  56791. * Index of a single image to load (Default: all images)
  56792. */
  56793. loadSingleImage?: number;
  56794. }
  56795. /**
  56796. * Used to load .Basis files
  56797. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56798. */
  56799. export class BasisTools {
  56800. private static _IgnoreSupportedFormats;
  56801. /**
  56802. * URL to use when loading the basis transcoder
  56803. */
  56804. static JSModuleURL: string;
  56805. /**
  56806. * URL to use when loading the wasm module for the transcoder
  56807. */
  56808. static WasmModuleURL: string;
  56809. /**
  56810. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56811. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56812. * @returns internal format corresponding to the Basis format
  56813. */
  56814. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56815. private static _WorkerPromise;
  56816. private static _Worker;
  56817. private static _actionId;
  56818. private static _CreateWorkerAsync;
  56819. /**
  56820. * Transcodes a loaded image file to compressed pixel data
  56821. * @param data image data to transcode
  56822. * @param config configuration options for the transcoding
  56823. * @returns a promise resulting in the transcoded image
  56824. */
  56825. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56826. /**
  56827. * Loads a texture from the transcode result
  56828. * @param texture texture load to
  56829. * @param transcodeResult the result of transcoding the basis file to load from
  56830. */
  56831. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56832. }
  56833. }
  56834. declare module BABYLON {
  56835. /**
  56836. * Loader for .basis file format
  56837. */
  56838. export class _BasisTextureLoader implements IInternalTextureLoader {
  56839. /**
  56840. * Defines whether the loader supports cascade loading the different faces.
  56841. */
  56842. readonly supportCascades: boolean;
  56843. /**
  56844. * This returns if the loader support the current file information.
  56845. * @param extension defines the file extension of the file being loaded
  56846. * @returns true if the loader can load the specified file
  56847. */
  56848. canLoad(extension: string): boolean;
  56849. /**
  56850. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56851. * @param data contains the texture data
  56852. * @param texture defines the BabylonJS internal texture
  56853. * @param createPolynomials will be true if polynomials have been requested
  56854. * @param onLoad defines the callback to trigger once the texture is ready
  56855. * @param onError defines the callback to trigger in case of error
  56856. */
  56857. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56858. /**
  56859. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56860. * @param data contains the texture data
  56861. * @param texture defines the BabylonJS internal texture
  56862. * @param callback defines the method to call once ready to upload
  56863. */
  56864. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56865. }
  56866. }
  56867. declare module BABYLON {
  56868. /**
  56869. * 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.
  56870. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56871. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56872. */
  56873. export class CustomProceduralTexture extends ProceduralTexture {
  56874. private _animate;
  56875. private _time;
  56876. private _config;
  56877. private _texturePath;
  56878. /**
  56879. * Instantiates a new Custom Procedural Texture.
  56880. * 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.
  56881. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56882. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56883. * @param name Define the name of the texture
  56884. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56885. * @param size Define the size of the texture to create
  56886. * @param scene Define the scene the texture belongs to
  56887. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56888. * @param generateMipMaps Define if the texture should creates mip maps or not
  56889. */
  56890. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56891. private _loadJson;
  56892. /**
  56893. * Is the texture ready to be used ? (rendered at least once)
  56894. * @returns true if ready, otherwise, false.
  56895. */
  56896. isReady(): boolean;
  56897. /**
  56898. * Render the texture to its associated render target.
  56899. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56900. */
  56901. render(useCameraPostProcess?: boolean): void;
  56902. /**
  56903. * Update the list of dependant textures samplers in the shader.
  56904. */
  56905. updateTextures(): void;
  56906. /**
  56907. * Update the uniform values of the procedural texture in the shader.
  56908. */
  56909. updateShaderUniforms(): void;
  56910. /**
  56911. * Define if the texture animates or not.
  56912. */
  56913. get animate(): boolean;
  56914. set animate(value: boolean);
  56915. }
  56916. }
  56917. declare module BABYLON {
  56918. /** @hidden */
  56919. export var noisePixelShader: {
  56920. name: string;
  56921. shader: string;
  56922. };
  56923. }
  56924. declare module BABYLON {
  56925. /**
  56926. * Class used to generate noise procedural textures
  56927. */
  56928. export class NoiseProceduralTexture extends ProceduralTexture {
  56929. private _time;
  56930. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56931. brightness: number;
  56932. /** Defines the number of octaves to process */
  56933. octaves: number;
  56934. /** Defines the level of persistence (0.8 by default) */
  56935. persistence: number;
  56936. /** Gets or sets animation speed factor (default is 1) */
  56937. animationSpeedFactor: number;
  56938. /**
  56939. * Creates a new NoiseProceduralTexture
  56940. * @param name defines the name fo the texture
  56941. * @param size defines the size of the texture (default is 256)
  56942. * @param scene defines the hosting scene
  56943. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56944. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56945. */
  56946. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56947. private _updateShaderUniforms;
  56948. protected _getDefines(): string;
  56949. /** Generate the current state of the procedural texture */
  56950. render(useCameraPostProcess?: boolean): void;
  56951. /**
  56952. * Serializes this noise procedural texture
  56953. * @returns a serialized noise procedural texture object
  56954. */
  56955. serialize(): any;
  56956. /**
  56957. * Clone the texture.
  56958. * @returns the cloned texture
  56959. */
  56960. clone(): NoiseProceduralTexture;
  56961. /**
  56962. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56963. * @param parsedTexture defines parsed texture data
  56964. * @param scene defines the current scene
  56965. * @param rootUrl defines the root URL containing noise procedural texture information
  56966. * @returns a parsed NoiseProceduralTexture
  56967. */
  56968. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56969. }
  56970. }
  56971. declare module BABYLON {
  56972. /**
  56973. * Raw cube texture where the raw buffers are passed in
  56974. */
  56975. export class RawCubeTexture extends CubeTexture {
  56976. /**
  56977. * Creates a cube texture where the raw buffers are passed in.
  56978. * @param scene defines the scene the texture is attached to
  56979. * @param data defines the array of data to use to create each face
  56980. * @param size defines the size of the textures
  56981. * @param format defines the format of the data
  56982. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56983. * @param generateMipMaps defines if the engine should generate the mip levels
  56984. * @param invertY defines if data must be stored with Y axis inverted
  56985. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56986. * @param compression defines the compression used (null by default)
  56987. */
  56988. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56989. /**
  56990. * Updates the raw cube texture.
  56991. * @param data defines the data to store
  56992. * @param format defines the data format
  56993. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56994. * @param invertY defines if data must be stored with Y axis inverted
  56995. * @param compression defines the compression used (null by default)
  56996. * @param level defines which level of the texture to update
  56997. */
  56998. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56999. /**
  57000. * Updates a raw cube texture with RGBD encoded data.
  57001. * @param data defines the array of data [mipmap][face] to use to create each face
  57002. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57003. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57004. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57005. * @returns a promsie that resolves when the operation is complete
  57006. */
  57007. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57008. /**
  57009. * Clones the raw cube texture.
  57010. * @return a new cube texture
  57011. */
  57012. clone(): CubeTexture;
  57013. /** @hidden */
  57014. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57015. }
  57016. }
  57017. declare module BABYLON {
  57018. /**
  57019. * Class used to store 3D textures containing user data
  57020. */
  57021. export class RawTexture3D extends Texture {
  57022. /** Gets or sets the texture format to use */
  57023. format: number;
  57024. private _engine;
  57025. /**
  57026. * Create a new RawTexture3D
  57027. * @param data defines the data of the texture
  57028. * @param width defines the width of the texture
  57029. * @param height defines the height of the texture
  57030. * @param depth defines the depth of the texture
  57031. * @param format defines the texture format to use
  57032. * @param scene defines the hosting scene
  57033. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57034. * @param invertY defines if texture must be stored with Y axis inverted
  57035. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57036. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57037. */
  57038. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57039. /** Gets or sets the texture format to use */
  57040. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57041. /**
  57042. * Update the texture with new data
  57043. * @param data defines the data to store in the texture
  57044. */
  57045. update(data: ArrayBufferView): void;
  57046. }
  57047. }
  57048. declare module BABYLON {
  57049. /**
  57050. * Class used to store 2D array textures containing user data
  57051. */
  57052. export class RawTexture2DArray extends Texture {
  57053. /** Gets or sets the texture format to use */
  57054. format: number;
  57055. private _engine;
  57056. /**
  57057. * Create a new RawTexture2DArray
  57058. * @param data defines the data of the texture
  57059. * @param width defines the width of the texture
  57060. * @param height defines the height of the texture
  57061. * @param depth defines the number of layers of the texture
  57062. * @param format defines the texture format to use
  57063. * @param scene defines the hosting scene
  57064. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57065. * @param invertY defines if texture must be stored with Y axis inverted
  57066. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57067. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57068. */
  57069. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57070. /** Gets or sets the texture format to use */
  57071. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57072. /**
  57073. * Update the texture with new data
  57074. * @param data defines the data to store in the texture
  57075. */
  57076. update(data: ArrayBufferView): void;
  57077. }
  57078. }
  57079. declare module BABYLON {
  57080. /**
  57081. * Creates a refraction texture used by refraction channel of the standard material.
  57082. * It is like a mirror but to see through a material.
  57083. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57084. */
  57085. export class RefractionTexture extends RenderTargetTexture {
  57086. /**
  57087. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57088. * 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.
  57089. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57090. */
  57091. refractionPlane: Plane;
  57092. /**
  57093. * Define how deep under the surface we should see.
  57094. */
  57095. depth: number;
  57096. /**
  57097. * Creates a refraction texture used by refraction channel of the standard material.
  57098. * It is like a mirror but to see through a material.
  57099. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57100. * @param name Define the texture name
  57101. * @param size Define the size of the underlying texture
  57102. * @param scene Define the scene the refraction belongs to
  57103. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57104. */
  57105. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57106. /**
  57107. * Clone the refraction texture.
  57108. * @returns the cloned texture
  57109. */
  57110. clone(): RefractionTexture;
  57111. /**
  57112. * Serialize the texture to a JSON representation you could use in Parse later on
  57113. * @returns the serialized JSON representation
  57114. */
  57115. serialize(): any;
  57116. }
  57117. }
  57118. declare module BABYLON {
  57119. /**
  57120. * Defines the options related to the creation of an HtmlElementTexture
  57121. */
  57122. export interface IHtmlElementTextureOptions {
  57123. /**
  57124. * Defines wether mip maps should be created or not.
  57125. */
  57126. generateMipMaps?: boolean;
  57127. /**
  57128. * Defines the sampling mode of the texture.
  57129. */
  57130. samplingMode?: number;
  57131. /**
  57132. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57133. */
  57134. engine: Nullable<ThinEngine>;
  57135. /**
  57136. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57137. */
  57138. scene: Nullable<Scene>;
  57139. }
  57140. /**
  57141. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57142. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57143. * is automatically managed.
  57144. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57145. * in your application.
  57146. *
  57147. * As the update is not automatic, you need to call them manually.
  57148. */
  57149. export class HtmlElementTexture extends BaseTexture {
  57150. /**
  57151. * The texture URL.
  57152. */
  57153. element: HTMLVideoElement | HTMLCanvasElement;
  57154. private static readonly DefaultOptions;
  57155. private _textureMatrix;
  57156. private _engine;
  57157. private _isVideo;
  57158. private _generateMipMaps;
  57159. private _samplingMode;
  57160. /**
  57161. * Instantiates a HtmlElementTexture from the following parameters.
  57162. *
  57163. * @param name Defines the name of the texture
  57164. * @param element Defines the video or canvas the texture is filled with
  57165. * @param options Defines the other none mandatory texture creation options
  57166. */
  57167. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57168. private _createInternalTexture;
  57169. /**
  57170. * Returns the texture matrix used in most of the material.
  57171. */
  57172. getTextureMatrix(): Matrix;
  57173. /**
  57174. * Updates the content of the texture.
  57175. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57176. */
  57177. update(invertY?: Nullable<boolean>): void;
  57178. }
  57179. }
  57180. declare module BABYLON {
  57181. /**
  57182. * Defines the basic options interface of a TexturePacker Frame
  57183. */
  57184. export interface ITexturePackerFrame {
  57185. /**
  57186. * The frame ID
  57187. */
  57188. id: number;
  57189. /**
  57190. * The frames Scale
  57191. */
  57192. scale: Vector2;
  57193. /**
  57194. * The Frames offset
  57195. */
  57196. offset: Vector2;
  57197. }
  57198. /**
  57199. * This is a support class for frame Data on texture packer sets.
  57200. */
  57201. export class TexturePackerFrame implements ITexturePackerFrame {
  57202. /**
  57203. * The frame ID
  57204. */
  57205. id: number;
  57206. /**
  57207. * The frames Scale
  57208. */
  57209. scale: Vector2;
  57210. /**
  57211. * The Frames offset
  57212. */
  57213. offset: Vector2;
  57214. /**
  57215. * Initializes a texture package frame.
  57216. * @param id The numerical frame identifier
  57217. * @param scale Scalar Vector2 for UV frame
  57218. * @param offset Vector2 for the frame position in UV units.
  57219. * @returns TexturePackerFrame
  57220. */
  57221. constructor(id: number, scale: Vector2, offset: Vector2);
  57222. }
  57223. }
  57224. declare module BABYLON {
  57225. /**
  57226. * Defines the basic options interface of a TexturePacker
  57227. */
  57228. export interface ITexturePackerOptions {
  57229. /**
  57230. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57231. */
  57232. map?: string[];
  57233. /**
  57234. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57235. */
  57236. uvsIn?: string;
  57237. /**
  57238. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57239. */
  57240. uvsOut?: string;
  57241. /**
  57242. * number representing the layout style. Defaults to LAYOUT_STRIP
  57243. */
  57244. layout?: number;
  57245. /**
  57246. * number of columns if using custom column count layout(2). This defaults to 4.
  57247. */
  57248. colnum?: number;
  57249. /**
  57250. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57251. */
  57252. updateInputMeshes?: boolean;
  57253. /**
  57254. * boolean flag to dispose all the source textures. Defaults to true.
  57255. */
  57256. disposeSources?: boolean;
  57257. /**
  57258. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57259. */
  57260. fillBlanks?: boolean;
  57261. /**
  57262. * string value representing the context fill style color. Defaults to 'black'.
  57263. */
  57264. customFillColor?: string;
  57265. /**
  57266. * Width and Height Value of each Frame in the TexturePacker Sets
  57267. */
  57268. frameSize?: number;
  57269. /**
  57270. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57271. */
  57272. paddingRatio?: number;
  57273. /**
  57274. * Number that declares the fill method for the padding gutter.
  57275. */
  57276. paddingMode?: number;
  57277. /**
  57278. * If in SUBUV_COLOR padding mode what color to use.
  57279. */
  57280. paddingColor?: Color3 | Color4;
  57281. }
  57282. /**
  57283. * Defines the basic interface of a TexturePacker JSON File
  57284. */
  57285. export interface ITexturePackerJSON {
  57286. /**
  57287. * The frame ID
  57288. */
  57289. name: string;
  57290. /**
  57291. * The base64 channel data
  57292. */
  57293. sets: any;
  57294. /**
  57295. * The options of the Packer
  57296. */
  57297. options: ITexturePackerOptions;
  57298. /**
  57299. * The frame data of the Packer
  57300. */
  57301. frames: Array<number>;
  57302. }
  57303. /**
  57304. * This is a support class that generates a series of packed texture sets.
  57305. * @see https://doc.babylonjs.com/babylon101/materials
  57306. */
  57307. export class TexturePacker {
  57308. /** Packer Layout Constant 0 */
  57309. static readonly LAYOUT_STRIP: number;
  57310. /** Packer Layout Constant 1 */
  57311. static readonly LAYOUT_POWER2: number;
  57312. /** Packer Layout Constant 2 */
  57313. static readonly LAYOUT_COLNUM: number;
  57314. /** Packer Layout Constant 0 */
  57315. static readonly SUBUV_WRAP: number;
  57316. /** Packer Layout Constant 1 */
  57317. static readonly SUBUV_EXTEND: number;
  57318. /** Packer Layout Constant 2 */
  57319. static readonly SUBUV_COLOR: number;
  57320. /** The Name of the Texture Package */
  57321. name: string;
  57322. /** The scene scope of the TexturePacker */
  57323. scene: Scene;
  57324. /** The Meshes to target */
  57325. meshes: AbstractMesh[];
  57326. /** Arguments passed with the Constructor */
  57327. options: ITexturePackerOptions;
  57328. /** The promise that is started upon initialization */
  57329. promise: Nullable<Promise<TexturePacker | string>>;
  57330. /** The Container object for the channel sets that are generated */
  57331. sets: object;
  57332. /** The Container array for the frames that are generated */
  57333. frames: TexturePackerFrame[];
  57334. /** The expected number of textures the system is parsing. */
  57335. private _expecting;
  57336. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57337. private _paddingValue;
  57338. /**
  57339. * Initializes a texture package series from an array of meshes or a single mesh.
  57340. * @param name The name of the package
  57341. * @param meshes The target meshes to compose the package from
  57342. * @param options The arguments that texture packer should follow while building.
  57343. * @param scene The scene which the textures are scoped to.
  57344. * @returns TexturePacker
  57345. */
  57346. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57347. /**
  57348. * Starts the package process
  57349. * @param resolve The promises resolution function
  57350. * @returns TexturePacker
  57351. */
  57352. private _createFrames;
  57353. /**
  57354. * Calculates the Size of the Channel Sets
  57355. * @returns Vector2
  57356. */
  57357. private _calculateSize;
  57358. /**
  57359. * Calculates the UV data for the frames.
  57360. * @param baseSize the base frameSize
  57361. * @param padding the base frame padding
  57362. * @param dtSize size of the Dynamic Texture for that channel
  57363. * @param dtUnits is 1/dtSize
  57364. * @param update flag to update the input meshes
  57365. */
  57366. private _calculateMeshUVFrames;
  57367. /**
  57368. * Calculates the frames Offset.
  57369. * @param index of the frame
  57370. * @returns Vector2
  57371. */
  57372. private _getFrameOffset;
  57373. /**
  57374. * Updates a Mesh to the frame data
  57375. * @param mesh that is the target
  57376. * @param frameID or the frame index
  57377. */
  57378. private _updateMeshUV;
  57379. /**
  57380. * Updates a Meshes materials to use the texture packer channels
  57381. * @param m is the mesh to target
  57382. * @param force all channels on the packer to be set.
  57383. */
  57384. private _updateTextureReferences;
  57385. /**
  57386. * Public method to set a Mesh to a frame
  57387. * @param m that is the target
  57388. * @param frameID or the frame index
  57389. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57390. */
  57391. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57392. /**
  57393. * Starts the async promise to compile the texture packer.
  57394. * @returns Promise<void>
  57395. */
  57396. processAsync(): Promise<void>;
  57397. /**
  57398. * Disposes all textures associated with this packer
  57399. */
  57400. dispose(): void;
  57401. /**
  57402. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57403. * @param imageType is the image type to use.
  57404. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57405. */
  57406. download(imageType?: string, quality?: number): void;
  57407. /**
  57408. * Public method to load a texturePacker JSON file.
  57409. * @param data of the JSON file in string format.
  57410. */
  57411. updateFromJSON(data: string): void;
  57412. }
  57413. }
  57414. declare module BABYLON {
  57415. /**
  57416. * Enum used to define the target of a block
  57417. */
  57418. export enum NodeMaterialBlockTargets {
  57419. /** Vertex shader */
  57420. Vertex = 1,
  57421. /** Fragment shader */
  57422. Fragment = 2,
  57423. /** Neutral */
  57424. Neutral = 4,
  57425. /** Vertex and Fragment */
  57426. VertexAndFragment = 3
  57427. }
  57428. }
  57429. declare module BABYLON {
  57430. /**
  57431. * Defines the kind of connection point for node based material
  57432. */
  57433. export enum NodeMaterialBlockConnectionPointTypes {
  57434. /** Float */
  57435. Float = 1,
  57436. /** Int */
  57437. Int = 2,
  57438. /** Vector2 */
  57439. Vector2 = 4,
  57440. /** Vector3 */
  57441. Vector3 = 8,
  57442. /** Vector4 */
  57443. Vector4 = 16,
  57444. /** Color3 */
  57445. Color3 = 32,
  57446. /** Color4 */
  57447. Color4 = 64,
  57448. /** Matrix */
  57449. Matrix = 128,
  57450. /** Detect type based on connection */
  57451. AutoDetect = 1024,
  57452. /** Output type that will be defined by input type */
  57453. BasedOnInput = 2048
  57454. }
  57455. }
  57456. declare module BABYLON {
  57457. /**
  57458. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57459. */
  57460. export enum NodeMaterialBlockConnectionPointMode {
  57461. /** Value is an uniform */
  57462. Uniform = 0,
  57463. /** Value is a mesh attribute */
  57464. Attribute = 1,
  57465. /** Value is a varying between vertex and fragment shaders */
  57466. Varying = 2,
  57467. /** Mode is undefined */
  57468. Undefined = 3
  57469. }
  57470. }
  57471. declare module BABYLON {
  57472. /**
  57473. * Enum used to define system values e.g. values automatically provided by the system
  57474. */
  57475. export enum NodeMaterialSystemValues {
  57476. /** World */
  57477. World = 1,
  57478. /** View */
  57479. View = 2,
  57480. /** Projection */
  57481. Projection = 3,
  57482. /** ViewProjection */
  57483. ViewProjection = 4,
  57484. /** WorldView */
  57485. WorldView = 5,
  57486. /** WorldViewProjection */
  57487. WorldViewProjection = 6,
  57488. /** CameraPosition */
  57489. CameraPosition = 7,
  57490. /** Fog Color */
  57491. FogColor = 8,
  57492. /** Delta time */
  57493. DeltaTime = 9
  57494. }
  57495. }
  57496. declare module BABYLON {
  57497. /**
  57498. * Root class for all node material optimizers
  57499. */
  57500. export class NodeMaterialOptimizer {
  57501. /**
  57502. * Function used to optimize a NodeMaterial graph
  57503. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57504. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57505. */
  57506. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57507. }
  57508. }
  57509. declare module BABYLON {
  57510. /**
  57511. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57512. */
  57513. export class TransformBlock extends NodeMaterialBlock {
  57514. /**
  57515. * Defines the value to use to complement W value to transform it to a Vector4
  57516. */
  57517. complementW: number;
  57518. /**
  57519. * Defines the value to use to complement z value to transform it to a Vector4
  57520. */
  57521. complementZ: number;
  57522. /**
  57523. * Creates a new TransformBlock
  57524. * @param name defines the block name
  57525. */
  57526. constructor(name: string);
  57527. /**
  57528. * Gets the current class name
  57529. * @returns the class name
  57530. */
  57531. getClassName(): string;
  57532. /**
  57533. * Gets the vector input
  57534. */
  57535. get vector(): NodeMaterialConnectionPoint;
  57536. /**
  57537. * Gets the output component
  57538. */
  57539. get output(): NodeMaterialConnectionPoint;
  57540. /**
  57541. * Gets the xyz output component
  57542. */
  57543. get xyz(): NodeMaterialConnectionPoint;
  57544. /**
  57545. * Gets the matrix transform input
  57546. */
  57547. get transform(): NodeMaterialConnectionPoint;
  57548. protected _buildBlock(state: NodeMaterialBuildState): this;
  57549. serialize(): any;
  57550. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57551. protected _dumpPropertiesCode(): string;
  57552. }
  57553. }
  57554. declare module BABYLON {
  57555. /**
  57556. * Block used to output the vertex position
  57557. */
  57558. export class VertexOutputBlock extends NodeMaterialBlock {
  57559. /**
  57560. * Creates a new VertexOutputBlock
  57561. * @param name defines the block name
  57562. */
  57563. constructor(name: string);
  57564. /**
  57565. * Gets the current class name
  57566. * @returns the class name
  57567. */
  57568. getClassName(): string;
  57569. /**
  57570. * Gets the vector input component
  57571. */
  57572. get vector(): NodeMaterialConnectionPoint;
  57573. protected _buildBlock(state: NodeMaterialBuildState): this;
  57574. }
  57575. }
  57576. declare module BABYLON {
  57577. /**
  57578. * Block used to output the final color
  57579. */
  57580. export class FragmentOutputBlock extends NodeMaterialBlock {
  57581. /**
  57582. * Create a new FragmentOutputBlock
  57583. * @param name defines the block name
  57584. */
  57585. constructor(name: string);
  57586. /**
  57587. * Gets the current class name
  57588. * @returns the class name
  57589. */
  57590. getClassName(): string;
  57591. /**
  57592. * Gets the rgba input component
  57593. */
  57594. get rgba(): NodeMaterialConnectionPoint;
  57595. /**
  57596. * Gets the rgb input component
  57597. */
  57598. get rgb(): NodeMaterialConnectionPoint;
  57599. /**
  57600. * Gets the a input component
  57601. */
  57602. get a(): NodeMaterialConnectionPoint;
  57603. protected _buildBlock(state: NodeMaterialBuildState): this;
  57604. }
  57605. }
  57606. declare module BABYLON {
  57607. /**
  57608. * Block used to read a reflection texture from a sampler
  57609. */
  57610. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57611. private _define3DName;
  57612. private _defineCubicName;
  57613. private _defineExplicitName;
  57614. private _defineProjectionName;
  57615. private _defineLocalCubicName;
  57616. private _defineSphericalName;
  57617. private _definePlanarName;
  57618. private _defineEquirectangularName;
  57619. private _defineMirroredEquirectangularFixedName;
  57620. private _defineEquirectangularFixedName;
  57621. private _defineSkyboxName;
  57622. private _cubeSamplerName;
  57623. private _2DSamplerName;
  57624. private _positionUVWName;
  57625. private _directionWName;
  57626. private _reflectionCoordsName;
  57627. private _reflection2DCoordsName;
  57628. private _reflectionColorName;
  57629. private _reflectionMatrixName;
  57630. /**
  57631. * Gets or sets the texture associated with the node
  57632. */
  57633. texture: Nullable<BaseTexture>;
  57634. /**
  57635. * Create a new TextureBlock
  57636. * @param name defines the block name
  57637. */
  57638. constructor(name: string);
  57639. /**
  57640. * Gets the current class name
  57641. * @returns the class name
  57642. */
  57643. getClassName(): string;
  57644. /**
  57645. * Gets the world position input component
  57646. */
  57647. get position(): NodeMaterialConnectionPoint;
  57648. /**
  57649. * Gets the world position input component
  57650. */
  57651. get worldPosition(): NodeMaterialConnectionPoint;
  57652. /**
  57653. * Gets the world normal input component
  57654. */
  57655. get worldNormal(): NodeMaterialConnectionPoint;
  57656. /**
  57657. * Gets the world input component
  57658. */
  57659. get world(): NodeMaterialConnectionPoint;
  57660. /**
  57661. * Gets the camera (or eye) position component
  57662. */
  57663. get cameraPosition(): NodeMaterialConnectionPoint;
  57664. /**
  57665. * Gets the view input component
  57666. */
  57667. get view(): NodeMaterialConnectionPoint;
  57668. /**
  57669. * Gets the rgb output component
  57670. */
  57671. get rgb(): NodeMaterialConnectionPoint;
  57672. /**
  57673. * Gets the r output component
  57674. */
  57675. get r(): NodeMaterialConnectionPoint;
  57676. /**
  57677. * Gets the g output component
  57678. */
  57679. get g(): NodeMaterialConnectionPoint;
  57680. /**
  57681. * Gets the b output component
  57682. */
  57683. get b(): NodeMaterialConnectionPoint;
  57684. autoConfigure(material: NodeMaterial): void;
  57685. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57686. isReady(): boolean;
  57687. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57688. private _injectVertexCode;
  57689. private _writeOutput;
  57690. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57691. protected _dumpPropertiesCode(): string;
  57692. serialize(): any;
  57693. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57694. }
  57695. }
  57696. declare module BABYLON {
  57697. /**
  57698. * Interface used to configure the node material editor
  57699. */
  57700. export interface INodeMaterialEditorOptions {
  57701. /** Define the URl to load node editor script */
  57702. editorURL?: string;
  57703. }
  57704. /** @hidden */
  57705. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57706. NORMAL: boolean;
  57707. TANGENT: boolean;
  57708. UV1: boolean;
  57709. /** BONES */
  57710. NUM_BONE_INFLUENCERS: number;
  57711. BonesPerMesh: number;
  57712. BONETEXTURE: boolean;
  57713. /** MORPH TARGETS */
  57714. MORPHTARGETS: boolean;
  57715. MORPHTARGETS_NORMAL: boolean;
  57716. MORPHTARGETS_TANGENT: boolean;
  57717. MORPHTARGETS_UV: boolean;
  57718. NUM_MORPH_INFLUENCERS: number;
  57719. /** IMAGE PROCESSING */
  57720. IMAGEPROCESSING: boolean;
  57721. VIGNETTE: boolean;
  57722. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57723. VIGNETTEBLENDMODEOPAQUE: boolean;
  57724. TONEMAPPING: boolean;
  57725. TONEMAPPING_ACES: boolean;
  57726. CONTRAST: boolean;
  57727. EXPOSURE: boolean;
  57728. COLORCURVES: boolean;
  57729. COLORGRADING: boolean;
  57730. COLORGRADING3D: boolean;
  57731. SAMPLER3DGREENDEPTH: boolean;
  57732. SAMPLER3DBGRMAP: boolean;
  57733. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57734. /** MISC. */
  57735. BUMPDIRECTUV: number;
  57736. constructor();
  57737. setValue(name: string, value: boolean): void;
  57738. }
  57739. /**
  57740. * Class used to configure NodeMaterial
  57741. */
  57742. export interface INodeMaterialOptions {
  57743. /**
  57744. * Defines if blocks should emit comments
  57745. */
  57746. emitComments: boolean;
  57747. }
  57748. /**
  57749. * Class used to create a node based material built by assembling shader blocks
  57750. */
  57751. export class NodeMaterial extends PushMaterial {
  57752. private static _BuildIdGenerator;
  57753. private _options;
  57754. private _vertexCompilationState;
  57755. private _fragmentCompilationState;
  57756. private _sharedData;
  57757. private _buildId;
  57758. private _buildWasSuccessful;
  57759. private _cachedWorldViewMatrix;
  57760. private _cachedWorldViewProjectionMatrix;
  57761. private _optimizers;
  57762. private _animationFrame;
  57763. /** Define the Url to load node editor script */
  57764. static EditorURL: string;
  57765. /** Define the Url to load snippets */
  57766. static SnippetUrl: string;
  57767. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  57768. static IgnoreTexturesAtLoadTime: boolean;
  57769. private BJSNODEMATERIALEDITOR;
  57770. /** Get the inspector from bundle or global */
  57771. private _getGlobalNodeMaterialEditor;
  57772. /**
  57773. * Snippet ID if the material was created from the snippet server
  57774. */
  57775. snippetId: string;
  57776. /**
  57777. * Gets or sets data used by visual editor
  57778. * @see https://nme.babylonjs.com
  57779. */
  57780. editorData: any;
  57781. /**
  57782. * 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)
  57783. */
  57784. ignoreAlpha: boolean;
  57785. /**
  57786. * Defines the maximum number of lights that can be used in the material
  57787. */
  57788. maxSimultaneousLights: number;
  57789. /**
  57790. * Observable raised when the material is built
  57791. */
  57792. onBuildObservable: Observable<NodeMaterial>;
  57793. /**
  57794. * Gets or sets the root nodes of the material vertex shader
  57795. */
  57796. _vertexOutputNodes: NodeMaterialBlock[];
  57797. /**
  57798. * Gets or sets the root nodes of the material fragment (pixel) shader
  57799. */
  57800. _fragmentOutputNodes: NodeMaterialBlock[];
  57801. /** Gets or sets options to control the node material overall behavior */
  57802. get options(): INodeMaterialOptions;
  57803. set options(options: INodeMaterialOptions);
  57804. /**
  57805. * Default configuration related to image processing available in the standard Material.
  57806. */
  57807. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57808. /**
  57809. * Gets the image processing configuration used either in this material.
  57810. */
  57811. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57812. /**
  57813. * Sets the Default image processing configuration used either in the this material.
  57814. *
  57815. * If sets to null, the scene one is in use.
  57816. */
  57817. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57818. /**
  57819. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57820. */
  57821. attachedBlocks: NodeMaterialBlock[];
  57822. /**
  57823. * Create a new node based material
  57824. * @param name defines the material name
  57825. * @param scene defines the hosting scene
  57826. * @param options defines creation option
  57827. */
  57828. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57829. /**
  57830. * Gets the current class name of the material e.g. "NodeMaterial"
  57831. * @returns the class name
  57832. */
  57833. getClassName(): string;
  57834. /**
  57835. * Keep track of the image processing observer to allow dispose and replace.
  57836. */
  57837. private _imageProcessingObserver;
  57838. /**
  57839. * Attaches a new image processing configuration to the Standard Material.
  57840. * @param configuration
  57841. */
  57842. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57843. /**
  57844. * Get a block by its name
  57845. * @param name defines the name of the block to retrieve
  57846. * @returns the required block or null if not found
  57847. */
  57848. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57849. /**
  57850. * Get a block by its name
  57851. * @param predicate defines the predicate used to find the good candidate
  57852. * @returns the required block or null if not found
  57853. */
  57854. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57855. /**
  57856. * Get an input block by its name
  57857. * @param predicate defines the predicate used to find the good candidate
  57858. * @returns the required input block or null if not found
  57859. */
  57860. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57861. /**
  57862. * Gets the list of input blocks attached to this material
  57863. * @returns an array of InputBlocks
  57864. */
  57865. getInputBlocks(): InputBlock[];
  57866. /**
  57867. * Adds a new optimizer to the list of optimizers
  57868. * @param optimizer defines the optimizers to add
  57869. * @returns the current material
  57870. */
  57871. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57872. /**
  57873. * Remove an optimizer from the list of optimizers
  57874. * @param optimizer defines the optimizers to remove
  57875. * @returns the current material
  57876. */
  57877. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57878. /**
  57879. * Add a new block to the list of output nodes
  57880. * @param node defines the node to add
  57881. * @returns the current material
  57882. */
  57883. addOutputNode(node: NodeMaterialBlock): this;
  57884. /**
  57885. * Remove a block from the list of root nodes
  57886. * @param node defines the node to remove
  57887. * @returns the current material
  57888. */
  57889. removeOutputNode(node: NodeMaterialBlock): this;
  57890. private _addVertexOutputNode;
  57891. private _removeVertexOutputNode;
  57892. private _addFragmentOutputNode;
  57893. private _removeFragmentOutputNode;
  57894. /**
  57895. * Specifies if the material will require alpha blending
  57896. * @returns a boolean specifying if alpha blending is needed
  57897. */
  57898. needAlphaBlending(): boolean;
  57899. /**
  57900. * Specifies if this material should be rendered in alpha test mode
  57901. * @returns a boolean specifying if an alpha test is needed.
  57902. */
  57903. needAlphaTesting(): boolean;
  57904. private _initializeBlock;
  57905. private _resetDualBlocks;
  57906. /**
  57907. * Remove a block from the current node material
  57908. * @param block defines the block to remove
  57909. */
  57910. removeBlock(block: NodeMaterialBlock): void;
  57911. /**
  57912. * Build the material and generates the inner effect
  57913. * @param verbose defines if the build should log activity
  57914. */
  57915. build(verbose?: boolean): void;
  57916. /**
  57917. * Runs an otpimization phase to try to improve the shader code
  57918. */
  57919. optimize(): void;
  57920. private _prepareDefinesForAttributes;
  57921. /**
  57922. * Get if the submesh is ready to be used and all its information available.
  57923. * Child classes can use it to update shaders
  57924. * @param mesh defines the mesh to check
  57925. * @param subMesh defines which submesh to check
  57926. * @param useInstances specifies that instances should be used
  57927. * @returns a boolean indicating that the submesh is ready or not
  57928. */
  57929. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57930. /**
  57931. * Get a string representing the shaders built by the current node graph
  57932. */
  57933. get compiledShaders(): string;
  57934. /**
  57935. * Binds the world matrix to the material
  57936. * @param world defines the world transformation matrix
  57937. */
  57938. bindOnlyWorldMatrix(world: Matrix): void;
  57939. /**
  57940. * Binds the submesh to this material by preparing the effect and shader to draw
  57941. * @param world defines the world transformation matrix
  57942. * @param mesh defines the mesh containing the submesh
  57943. * @param subMesh defines the submesh to bind the material to
  57944. */
  57945. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57946. /**
  57947. * Gets the active textures from the material
  57948. * @returns an array of textures
  57949. */
  57950. getActiveTextures(): BaseTexture[];
  57951. /**
  57952. * Gets the list of texture blocks
  57953. * @returns an array of texture blocks
  57954. */
  57955. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57956. /**
  57957. * Specifies if the material uses a texture
  57958. * @param texture defines the texture to check against the material
  57959. * @returns a boolean specifying if the material uses the texture
  57960. */
  57961. hasTexture(texture: BaseTexture): boolean;
  57962. /**
  57963. * Disposes the material
  57964. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57965. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57966. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57967. */
  57968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57969. /** Creates the node editor window. */
  57970. private _createNodeEditor;
  57971. /**
  57972. * Launch the node material editor
  57973. * @param config Define the configuration of the editor
  57974. * @return a promise fulfilled when the node editor is visible
  57975. */
  57976. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57977. /**
  57978. * Clear the current material
  57979. */
  57980. clear(): void;
  57981. /**
  57982. * Clear the current material and set it to a default state
  57983. */
  57984. setToDefault(): void;
  57985. /**
  57986. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57987. * @param url defines the url to load from
  57988. * @returns a promise that will fullfil when the material is fully loaded
  57989. */
  57990. loadAsync(url: string): Promise<void>;
  57991. private _gatherBlocks;
  57992. /**
  57993. * Generate a string containing the code declaration required to create an equivalent of this material
  57994. * @returns a string
  57995. */
  57996. generateCode(): string;
  57997. /**
  57998. * Serializes this material in a JSON representation
  57999. * @returns the serialized material object
  58000. */
  58001. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58002. private _restoreConnections;
  58003. /**
  58004. * Clear the current graph and load a new one from a serialization object
  58005. * @param source defines the JSON representation of the material
  58006. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58007. */
  58008. loadFromSerialization(source: any, rootUrl?: string): void;
  58009. /**
  58010. * Makes a duplicate of the current material.
  58011. * @param name - name to use for the new material.
  58012. */
  58013. clone(name: string): NodeMaterial;
  58014. /**
  58015. * Creates a node material from parsed material data
  58016. * @param source defines the JSON representation of the material
  58017. * @param scene defines the hosting scene
  58018. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58019. * @returns a new node material
  58020. */
  58021. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58022. /**
  58023. * Creates a node material from a snippet saved in a remote file
  58024. * @param name defines the name of the material to create
  58025. * @param url defines the url to load from
  58026. * @param scene defines the hosting scene
  58027. * @returns a promise that will resolve to the new node material
  58028. */
  58029. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  58030. /**
  58031. * Creates a node material from a snippet saved by the node material editor
  58032. * @param snippetId defines the snippet to load
  58033. * @param scene defines the hosting scene
  58034. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58035. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  58036. * @returns a promise that will resolve to the new node material
  58037. */
  58038. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  58039. /**
  58040. * Creates a new node material set to default basic configuration
  58041. * @param name defines the name of the material
  58042. * @param scene defines the hosting scene
  58043. * @returns a new NodeMaterial
  58044. */
  58045. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58046. }
  58047. }
  58048. declare module BABYLON {
  58049. /**
  58050. * Block used to read a texture from a sampler
  58051. */
  58052. export class TextureBlock extends NodeMaterialBlock {
  58053. private _defineName;
  58054. private _linearDefineName;
  58055. private _tempTextureRead;
  58056. private _samplerName;
  58057. private _transformedUVName;
  58058. private _textureTransformName;
  58059. private _textureInfoName;
  58060. private _mainUVName;
  58061. private _mainUVDefineName;
  58062. /**
  58063. * Gets or sets the texture associated with the node
  58064. */
  58065. texture: Nullable<Texture>;
  58066. /**
  58067. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58068. */
  58069. convertToGammaSpace: boolean;
  58070. /**
  58071. * Create a new TextureBlock
  58072. * @param name defines the block name
  58073. */
  58074. constructor(name: string);
  58075. /**
  58076. * Gets the current class name
  58077. * @returns the class name
  58078. */
  58079. getClassName(): string;
  58080. /**
  58081. * Gets the uv input component
  58082. */
  58083. get uv(): NodeMaterialConnectionPoint;
  58084. /**
  58085. * Gets the rgba output component
  58086. */
  58087. get rgba(): NodeMaterialConnectionPoint;
  58088. /**
  58089. * Gets the rgb output component
  58090. */
  58091. get rgb(): NodeMaterialConnectionPoint;
  58092. /**
  58093. * Gets the r output component
  58094. */
  58095. get r(): NodeMaterialConnectionPoint;
  58096. /**
  58097. * Gets the g output component
  58098. */
  58099. get g(): NodeMaterialConnectionPoint;
  58100. /**
  58101. * Gets the b output component
  58102. */
  58103. get b(): NodeMaterialConnectionPoint;
  58104. /**
  58105. * Gets the a output component
  58106. */
  58107. get a(): NodeMaterialConnectionPoint;
  58108. get target(): NodeMaterialBlockTargets;
  58109. autoConfigure(material: NodeMaterial): void;
  58110. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58111. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58112. isReady(): boolean;
  58113. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58114. private get _isMixed();
  58115. private _injectVertexCode;
  58116. private _writeTextureRead;
  58117. private _writeOutput;
  58118. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58119. protected _dumpPropertiesCode(): string;
  58120. serialize(): any;
  58121. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58122. }
  58123. }
  58124. declare module BABYLON {
  58125. /**
  58126. * Class used to store shared data between 2 NodeMaterialBuildState
  58127. */
  58128. export class NodeMaterialBuildStateSharedData {
  58129. /**
  58130. * Gets the list of emitted varyings
  58131. */
  58132. temps: string[];
  58133. /**
  58134. * Gets the list of emitted varyings
  58135. */
  58136. varyings: string[];
  58137. /**
  58138. * Gets the varying declaration string
  58139. */
  58140. varyingDeclaration: string;
  58141. /**
  58142. * Input blocks
  58143. */
  58144. inputBlocks: InputBlock[];
  58145. /**
  58146. * Input blocks
  58147. */
  58148. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58149. /**
  58150. * Bindable blocks (Blocks that need to set data to the effect)
  58151. */
  58152. bindableBlocks: NodeMaterialBlock[];
  58153. /**
  58154. * List of blocks that can provide a compilation fallback
  58155. */
  58156. blocksWithFallbacks: NodeMaterialBlock[];
  58157. /**
  58158. * List of blocks that can provide a define update
  58159. */
  58160. blocksWithDefines: NodeMaterialBlock[];
  58161. /**
  58162. * List of blocks that can provide a repeatable content
  58163. */
  58164. repeatableContentBlocks: NodeMaterialBlock[];
  58165. /**
  58166. * List of blocks that can provide a dynamic list of uniforms
  58167. */
  58168. dynamicUniformBlocks: NodeMaterialBlock[];
  58169. /**
  58170. * List of blocks that can block the isReady function for the material
  58171. */
  58172. blockingBlocks: NodeMaterialBlock[];
  58173. /**
  58174. * Gets the list of animated inputs
  58175. */
  58176. animatedInputs: InputBlock[];
  58177. /**
  58178. * Build Id used to avoid multiple recompilations
  58179. */
  58180. buildId: number;
  58181. /** List of emitted variables */
  58182. variableNames: {
  58183. [key: string]: number;
  58184. };
  58185. /** List of emitted defines */
  58186. defineNames: {
  58187. [key: string]: number;
  58188. };
  58189. /** Should emit comments? */
  58190. emitComments: boolean;
  58191. /** Emit build activity */
  58192. verbose: boolean;
  58193. /** Gets or sets the hosting scene */
  58194. scene: Scene;
  58195. /**
  58196. * Gets the compilation hints emitted at compilation time
  58197. */
  58198. hints: {
  58199. needWorldViewMatrix: boolean;
  58200. needWorldViewProjectionMatrix: boolean;
  58201. needAlphaBlending: boolean;
  58202. needAlphaTesting: boolean;
  58203. };
  58204. /**
  58205. * List of compilation checks
  58206. */
  58207. checks: {
  58208. emitVertex: boolean;
  58209. emitFragment: boolean;
  58210. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58211. };
  58212. /** Creates a new shared data */
  58213. constructor();
  58214. /**
  58215. * Emits console errors and exceptions if there is a failing check
  58216. */
  58217. emitErrors(): void;
  58218. }
  58219. }
  58220. declare module BABYLON {
  58221. /**
  58222. * Class used to store node based material build state
  58223. */
  58224. export class NodeMaterialBuildState {
  58225. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58226. supportUniformBuffers: boolean;
  58227. /**
  58228. * Gets the list of emitted attributes
  58229. */
  58230. attributes: string[];
  58231. /**
  58232. * Gets the list of emitted uniforms
  58233. */
  58234. uniforms: string[];
  58235. /**
  58236. * Gets the list of emitted constants
  58237. */
  58238. constants: string[];
  58239. /**
  58240. * Gets the list of emitted samplers
  58241. */
  58242. samplers: string[];
  58243. /**
  58244. * Gets the list of emitted functions
  58245. */
  58246. functions: {
  58247. [key: string]: string;
  58248. };
  58249. /**
  58250. * Gets the list of emitted extensions
  58251. */
  58252. extensions: {
  58253. [key: string]: string;
  58254. };
  58255. /**
  58256. * Gets the target of the compilation state
  58257. */
  58258. target: NodeMaterialBlockTargets;
  58259. /**
  58260. * Gets the list of emitted counters
  58261. */
  58262. counters: {
  58263. [key: string]: number;
  58264. };
  58265. /**
  58266. * Shared data between multiple NodeMaterialBuildState instances
  58267. */
  58268. sharedData: NodeMaterialBuildStateSharedData;
  58269. /** @hidden */
  58270. _vertexState: NodeMaterialBuildState;
  58271. /** @hidden */
  58272. _attributeDeclaration: string;
  58273. /** @hidden */
  58274. _uniformDeclaration: string;
  58275. /** @hidden */
  58276. _constantDeclaration: string;
  58277. /** @hidden */
  58278. _samplerDeclaration: string;
  58279. /** @hidden */
  58280. _varyingTransfer: string;
  58281. private _repeatableContentAnchorIndex;
  58282. /** @hidden */
  58283. _builtCompilationString: string;
  58284. /**
  58285. * Gets the emitted compilation strings
  58286. */
  58287. compilationString: string;
  58288. /**
  58289. * Finalize the compilation strings
  58290. * @param state defines the current compilation state
  58291. */
  58292. finalize(state: NodeMaterialBuildState): void;
  58293. /** @hidden */
  58294. get _repeatableContentAnchor(): string;
  58295. /** @hidden */
  58296. _getFreeVariableName(prefix: string): string;
  58297. /** @hidden */
  58298. _getFreeDefineName(prefix: string): string;
  58299. /** @hidden */
  58300. _excludeVariableName(name: string): void;
  58301. /** @hidden */
  58302. _emit2DSampler(name: string): void;
  58303. /** @hidden */
  58304. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58305. /** @hidden */
  58306. _emitExtension(name: string, extension: string): void;
  58307. /** @hidden */
  58308. _emitFunction(name: string, code: string, comments: string): void;
  58309. /** @hidden */
  58310. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58311. replaceStrings?: {
  58312. search: RegExp;
  58313. replace: string;
  58314. }[];
  58315. repeatKey?: string;
  58316. }): string;
  58317. /** @hidden */
  58318. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58319. repeatKey?: string;
  58320. removeAttributes?: boolean;
  58321. removeUniforms?: boolean;
  58322. removeVaryings?: boolean;
  58323. removeIfDef?: boolean;
  58324. replaceStrings?: {
  58325. search: RegExp;
  58326. replace: string;
  58327. }[];
  58328. }, storeKey?: string): void;
  58329. /** @hidden */
  58330. _registerTempVariable(name: string): boolean;
  58331. /** @hidden */
  58332. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58333. /** @hidden */
  58334. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58335. /** @hidden */
  58336. _emitFloat(value: number): string;
  58337. }
  58338. }
  58339. declare module BABYLON {
  58340. /**
  58341. * Defines a block that can be used inside a node based material
  58342. */
  58343. export class NodeMaterialBlock {
  58344. private _buildId;
  58345. private _buildTarget;
  58346. private _target;
  58347. private _isFinalMerger;
  58348. private _isInput;
  58349. protected _isUnique: boolean;
  58350. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58351. inputsAreExclusive: boolean;
  58352. /** @hidden */
  58353. _codeVariableName: string;
  58354. /** @hidden */
  58355. _inputs: NodeMaterialConnectionPoint[];
  58356. /** @hidden */
  58357. _outputs: NodeMaterialConnectionPoint[];
  58358. /** @hidden */
  58359. _preparationId: number;
  58360. /**
  58361. * Gets or sets the name of the block
  58362. */
  58363. name: string;
  58364. /**
  58365. * Gets or sets the unique id of the node
  58366. */
  58367. uniqueId: number;
  58368. /**
  58369. * Gets or sets the comments associated with this block
  58370. */
  58371. comments: string;
  58372. /**
  58373. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58374. */
  58375. get isUnique(): boolean;
  58376. /**
  58377. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58378. */
  58379. get isFinalMerger(): boolean;
  58380. /**
  58381. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58382. */
  58383. get isInput(): boolean;
  58384. /**
  58385. * Gets or sets the build Id
  58386. */
  58387. get buildId(): number;
  58388. set buildId(value: number);
  58389. /**
  58390. * Gets or sets the target of the block
  58391. */
  58392. get target(): NodeMaterialBlockTargets;
  58393. set target(value: NodeMaterialBlockTargets);
  58394. /**
  58395. * Gets the list of input points
  58396. */
  58397. get inputs(): NodeMaterialConnectionPoint[];
  58398. /** Gets the list of output points */
  58399. get outputs(): NodeMaterialConnectionPoint[];
  58400. /**
  58401. * Find an input by its name
  58402. * @param name defines the name of the input to look for
  58403. * @returns the input or null if not found
  58404. */
  58405. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58406. /**
  58407. * Find an output by its name
  58408. * @param name defines the name of the outputto look for
  58409. * @returns the output or null if not found
  58410. */
  58411. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58412. /**
  58413. * Creates a new NodeMaterialBlock
  58414. * @param name defines the block name
  58415. * @param target defines the target of that block (Vertex by default)
  58416. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58417. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58418. */
  58419. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58420. /**
  58421. * Initialize the block and prepare the context for build
  58422. * @param state defines the state that will be used for the build
  58423. */
  58424. initialize(state: NodeMaterialBuildState): void;
  58425. /**
  58426. * Bind data to effect. Will only be called for blocks with isBindable === true
  58427. * @param effect defines the effect to bind data to
  58428. * @param nodeMaterial defines the hosting NodeMaterial
  58429. * @param mesh defines the mesh that will be rendered
  58430. */
  58431. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58432. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58433. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58434. protected _writeFloat(value: number): string;
  58435. /**
  58436. * Gets the current class name e.g. "NodeMaterialBlock"
  58437. * @returns the class name
  58438. */
  58439. getClassName(): string;
  58440. /**
  58441. * Register a new input. Must be called inside a block constructor
  58442. * @param name defines the connection point name
  58443. * @param type defines the connection point type
  58444. * @param isOptional defines a boolean indicating that this input can be omitted
  58445. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58446. * @returns the current block
  58447. */
  58448. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58449. /**
  58450. * Register a new output. Must be called inside a block constructor
  58451. * @param name defines the connection point name
  58452. * @param type defines the connection point type
  58453. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58454. * @returns the current block
  58455. */
  58456. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58457. /**
  58458. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58459. * @param forOutput defines an optional connection point to check compatibility with
  58460. * @returns the first available input or null
  58461. */
  58462. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58463. /**
  58464. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58465. * @param forBlock defines an optional block to check compatibility with
  58466. * @returns the first available input or null
  58467. */
  58468. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58469. /**
  58470. * Gets the sibling of the given output
  58471. * @param current defines the current output
  58472. * @returns the next output in the list or null
  58473. */
  58474. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58475. /**
  58476. * Connect current block with another block
  58477. * @param other defines the block to connect with
  58478. * @param options define the various options to help pick the right connections
  58479. * @returns the current block
  58480. */
  58481. connectTo(other: NodeMaterialBlock, options?: {
  58482. input?: string;
  58483. output?: string;
  58484. outputSwizzle?: string;
  58485. }): this | undefined;
  58486. protected _buildBlock(state: NodeMaterialBuildState): void;
  58487. /**
  58488. * Add uniforms, samplers and uniform buffers at compilation time
  58489. * @param state defines the state to update
  58490. * @param nodeMaterial defines the node material requesting the update
  58491. * @param defines defines the material defines to update
  58492. * @param uniformBuffers defines the list of uniform buffer names
  58493. */
  58494. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58495. /**
  58496. * Add potential fallbacks if shader compilation fails
  58497. * @param mesh defines the mesh to be rendered
  58498. * @param fallbacks defines the current prioritized list of fallbacks
  58499. */
  58500. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58501. /**
  58502. * Initialize defines for shader compilation
  58503. * @param mesh defines the mesh to be rendered
  58504. * @param nodeMaterial defines the node material requesting the update
  58505. * @param defines defines the material defines to update
  58506. * @param useInstances specifies that instances should be used
  58507. */
  58508. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58509. /**
  58510. * Update defines for shader compilation
  58511. * @param mesh defines the mesh to be rendered
  58512. * @param nodeMaterial defines the node material requesting the update
  58513. * @param defines defines the material defines to update
  58514. * @param useInstances specifies that instances should be used
  58515. */
  58516. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58517. /**
  58518. * Lets the block try to connect some inputs automatically
  58519. * @param material defines the hosting NodeMaterial
  58520. */
  58521. autoConfigure(material: NodeMaterial): void;
  58522. /**
  58523. * Function called when a block is declared as repeatable content generator
  58524. * @param vertexShaderState defines the current compilation state for the vertex shader
  58525. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58526. * @param mesh defines the mesh to be rendered
  58527. * @param defines defines the material defines to update
  58528. */
  58529. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58530. /**
  58531. * Checks if the block is ready
  58532. * @param mesh defines the mesh to be rendered
  58533. * @param nodeMaterial defines the node material requesting the update
  58534. * @param defines defines the material defines to update
  58535. * @param useInstances specifies that instances should be used
  58536. * @returns true if the block is ready
  58537. */
  58538. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58539. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58540. private _processBuild;
  58541. /**
  58542. * Compile the current node and generate the shader code
  58543. * @param state defines the current compilation state (uniforms, samplers, current string)
  58544. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58545. * @returns true if already built
  58546. */
  58547. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58548. protected _inputRename(name: string): string;
  58549. protected _outputRename(name: string): string;
  58550. protected _dumpPropertiesCode(): string;
  58551. /** @hidden */
  58552. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58553. /** @hidden */
  58554. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58555. /**
  58556. * Clone the current block to a new identical block
  58557. * @param scene defines the hosting scene
  58558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58559. * @returns a copy of the current block
  58560. */
  58561. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58562. /**
  58563. * Serializes this block in a JSON representation
  58564. * @returns the serialized block object
  58565. */
  58566. serialize(): any;
  58567. /** @hidden */
  58568. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58569. /**
  58570. * Release resources
  58571. */
  58572. dispose(): void;
  58573. }
  58574. }
  58575. declare module BABYLON {
  58576. /**
  58577. * Enum defining the type of animations supported by InputBlock
  58578. */
  58579. export enum AnimatedInputBlockTypes {
  58580. /** No animation */
  58581. None = 0,
  58582. /** Time based animation. Will only work for floats */
  58583. Time = 1
  58584. }
  58585. }
  58586. declare module BABYLON {
  58587. /**
  58588. * Block used to expose an input value
  58589. */
  58590. export class InputBlock extends NodeMaterialBlock {
  58591. private _mode;
  58592. private _associatedVariableName;
  58593. private _storedValue;
  58594. private _valueCallback;
  58595. private _type;
  58596. private _animationType;
  58597. /** Gets or set a value used to limit the range of float values */
  58598. min: number;
  58599. /** Gets or set a value used to limit the range of float values */
  58600. max: number;
  58601. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58602. isBoolean: boolean;
  58603. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58604. matrixMode: number;
  58605. /** @hidden */
  58606. _systemValue: Nullable<NodeMaterialSystemValues>;
  58607. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58608. visibleInInspector: boolean;
  58609. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58610. isConstant: boolean;
  58611. /** Gets or sets the group to use to display this block in the Inspector */
  58612. groupInInspector: string;
  58613. /** Gets an observable raised when the value is changed */
  58614. onValueChangedObservable: Observable<InputBlock>;
  58615. /**
  58616. * Gets or sets the connection point type (default is float)
  58617. */
  58618. get type(): NodeMaterialBlockConnectionPointTypes;
  58619. /**
  58620. * Creates a new InputBlock
  58621. * @param name defines the block name
  58622. * @param target defines the target of that block (Vertex by default)
  58623. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58624. */
  58625. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58626. /**
  58627. * Gets the output component
  58628. */
  58629. get output(): NodeMaterialConnectionPoint;
  58630. /**
  58631. * Set the source of this connection point to a vertex attribute
  58632. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58633. * @returns the current connection point
  58634. */
  58635. setAsAttribute(attributeName?: string): InputBlock;
  58636. /**
  58637. * Set the source of this connection point to a system value
  58638. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58639. * @returns the current connection point
  58640. */
  58641. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58642. /**
  58643. * Gets or sets the value of that point.
  58644. * Please note that this value will be ignored if valueCallback is defined
  58645. */
  58646. get value(): any;
  58647. set value(value: any);
  58648. /**
  58649. * Gets or sets a callback used to get the value of that point.
  58650. * Please note that setting this value will force the connection point to ignore the value property
  58651. */
  58652. get valueCallback(): () => any;
  58653. set valueCallback(value: () => any);
  58654. /**
  58655. * Gets or sets the associated variable name in the shader
  58656. */
  58657. get associatedVariableName(): string;
  58658. set associatedVariableName(value: string);
  58659. /** Gets or sets the type of animation applied to the input */
  58660. get animationType(): AnimatedInputBlockTypes;
  58661. set animationType(value: AnimatedInputBlockTypes);
  58662. /**
  58663. * Gets a boolean indicating that this connection point not defined yet
  58664. */
  58665. get isUndefined(): boolean;
  58666. /**
  58667. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58668. * In this case the connection point name must be the name of the uniform to use.
  58669. * Can only be set on inputs
  58670. */
  58671. get isUniform(): boolean;
  58672. set isUniform(value: boolean);
  58673. /**
  58674. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58675. * In this case the connection point name must be the name of the attribute to use
  58676. * Can only be set on inputs
  58677. */
  58678. get isAttribute(): boolean;
  58679. set isAttribute(value: boolean);
  58680. /**
  58681. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58682. * Can only be set on exit points
  58683. */
  58684. get isVarying(): boolean;
  58685. set isVarying(value: boolean);
  58686. /**
  58687. * Gets a boolean indicating that the current connection point is a system value
  58688. */
  58689. get isSystemValue(): boolean;
  58690. /**
  58691. * Gets or sets the current well known value or null if not defined as a system value
  58692. */
  58693. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58694. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58695. /**
  58696. * Gets the current class name
  58697. * @returns the class name
  58698. */
  58699. getClassName(): string;
  58700. /**
  58701. * Animate the input if animationType !== None
  58702. * @param scene defines the rendering scene
  58703. */
  58704. animate(scene: Scene): void;
  58705. private _emitDefine;
  58706. initialize(state: NodeMaterialBuildState): void;
  58707. /**
  58708. * Set the input block to its default value (based on its type)
  58709. */
  58710. setDefaultValue(): void;
  58711. private _emitConstant;
  58712. private _emit;
  58713. /** @hidden */
  58714. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58715. /** @hidden */
  58716. _transmit(effect: Effect, scene: Scene): void;
  58717. protected _buildBlock(state: NodeMaterialBuildState): void;
  58718. protected _dumpPropertiesCode(): string;
  58719. dispose(): void;
  58720. serialize(): any;
  58721. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58722. }
  58723. }
  58724. declare module BABYLON {
  58725. /**
  58726. * Enum used to define the compatibility state between two connection points
  58727. */
  58728. export enum NodeMaterialConnectionPointCompatibilityStates {
  58729. /** Points are compatibles */
  58730. Compatible = 0,
  58731. /** Points are incompatible because of their types */
  58732. TypeIncompatible = 1,
  58733. /** Points are incompatible because of their targets (vertex vs fragment) */
  58734. TargetIncompatible = 2
  58735. }
  58736. /**
  58737. * Defines the direction of a connection point
  58738. */
  58739. export enum NodeMaterialConnectionPointDirection {
  58740. /** Input */
  58741. Input = 0,
  58742. /** Output */
  58743. Output = 1
  58744. }
  58745. /**
  58746. * Defines a connection point for a block
  58747. */
  58748. export class NodeMaterialConnectionPoint {
  58749. /** @hidden */
  58750. _ownerBlock: NodeMaterialBlock;
  58751. /** @hidden */
  58752. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58753. private _endpoints;
  58754. private _associatedVariableName;
  58755. private _direction;
  58756. /** @hidden */
  58757. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58758. /** @hidden */
  58759. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58760. private _type;
  58761. /** @hidden */
  58762. _enforceAssociatedVariableName: boolean;
  58763. /** Gets the direction of the point */
  58764. get direction(): NodeMaterialConnectionPointDirection;
  58765. /**
  58766. * Gets or sets the additional types supported by this connection point
  58767. */
  58768. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58769. /**
  58770. * Gets or sets the additional types excluded by this connection point
  58771. */
  58772. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58773. /**
  58774. * Observable triggered when this point is connected
  58775. */
  58776. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58777. /**
  58778. * Gets or sets the associated variable name in the shader
  58779. */
  58780. get associatedVariableName(): string;
  58781. set associatedVariableName(value: string);
  58782. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58783. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58784. /**
  58785. * Gets or sets the connection point type (default is float)
  58786. */
  58787. get type(): NodeMaterialBlockConnectionPointTypes;
  58788. set type(value: NodeMaterialBlockConnectionPointTypes);
  58789. /**
  58790. * Gets or sets the connection point name
  58791. */
  58792. name: string;
  58793. /**
  58794. * Gets or sets a boolean indicating that this connection point can be omitted
  58795. */
  58796. isOptional: boolean;
  58797. /**
  58798. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58799. */
  58800. define: string;
  58801. /** @hidden */
  58802. _prioritizeVertex: boolean;
  58803. private _target;
  58804. /** Gets or sets the target of that connection point */
  58805. get target(): NodeMaterialBlockTargets;
  58806. set target(value: NodeMaterialBlockTargets);
  58807. /**
  58808. * Gets a boolean indicating that the current point is connected
  58809. */
  58810. get isConnected(): boolean;
  58811. /**
  58812. * Gets a boolean indicating that the current point is connected to an input block
  58813. */
  58814. get isConnectedToInputBlock(): boolean;
  58815. /**
  58816. * Gets a the connected input block (if any)
  58817. */
  58818. get connectInputBlock(): Nullable<InputBlock>;
  58819. /** Get the other side of the connection (if any) */
  58820. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58821. /** Get the block that owns this connection point */
  58822. get ownerBlock(): NodeMaterialBlock;
  58823. /** Get the block connected on the other side of this connection (if any) */
  58824. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58825. /** Get the block connected on the endpoints of this connection (if any) */
  58826. get connectedBlocks(): Array<NodeMaterialBlock>;
  58827. /** Gets the list of connected endpoints */
  58828. get endpoints(): NodeMaterialConnectionPoint[];
  58829. /** Gets a boolean indicating if that output point is connected to at least one input */
  58830. get hasEndpoints(): boolean;
  58831. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58832. get isConnectedInVertexShader(): boolean;
  58833. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58834. get isConnectedInFragmentShader(): boolean;
  58835. /**
  58836. * Creates a new connection point
  58837. * @param name defines the connection point name
  58838. * @param ownerBlock defines the block hosting this connection point
  58839. * @param direction defines the direction of the connection point
  58840. */
  58841. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58842. /**
  58843. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58844. * @returns the class name
  58845. */
  58846. getClassName(): string;
  58847. /**
  58848. * Gets a boolean indicating if the current point can be connected to another point
  58849. * @param connectionPoint defines the other connection point
  58850. * @returns a boolean
  58851. */
  58852. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58853. /**
  58854. * Gets a number indicating if the current point can be connected to another point
  58855. * @param connectionPoint defines the other connection point
  58856. * @returns a number defining the compatibility state
  58857. */
  58858. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58859. /**
  58860. * Connect this point to another connection point
  58861. * @param connectionPoint defines the other connection point
  58862. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58863. * @returns the current connection point
  58864. */
  58865. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58866. /**
  58867. * Disconnect this point from one of his endpoint
  58868. * @param endpoint defines the other connection point
  58869. * @returns the current connection point
  58870. */
  58871. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58872. /**
  58873. * Serializes this point in a JSON representation
  58874. * @returns the serialized point object
  58875. */
  58876. serialize(): any;
  58877. /**
  58878. * Release resources
  58879. */
  58880. dispose(): void;
  58881. }
  58882. }
  58883. declare module BABYLON {
  58884. /**
  58885. * Block used to add support for vertex skinning (bones)
  58886. */
  58887. export class BonesBlock extends NodeMaterialBlock {
  58888. /**
  58889. * Creates a new BonesBlock
  58890. * @param name defines the block name
  58891. */
  58892. constructor(name: string);
  58893. /**
  58894. * Initialize the block and prepare the context for build
  58895. * @param state defines the state that will be used for the build
  58896. */
  58897. initialize(state: NodeMaterialBuildState): void;
  58898. /**
  58899. * Gets the current class name
  58900. * @returns the class name
  58901. */
  58902. getClassName(): string;
  58903. /**
  58904. * Gets the matrix indices input component
  58905. */
  58906. get matricesIndices(): NodeMaterialConnectionPoint;
  58907. /**
  58908. * Gets the matrix weights input component
  58909. */
  58910. get matricesWeights(): NodeMaterialConnectionPoint;
  58911. /**
  58912. * Gets the extra matrix indices input component
  58913. */
  58914. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58915. /**
  58916. * Gets the extra matrix weights input component
  58917. */
  58918. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58919. /**
  58920. * Gets the world input component
  58921. */
  58922. get world(): NodeMaterialConnectionPoint;
  58923. /**
  58924. * Gets the output component
  58925. */
  58926. get output(): NodeMaterialConnectionPoint;
  58927. autoConfigure(material: NodeMaterial): void;
  58928. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58929. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58931. protected _buildBlock(state: NodeMaterialBuildState): this;
  58932. }
  58933. }
  58934. declare module BABYLON {
  58935. /**
  58936. * Block used to add support for instances
  58937. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58938. */
  58939. export class InstancesBlock extends NodeMaterialBlock {
  58940. /**
  58941. * Creates a new InstancesBlock
  58942. * @param name defines the block name
  58943. */
  58944. constructor(name: string);
  58945. /**
  58946. * Gets the current class name
  58947. * @returns the class name
  58948. */
  58949. getClassName(): string;
  58950. /**
  58951. * Gets the first world row input component
  58952. */
  58953. get world0(): NodeMaterialConnectionPoint;
  58954. /**
  58955. * Gets the second world row input component
  58956. */
  58957. get world1(): NodeMaterialConnectionPoint;
  58958. /**
  58959. * Gets the third world row input component
  58960. */
  58961. get world2(): NodeMaterialConnectionPoint;
  58962. /**
  58963. * Gets the forth world row input component
  58964. */
  58965. get world3(): NodeMaterialConnectionPoint;
  58966. /**
  58967. * Gets the world input component
  58968. */
  58969. get world(): NodeMaterialConnectionPoint;
  58970. /**
  58971. * Gets the output component
  58972. */
  58973. get output(): NodeMaterialConnectionPoint;
  58974. /**
  58975. * Gets the isntanceID component
  58976. */
  58977. get instanceID(): NodeMaterialConnectionPoint;
  58978. autoConfigure(material: NodeMaterial): void;
  58979. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58980. protected _buildBlock(state: NodeMaterialBuildState): this;
  58981. }
  58982. }
  58983. declare module BABYLON {
  58984. /**
  58985. * Block used to add morph targets support to vertex shader
  58986. */
  58987. export class MorphTargetsBlock extends NodeMaterialBlock {
  58988. private _repeatableContentAnchor;
  58989. /**
  58990. * Create a new MorphTargetsBlock
  58991. * @param name defines the block name
  58992. */
  58993. constructor(name: string);
  58994. /**
  58995. * Gets the current class name
  58996. * @returns the class name
  58997. */
  58998. getClassName(): string;
  58999. /**
  59000. * Gets the position input component
  59001. */
  59002. get position(): NodeMaterialConnectionPoint;
  59003. /**
  59004. * Gets the normal input component
  59005. */
  59006. get normal(): NodeMaterialConnectionPoint;
  59007. /**
  59008. * Gets the tangent input component
  59009. */
  59010. get tangent(): NodeMaterialConnectionPoint;
  59011. /**
  59012. * Gets the tangent input component
  59013. */
  59014. get uv(): NodeMaterialConnectionPoint;
  59015. /**
  59016. * Gets the position output component
  59017. */
  59018. get positionOutput(): NodeMaterialConnectionPoint;
  59019. /**
  59020. * Gets the normal output component
  59021. */
  59022. get normalOutput(): NodeMaterialConnectionPoint;
  59023. /**
  59024. * Gets the tangent output component
  59025. */
  59026. get tangentOutput(): NodeMaterialConnectionPoint;
  59027. /**
  59028. * Gets the tangent output component
  59029. */
  59030. get uvOutput(): NodeMaterialConnectionPoint;
  59031. initialize(state: NodeMaterialBuildState): void;
  59032. autoConfigure(material: NodeMaterial): void;
  59033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59034. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59035. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59036. protected _buildBlock(state: NodeMaterialBuildState): this;
  59037. }
  59038. }
  59039. declare module BABYLON {
  59040. /**
  59041. * Block used to get data information from a light
  59042. */
  59043. export class LightInformationBlock extends NodeMaterialBlock {
  59044. private _lightDataUniformName;
  59045. private _lightColorUniformName;
  59046. private _lightTypeDefineName;
  59047. /**
  59048. * Gets or sets the light associated with this block
  59049. */
  59050. light: Nullable<Light>;
  59051. /**
  59052. * Creates a new LightInformationBlock
  59053. * @param name defines the block name
  59054. */
  59055. constructor(name: string);
  59056. /**
  59057. * Gets the current class name
  59058. * @returns the class name
  59059. */
  59060. getClassName(): string;
  59061. /**
  59062. * Gets the world position input component
  59063. */
  59064. get worldPosition(): NodeMaterialConnectionPoint;
  59065. /**
  59066. * Gets the direction output component
  59067. */
  59068. get direction(): NodeMaterialConnectionPoint;
  59069. /**
  59070. * Gets the direction output component
  59071. */
  59072. get color(): NodeMaterialConnectionPoint;
  59073. /**
  59074. * Gets the direction output component
  59075. */
  59076. get intensity(): NodeMaterialConnectionPoint;
  59077. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59078. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59079. protected _buildBlock(state: NodeMaterialBuildState): this;
  59080. serialize(): any;
  59081. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59082. }
  59083. }
  59084. declare module BABYLON {
  59085. /**
  59086. * Block used to add image processing support to fragment shader
  59087. */
  59088. export class ImageProcessingBlock extends NodeMaterialBlock {
  59089. /**
  59090. * Create a new ImageProcessingBlock
  59091. * @param name defines the block name
  59092. */
  59093. constructor(name: string);
  59094. /**
  59095. * Gets the current class name
  59096. * @returns the class name
  59097. */
  59098. getClassName(): string;
  59099. /**
  59100. * Gets the color input component
  59101. */
  59102. get color(): NodeMaterialConnectionPoint;
  59103. /**
  59104. * Gets the output component
  59105. */
  59106. get output(): NodeMaterialConnectionPoint;
  59107. /**
  59108. * Initialize the block and prepare the context for build
  59109. * @param state defines the state that will be used for the build
  59110. */
  59111. initialize(state: NodeMaterialBuildState): void;
  59112. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59113. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59115. protected _buildBlock(state: NodeMaterialBuildState): this;
  59116. }
  59117. }
  59118. declare module BABYLON {
  59119. /**
  59120. * Block used to pertub normals based on a normal map
  59121. */
  59122. export class PerturbNormalBlock extends NodeMaterialBlock {
  59123. private _tangentSpaceParameterName;
  59124. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59125. invertX: boolean;
  59126. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59127. invertY: boolean;
  59128. /**
  59129. * Create a new PerturbNormalBlock
  59130. * @param name defines the block name
  59131. */
  59132. constructor(name: string);
  59133. /**
  59134. * Gets the current class name
  59135. * @returns the class name
  59136. */
  59137. getClassName(): string;
  59138. /**
  59139. * Gets the world position input component
  59140. */
  59141. get worldPosition(): NodeMaterialConnectionPoint;
  59142. /**
  59143. * Gets the world normal input component
  59144. */
  59145. get worldNormal(): NodeMaterialConnectionPoint;
  59146. /**
  59147. * Gets the world tangent input component
  59148. */
  59149. get worldTangent(): NodeMaterialConnectionPoint;
  59150. /**
  59151. * Gets the uv input component
  59152. */
  59153. get uv(): NodeMaterialConnectionPoint;
  59154. /**
  59155. * Gets the normal map color input component
  59156. */
  59157. get normalMapColor(): NodeMaterialConnectionPoint;
  59158. /**
  59159. * Gets the strength input component
  59160. */
  59161. get strength(): NodeMaterialConnectionPoint;
  59162. /**
  59163. * Gets the output component
  59164. */
  59165. get output(): NodeMaterialConnectionPoint;
  59166. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59167. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59168. autoConfigure(material: NodeMaterial): void;
  59169. protected _buildBlock(state: NodeMaterialBuildState): this;
  59170. protected _dumpPropertiesCode(): string;
  59171. serialize(): any;
  59172. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59173. }
  59174. }
  59175. declare module BABYLON {
  59176. /**
  59177. * Block used to discard a pixel if a value is smaller than a cutoff
  59178. */
  59179. export class DiscardBlock extends NodeMaterialBlock {
  59180. /**
  59181. * Create a new DiscardBlock
  59182. * @param name defines the block name
  59183. */
  59184. constructor(name: string);
  59185. /**
  59186. * Gets the current class name
  59187. * @returns the class name
  59188. */
  59189. getClassName(): string;
  59190. /**
  59191. * Gets the color input component
  59192. */
  59193. get value(): NodeMaterialConnectionPoint;
  59194. /**
  59195. * Gets the cutoff input component
  59196. */
  59197. get cutoff(): NodeMaterialConnectionPoint;
  59198. protected _buildBlock(state: NodeMaterialBuildState): this;
  59199. }
  59200. }
  59201. declare module BABYLON {
  59202. /**
  59203. * Block used to test if the fragment shader is front facing
  59204. */
  59205. export class FrontFacingBlock extends NodeMaterialBlock {
  59206. /**
  59207. * Creates a new FrontFacingBlock
  59208. * @param name defines the block name
  59209. */
  59210. constructor(name: string);
  59211. /**
  59212. * Gets the current class name
  59213. * @returns the class name
  59214. */
  59215. getClassName(): string;
  59216. /**
  59217. * Gets the output component
  59218. */
  59219. get output(): NodeMaterialConnectionPoint;
  59220. protected _buildBlock(state: NodeMaterialBuildState): this;
  59221. }
  59222. }
  59223. declare module BABYLON {
  59224. /**
  59225. * Block used to get the derivative value on x and y of a given input
  59226. */
  59227. export class DerivativeBlock extends NodeMaterialBlock {
  59228. /**
  59229. * Create a new DerivativeBlock
  59230. * @param name defines the block name
  59231. */
  59232. constructor(name: string);
  59233. /**
  59234. * Gets the current class name
  59235. * @returns the class name
  59236. */
  59237. getClassName(): string;
  59238. /**
  59239. * Gets the input component
  59240. */
  59241. get input(): NodeMaterialConnectionPoint;
  59242. /**
  59243. * Gets the derivative output on x
  59244. */
  59245. get dx(): NodeMaterialConnectionPoint;
  59246. /**
  59247. * Gets the derivative output on y
  59248. */
  59249. get dy(): NodeMaterialConnectionPoint;
  59250. protected _buildBlock(state: NodeMaterialBuildState): this;
  59251. }
  59252. }
  59253. declare module BABYLON {
  59254. /**
  59255. * Block used to add support for scene fog
  59256. */
  59257. export class FogBlock extends NodeMaterialBlock {
  59258. private _fogDistanceName;
  59259. private _fogParameters;
  59260. /**
  59261. * Create a new FogBlock
  59262. * @param name defines the block name
  59263. */
  59264. constructor(name: string);
  59265. /**
  59266. * Gets the current class name
  59267. * @returns the class name
  59268. */
  59269. getClassName(): string;
  59270. /**
  59271. * Gets the world position input component
  59272. */
  59273. get worldPosition(): NodeMaterialConnectionPoint;
  59274. /**
  59275. * Gets the view input component
  59276. */
  59277. get view(): NodeMaterialConnectionPoint;
  59278. /**
  59279. * Gets the color input component
  59280. */
  59281. get input(): NodeMaterialConnectionPoint;
  59282. /**
  59283. * Gets the fog color input component
  59284. */
  59285. get fogColor(): NodeMaterialConnectionPoint;
  59286. /**
  59287. * Gets the output component
  59288. */
  59289. get output(): NodeMaterialConnectionPoint;
  59290. autoConfigure(material: NodeMaterial): void;
  59291. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59292. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59293. protected _buildBlock(state: NodeMaterialBuildState): this;
  59294. }
  59295. }
  59296. declare module BABYLON {
  59297. /**
  59298. * Block used to add light in the fragment shader
  59299. */
  59300. export class LightBlock extends NodeMaterialBlock {
  59301. private _lightId;
  59302. /**
  59303. * Gets or sets the light associated with this block
  59304. */
  59305. light: Nullable<Light>;
  59306. /**
  59307. * Create a new LightBlock
  59308. * @param name defines the block name
  59309. */
  59310. constructor(name: string);
  59311. /**
  59312. * Gets the current class name
  59313. * @returns the class name
  59314. */
  59315. getClassName(): string;
  59316. /**
  59317. * Gets the world position input component
  59318. */
  59319. get worldPosition(): NodeMaterialConnectionPoint;
  59320. /**
  59321. * Gets the world normal input component
  59322. */
  59323. get worldNormal(): NodeMaterialConnectionPoint;
  59324. /**
  59325. * Gets the camera (or eye) position component
  59326. */
  59327. get cameraPosition(): NodeMaterialConnectionPoint;
  59328. /**
  59329. * Gets the glossiness component
  59330. */
  59331. get glossiness(): NodeMaterialConnectionPoint;
  59332. /**
  59333. * Gets the glossinness power component
  59334. */
  59335. get glossPower(): NodeMaterialConnectionPoint;
  59336. /**
  59337. * Gets the diffuse color component
  59338. */
  59339. get diffuseColor(): NodeMaterialConnectionPoint;
  59340. /**
  59341. * Gets the specular color component
  59342. */
  59343. get specularColor(): NodeMaterialConnectionPoint;
  59344. /**
  59345. * Gets the diffuse output component
  59346. */
  59347. get diffuseOutput(): NodeMaterialConnectionPoint;
  59348. /**
  59349. * Gets the specular output component
  59350. */
  59351. get specularOutput(): NodeMaterialConnectionPoint;
  59352. /**
  59353. * Gets the shadow output component
  59354. */
  59355. get shadow(): NodeMaterialConnectionPoint;
  59356. autoConfigure(material: NodeMaterial): void;
  59357. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59358. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59359. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59360. private _injectVertexCode;
  59361. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59362. serialize(): any;
  59363. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59364. }
  59365. }
  59366. declare module BABYLON {
  59367. /**
  59368. * Block used to multiply 2 values
  59369. */
  59370. export class MultiplyBlock extends NodeMaterialBlock {
  59371. /**
  59372. * Creates a new MultiplyBlock
  59373. * @param name defines the block name
  59374. */
  59375. constructor(name: string);
  59376. /**
  59377. * Gets the current class name
  59378. * @returns the class name
  59379. */
  59380. getClassName(): string;
  59381. /**
  59382. * Gets the left operand input component
  59383. */
  59384. get left(): NodeMaterialConnectionPoint;
  59385. /**
  59386. * Gets the right operand input component
  59387. */
  59388. get right(): NodeMaterialConnectionPoint;
  59389. /**
  59390. * Gets the output component
  59391. */
  59392. get output(): NodeMaterialConnectionPoint;
  59393. protected _buildBlock(state: NodeMaterialBuildState): this;
  59394. }
  59395. }
  59396. declare module BABYLON {
  59397. /**
  59398. * Block used to add 2 vectors
  59399. */
  59400. export class AddBlock extends NodeMaterialBlock {
  59401. /**
  59402. * Creates a new AddBlock
  59403. * @param name defines the block name
  59404. */
  59405. constructor(name: string);
  59406. /**
  59407. * Gets the current class name
  59408. * @returns the class name
  59409. */
  59410. getClassName(): string;
  59411. /**
  59412. * Gets the left operand input component
  59413. */
  59414. get left(): NodeMaterialConnectionPoint;
  59415. /**
  59416. * Gets the right operand input component
  59417. */
  59418. get right(): NodeMaterialConnectionPoint;
  59419. /**
  59420. * Gets the output component
  59421. */
  59422. get output(): NodeMaterialConnectionPoint;
  59423. protected _buildBlock(state: NodeMaterialBuildState): this;
  59424. }
  59425. }
  59426. declare module BABYLON {
  59427. /**
  59428. * Block used to scale a vector by a float
  59429. */
  59430. export class ScaleBlock extends NodeMaterialBlock {
  59431. /**
  59432. * Creates a new ScaleBlock
  59433. * @param name defines the block name
  59434. */
  59435. constructor(name: string);
  59436. /**
  59437. * Gets the current class name
  59438. * @returns the class name
  59439. */
  59440. getClassName(): string;
  59441. /**
  59442. * Gets the input component
  59443. */
  59444. get input(): NodeMaterialConnectionPoint;
  59445. /**
  59446. * Gets the factor input component
  59447. */
  59448. get factor(): NodeMaterialConnectionPoint;
  59449. /**
  59450. * Gets the output component
  59451. */
  59452. get output(): NodeMaterialConnectionPoint;
  59453. protected _buildBlock(state: NodeMaterialBuildState): this;
  59454. }
  59455. }
  59456. declare module BABYLON {
  59457. /**
  59458. * Block used to clamp a float
  59459. */
  59460. export class ClampBlock extends NodeMaterialBlock {
  59461. /** Gets or sets the minimum range */
  59462. minimum: number;
  59463. /** Gets or sets the maximum range */
  59464. maximum: number;
  59465. /**
  59466. * Creates a new ClampBlock
  59467. * @param name defines the block name
  59468. */
  59469. constructor(name: string);
  59470. /**
  59471. * Gets the current class name
  59472. * @returns the class name
  59473. */
  59474. getClassName(): string;
  59475. /**
  59476. * Gets the value input component
  59477. */
  59478. get value(): NodeMaterialConnectionPoint;
  59479. /**
  59480. * Gets the output component
  59481. */
  59482. get output(): NodeMaterialConnectionPoint;
  59483. protected _buildBlock(state: NodeMaterialBuildState): this;
  59484. protected _dumpPropertiesCode(): string;
  59485. serialize(): any;
  59486. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59487. }
  59488. }
  59489. declare module BABYLON {
  59490. /**
  59491. * Block used to apply a cross product between 2 vectors
  59492. */
  59493. export class CrossBlock extends NodeMaterialBlock {
  59494. /**
  59495. * Creates a new CrossBlock
  59496. * @param name defines the block name
  59497. */
  59498. constructor(name: string);
  59499. /**
  59500. * Gets the current class name
  59501. * @returns the class name
  59502. */
  59503. getClassName(): string;
  59504. /**
  59505. * Gets the left operand input component
  59506. */
  59507. get left(): NodeMaterialConnectionPoint;
  59508. /**
  59509. * Gets the right operand input component
  59510. */
  59511. get right(): NodeMaterialConnectionPoint;
  59512. /**
  59513. * Gets the output component
  59514. */
  59515. get output(): NodeMaterialConnectionPoint;
  59516. protected _buildBlock(state: NodeMaterialBuildState): this;
  59517. }
  59518. }
  59519. declare module BABYLON {
  59520. /**
  59521. * Block used to apply a dot product between 2 vectors
  59522. */
  59523. export class DotBlock extends NodeMaterialBlock {
  59524. /**
  59525. * Creates a new DotBlock
  59526. * @param name defines the block name
  59527. */
  59528. constructor(name: string);
  59529. /**
  59530. * Gets the current class name
  59531. * @returns the class name
  59532. */
  59533. getClassName(): string;
  59534. /**
  59535. * Gets the left operand input component
  59536. */
  59537. get left(): NodeMaterialConnectionPoint;
  59538. /**
  59539. * Gets the right operand input component
  59540. */
  59541. get right(): NodeMaterialConnectionPoint;
  59542. /**
  59543. * Gets the output component
  59544. */
  59545. get output(): NodeMaterialConnectionPoint;
  59546. protected _buildBlock(state: NodeMaterialBuildState): this;
  59547. }
  59548. }
  59549. declare module BABYLON {
  59550. /**
  59551. * Block used to remap a float from a range to a new one
  59552. */
  59553. export class RemapBlock extends NodeMaterialBlock {
  59554. /**
  59555. * Gets or sets the source range
  59556. */
  59557. sourceRange: Vector2;
  59558. /**
  59559. * Gets or sets the target range
  59560. */
  59561. targetRange: Vector2;
  59562. /**
  59563. * Creates a new RemapBlock
  59564. * @param name defines the block name
  59565. */
  59566. constructor(name: string);
  59567. /**
  59568. * Gets the current class name
  59569. * @returns the class name
  59570. */
  59571. getClassName(): string;
  59572. /**
  59573. * Gets the input component
  59574. */
  59575. get input(): NodeMaterialConnectionPoint;
  59576. /**
  59577. * Gets the source min input component
  59578. */
  59579. get sourceMin(): NodeMaterialConnectionPoint;
  59580. /**
  59581. * Gets the source max input component
  59582. */
  59583. get sourceMax(): NodeMaterialConnectionPoint;
  59584. /**
  59585. * Gets the target min input component
  59586. */
  59587. get targetMin(): NodeMaterialConnectionPoint;
  59588. /**
  59589. * Gets the target max input component
  59590. */
  59591. get targetMax(): NodeMaterialConnectionPoint;
  59592. /**
  59593. * Gets the output component
  59594. */
  59595. get output(): NodeMaterialConnectionPoint;
  59596. protected _buildBlock(state: NodeMaterialBuildState): this;
  59597. protected _dumpPropertiesCode(): string;
  59598. serialize(): any;
  59599. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59600. }
  59601. }
  59602. declare module BABYLON {
  59603. /**
  59604. * Block used to normalize a vector
  59605. */
  59606. export class NormalizeBlock extends NodeMaterialBlock {
  59607. /**
  59608. * Creates a new NormalizeBlock
  59609. * @param name defines the block name
  59610. */
  59611. constructor(name: string);
  59612. /**
  59613. * Gets the current class name
  59614. * @returns the class name
  59615. */
  59616. getClassName(): string;
  59617. /**
  59618. * Gets the input component
  59619. */
  59620. get input(): NodeMaterialConnectionPoint;
  59621. /**
  59622. * Gets the output component
  59623. */
  59624. get output(): NodeMaterialConnectionPoint;
  59625. protected _buildBlock(state: NodeMaterialBuildState): this;
  59626. }
  59627. }
  59628. declare module BABYLON {
  59629. /**
  59630. * Operations supported by the Trigonometry block
  59631. */
  59632. export enum TrigonometryBlockOperations {
  59633. /** Cos */
  59634. Cos = 0,
  59635. /** Sin */
  59636. Sin = 1,
  59637. /** Abs */
  59638. Abs = 2,
  59639. /** Exp */
  59640. Exp = 3,
  59641. /** Exp2 */
  59642. Exp2 = 4,
  59643. /** Round */
  59644. Round = 5,
  59645. /** Floor */
  59646. Floor = 6,
  59647. /** Ceiling */
  59648. Ceiling = 7,
  59649. /** Square root */
  59650. Sqrt = 8,
  59651. /** Log */
  59652. Log = 9,
  59653. /** Tangent */
  59654. Tan = 10,
  59655. /** Arc tangent */
  59656. ArcTan = 11,
  59657. /** Arc cosinus */
  59658. ArcCos = 12,
  59659. /** Arc sinus */
  59660. ArcSin = 13,
  59661. /** Fraction */
  59662. Fract = 14,
  59663. /** Sign */
  59664. Sign = 15,
  59665. /** To radians (from degrees) */
  59666. Radians = 16,
  59667. /** To degrees (from radians) */
  59668. Degrees = 17
  59669. }
  59670. /**
  59671. * Block used to apply trigonometry operation to floats
  59672. */
  59673. export class TrigonometryBlock extends NodeMaterialBlock {
  59674. /**
  59675. * Gets or sets the operation applied by the block
  59676. */
  59677. operation: TrigonometryBlockOperations;
  59678. /**
  59679. * Creates a new TrigonometryBlock
  59680. * @param name defines the block name
  59681. */
  59682. constructor(name: string);
  59683. /**
  59684. * Gets the current class name
  59685. * @returns the class name
  59686. */
  59687. getClassName(): string;
  59688. /**
  59689. * Gets the input component
  59690. */
  59691. get input(): NodeMaterialConnectionPoint;
  59692. /**
  59693. * Gets the output component
  59694. */
  59695. get output(): NodeMaterialConnectionPoint;
  59696. protected _buildBlock(state: NodeMaterialBuildState): this;
  59697. serialize(): any;
  59698. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59699. protected _dumpPropertiesCode(): string;
  59700. }
  59701. }
  59702. declare module BABYLON {
  59703. /**
  59704. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59705. */
  59706. export class ColorMergerBlock extends NodeMaterialBlock {
  59707. /**
  59708. * Create a new ColorMergerBlock
  59709. * @param name defines the block name
  59710. */
  59711. constructor(name: string);
  59712. /**
  59713. * Gets the current class name
  59714. * @returns the class name
  59715. */
  59716. getClassName(): string;
  59717. /**
  59718. * Gets the rgb component (input)
  59719. */
  59720. get rgbIn(): NodeMaterialConnectionPoint;
  59721. /**
  59722. * Gets the r component (input)
  59723. */
  59724. get r(): NodeMaterialConnectionPoint;
  59725. /**
  59726. * Gets the g component (input)
  59727. */
  59728. get g(): NodeMaterialConnectionPoint;
  59729. /**
  59730. * Gets the b component (input)
  59731. */
  59732. get b(): NodeMaterialConnectionPoint;
  59733. /**
  59734. * Gets the a component (input)
  59735. */
  59736. get a(): NodeMaterialConnectionPoint;
  59737. /**
  59738. * Gets the rgba component (output)
  59739. */
  59740. get rgba(): NodeMaterialConnectionPoint;
  59741. /**
  59742. * Gets the rgb component (output)
  59743. */
  59744. get rgbOut(): NodeMaterialConnectionPoint;
  59745. /**
  59746. * Gets the rgb component (output)
  59747. * @deprecated Please use rgbOut instead.
  59748. */
  59749. get rgb(): NodeMaterialConnectionPoint;
  59750. protected _buildBlock(state: NodeMaterialBuildState): this;
  59751. }
  59752. }
  59753. declare module BABYLON {
  59754. /**
  59755. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59756. */
  59757. export class VectorMergerBlock extends NodeMaterialBlock {
  59758. /**
  59759. * Create a new VectorMergerBlock
  59760. * @param name defines the block name
  59761. */
  59762. constructor(name: string);
  59763. /**
  59764. * Gets the current class name
  59765. * @returns the class name
  59766. */
  59767. getClassName(): string;
  59768. /**
  59769. * Gets the xyz component (input)
  59770. */
  59771. get xyzIn(): NodeMaterialConnectionPoint;
  59772. /**
  59773. * Gets the xy component (input)
  59774. */
  59775. get xyIn(): NodeMaterialConnectionPoint;
  59776. /**
  59777. * Gets the x component (input)
  59778. */
  59779. get x(): NodeMaterialConnectionPoint;
  59780. /**
  59781. * Gets the y component (input)
  59782. */
  59783. get y(): NodeMaterialConnectionPoint;
  59784. /**
  59785. * Gets the z component (input)
  59786. */
  59787. get z(): NodeMaterialConnectionPoint;
  59788. /**
  59789. * Gets the w component (input)
  59790. */
  59791. get w(): NodeMaterialConnectionPoint;
  59792. /**
  59793. * Gets the xyzw component (output)
  59794. */
  59795. get xyzw(): NodeMaterialConnectionPoint;
  59796. /**
  59797. * Gets the xyz component (output)
  59798. */
  59799. get xyzOut(): NodeMaterialConnectionPoint;
  59800. /**
  59801. * Gets the xy component (output)
  59802. */
  59803. get xyOut(): NodeMaterialConnectionPoint;
  59804. /**
  59805. * Gets the xy component (output)
  59806. * @deprecated Please use xyOut instead.
  59807. */
  59808. get xy(): NodeMaterialConnectionPoint;
  59809. /**
  59810. * Gets the xyz component (output)
  59811. * @deprecated Please use xyzOut instead.
  59812. */
  59813. get xyz(): NodeMaterialConnectionPoint;
  59814. protected _buildBlock(state: NodeMaterialBuildState): this;
  59815. }
  59816. }
  59817. declare module BABYLON {
  59818. /**
  59819. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59820. */
  59821. export class ColorSplitterBlock extends NodeMaterialBlock {
  59822. /**
  59823. * Create a new ColorSplitterBlock
  59824. * @param name defines the block name
  59825. */
  59826. constructor(name: string);
  59827. /**
  59828. * Gets the current class name
  59829. * @returns the class name
  59830. */
  59831. getClassName(): string;
  59832. /**
  59833. * Gets the rgba component (input)
  59834. */
  59835. get rgba(): NodeMaterialConnectionPoint;
  59836. /**
  59837. * Gets the rgb component (input)
  59838. */
  59839. get rgbIn(): NodeMaterialConnectionPoint;
  59840. /**
  59841. * Gets the rgb component (output)
  59842. */
  59843. get rgbOut(): NodeMaterialConnectionPoint;
  59844. /**
  59845. * Gets the r component (output)
  59846. */
  59847. get r(): NodeMaterialConnectionPoint;
  59848. /**
  59849. * Gets the g component (output)
  59850. */
  59851. get g(): NodeMaterialConnectionPoint;
  59852. /**
  59853. * Gets the b component (output)
  59854. */
  59855. get b(): NodeMaterialConnectionPoint;
  59856. /**
  59857. * Gets the a component (output)
  59858. */
  59859. get a(): NodeMaterialConnectionPoint;
  59860. protected _inputRename(name: string): string;
  59861. protected _outputRename(name: string): string;
  59862. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59863. }
  59864. }
  59865. declare module BABYLON {
  59866. /**
  59867. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59868. */
  59869. export class VectorSplitterBlock extends NodeMaterialBlock {
  59870. /**
  59871. * Create a new VectorSplitterBlock
  59872. * @param name defines the block name
  59873. */
  59874. constructor(name: string);
  59875. /**
  59876. * Gets the current class name
  59877. * @returns the class name
  59878. */
  59879. getClassName(): string;
  59880. /**
  59881. * Gets the xyzw component (input)
  59882. */
  59883. get xyzw(): NodeMaterialConnectionPoint;
  59884. /**
  59885. * Gets the xyz component (input)
  59886. */
  59887. get xyzIn(): NodeMaterialConnectionPoint;
  59888. /**
  59889. * Gets the xy component (input)
  59890. */
  59891. get xyIn(): NodeMaterialConnectionPoint;
  59892. /**
  59893. * Gets the xyz component (output)
  59894. */
  59895. get xyzOut(): NodeMaterialConnectionPoint;
  59896. /**
  59897. * Gets the xy component (output)
  59898. */
  59899. get xyOut(): NodeMaterialConnectionPoint;
  59900. /**
  59901. * Gets the x component (output)
  59902. */
  59903. get x(): NodeMaterialConnectionPoint;
  59904. /**
  59905. * Gets the y component (output)
  59906. */
  59907. get y(): NodeMaterialConnectionPoint;
  59908. /**
  59909. * Gets the z component (output)
  59910. */
  59911. get z(): NodeMaterialConnectionPoint;
  59912. /**
  59913. * Gets the w component (output)
  59914. */
  59915. get w(): NodeMaterialConnectionPoint;
  59916. protected _inputRename(name: string): string;
  59917. protected _outputRename(name: string): string;
  59918. protected _buildBlock(state: NodeMaterialBuildState): this;
  59919. }
  59920. }
  59921. declare module BABYLON {
  59922. /**
  59923. * Block used to lerp between 2 values
  59924. */
  59925. export class LerpBlock extends NodeMaterialBlock {
  59926. /**
  59927. * Creates a new LerpBlock
  59928. * @param name defines the block name
  59929. */
  59930. constructor(name: string);
  59931. /**
  59932. * Gets the current class name
  59933. * @returns the class name
  59934. */
  59935. getClassName(): string;
  59936. /**
  59937. * Gets the left operand input component
  59938. */
  59939. get left(): NodeMaterialConnectionPoint;
  59940. /**
  59941. * Gets the right operand input component
  59942. */
  59943. get right(): NodeMaterialConnectionPoint;
  59944. /**
  59945. * Gets the gradient operand input component
  59946. */
  59947. get gradient(): NodeMaterialConnectionPoint;
  59948. /**
  59949. * Gets the output component
  59950. */
  59951. get output(): NodeMaterialConnectionPoint;
  59952. protected _buildBlock(state: NodeMaterialBuildState): this;
  59953. }
  59954. }
  59955. declare module BABYLON {
  59956. /**
  59957. * Block used to divide 2 vectors
  59958. */
  59959. export class DivideBlock extends NodeMaterialBlock {
  59960. /**
  59961. * Creates a new DivideBlock
  59962. * @param name defines the block name
  59963. */
  59964. constructor(name: string);
  59965. /**
  59966. * Gets the current class name
  59967. * @returns the class name
  59968. */
  59969. getClassName(): string;
  59970. /**
  59971. * Gets the left operand input component
  59972. */
  59973. get left(): NodeMaterialConnectionPoint;
  59974. /**
  59975. * Gets the right operand input component
  59976. */
  59977. get right(): NodeMaterialConnectionPoint;
  59978. /**
  59979. * Gets the output component
  59980. */
  59981. get output(): NodeMaterialConnectionPoint;
  59982. protected _buildBlock(state: NodeMaterialBuildState): this;
  59983. }
  59984. }
  59985. declare module BABYLON {
  59986. /**
  59987. * Block used to subtract 2 vectors
  59988. */
  59989. export class SubtractBlock extends NodeMaterialBlock {
  59990. /**
  59991. * Creates a new SubtractBlock
  59992. * @param name defines the block name
  59993. */
  59994. constructor(name: string);
  59995. /**
  59996. * Gets the current class name
  59997. * @returns the class name
  59998. */
  59999. getClassName(): string;
  60000. /**
  60001. * Gets the left operand input component
  60002. */
  60003. get left(): NodeMaterialConnectionPoint;
  60004. /**
  60005. * Gets the right operand input component
  60006. */
  60007. get right(): NodeMaterialConnectionPoint;
  60008. /**
  60009. * Gets the output component
  60010. */
  60011. get output(): NodeMaterialConnectionPoint;
  60012. protected _buildBlock(state: NodeMaterialBuildState): this;
  60013. }
  60014. }
  60015. declare module BABYLON {
  60016. /**
  60017. * Block used to step a value
  60018. */
  60019. export class StepBlock extends NodeMaterialBlock {
  60020. /**
  60021. * Creates a new StepBlock
  60022. * @param name defines the block name
  60023. */
  60024. constructor(name: string);
  60025. /**
  60026. * Gets the current class name
  60027. * @returns the class name
  60028. */
  60029. getClassName(): string;
  60030. /**
  60031. * Gets the value operand input component
  60032. */
  60033. get value(): NodeMaterialConnectionPoint;
  60034. /**
  60035. * Gets the edge operand input component
  60036. */
  60037. get edge(): NodeMaterialConnectionPoint;
  60038. /**
  60039. * Gets the output component
  60040. */
  60041. get output(): NodeMaterialConnectionPoint;
  60042. protected _buildBlock(state: NodeMaterialBuildState): this;
  60043. }
  60044. }
  60045. declare module BABYLON {
  60046. /**
  60047. * Block used to get the opposite (1 - x) of a value
  60048. */
  60049. export class OneMinusBlock extends NodeMaterialBlock {
  60050. /**
  60051. * Creates a new OneMinusBlock
  60052. * @param name defines the block name
  60053. */
  60054. constructor(name: string);
  60055. /**
  60056. * Gets the current class name
  60057. * @returns the class name
  60058. */
  60059. getClassName(): string;
  60060. /**
  60061. * Gets the input component
  60062. */
  60063. get input(): NodeMaterialConnectionPoint;
  60064. /**
  60065. * Gets the output component
  60066. */
  60067. get output(): NodeMaterialConnectionPoint;
  60068. protected _buildBlock(state: NodeMaterialBuildState): this;
  60069. }
  60070. }
  60071. declare module BABYLON {
  60072. /**
  60073. * Block used to get the view direction
  60074. */
  60075. export class ViewDirectionBlock extends NodeMaterialBlock {
  60076. /**
  60077. * Creates a new ViewDirectionBlock
  60078. * @param name defines the block name
  60079. */
  60080. constructor(name: string);
  60081. /**
  60082. * Gets the current class name
  60083. * @returns the class name
  60084. */
  60085. getClassName(): string;
  60086. /**
  60087. * Gets the world position component
  60088. */
  60089. get worldPosition(): NodeMaterialConnectionPoint;
  60090. /**
  60091. * Gets the camera position component
  60092. */
  60093. get cameraPosition(): NodeMaterialConnectionPoint;
  60094. /**
  60095. * Gets the output component
  60096. */
  60097. get output(): NodeMaterialConnectionPoint;
  60098. autoConfigure(material: NodeMaterial): void;
  60099. protected _buildBlock(state: NodeMaterialBuildState): this;
  60100. }
  60101. }
  60102. declare module BABYLON {
  60103. /**
  60104. * Block used to compute fresnel value
  60105. */
  60106. export class FresnelBlock extends NodeMaterialBlock {
  60107. /**
  60108. * Create a new FresnelBlock
  60109. * @param name defines the block name
  60110. */
  60111. constructor(name: string);
  60112. /**
  60113. * Gets the current class name
  60114. * @returns the class name
  60115. */
  60116. getClassName(): string;
  60117. /**
  60118. * Gets the world normal input component
  60119. */
  60120. get worldNormal(): NodeMaterialConnectionPoint;
  60121. /**
  60122. * Gets the view direction input component
  60123. */
  60124. get viewDirection(): NodeMaterialConnectionPoint;
  60125. /**
  60126. * Gets the bias input component
  60127. */
  60128. get bias(): NodeMaterialConnectionPoint;
  60129. /**
  60130. * Gets the camera (or eye) position component
  60131. */
  60132. get power(): NodeMaterialConnectionPoint;
  60133. /**
  60134. * Gets the fresnel output component
  60135. */
  60136. get fresnel(): NodeMaterialConnectionPoint;
  60137. autoConfigure(material: NodeMaterial): void;
  60138. protected _buildBlock(state: NodeMaterialBuildState): this;
  60139. }
  60140. }
  60141. declare module BABYLON {
  60142. /**
  60143. * Block used to get the max of 2 values
  60144. */
  60145. export class MaxBlock extends NodeMaterialBlock {
  60146. /**
  60147. * Creates a new MaxBlock
  60148. * @param name defines the block name
  60149. */
  60150. constructor(name: string);
  60151. /**
  60152. * Gets the current class name
  60153. * @returns the class name
  60154. */
  60155. getClassName(): string;
  60156. /**
  60157. * Gets the left operand input component
  60158. */
  60159. get left(): NodeMaterialConnectionPoint;
  60160. /**
  60161. * Gets the right operand input component
  60162. */
  60163. get right(): NodeMaterialConnectionPoint;
  60164. /**
  60165. * Gets the output component
  60166. */
  60167. get output(): NodeMaterialConnectionPoint;
  60168. protected _buildBlock(state: NodeMaterialBuildState): this;
  60169. }
  60170. }
  60171. declare module BABYLON {
  60172. /**
  60173. * Block used to get the min of 2 values
  60174. */
  60175. export class MinBlock extends NodeMaterialBlock {
  60176. /**
  60177. * Creates a new MinBlock
  60178. * @param name defines the block name
  60179. */
  60180. constructor(name: string);
  60181. /**
  60182. * Gets the current class name
  60183. * @returns the class name
  60184. */
  60185. getClassName(): string;
  60186. /**
  60187. * Gets the left operand input component
  60188. */
  60189. get left(): NodeMaterialConnectionPoint;
  60190. /**
  60191. * Gets the right operand input component
  60192. */
  60193. get right(): NodeMaterialConnectionPoint;
  60194. /**
  60195. * Gets the output component
  60196. */
  60197. get output(): NodeMaterialConnectionPoint;
  60198. protected _buildBlock(state: NodeMaterialBuildState): this;
  60199. }
  60200. }
  60201. declare module BABYLON {
  60202. /**
  60203. * Block used to get the distance between 2 values
  60204. */
  60205. export class DistanceBlock extends NodeMaterialBlock {
  60206. /**
  60207. * Creates a new DistanceBlock
  60208. * @param name defines the block name
  60209. */
  60210. constructor(name: string);
  60211. /**
  60212. * Gets the current class name
  60213. * @returns the class name
  60214. */
  60215. getClassName(): string;
  60216. /**
  60217. * Gets the left operand input component
  60218. */
  60219. get left(): NodeMaterialConnectionPoint;
  60220. /**
  60221. * Gets the right operand input component
  60222. */
  60223. get right(): NodeMaterialConnectionPoint;
  60224. /**
  60225. * Gets the output component
  60226. */
  60227. get output(): NodeMaterialConnectionPoint;
  60228. protected _buildBlock(state: NodeMaterialBuildState): this;
  60229. }
  60230. }
  60231. declare module BABYLON {
  60232. /**
  60233. * Block used to get the length of a vector
  60234. */
  60235. export class LengthBlock extends NodeMaterialBlock {
  60236. /**
  60237. * Creates a new LengthBlock
  60238. * @param name defines the block name
  60239. */
  60240. constructor(name: string);
  60241. /**
  60242. * Gets the current class name
  60243. * @returns the class name
  60244. */
  60245. getClassName(): string;
  60246. /**
  60247. * Gets the value input component
  60248. */
  60249. get value(): NodeMaterialConnectionPoint;
  60250. /**
  60251. * Gets the output component
  60252. */
  60253. get output(): NodeMaterialConnectionPoint;
  60254. protected _buildBlock(state: NodeMaterialBuildState): this;
  60255. }
  60256. }
  60257. declare module BABYLON {
  60258. /**
  60259. * Block used to get negative version of a value (i.e. x * -1)
  60260. */
  60261. export class NegateBlock extends NodeMaterialBlock {
  60262. /**
  60263. * Creates a new NegateBlock
  60264. * @param name defines the block name
  60265. */
  60266. constructor(name: string);
  60267. /**
  60268. * Gets the current class name
  60269. * @returns the class name
  60270. */
  60271. getClassName(): string;
  60272. /**
  60273. * Gets the value input component
  60274. */
  60275. get value(): NodeMaterialConnectionPoint;
  60276. /**
  60277. * Gets the output component
  60278. */
  60279. get output(): NodeMaterialConnectionPoint;
  60280. protected _buildBlock(state: NodeMaterialBuildState): this;
  60281. }
  60282. }
  60283. declare module BABYLON {
  60284. /**
  60285. * Block used to get the value of the first parameter raised to the power of the second
  60286. */
  60287. export class PowBlock extends NodeMaterialBlock {
  60288. /**
  60289. * Creates a new PowBlock
  60290. * @param name defines the block name
  60291. */
  60292. constructor(name: string);
  60293. /**
  60294. * Gets the current class name
  60295. * @returns the class name
  60296. */
  60297. getClassName(): string;
  60298. /**
  60299. * Gets the value operand input component
  60300. */
  60301. get value(): NodeMaterialConnectionPoint;
  60302. /**
  60303. * Gets the power operand input component
  60304. */
  60305. get power(): NodeMaterialConnectionPoint;
  60306. /**
  60307. * Gets the output component
  60308. */
  60309. get output(): NodeMaterialConnectionPoint;
  60310. protected _buildBlock(state: NodeMaterialBuildState): this;
  60311. }
  60312. }
  60313. declare module BABYLON {
  60314. /**
  60315. * Block used to get a random number
  60316. */
  60317. export class RandomNumberBlock extends NodeMaterialBlock {
  60318. /**
  60319. * Creates a new RandomNumberBlock
  60320. * @param name defines the block name
  60321. */
  60322. constructor(name: string);
  60323. /**
  60324. * Gets the current class name
  60325. * @returns the class name
  60326. */
  60327. getClassName(): string;
  60328. /**
  60329. * Gets the seed input component
  60330. */
  60331. get seed(): NodeMaterialConnectionPoint;
  60332. /**
  60333. * Gets the output component
  60334. */
  60335. get output(): NodeMaterialConnectionPoint;
  60336. protected _buildBlock(state: NodeMaterialBuildState): this;
  60337. }
  60338. }
  60339. declare module BABYLON {
  60340. /**
  60341. * Block used to compute arc tangent of 2 values
  60342. */
  60343. export class ArcTan2Block extends NodeMaterialBlock {
  60344. /**
  60345. * Creates a new ArcTan2Block
  60346. * @param name defines the block name
  60347. */
  60348. constructor(name: string);
  60349. /**
  60350. * Gets the current class name
  60351. * @returns the class name
  60352. */
  60353. getClassName(): string;
  60354. /**
  60355. * Gets the x operand input component
  60356. */
  60357. get x(): NodeMaterialConnectionPoint;
  60358. /**
  60359. * Gets the y operand input component
  60360. */
  60361. get y(): NodeMaterialConnectionPoint;
  60362. /**
  60363. * Gets the output component
  60364. */
  60365. get output(): NodeMaterialConnectionPoint;
  60366. protected _buildBlock(state: NodeMaterialBuildState): this;
  60367. }
  60368. }
  60369. declare module BABYLON {
  60370. /**
  60371. * Block used to smooth step a value
  60372. */
  60373. export class SmoothStepBlock extends NodeMaterialBlock {
  60374. /**
  60375. * Creates a new SmoothStepBlock
  60376. * @param name defines the block name
  60377. */
  60378. constructor(name: string);
  60379. /**
  60380. * Gets the current class name
  60381. * @returns the class name
  60382. */
  60383. getClassName(): string;
  60384. /**
  60385. * Gets the value operand input component
  60386. */
  60387. get value(): NodeMaterialConnectionPoint;
  60388. /**
  60389. * Gets the first edge operand input component
  60390. */
  60391. get edge0(): NodeMaterialConnectionPoint;
  60392. /**
  60393. * Gets the second edge operand input component
  60394. */
  60395. get edge1(): NodeMaterialConnectionPoint;
  60396. /**
  60397. * Gets the output component
  60398. */
  60399. get output(): NodeMaterialConnectionPoint;
  60400. protected _buildBlock(state: NodeMaterialBuildState): this;
  60401. }
  60402. }
  60403. declare module BABYLON {
  60404. /**
  60405. * Block used to get the reciprocal (1 / x) of a value
  60406. */
  60407. export class ReciprocalBlock extends NodeMaterialBlock {
  60408. /**
  60409. * Creates a new ReciprocalBlock
  60410. * @param name defines the block name
  60411. */
  60412. constructor(name: string);
  60413. /**
  60414. * Gets the current class name
  60415. * @returns the class name
  60416. */
  60417. getClassName(): string;
  60418. /**
  60419. * Gets the input component
  60420. */
  60421. get input(): NodeMaterialConnectionPoint;
  60422. /**
  60423. * Gets the output component
  60424. */
  60425. get output(): NodeMaterialConnectionPoint;
  60426. protected _buildBlock(state: NodeMaterialBuildState): this;
  60427. }
  60428. }
  60429. declare module BABYLON {
  60430. /**
  60431. * Block used to replace a color by another one
  60432. */
  60433. export class ReplaceColorBlock extends NodeMaterialBlock {
  60434. /**
  60435. * Creates a new ReplaceColorBlock
  60436. * @param name defines the block name
  60437. */
  60438. constructor(name: string);
  60439. /**
  60440. * Gets the current class name
  60441. * @returns the class name
  60442. */
  60443. getClassName(): string;
  60444. /**
  60445. * Gets the value input component
  60446. */
  60447. get value(): NodeMaterialConnectionPoint;
  60448. /**
  60449. * Gets the reference input component
  60450. */
  60451. get reference(): NodeMaterialConnectionPoint;
  60452. /**
  60453. * Gets the distance input component
  60454. */
  60455. get distance(): NodeMaterialConnectionPoint;
  60456. /**
  60457. * Gets the replacement input component
  60458. */
  60459. get replacement(): NodeMaterialConnectionPoint;
  60460. /**
  60461. * Gets the output component
  60462. */
  60463. get output(): NodeMaterialConnectionPoint;
  60464. protected _buildBlock(state: NodeMaterialBuildState): this;
  60465. }
  60466. }
  60467. declare module BABYLON {
  60468. /**
  60469. * Block used to posterize a value
  60470. * @see https://en.wikipedia.org/wiki/Posterization
  60471. */
  60472. export class PosterizeBlock extends NodeMaterialBlock {
  60473. /**
  60474. * Creates a new PosterizeBlock
  60475. * @param name defines the block name
  60476. */
  60477. constructor(name: string);
  60478. /**
  60479. * Gets the current class name
  60480. * @returns the class name
  60481. */
  60482. getClassName(): string;
  60483. /**
  60484. * Gets the value input component
  60485. */
  60486. get value(): NodeMaterialConnectionPoint;
  60487. /**
  60488. * Gets the steps input component
  60489. */
  60490. get steps(): NodeMaterialConnectionPoint;
  60491. /**
  60492. * Gets the output component
  60493. */
  60494. get output(): NodeMaterialConnectionPoint;
  60495. protected _buildBlock(state: NodeMaterialBuildState): this;
  60496. }
  60497. }
  60498. declare module BABYLON {
  60499. /**
  60500. * Operations supported by the Wave block
  60501. */
  60502. export enum WaveBlockKind {
  60503. /** SawTooth */
  60504. SawTooth = 0,
  60505. /** Square */
  60506. Square = 1,
  60507. /** Triangle */
  60508. Triangle = 2
  60509. }
  60510. /**
  60511. * Block used to apply wave operation to floats
  60512. */
  60513. export class WaveBlock extends NodeMaterialBlock {
  60514. /**
  60515. * Gets or sets the kibnd of wave to be applied by the block
  60516. */
  60517. kind: WaveBlockKind;
  60518. /**
  60519. * Creates a new WaveBlock
  60520. * @param name defines the block name
  60521. */
  60522. constructor(name: string);
  60523. /**
  60524. * Gets the current class name
  60525. * @returns the class name
  60526. */
  60527. getClassName(): string;
  60528. /**
  60529. * Gets the input component
  60530. */
  60531. get input(): NodeMaterialConnectionPoint;
  60532. /**
  60533. * Gets the output component
  60534. */
  60535. get output(): NodeMaterialConnectionPoint;
  60536. protected _buildBlock(state: NodeMaterialBuildState): this;
  60537. serialize(): any;
  60538. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60539. }
  60540. }
  60541. declare module BABYLON {
  60542. /**
  60543. * Class used to store a color step for the GradientBlock
  60544. */
  60545. export class GradientBlockColorStep {
  60546. /**
  60547. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60548. */
  60549. step: number;
  60550. /**
  60551. * Gets or sets the color associated with this step
  60552. */
  60553. color: Color3;
  60554. /**
  60555. * Creates a new GradientBlockColorStep
  60556. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60557. * @param color defines the color associated with this step
  60558. */
  60559. constructor(
  60560. /**
  60561. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60562. */
  60563. step: number,
  60564. /**
  60565. * Gets or sets the color associated with this step
  60566. */
  60567. color: Color3);
  60568. }
  60569. /**
  60570. * Block used to return a color from a gradient based on an input value between 0 and 1
  60571. */
  60572. export class GradientBlock extends NodeMaterialBlock {
  60573. /**
  60574. * Gets or sets the list of color steps
  60575. */
  60576. colorSteps: GradientBlockColorStep[];
  60577. /**
  60578. * Creates a new GradientBlock
  60579. * @param name defines the block name
  60580. */
  60581. constructor(name: string);
  60582. /**
  60583. * Gets the current class name
  60584. * @returns the class name
  60585. */
  60586. getClassName(): string;
  60587. /**
  60588. * Gets the gradient input component
  60589. */
  60590. get gradient(): NodeMaterialConnectionPoint;
  60591. /**
  60592. * Gets the output component
  60593. */
  60594. get output(): NodeMaterialConnectionPoint;
  60595. private _writeColorConstant;
  60596. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60597. serialize(): any;
  60598. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60599. protected _dumpPropertiesCode(): string;
  60600. }
  60601. }
  60602. declare module BABYLON {
  60603. /**
  60604. * Block used to normalize lerp between 2 values
  60605. */
  60606. export class NLerpBlock extends NodeMaterialBlock {
  60607. /**
  60608. * Creates a new NLerpBlock
  60609. * @param name defines the block name
  60610. */
  60611. constructor(name: string);
  60612. /**
  60613. * Gets the current class name
  60614. * @returns the class name
  60615. */
  60616. getClassName(): string;
  60617. /**
  60618. * Gets the left operand input component
  60619. */
  60620. get left(): NodeMaterialConnectionPoint;
  60621. /**
  60622. * Gets the right operand input component
  60623. */
  60624. get right(): NodeMaterialConnectionPoint;
  60625. /**
  60626. * Gets the gradient operand input component
  60627. */
  60628. get gradient(): NodeMaterialConnectionPoint;
  60629. /**
  60630. * Gets the output component
  60631. */
  60632. get output(): NodeMaterialConnectionPoint;
  60633. protected _buildBlock(state: NodeMaterialBuildState): this;
  60634. }
  60635. }
  60636. declare module BABYLON {
  60637. /**
  60638. * block used to Generate a Worley Noise 3D Noise Pattern
  60639. */
  60640. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60641. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60642. manhattanDistance: boolean;
  60643. /**
  60644. * Creates a new WorleyNoise3DBlock
  60645. * @param name defines the block name
  60646. */
  60647. constructor(name: string);
  60648. /**
  60649. * Gets the current class name
  60650. * @returns the class name
  60651. */
  60652. getClassName(): string;
  60653. /**
  60654. * Gets the seed input component
  60655. */
  60656. get seed(): NodeMaterialConnectionPoint;
  60657. /**
  60658. * Gets the jitter input component
  60659. */
  60660. get jitter(): NodeMaterialConnectionPoint;
  60661. /**
  60662. * Gets the output component
  60663. */
  60664. get output(): NodeMaterialConnectionPoint;
  60665. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60666. /**
  60667. * Exposes the properties to the UI?
  60668. */
  60669. protected _dumpPropertiesCode(): string;
  60670. /**
  60671. * Exposes the properties to the Seralize?
  60672. */
  60673. serialize(): any;
  60674. /**
  60675. * Exposes the properties to the deseralize?
  60676. */
  60677. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60678. }
  60679. }
  60680. declare module BABYLON {
  60681. /**
  60682. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60683. */
  60684. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60685. /**
  60686. * Creates a new SimplexPerlin3DBlock
  60687. * @param name defines the block name
  60688. */
  60689. constructor(name: string);
  60690. /**
  60691. * Gets the current class name
  60692. * @returns the class name
  60693. */
  60694. getClassName(): string;
  60695. /**
  60696. * Gets the seed operand input component
  60697. */
  60698. get seed(): NodeMaterialConnectionPoint;
  60699. /**
  60700. * Gets the output component
  60701. */
  60702. get output(): NodeMaterialConnectionPoint;
  60703. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60704. }
  60705. }
  60706. declare module BABYLON {
  60707. /**
  60708. * Block used to blend normals
  60709. */
  60710. export class NormalBlendBlock extends NodeMaterialBlock {
  60711. /**
  60712. * Creates a new NormalBlendBlock
  60713. * @param name defines the block name
  60714. */
  60715. constructor(name: string);
  60716. /**
  60717. * Gets the current class name
  60718. * @returns the class name
  60719. */
  60720. getClassName(): string;
  60721. /**
  60722. * Gets the first input component
  60723. */
  60724. get normalMap0(): NodeMaterialConnectionPoint;
  60725. /**
  60726. * Gets the second input component
  60727. */
  60728. get normalMap1(): NodeMaterialConnectionPoint;
  60729. /**
  60730. * Gets the output component
  60731. */
  60732. get output(): NodeMaterialConnectionPoint;
  60733. protected _buildBlock(state: NodeMaterialBuildState): this;
  60734. }
  60735. }
  60736. declare module BABYLON {
  60737. /**
  60738. * Block used to rotate a 2d vector by a given angle
  60739. */
  60740. export class Rotate2dBlock extends NodeMaterialBlock {
  60741. /**
  60742. * Creates a new Rotate2dBlock
  60743. * @param name defines the block name
  60744. */
  60745. constructor(name: string);
  60746. /**
  60747. * Gets the current class name
  60748. * @returns the class name
  60749. */
  60750. getClassName(): string;
  60751. /**
  60752. * Gets the input vector
  60753. */
  60754. get input(): NodeMaterialConnectionPoint;
  60755. /**
  60756. * Gets the input angle
  60757. */
  60758. get angle(): NodeMaterialConnectionPoint;
  60759. /**
  60760. * Gets the output component
  60761. */
  60762. get output(): NodeMaterialConnectionPoint;
  60763. autoConfigure(material: NodeMaterial): void;
  60764. protected _buildBlock(state: NodeMaterialBuildState): this;
  60765. }
  60766. }
  60767. declare module BABYLON {
  60768. /**
  60769. * Block used to get the reflected vector from a direction and a normal
  60770. */
  60771. export class ReflectBlock extends NodeMaterialBlock {
  60772. /**
  60773. * Creates a new ReflectBlock
  60774. * @param name defines the block name
  60775. */
  60776. constructor(name: string);
  60777. /**
  60778. * Gets the current class name
  60779. * @returns the class name
  60780. */
  60781. getClassName(): string;
  60782. /**
  60783. * Gets the incident component
  60784. */
  60785. get incident(): NodeMaterialConnectionPoint;
  60786. /**
  60787. * Gets the normal component
  60788. */
  60789. get normal(): NodeMaterialConnectionPoint;
  60790. /**
  60791. * Gets the output component
  60792. */
  60793. get output(): NodeMaterialConnectionPoint;
  60794. protected _buildBlock(state: NodeMaterialBuildState): this;
  60795. }
  60796. }
  60797. declare module BABYLON {
  60798. /**
  60799. * Block used to get the refracted vector from a direction and a normal
  60800. */
  60801. export class RefractBlock extends NodeMaterialBlock {
  60802. /**
  60803. * Creates a new RefractBlock
  60804. * @param name defines the block name
  60805. */
  60806. constructor(name: string);
  60807. /**
  60808. * Gets the current class name
  60809. * @returns the class name
  60810. */
  60811. getClassName(): string;
  60812. /**
  60813. * Gets the incident component
  60814. */
  60815. get incident(): NodeMaterialConnectionPoint;
  60816. /**
  60817. * Gets the normal component
  60818. */
  60819. get normal(): NodeMaterialConnectionPoint;
  60820. /**
  60821. * Gets the index of refraction component
  60822. */
  60823. get ior(): NodeMaterialConnectionPoint;
  60824. /**
  60825. * Gets the output component
  60826. */
  60827. get output(): NodeMaterialConnectionPoint;
  60828. protected _buildBlock(state: NodeMaterialBuildState): this;
  60829. }
  60830. }
  60831. declare module BABYLON {
  60832. /**
  60833. * Block used to desaturate a color
  60834. */
  60835. export class DesaturateBlock extends NodeMaterialBlock {
  60836. /**
  60837. * Creates a new DesaturateBlock
  60838. * @param name defines the block name
  60839. */
  60840. constructor(name: string);
  60841. /**
  60842. * Gets the current class name
  60843. * @returns the class name
  60844. */
  60845. getClassName(): string;
  60846. /**
  60847. * Gets the color operand input component
  60848. */
  60849. get color(): NodeMaterialConnectionPoint;
  60850. /**
  60851. * Gets the level operand input component
  60852. */
  60853. get level(): NodeMaterialConnectionPoint;
  60854. /**
  60855. * Gets the output component
  60856. */
  60857. get output(): NodeMaterialConnectionPoint;
  60858. protected _buildBlock(state: NodeMaterialBuildState): this;
  60859. }
  60860. }
  60861. declare module BABYLON {
  60862. /**
  60863. * Effect Render Options
  60864. */
  60865. export interface IEffectRendererOptions {
  60866. /**
  60867. * Defines the vertices positions.
  60868. */
  60869. positions?: number[];
  60870. /**
  60871. * Defines the indices.
  60872. */
  60873. indices?: number[];
  60874. }
  60875. /**
  60876. * Helper class to render one or more effects.
  60877. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60878. */
  60879. export class EffectRenderer {
  60880. private engine;
  60881. private static _DefaultOptions;
  60882. private _vertexBuffers;
  60883. private _indexBuffer;
  60884. private _fullscreenViewport;
  60885. /**
  60886. * Creates an effect renderer
  60887. * @param engine the engine to use for rendering
  60888. * @param options defines the options of the effect renderer
  60889. */
  60890. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60891. /**
  60892. * Sets the current viewport in normalized coordinates 0-1
  60893. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60894. */
  60895. setViewport(viewport?: Viewport): void;
  60896. /**
  60897. * Binds the embedded attributes buffer to the effect.
  60898. * @param effect Defines the effect to bind the attributes for
  60899. */
  60900. bindBuffers(effect: Effect): void;
  60901. /**
  60902. * Sets the current effect wrapper to use during draw.
  60903. * The effect needs to be ready before calling this api.
  60904. * This also sets the default full screen position attribute.
  60905. * @param effectWrapper Defines the effect to draw with
  60906. */
  60907. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60908. /**
  60909. * Draws a full screen quad.
  60910. */
  60911. draw(): void;
  60912. private isRenderTargetTexture;
  60913. /**
  60914. * renders one or more effects to a specified texture
  60915. * @param effectWrapper the effect to renderer
  60916. * @param outputTexture texture to draw to, if null it will render to the screen.
  60917. */
  60918. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60919. /**
  60920. * Disposes of the effect renderer
  60921. */
  60922. dispose(): void;
  60923. }
  60924. /**
  60925. * Options to create an EffectWrapper
  60926. */
  60927. interface EffectWrapperCreationOptions {
  60928. /**
  60929. * Engine to use to create the effect
  60930. */
  60931. engine: ThinEngine;
  60932. /**
  60933. * Fragment shader for the effect
  60934. */
  60935. fragmentShader: string;
  60936. /**
  60937. * Vertex shader for the effect
  60938. */
  60939. vertexShader?: string;
  60940. /**
  60941. * Attributes to use in the shader
  60942. */
  60943. attributeNames?: Array<string>;
  60944. /**
  60945. * Uniforms to use in the shader
  60946. */
  60947. uniformNames?: Array<string>;
  60948. /**
  60949. * Texture sampler names to use in the shader
  60950. */
  60951. samplerNames?: Array<string>;
  60952. /**
  60953. * The friendly name of the effect displayed in Spector.
  60954. */
  60955. name?: string;
  60956. }
  60957. /**
  60958. * Wraps an effect to be used for rendering
  60959. */
  60960. export class EffectWrapper {
  60961. /**
  60962. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60963. */
  60964. onApplyObservable: Observable<{}>;
  60965. /**
  60966. * The underlying effect
  60967. */
  60968. effect: Effect;
  60969. /**
  60970. * Creates an effect to be renderer
  60971. * @param creationOptions options to create the effect
  60972. */
  60973. constructor(creationOptions: EffectWrapperCreationOptions);
  60974. /**
  60975. * Disposes of the effect wrapper
  60976. */
  60977. dispose(): void;
  60978. }
  60979. }
  60980. declare module BABYLON {
  60981. /**
  60982. * Helper class to push actions to a pool of workers.
  60983. */
  60984. export class WorkerPool implements IDisposable {
  60985. private _workerInfos;
  60986. private _pendingActions;
  60987. /**
  60988. * Constructor
  60989. * @param workers Array of workers to use for actions
  60990. */
  60991. constructor(workers: Array<Worker>);
  60992. /**
  60993. * Terminates all workers and clears any pending actions.
  60994. */
  60995. dispose(): void;
  60996. /**
  60997. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60998. * pended until a worker has completed its action.
  60999. * @param action The action to perform. Call onComplete when the action is complete.
  61000. */
  61001. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61002. private _execute;
  61003. }
  61004. }
  61005. declare module BABYLON {
  61006. /**
  61007. * Configuration for Draco compression
  61008. */
  61009. export interface IDracoCompressionConfiguration {
  61010. /**
  61011. * Configuration for the decoder.
  61012. */
  61013. decoder: {
  61014. /**
  61015. * The url to the WebAssembly module.
  61016. */
  61017. wasmUrl?: string;
  61018. /**
  61019. * The url to the WebAssembly binary.
  61020. */
  61021. wasmBinaryUrl?: string;
  61022. /**
  61023. * The url to the fallback JavaScript module.
  61024. */
  61025. fallbackUrl?: string;
  61026. };
  61027. }
  61028. /**
  61029. * Draco compression (https://google.github.io/draco/)
  61030. *
  61031. * This class wraps the Draco module.
  61032. *
  61033. * **Encoder**
  61034. *
  61035. * The encoder is not currently implemented.
  61036. *
  61037. * **Decoder**
  61038. *
  61039. * 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.
  61040. *
  61041. * To update the configuration, use the following code:
  61042. * ```javascript
  61043. * DracoCompression.Configuration = {
  61044. * decoder: {
  61045. * wasmUrl: "<url to the WebAssembly library>",
  61046. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61047. * fallbackUrl: "<url to the fallback JavaScript library>",
  61048. * }
  61049. * };
  61050. * ```
  61051. *
  61052. * 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.
  61053. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61054. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61055. *
  61056. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61057. * ```javascript
  61058. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61059. * ```
  61060. *
  61061. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61062. */
  61063. export class DracoCompression implements IDisposable {
  61064. private _workerPoolPromise?;
  61065. private _decoderModulePromise?;
  61066. /**
  61067. * The configuration. Defaults to the following urls:
  61068. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61069. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61070. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61071. */
  61072. static Configuration: IDracoCompressionConfiguration;
  61073. /**
  61074. * Returns true if the decoder configuration is available.
  61075. */
  61076. static get DecoderAvailable(): boolean;
  61077. /**
  61078. * Default number of workers to create when creating the draco compression object.
  61079. */
  61080. static DefaultNumWorkers: number;
  61081. private static GetDefaultNumWorkers;
  61082. private static _Default;
  61083. /**
  61084. * Default instance for the draco compression object.
  61085. */
  61086. static get Default(): DracoCompression;
  61087. /**
  61088. * Constructor
  61089. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61090. */
  61091. constructor(numWorkers?: number);
  61092. /**
  61093. * Stop all async operations and release resources.
  61094. */
  61095. dispose(): void;
  61096. /**
  61097. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61098. * @returns a promise that resolves when ready
  61099. */
  61100. whenReadyAsync(): Promise<void>;
  61101. /**
  61102. * Decode Draco compressed mesh data to vertex data.
  61103. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61104. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61105. * @returns A promise that resolves with the decoded vertex data
  61106. */
  61107. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61108. [kind: string]: number;
  61109. }): Promise<VertexData>;
  61110. }
  61111. }
  61112. declare module BABYLON {
  61113. /**
  61114. * Class for building Constructive Solid Geometry
  61115. */
  61116. export class CSG {
  61117. private polygons;
  61118. /**
  61119. * The world matrix
  61120. */
  61121. matrix: Matrix;
  61122. /**
  61123. * Stores the position
  61124. */
  61125. position: Vector3;
  61126. /**
  61127. * Stores the rotation
  61128. */
  61129. rotation: Vector3;
  61130. /**
  61131. * Stores the rotation quaternion
  61132. */
  61133. rotationQuaternion: Nullable<Quaternion>;
  61134. /**
  61135. * Stores the scaling vector
  61136. */
  61137. scaling: Vector3;
  61138. /**
  61139. * Convert the Mesh to CSG
  61140. * @param mesh The Mesh to convert to CSG
  61141. * @returns A new CSG from the Mesh
  61142. */
  61143. static FromMesh(mesh: Mesh): CSG;
  61144. /**
  61145. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61146. * @param polygons Polygons used to construct a CSG solid
  61147. */
  61148. private static FromPolygons;
  61149. /**
  61150. * Clones, or makes a deep copy, of the CSG
  61151. * @returns A new CSG
  61152. */
  61153. clone(): CSG;
  61154. /**
  61155. * Unions this CSG with another CSG
  61156. * @param csg The CSG to union against this CSG
  61157. * @returns The unioned CSG
  61158. */
  61159. union(csg: CSG): CSG;
  61160. /**
  61161. * Unions this CSG with another CSG in place
  61162. * @param csg The CSG to union against this CSG
  61163. */
  61164. unionInPlace(csg: CSG): void;
  61165. /**
  61166. * Subtracts this CSG with another CSG
  61167. * @param csg The CSG to subtract against this CSG
  61168. * @returns A new CSG
  61169. */
  61170. subtract(csg: CSG): CSG;
  61171. /**
  61172. * Subtracts this CSG with another CSG in place
  61173. * @param csg The CSG to subtact against this CSG
  61174. */
  61175. subtractInPlace(csg: CSG): void;
  61176. /**
  61177. * Intersect this CSG with another CSG
  61178. * @param csg The CSG to intersect against this CSG
  61179. * @returns A new CSG
  61180. */
  61181. intersect(csg: CSG): CSG;
  61182. /**
  61183. * Intersects this CSG with another CSG in place
  61184. * @param csg The CSG to intersect against this CSG
  61185. */
  61186. intersectInPlace(csg: CSG): void;
  61187. /**
  61188. * Return a new CSG solid with solid and empty space switched. This solid is
  61189. * not modified.
  61190. * @returns A new CSG solid with solid and empty space switched
  61191. */
  61192. inverse(): CSG;
  61193. /**
  61194. * Inverses the CSG in place
  61195. */
  61196. inverseInPlace(): void;
  61197. /**
  61198. * This is used to keep meshes transformations so they can be restored
  61199. * when we build back a Babylon Mesh
  61200. * NB : All CSG operations are performed in world coordinates
  61201. * @param csg The CSG to copy the transform attributes from
  61202. * @returns This CSG
  61203. */
  61204. copyTransformAttributes(csg: CSG): CSG;
  61205. /**
  61206. * Build Raw mesh from CSG
  61207. * Coordinates here are in world space
  61208. * @param name The name of the mesh geometry
  61209. * @param scene The Scene
  61210. * @param keepSubMeshes Specifies if the submeshes should be kept
  61211. * @returns A new Mesh
  61212. */
  61213. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61214. /**
  61215. * Build Mesh from CSG taking material and transforms into account
  61216. * @param name The name of the Mesh
  61217. * @param material The material of the Mesh
  61218. * @param scene The Scene
  61219. * @param keepSubMeshes Specifies if submeshes should be kept
  61220. * @returns The new Mesh
  61221. */
  61222. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61223. }
  61224. }
  61225. declare module BABYLON {
  61226. /**
  61227. * Class used to create a trail following a mesh
  61228. */
  61229. export class TrailMesh extends Mesh {
  61230. private _generator;
  61231. private _autoStart;
  61232. private _running;
  61233. private _diameter;
  61234. private _length;
  61235. private _sectionPolygonPointsCount;
  61236. private _sectionVectors;
  61237. private _sectionNormalVectors;
  61238. private _beforeRenderObserver;
  61239. /**
  61240. * @constructor
  61241. * @param name The value used by scene.getMeshByName() to do a lookup.
  61242. * @param generator The mesh or transform node to generate a trail.
  61243. * @param scene The scene to add this mesh to.
  61244. * @param diameter Diameter of trailing mesh. Default is 1.
  61245. * @param length Length of trailing mesh. Default is 60.
  61246. * @param autoStart Automatically start trailing mesh. Default true.
  61247. */
  61248. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61249. /**
  61250. * "TrailMesh"
  61251. * @returns "TrailMesh"
  61252. */
  61253. getClassName(): string;
  61254. private _createMesh;
  61255. /**
  61256. * Start trailing mesh.
  61257. */
  61258. start(): void;
  61259. /**
  61260. * Stop trailing mesh.
  61261. */
  61262. stop(): void;
  61263. /**
  61264. * Update trailing mesh geometry.
  61265. */
  61266. update(): void;
  61267. /**
  61268. * Returns a new TrailMesh object.
  61269. * @param name is a string, the name given to the new mesh
  61270. * @param newGenerator use new generator object for cloned trail mesh
  61271. * @returns a new mesh
  61272. */
  61273. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61274. /**
  61275. * Serializes this trail mesh
  61276. * @param serializationObject object to write serialization to
  61277. */
  61278. serialize(serializationObject: any): void;
  61279. /**
  61280. * Parses a serialized trail mesh
  61281. * @param parsedMesh the serialized mesh
  61282. * @param scene the scene to create the trail mesh in
  61283. * @returns the created trail mesh
  61284. */
  61285. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61286. }
  61287. }
  61288. declare module BABYLON {
  61289. /**
  61290. * Class containing static functions to help procedurally build meshes
  61291. */
  61292. export class TiledBoxBuilder {
  61293. /**
  61294. * Creates a box mesh
  61295. * 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)
  61296. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61298. * * 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
  61299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61300. * @param name defines the name of the mesh
  61301. * @param options defines the options used to create the mesh
  61302. * @param scene defines the hosting scene
  61303. * @returns the box mesh
  61304. */
  61305. static CreateTiledBox(name: string, options: {
  61306. pattern?: number;
  61307. width?: number;
  61308. height?: number;
  61309. depth?: number;
  61310. tileSize?: number;
  61311. tileWidth?: number;
  61312. tileHeight?: number;
  61313. alignHorizontal?: number;
  61314. alignVertical?: number;
  61315. faceUV?: Vector4[];
  61316. faceColors?: Color4[];
  61317. sideOrientation?: number;
  61318. updatable?: boolean;
  61319. }, scene?: Nullable<Scene>): Mesh;
  61320. }
  61321. }
  61322. declare module BABYLON {
  61323. /**
  61324. * Class containing static functions to help procedurally build meshes
  61325. */
  61326. export class TorusKnotBuilder {
  61327. /**
  61328. * Creates a torus knot mesh
  61329. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61330. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61331. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61332. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61334. * * 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
  61335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61336. * @param name defines the name of the mesh
  61337. * @param options defines the options used to create the mesh
  61338. * @param scene defines the hosting scene
  61339. * @returns the torus knot mesh
  61340. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61341. */
  61342. static CreateTorusKnot(name: string, options: {
  61343. radius?: number;
  61344. tube?: number;
  61345. radialSegments?: number;
  61346. tubularSegments?: number;
  61347. p?: number;
  61348. q?: number;
  61349. updatable?: boolean;
  61350. sideOrientation?: number;
  61351. frontUVs?: Vector4;
  61352. backUVs?: Vector4;
  61353. }, scene: any): Mesh;
  61354. }
  61355. }
  61356. declare module BABYLON {
  61357. /**
  61358. * Polygon
  61359. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61360. */
  61361. export class Polygon {
  61362. /**
  61363. * Creates a rectangle
  61364. * @param xmin bottom X coord
  61365. * @param ymin bottom Y coord
  61366. * @param xmax top X coord
  61367. * @param ymax top Y coord
  61368. * @returns points that make the resulting rectation
  61369. */
  61370. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61371. /**
  61372. * Creates a circle
  61373. * @param radius radius of circle
  61374. * @param cx scale in x
  61375. * @param cy scale in y
  61376. * @param numberOfSides number of sides that make up the circle
  61377. * @returns points that make the resulting circle
  61378. */
  61379. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61380. /**
  61381. * Creates a polygon from input string
  61382. * @param input Input polygon data
  61383. * @returns the parsed points
  61384. */
  61385. static Parse(input: string): Vector2[];
  61386. /**
  61387. * Starts building a polygon from x and y coordinates
  61388. * @param x x coordinate
  61389. * @param y y coordinate
  61390. * @returns the started path2
  61391. */
  61392. static StartingAt(x: number, y: number): Path2;
  61393. }
  61394. /**
  61395. * Builds a polygon
  61396. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61397. */
  61398. export class PolygonMeshBuilder {
  61399. private _points;
  61400. private _outlinepoints;
  61401. private _holes;
  61402. private _name;
  61403. private _scene;
  61404. private _epoints;
  61405. private _eholes;
  61406. private _addToepoint;
  61407. /**
  61408. * Babylon reference to the earcut plugin.
  61409. */
  61410. bjsEarcut: any;
  61411. /**
  61412. * Creates a PolygonMeshBuilder
  61413. * @param name name of the builder
  61414. * @param contours Path of the polygon
  61415. * @param scene scene to add to when creating the mesh
  61416. * @param earcutInjection can be used to inject your own earcut reference
  61417. */
  61418. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61419. /**
  61420. * Adds a whole within the polygon
  61421. * @param hole Array of points defining the hole
  61422. * @returns this
  61423. */
  61424. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61425. /**
  61426. * Creates the polygon
  61427. * @param updatable If the mesh should be updatable
  61428. * @param depth The depth of the mesh created
  61429. * @returns the created mesh
  61430. */
  61431. build(updatable?: boolean, depth?: number): Mesh;
  61432. /**
  61433. * Creates the polygon
  61434. * @param depth The depth of the mesh created
  61435. * @returns the created VertexData
  61436. */
  61437. buildVertexData(depth?: number): VertexData;
  61438. /**
  61439. * Adds a side to the polygon
  61440. * @param positions points that make the polygon
  61441. * @param normals normals of the polygon
  61442. * @param uvs uvs of the polygon
  61443. * @param indices indices of the polygon
  61444. * @param bounds bounds of the polygon
  61445. * @param points points of the polygon
  61446. * @param depth depth of the polygon
  61447. * @param flip flip of the polygon
  61448. */
  61449. private addSide;
  61450. }
  61451. }
  61452. declare module BABYLON {
  61453. /**
  61454. * Class containing static functions to help procedurally build meshes
  61455. */
  61456. export class PolygonBuilder {
  61457. /**
  61458. * Creates a polygon mesh
  61459. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61460. * * 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
  61461. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61463. * * 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)
  61464. * * Remember you can only change the shape positions, not their number when updating a polygon
  61465. * @param name defines the name of the mesh
  61466. * @param options defines the options used to create the mesh
  61467. * @param scene defines the hosting scene
  61468. * @param earcutInjection can be used to inject your own earcut reference
  61469. * @returns the polygon mesh
  61470. */
  61471. static CreatePolygon(name: string, options: {
  61472. shape: Vector3[];
  61473. holes?: Vector3[][];
  61474. depth?: number;
  61475. faceUV?: Vector4[];
  61476. faceColors?: Color4[];
  61477. updatable?: boolean;
  61478. sideOrientation?: number;
  61479. frontUVs?: Vector4;
  61480. backUVs?: Vector4;
  61481. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61482. /**
  61483. * Creates an extruded polygon mesh, with depth in the Y direction.
  61484. * * 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)
  61485. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61486. * @param name defines the name of the mesh
  61487. * @param options defines the options used to create the mesh
  61488. * @param scene defines the hosting scene
  61489. * @param earcutInjection can be used to inject your own earcut reference
  61490. * @returns the polygon mesh
  61491. */
  61492. static ExtrudePolygon(name: string, options: {
  61493. shape: Vector3[];
  61494. holes?: Vector3[][];
  61495. depth?: number;
  61496. faceUV?: Vector4[];
  61497. faceColors?: Color4[];
  61498. updatable?: boolean;
  61499. sideOrientation?: number;
  61500. frontUVs?: Vector4;
  61501. backUVs?: Vector4;
  61502. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61503. }
  61504. }
  61505. declare module BABYLON {
  61506. /**
  61507. * Class containing static functions to help procedurally build meshes
  61508. */
  61509. export class LatheBuilder {
  61510. /**
  61511. * Creates lathe mesh.
  61512. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61513. * * 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
  61514. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61515. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61516. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61517. * * 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
  61518. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61519. * * 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
  61520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61521. * * 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
  61522. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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 lathe mesh
  61528. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61529. */
  61530. static CreateLathe(name: string, options: {
  61531. shape: Vector3[];
  61532. radius?: number;
  61533. tessellation?: number;
  61534. clip?: number;
  61535. arc?: number;
  61536. closed?: boolean;
  61537. updatable?: boolean;
  61538. sideOrientation?: number;
  61539. frontUVs?: Vector4;
  61540. backUVs?: Vector4;
  61541. cap?: number;
  61542. invertUV?: 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 TiledPlaneBuilder {
  61551. /**
  61552. * Creates a tiled plane mesh
  61553. * * The parameter `pattern` will, depending on value, do nothing or
  61554. * * * flip (reflect about central vertical) alternate tiles across and up
  61555. * * * flip every tile on alternate rows
  61556. * * * rotate (180 degs) alternate tiles across and up
  61557. * * * rotate every tile on alternate rows
  61558. * * * flip and rotate alternate tiles across and up
  61559. * * * flip and rotate every tile on alternate rows
  61560. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61561. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61562. * * 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
  61563. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61564. * * 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)
  61565. * * 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)
  61566. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61567. * @param name defines the name of the mesh
  61568. * @param options defines the options used to create the mesh
  61569. * @param scene defines the hosting scene
  61570. * @returns the box mesh
  61571. */
  61572. static CreateTiledPlane(name: string, options: {
  61573. pattern?: number;
  61574. tileSize?: number;
  61575. tileWidth?: number;
  61576. tileHeight?: number;
  61577. size?: number;
  61578. width?: number;
  61579. height?: number;
  61580. alignHorizontal?: number;
  61581. alignVertical?: number;
  61582. sideOrientation?: number;
  61583. frontUVs?: Vector4;
  61584. backUVs?: Vector4;
  61585. updatable?: boolean;
  61586. }, scene?: Nullable<Scene>): Mesh;
  61587. }
  61588. }
  61589. declare module BABYLON {
  61590. /**
  61591. * Class containing static functions to help procedurally build meshes
  61592. */
  61593. export class TubeBuilder {
  61594. /**
  61595. * Creates a tube mesh.
  61596. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61597. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61598. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61599. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61600. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61601. * * 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)
  61602. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61603. * * 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
  61604. * * 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
  61605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61607. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61609. * @param name defines the name of the mesh
  61610. * @param options defines the options used to create the mesh
  61611. * @param scene defines the hosting scene
  61612. * @returns the tube mesh
  61613. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61614. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61615. */
  61616. static CreateTube(name: string, options: {
  61617. path: Vector3[];
  61618. radius?: number;
  61619. tessellation?: number;
  61620. radiusFunction?: {
  61621. (i: number, distance: number): number;
  61622. };
  61623. cap?: number;
  61624. arc?: number;
  61625. updatable?: boolean;
  61626. sideOrientation?: number;
  61627. frontUVs?: Vector4;
  61628. backUVs?: Vector4;
  61629. instance?: Mesh;
  61630. invertUV?: boolean;
  61631. }, scene?: Nullable<Scene>): Mesh;
  61632. }
  61633. }
  61634. declare module BABYLON {
  61635. /**
  61636. * Class containing static functions to help procedurally build meshes
  61637. */
  61638. export class IcoSphereBuilder {
  61639. /**
  61640. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61641. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61642. * * 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`)
  61643. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61644. * * 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
  61645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61646. * * 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
  61647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61648. * @param name defines the name of the mesh
  61649. * @param options defines the options used to create the mesh
  61650. * @param scene defines the hosting scene
  61651. * @returns the icosahedron mesh
  61652. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61653. */
  61654. static CreateIcoSphere(name: string, options: {
  61655. radius?: number;
  61656. radiusX?: number;
  61657. radiusY?: number;
  61658. radiusZ?: number;
  61659. flat?: boolean;
  61660. subdivisions?: number;
  61661. sideOrientation?: number;
  61662. frontUVs?: Vector4;
  61663. backUVs?: Vector4;
  61664. updatable?: boolean;
  61665. }, scene?: Nullable<Scene>): Mesh;
  61666. }
  61667. }
  61668. declare module BABYLON {
  61669. /**
  61670. * Class containing static functions to help procedurally build meshes
  61671. */
  61672. export class DecalBuilder {
  61673. /**
  61674. * Creates a decal mesh.
  61675. * 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
  61676. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61677. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61678. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61679. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61680. * @param name defines the name of the mesh
  61681. * @param sourceMesh defines the mesh where the decal must be applied
  61682. * @param options defines the options used to create the mesh
  61683. * @param scene defines the hosting scene
  61684. * @returns the decal mesh
  61685. * @see https://doc.babylonjs.com/how_to/decals
  61686. */
  61687. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61688. position?: Vector3;
  61689. normal?: Vector3;
  61690. size?: Vector3;
  61691. angle?: number;
  61692. }): Mesh;
  61693. }
  61694. }
  61695. declare module BABYLON {
  61696. /**
  61697. * Class containing static functions to help procedurally build meshes
  61698. */
  61699. export class MeshBuilder {
  61700. /**
  61701. * Creates a box mesh
  61702. * * The parameter `size` sets the size (float) of each box side (default 1)
  61703. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61704. * * 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)
  61705. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61707. * * 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
  61708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61709. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61710. * @param name defines the name of the mesh
  61711. * @param options defines the options used to create the mesh
  61712. * @param scene defines the hosting scene
  61713. * @returns the box mesh
  61714. */
  61715. static CreateBox(name: string, options: {
  61716. size?: number;
  61717. width?: number;
  61718. height?: number;
  61719. depth?: number;
  61720. faceUV?: Vector4[];
  61721. faceColors?: Color4[];
  61722. sideOrientation?: number;
  61723. frontUVs?: Vector4;
  61724. backUVs?: Vector4;
  61725. wrap?: boolean;
  61726. topBaseAt?: number;
  61727. bottomBaseAt?: number;
  61728. updatable?: boolean;
  61729. }, scene?: Nullable<Scene>): Mesh;
  61730. /**
  61731. * Creates a tiled box mesh
  61732. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61734. * @param name defines the name of the mesh
  61735. * @param options defines the options used to create the mesh
  61736. * @param scene defines the hosting scene
  61737. * @returns the tiled box mesh
  61738. */
  61739. static CreateTiledBox(name: string, options: {
  61740. pattern?: number;
  61741. size?: number;
  61742. width?: number;
  61743. height?: number;
  61744. depth: number;
  61745. tileSize?: number;
  61746. tileWidth?: number;
  61747. tileHeight?: number;
  61748. faceUV?: Vector4[];
  61749. faceColors?: Color4[];
  61750. alignHorizontal?: number;
  61751. alignVertical?: number;
  61752. sideOrientation?: number;
  61753. updatable?: boolean;
  61754. }, scene?: Nullable<Scene>): Mesh;
  61755. /**
  61756. * Creates a sphere mesh
  61757. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61758. * * 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`)
  61759. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61760. * * 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
  61761. * * 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)
  61762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61763. * * 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
  61764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61765. * @param name defines the name of the mesh
  61766. * @param options defines the options used to create the mesh
  61767. * @param scene defines the hosting scene
  61768. * @returns the sphere mesh
  61769. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61770. */
  61771. static CreateSphere(name: string, options: {
  61772. segments?: number;
  61773. diameter?: number;
  61774. diameterX?: number;
  61775. diameterY?: number;
  61776. diameterZ?: number;
  61777. arc?: number;
  61778. slice?: number;
  61779. sideOrientation?: number;
  61780. frontUVs?: Vector4;
  61781. backUVs?: Vector4;
  61782. updatable?: boolean;
  61783. }, scene?: Nullable<Scene>): Mesh;
  61784. /**
  61785. * Creates a plane polygonal mesh. By default, this is a disc
  61786. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61787. * * 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
  61788. * * 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
  61789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61790. * * 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
  61791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61792. * @param name defines the name of the mesh
  61793. * @param options defines the options used to create the mesh
  61794. * @param scene defines the hosting scene
  61795. * @returns the plane polygonal mesh
  61796. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61797. */
  61798. static CreateDisc(name: string, options: {
  61799. radius?: number;
  61800. tessellation?: number;
  61801. arc?: number;
  61802. updatable?: boolean;
  61803. sideOrientation?: number;
  61804. frontUVs?: Vector4;
  61805. backUVs?: Vector4;
  61806. }, scene?: Nullable<Scene>): Mesh;
  61807. /**
  61808. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61809. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61810. * * 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`)
  61811. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61812. * * 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
  61813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61814. * * 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
  61815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61816. * @param name defines the name of the mesh
  61817. * @param options defines the options used to create the mesh
  61818. * @param scene defines the hosting scene
  61819. * @returns the icosahedron mesh
  61820. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61821. */
  61822. static CreateIcoSphere(name: string, options: {
  61823. radius?: number;
  61824. radiusX?: number;
  61825. radiusY?: number;
  61826. radiusZ?: number;
  61827. flat?: boolean;
  61828. subdivisions?: number;
  61829. sideOrientation?: number;
  61830. frontUVs?: Vector4;
  61831. backUVs?: Vector4;
  61832. updatable?: boolean;
  61833. }, scene?: Nullable<Scene>): Mesh;
  61834. /**
  61835. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61836. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61837. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61838. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61839. * * 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
  61840. * * 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
  61841. * * 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
  61842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61843. * * 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
  61844. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61845. * * 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
  61846. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61847. * * 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
  61848. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  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 ribbon mesh
  61854. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61855. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61856. */
  61857. static CreateRibbon(name: string, options: {
  61858. pathArray: Vector3[][];
  61859. closeArray?: boolean;
  61860. closePath?: boolean;
  61861. offset?: number;
  61862. updatable?: boolean;
  61863. sideOrientation?: number;
  61864. frontUVs?: Vector4;
  61865. backUVs?: Vector4;
  61866. instance?: Mesh;
  61867. invertUV?: boolean;
  61868. uvs?: Vector2[];
  61869. colors?: Color4[];
  61870. }, scene?: Nullable<Scene>): Mesh;
  61871. /**
  61872. * Creates a cylinder or a cone mesh
  61873. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61874. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61875. * * 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.
  61876. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61877. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61878. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61879. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61880. * * 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).
  61881. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61882. * * 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).
  61883. * * 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
  61884. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61885. * * 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
  61886. * * 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.
  61887. * * If `enclose` is false, a ring surface is one element.
  61888. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61889. * * 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
  61890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61891. * * 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
  61892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61893. * @param name defines the name of the mesh
  61894. * @param options defines the options used to create the mesh
  61895. * @param scene defines the hosting scene
  61896. * @returns the cylinder mesh
  61897. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61898. */
  61899. static CreateCylinder(name: string, options: {
  61900. height?: number;
  61901. diameterTop?: number;
  61902. diameterBottom?: number;
  61903. diameter?: number;
  61904. tessellation?: number;
  61905. subdivisions?: number;
  61906. arc?: number;
  61907. faceColors?: Color4[];
  61908. faceUV?: Vector4[];
  61909. updatable?: boolean;
  61910. hasRings?: boolean;
  61911. enclose?: boolean;
  61912. cap?: number;
  61913. sideOrientation?: number;
  61914. frontUVs?: Vector4;
  61915. backUVs?: Vector4;
  61916. }, scene?: Nullable<Scene>): Mesh;
  61917. /**
  61918. * Creates a torus mesh
  61919. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61920. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61921. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61923. * * 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
  61924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61925. * @param name defines the name of the mesh
  61926. * @param options defines the options used to create the mesh
  61927. * @param scene defines the hosting scene
  61928. * @returns the torus mesh
  61929. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61930. */
  61931. static CreateTorus(name: string, options: {
  61932. diameter?: number;
  61933. thickness?: number;
  61934. tessellation?: number;
  61935. updatable?: boolean;
  61936. sideOrientation?: number;
  61937. frontUVs?: Vector4;
  61938. backUVs?: Vector4;
  61939. }, scene?: Nullable<Scene>): Mesh;
  61940. /**
  61941. * Creates a torus knot mesh
  61942. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61943. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61944. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61945. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61947. * * 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
  61948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61949. * @param name defines the name of the mesh
  61950. * @param options defines the options used to create the mesh
  61951. * @param scene defines the hosting scene
  61952. * @returns the torus knot mesh
  61953. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61954. */
  61955. static CreateTorusKnot(name: string, options: {
  61956. radius?: number;
  61957. tube?: number;
  61958. radialSegments?: number;
  61959. tubularSegments?: number;
  61960. p?: number;
  61961. q?: number;
  61962. updatable?: boolean;
  61963. sideOrientation?: number;
  61964. frontUVs?: Vector4;
  61965. backUVs?: Vector4;
  61966. }, scene?: Nullable<Scene>): Mesh;
  61967. /**
  61968. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61969. * * 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
  61970. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61971. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61972. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61973. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61974. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61975. * * 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
  61976. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61978. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61979. * @param name defines the name of the new line system
  61980. * @param options defines the options used to create the line system
  61981. * @param scene defines the hosting scene
  61982. * @returns a new line system mesh
  61983. */
  61984. static CreateLineSystem(name: string, options: {
  61985. lines: Vector3[][];
  61986. updatable?: boolean;
  61987. instance?: Nullable<LinesMesh>;
  61988. colors?: Nullable<Color4[][]>;
  61989. useVertexAlpha?: boolean;
  61990. }, scene: Nullable<Scene>): LinesMesh;
  61991. /**
  61992. * Creates a line mesh
  61993. * 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
  61994. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61995. * * The parameter `points` is an array successive Vector3
  61996. * * 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
  61997. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61998. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61999. * * When updating an instance, remember that only point positions can change, not the number of points
  62000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62001. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  62002. * @param name defines the name of the new line system
  62003. * @param options defines the options used to create the line system
  62004. * @param scene defines the hosting scene
  62005. * @returns a new line mesh
  62006. */
  62007. static CreateLines(name: string, options: {
  62008. points: Vector3[];
  62009. updatable?: boolean;
  62010. instance?: Nullable<LinesMesh>;
  62011. colors?: Color4[];
  62012. useVertexAlpha?: boolean;
  62013. }, scene?: Nullable<Scene>): LinesMesh;
  62014. /**
  62015. * Creates a dashed line mesh
  62016. * * 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
  62017. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62018. * * The parameter `points` is an array successive Vector3
  62019. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  62020. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  62021. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  62022. * * 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
  62023. * * When updating an instance, remember that only point positions can change, not the number of points
  62024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62025. * @param name defines the name of the mesh
  62026. * @param options defines the options used to create the mesh
  62027. * @param scene defines the hosting scene
  62028. * @returns the dashed line mesh
  62029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62030. */
  62031. static CreateDashedLines(name: string, options: {
  62032. points: Vector3[];
  62033. dashSize?: number;
  62034. gapSize?: number;
  62035. dashNb?: number;
  62036. updatable?: boolean;
  62037. instance?: LinesMesh;
  62038. }, scene?: Nullable<Scene>): LinesMesh;
  62039. /**
  62040. * 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.
  62041. * * 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.
  62042. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62043. * * 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.
  62044. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62045. * * 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
  62046. * * 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
  62047. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62049. * * 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
  62050. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62052. * @param name defines the name of the mesh
  62053. * @param options defines the options used to create the mesh
  62054. * @param scene defines the hosting scene
  62055. * @returns the extruded shape mesh
  62056. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62057. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62058. */
  62059. static ExtrudeShape(name: string, options: {
  62060. shape: Vector3[];
  62061. path: Vector3[];
  62062. scale?: number;
  62063. rotation?: number;
  62064. cap?: number;
  62065. updatable?: boolean;
  62066. sideOrientation?: number;
  62067. frontUVs?: Vector4;
  62068. backUVs?: Vector4;
  62069. instance?: Mesh;
  62070. invertUV?: boolean;
  62071. }, scene?: Nullable<Scene>): Mesh;
  62072. /**
  62073. * Creates an custom extruded shape mesh.
  62074. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62075. * * 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.
  62076. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62077. * * 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
  62078. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62079. * * 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
  62080. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62081. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62082. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62083. * * 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
  62084. * * 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
  62085. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62087. * * 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
  62088. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62090. * @param name defines the name of the mesh
  62091. * @param options defines the options used to create the mesh
  62092. * @param scene defines the hosting scene
  62093. * @returns the custom extruded shape mesh
  62094. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62095. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62097. */
  62098. static ExtrudeShapeCustom(name: string, options: {
  62099. shape: Vector3[];
  62100. path: Vector3[];
  62101. scaleFunction?: any;
  62102. rotationFunction?: any;
  62103. ribbonCloseArray?: boolean;
  62104. ribbonClosePath?: boolean;
  62105. cap?: number;
  62106. updatable?: boolean;
  62107. sideOrientation?: number;
  62108. frontUVs?: Vector4;
  62109. backUVs?: Vector4;
  62110. instance?: Mesh;
  62111. invertUV?: boolean;
  62112. }, scene?: Nullable<Scene>): Mesh;
  62113. /**
  62114. * Creates lathe mesh.
  62115. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62116. * * 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
  62117. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62118. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62119. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62120. * * 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
  62121. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62122. * * 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
  62123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62124. * * 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
  62125. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62127. * @param name defines the name of the mesh
  62128. * @param options defines the options used to create the mesh
  62129. * @param scene defines the hosting scene
  62130. * @returns the lathe mesh
  62131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62132. */
  62133. static CreateLathe(name: string, options: {
  62134. shape: Vector3[];
  62135. radius?: number;
  62136. tessellation?: number;
  62137. clip?: number;
  62138. arc?: number;
  62139. closed?: boolean;
  62140. updatable?: boolean;
  62141. sideOrientation?: number;
  62142. frontUVs?: Vector4;
  62143. backUVs?: Vector4;
  62144. cap?: number;
  62145. invertUV?: boolean;
  62146. }, scene?: Nullable<Scene>): Mesh;
  62147. /**
  62148. * Creates a tiled plane mesh
  62149. * * You can set a limited pattern arrangement with the tiles
  62150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62151. * * 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
  62152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62153. * @param name defines the name of the mesh
  62154. * @param options defines the options used to create the mesh
  62155. * @param scene defines the hosting scene
  62156. * @returns the plane mesh
  62157. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62158. */
  62159. static CreateTiledPlane(name: string, options: {
  62160. pattern?: number;
  62161. tileSize?: number;
  62162. tileWidth?: number;
  62163. tileHeight?: number;
  62164. size?: number;
  62165. width?: number;
  62166. height?: number;
  62167. alignHorizontal?: number;
  62168. alignVertical?: number;
  62169. sideOrientation?: number;
  62170. frontUVs?: Vector4;
  62171. backUVs?: Vector4;
  62172. updatable?: boolean;
  62173. }, scene?: Nullable<Scene>): Mesh;
  62174. /**
  62175. * Creates a plane mesh
  62176. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62177. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62178. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62180. * * 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
  62181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62182. * @param name defines the name of the mesh
  62183. * @param options defines the options used to create the mesh
  62184. * @param scene defines the hosting scene
  62185. * @returns the plane mesh
  62186. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62187. */
  62188. static CreatePlane(name: string, options: {
  62189. size?: number;
  62190. width?: number;
  62191. height?: number;
  62192. sideOrientation?: number;
  62193. frontUVs?: Vector4;
  62194. backUVs?: Vector4;
  62195. updatable?: boolean;
  62196. sourcePlane?: Plane;
  62197. }, scene?: Nullable<Scene>): Mesh;
  62198. /**
  62199. * Creates a ground mesh
  62200. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62201. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62203. * @param name defines the name of the mesh
  62204. * @param options defines the options used to create the mesh
  62205. * @param scene defines the hosting scene
  62206. * @returns the ground mesh
  62207. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62208. */
  62209. static CreateGround(name: string, options: {
  62210. width?: number;
  62211. height?: number;
  62212. subdivisions?: number;
  62213. subdivisionsX?: number;
  62214. subdivisionsY?: number;
  62215. updatable?: boolean;
  62216. }, scene?: Nullable<Scene>): Mesh;
  62217. /**
  62218. * Creates a tiled ground mesh
  62219. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62220. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62221. * * 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
  62222. * * 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
  62223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62224. * @param name defines the name of the mesh
  62225. * @param options defines the options used to create the mesh
  62226. * @param scene defines the hosting scene
  62227. * @returns the tiled ground mesh
  62228. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62229. */
  62230. static CreateTiledGround(name: string, options: {
  62231. xmin: number;
  62232. zmin: number;
  62233. xmax: number;
  62234. zmax: number;
  62235. subdivisions?: {
  62236. w: number;
  62237. h: number;
  62238. };
  62239. precision?: {
  62240. w: number;
  62241. h: number;
  62242. };
  62243. updatable?: boolean;
  62244. }, scene?: Nullable<Scene>): Mesh;
  62245. /**
  62246. * Creates a ground mesh from a height map
  62247. * * The parameter `url` sets the URL of the height map image resource.
  62248. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62249. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62250. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62251. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62252. * * 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.
  62253. * * 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).
  62254. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62256. * @param name defines the name of the mesh
  62257. * @param url defines the url to the height map
  62258. * @param options defines the options used to create the mesh
  62259. * @param scene defines the hosting scene
  62260. * @returns the ground mesh
  62261. * @see https://doc.babylonjs.com/babylon101/height_map
  62262. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62263. */
  62264. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62265. width?: number;
  62266. height?: number;
  62267. subdivisions?: number;
  62268. minHeight?: number;
  62269. maxHeight?: number;
  62270. colorFilter?: Color3;
  62271. alphaFilter?: number;
  62272. updatable?: boolean;
  62273. onReady?: (mesh: GroundMesh) => void;
  62274. }, scene?: Nullable<Scene>): GroundMesh;
  62275. /**
  62276. * Creates a polygon mesh
  62277. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62278. * * 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
  62279. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62281. * * 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)
  62282. * * Remember you can only change the shape positions, not their number when updating a polygon
  62283. * @param name defines the name of the mesh
  62284. * @param options defines the options used to create the mesh
  62285. * @param scene defines the hosting scene
  62286. * @param earcutInjection can be used to inject your own earcut reference
  62287. * @returns the polygon mesh
  62288. */
  62289. static CreatePolygon(name: string, options: {
  62290. shape: Vector3[];
  62291. holes?: Vector3[][];
  62292. depth?: number;
  62293. faceUV?: Vector4[];
  62294. faceColors?: Color4[];
  62295. updatable?: boolean;
  62296. sideOrientation?: number;
  62297. frontUVs?: Vector4;
  62298. backUVs?: Vector4;
  62299. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62300. /**
  62301. * Creates an extruded polygon mesh, with depth in the Y direction.
  62302. * * 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)
  62303. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62304. * @param name defines the name of the mesh
  62305. * @param options defines the options used to create the mesh
  62306. * @param scene defines the hosting scene
  62307. * @param earcutInjection can be used to inject your own earcut reference
  62308. * @returns the polygon mesh
  62309. */
  62310. static ExtrudePolygon(name: string, options: {
  62311. shape: Vector3[];
  62312. holes?: Vector3[][];
  62313. depth?: number;
  62314. faceUV?: Vector4[];
  62315. faceColors?: Color4[];
  62316. updatable?: boolean;
  62317. sideOrientation?: number;
  62318. frontUVs?: Vector4;
  62319. backUVs?: Vector4;
  62320. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62321. /**
  62322. * Creates a tube mesh.
  62323. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62324. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62325. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62326. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62327. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62328. * * 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)
  62329. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62330. * * 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
  62331. * * 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
  62332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62333. * * 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
  62334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62336. * @param name defines the name of the mesh
  62337. * @param options defines the options used to create the mesh
  62338. * @param scene defines the hosting scene
  62339. * @returns the tube mesh
  62340. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62341. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62342. */
  62343. static CreateTube(name: string, options: {
  62344. path: Vector3[];
  62345. radius?: number;
  62346. tessellation?: number;
  62347. radiusFunction?: {
  62348. (i: number, distance: number): number;
  62349. };
  62350. cap?: number;
  62351. arc?: number;
  62352. updatable?: boolean;
  62353. sideOrientation?: number;
  62354. frontUVs?: Vector4;
  62355. backUVs?: Vector4;
  62356. instance?: Mesh;
  62357. invertUV?: boolean;
  62358. }, scene?: Nullable<Scene>): Mesh;
  62359. /**
  62360. * Creates a polyhedron mesh
  62361. * * 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
  62362. * * The parameter `size` (positive float, default 1) sets the polygon size
  62363. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62364. * * 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`
  62365. * * 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
  62366. * * 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)`)
  62367. * * 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
  62368. * * 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
  62369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62370. * * 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
  62371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62372. * @param name defines the name of the mesh
  62373. * @param options defines the options used to create the mesh
  62374. * @param scene defines the hosting scene
  62375. * @returns the polyhedron mesh
  62376. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62377. */
  62378. static CreatePolyhedron(name: string, options: {
  62379. type?: number;
  62380. size?: number;
  62381. sizeX?: number;
  62382. sizeY?: number;
  62383. sizeZ?: number;
  62384. custom?: any;
  62385. faceUV?: Vector4[];
  62386. faceColors?: Color4[];
  62387. flat?: boolean;
  62388. updatable?: boolean;
  62389. sideOrientation?: number;
  62390. frontUVs?: Vector4;
  62391. backUVs?: Vector4;
  62392. }, scene?: Nullable<Scene>): Mesh;
  62393. /**
  62394. * Creates a decal mesh.
  62395. * 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
  62396. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62397. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62398. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62399. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62400. * @param name defines the name of the mesh
  62401. * @param sourceMesh defines the mesh where the decal must be applied
  62402. * @param options defines the options used to create the mesh
  62403. * @param scene defines the hosting scene
  62404. * @returns the decal mesh
  62405. * @see https://doc.babylonjs.com/how_to/decals
  62406. */
  62407. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62408. position?: Vector3;
  62409. normal?: Vector3;
  62410. size?: Vector3;
  62411. angle?: number;
  62412. }): Mesh;
  62413. }
  62414. }
  62415. declare module BABYLON {
  62416. /**
  62417. * A simplifier interface for future simplification implementations
  62418. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62419. */
  62420. export interface ISimplifier {
  62421. /**
  62422. * Simplification of a given mesh according to the given settings.
  62423. * Since this requires computation, it is assumed that the function runs async.
  62424. * @param settings The settings of the simplification, including quality and distance
  62425. * @param successCallback A callback that will be called after the mesh was simplified.
  62426. * @param errorCallback in case of an error, this callback will be called. optional.
  62427. */
  62428. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62429. }
  62430. /**
  62431. * Expected simplification settings.
  62432. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62433. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62434. */
  62435. export interface ISimplificationSettings {
  62436. /**
  62437. * Gets or sets the expected quality
  62438. */
  62439. quality: number;
  62440. /**
  62441. * Gets or sets the distance when this optimized version should be used
  62442. */
  62443. distance: number;
  62444. /**
  62445. * Gets an already optimized mesh
  62446. */
  62447. optimizeMesh?: boolean;
  62448. }
  62449. /**
  62450. * Class used to specify simplification options
  62451. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62452. */
  62453. export class SimplificationSettings implements ISimplificationSettings {
  62454. /** expected quality */
  62455. quality: number;
  62456. /** distance when this optimized version should be used */
  62457. distance: number;
  62458. /** already optimized mesh */
  62459. optimizeMesh?: boolean | undefined;
  62460. /**
  62461. * Creates a SimplificationSettings
  62462. * @param quality expected quality
  62463. * @param distance distance when this optimized version should be used
  62464. * @param optimizeMesh already optimized mesh
  62465. */
  62466. constructor(
  62467. /** expected quality */
  62468. quality: number,
  62469. /** distance when this optimized version should be used */
  62470. distance: number,
  62471. /** already optimized mesh */
  62472. optimizeMesh?: boolean | undefined);
  62473. }
  62474. /**
  62475. * Interface used to define a simplification task
  62476. */
  62477. export interface ISimplificationTask {
  62478. /**
  62479. * Array of settings
  62480. */
  62481. settings: Array<ISimplificationSettings>;
  62482. /**
  62483. * Simplification type
  62484. */
  62485. simplificationType: SimplificationType;
  62486. /**
  62487. * Mesh to simplify
  62488. */
  62489. mesh: Mesh;
  62490. /**
  62491. * Callback called on success
  62492. */
  62493. successCallback?: () => void;
  62494. /**
  62495. * Defines if parallel processing can be used
  62496. */
  62497. parallelProcessing: boolean;
  62498. }
  62499. /**
  62500. * Queue used to order the simplification tasks
  62501. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62502. */
  62503. export class SimplificationQueue {
  62504. private _simplificationArray;
  62505. /**
  62506. * Gets a boolean indicating that the process is still running
  62507. */
  62508. running: boolean;
  62509. /**
  62510. * Creates a new queue
  62511. */
  62512. constructor();
  62513. /**
  62514. * Adds a new simplification task
  62515. * @param task defines a task to add
  62516. */
  62517. addTask(task: ISimplificationTask): void;
  62518. /**
  62519. * Execute next task
  62520. */
  62521. executeNext(): void;
  62522. /**
  62523. * Execute a simplification task
  62524. * @param task defines the task to run
  62525. */
  62526. runSimplification(task: ISimplificationTask): void;
  62527. private getSimplifier;
  62528. }
  62529. /**
  62530. * The implemented types of simplification
  62531. * At the moment only Quadratic Error Decimation is implemented
  62532. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62533. */
  62534. export enum SimplificationType {
  62535. /** Quadratic error decimation */
  62536. QUADRATIC = 0
  62537. }
  62538. /**
  62539. * An implementation of the Quadratic Error simplification algorithm.
  62540. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62541. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62542. * @author RaananW
  62543. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62544. */
  62545. export class QuadraticErrorSimplification implements ISimplifier {
  62546. private _mesh;
  62547. private triangles;
  62548. private vertices;
  62549. private references;
  62550. private _reconstructedMesh;
  62551. /** Gets or sets the number pf sync interations */
  62552. syncIterations: number;
  62553. /** Gets or sets the aggressiveness of the simplifier */
  62554. aggressiveness: number;
  62555. /** Gets or sets the number of allowed iterations for decimation */
  62556. decimationIterations: number;
  62557. /** Gets or sets the espilon to use for bounding box computation */
  62558. boundingBoxEpsilon: number;
  62559. /**
  62560. * Creates a new QuadraticErrorSimplification
  62561. * @param _mesh defines the target mesh
  62562. */
  62563. constructor(_mesh: Mesh);
  62564. /**
  62565. * Simplification of a given mesh according to the given settings.
  62566. * Since this requires computation, it is assumed that the function runs async.
  62567. * @param settings The settings of the simplification, including quality and distance
  62568. * @param successCallback A callback that will be called after the mesh was simplified.
  62569. */
  62570. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62571. private runDecimation;
  62572. private initWithMesh;
  62573. private init;
  62574. private reconstructMesh;
  62575. private initDecimatedMesh;
  62576. private isFlipped;
  62577. private updateTriangles;
  62578. private identifyBorder;
  62579. private updateMesh;
  62580. private vertexError;
  62581. private calculateError;
  62582. }
  62583. }
  62584. declare module BABYLON {
  62585. interface Scene {
  62586. /** @hidden (Backing field) */
  62587. _simplificationQueue: SimplificationQueue;
  62588. /**
  62589. * Gets or sets the simplification queue attached to the scene
  62590. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62591. */
  62592. simplificationQueue: SimplificationQueue;
  62593. }
  62594. interface Mesh {
  62595. /**
  62596. * Simplify the mesh according to the given array of settings.
  62597. * Function will return immediately and will simplify async
  62598. * @param settings a collection of simplification settings
  62599. * @param parallelProcessing should all levels calculate parallel or one after the other
  62600. * @param simplificationType the type of simplification to run
  62601. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62602. * @returns the current mesh
  62603. */
  62604. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62605. }
  62606. /**
  62607. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62608. * created in a scene
  62609. */
  62610. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62611. /**
  62612. * The component name helpfull to identify the component in the list of scene components.
  62613. */
  62614. readonly name: string;
  62615. /**
  62616. * The scene the component belongs to.
  62617. */
  62618. scene: Scene;
  62619. /**
  62620. * Creates a new instance of the component for the given scene
  62621. * @param scene Defines the scene to register the component in
  62622. */
  62623. constructor(scene: Scene);
  62624. /**
  62625. * Registers the component in a given scene
  62626. */
  62627. register(): void;
  62628. /**
  62629. * Rebuilds the elements related to this component in case of
  62630. * context lost for instance.
  62631. */
  62632. rebuild(): void;
  62633. /**
  62634. * Disposes the component and the associated ressources
  62635. */
  62636. dispose(): void;
  62637. private _beforeCameraUpdate;
  62638. }
  62639. }
  62640. declare module BABYLON {
  62641. /**
  62642. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62643. */
  62644. export interface INavigationEnginePlugin {
  62645. /**
  62646. * plugin name
  62647. */
  62648. name: string;
  62649. /**
  62650. * Creates a navigation mesh
  62651. * @param meshes array of all the geometry used to compute the navigatio mesh
  62652. * @param parameters bunch of parameters used to filter geometry
  62653. */
  62654. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62655. /**
  62656. * Create a navigation mesh debug mesh
  62657. * @param scene is where the mesh will be added
  62658. * @returns debug display mesh
  62659. */
  62660. createDebugNavMesh(scene: Scene): Mesh;
  62661. /**
  62662. * Get a navigation mesh constrained position, closest to the parameter position
  62663. * @param position world position
  62664. * @returns the closest point to position constrained by the navigation mesh
  62665. */
  62666. getClosestPoint(position: Vector3): Vector3;
  62667. /**
  62668. * Get a navigation mesh constrained position, closest to the parameter position
  62669. * @param position world position
  62670. * @param result output the closest point to position constrained by the navigation mesh
  62671. */
  62672. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62673. /**
  62674. * Get a navigation mesh constrained position, within a particular radius
  62675. * @param position world position
  62676. * @param maxRadius the maximum distance to the constrained world position
  62677. * @returns the closest point to position constrained by the navigation mesh
  62678. */
  62679. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62680. /**
  62681. * Get a navigation mesh constrained position, within a particular radius
  62682. * @param position world position
  62683. * @param maxRadius the maximum distance to the constrained world position
  62684. * @param result output the closest point to position constrained by the navigation mesh
  62685. */
  62686. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62687. /**
  62688. * Compute the final position from a segment made of destination-position
  62689. * @param position world position
  62690. * @param destination world position
  62691. * @returns the resulting point along the navmesh
  62692. */
  62693. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62694. /**
  62695. * Compute the final position from a segment made of destination-position
  62696. * @param position world position
  62697. * @param destination world position
  62698. * @param result output the resulting point along the navmesh
  62699. */
  62700. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62701. /**
  62702. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62703. * @param start world position
  62704. * @param end world position
  62705. * @returns array containing world position composing the path
  62706. */
  62707. computePath(start: Vector3, end: Vector3): Vector3[];
  62708. /**
  62709. * If this plugin is supported
  62710. * @returns true if plugin is supported
  62711. */
  62712. isSupported(): boolean;
  62713. /**
  62714. * Create a new Crowd so you can add agents
  62715. * @param maxAgents the maximum agent count in the crowd
  62716. * @param maxAgentRadius the maximum radius an agent can have
  62717. * @param scene to attach the crowd to
  62718. * @returns the crowd you can add agents to
  62719. */
  62720. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62721. /**
  62722. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62723. * The queries will try to find a solution within those bounds
  62724. * default is (1,1,1)
  62725. * @param extent x,y,z value that define the extent around the queries point of reference
  62726. */
  62727. setDefaultQueryExtent(extent: Vector3): void;
  62728. /**
  62729. * Get the Bounding box extent specified by setDefaultQueryExtent
  62730. * @returns the box extent values
  62731. */
  62732. getDefaultQueryExtent(): Vector3;
  62733. /**
  62734. * build the navmesh from a previously saved state using getNavmeshData
  62735. * @param data the Uint8Array returned by getNavmeshData
  62736. */
  62737. buildFromNavmeshData(data: Uint8Array): void;
  62738. /**
  62739. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62740. * @returns data the Uint8Array that can be saved and reused
  62741. */
  62742. getNavmeshData(): Uint8Array;
  62743. /**
  62744. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62745. * @param result output the box extent values
  62746. */
  62747. getDefaultQueryExtentToRef(result: Vector3): void;
  62748. /**
  62749. * Release all resources
  62750. */
  62751. dispose(): void;
  62752. }
  62753. /**
  62754. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62755. */
  62756. export interface ICrowd {
  62757. /**
  62758. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62759. * You can attach anything to that node. The node position is updated in the scene update tick.
  62760. * @param pos world position that will be constrained by the navigation mesh
  62761. * @param parameters agent parameters
  62762. * @param transform hooked to the agent that will be update by the scene
  62763. * @returns agent index
  62764. */
  62765. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62766. /**
  62767. * Returns the agent position in world space
  62768. * @param index agent index returned by addAgent
  62769. * @returns world space position
  62770. */
  62771. getAgentPosition(index: number): Vector3;
  62772. /**
  62773. * Gets the agent position result in world space
  62774. * @param index agent index returned by addAgent
  62775. * @param result output world space position
  62776. */
  62777. getAgentPositionToRef(index: number, result: Vector3): void;
  62778. /**
  62779. * Gets the agent velocity in world space
  62780. * @param index agent index returned by addAgent
  62781. * @returns world space velocity
  62782. */
  62783. getAgentVelocity(index: number): Vector3;
  62784. /**
  62785. * Gets the agent velocity result in world space
  62786. * @param index agent index returned by addAgent
  62787. * @param result output world space velocity
  62788. */
  62789. getAgentVelocityToRef(index: number, result: Vector3): void;
  62790. /**
  62791. * remove a particular agent previously created
  62792. * @param index agent index returned by addAgent
  62793. */
  62794. removeAgent(index: number): void;
  62795. /**
  62796. * get the list of all agents attached to this crowd
  62797. * @returns list of agent indices
  62798. */
  62799. getAgents(): number[];
  62800. /**
  62801. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62802. * @param deltaTime in seconds
  62803. */
  62804. update(deltaTime: number): void;
  62805. /**
  62806. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62807. * @param index agent index returned by addAgent
  62808. * @param destination targeted world position
  62809. */
  62810. agentGoto(index: number, destination: Vector3): void;
  62811. /**
  62812. * Teleport the agent to a new position
  62813. * @param index agent index returned by addAgent
  62814. * @param destination targeted world position
  62815. */
  62816. agentTeleport(index: number, destination: Vector3): void;
  62817. /**
  62818. * Update agent parameters
  62819. * @param index agent index returned by addAgent
  62820. * @param parameters agent parameters
  62821. */
  62822. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62823. /**
  62824. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62825. * The queries will try to find a solution within those bounds
  62826. * default is (1,1,1)
  62827. * @param extent x,y,z value that define the extent around the queries point of reference
  62828. */
  62829. setDefaultQueryExtent(extent: Vector3): void;
  62830. /**
  62831. * Get the Bounding box extent specified by setDefaultQueryExtent
  62832. * @returns the box extent values
  62833. */
  62834. getDefaultQueryExtent(): Vector3;
  62835. /**
  62836. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62837. * @param result output the box extent values
  62838. */
  62839. getDefaultQueryExtentToRef(result: Vector3): void;
  62840. /**
  62841. * Release all resources
  62842. */
  62843. dispose(): void;
  62844. }
  62845. /**
  62846. * Configures an agent
  62847. */
  62848. export interface IAgentParameters {
  62849. /**
  62850. * Agent radius. [Limit: >= 0]
  62851. */
  62852. radius: number;
  62853. /**
  62854. * Agent height. [Limit: > 0]
  62855. */
  62856. height: number;
  62857. /**
  62858. * Maximum allowed acceleration. [Limit: >= 0]
  62859. */
  62860. maxAcceleration: number;
  62861. /**
  62862. * Maximum allowed speed. [Limit: >= 0]
  62863. */
  62864. maxSpeed: number;
  62865. /**
  62866. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62867. */
  62868. collisionQueryRange: number;
  62869. /**
  62870. * The path visibility optimization range. [Limit: > 0]
  62871. */
  62872. pathOptimizationRange: number;
  62873. /**
  62874. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62875. */
  62876. separationWeight: number;
  62877. }
  62878. /**
  62879. * Configures the navigation mesh creation
  62880. */
  62881. export interface INavMeshParameters {
  62882. /**
  62883. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62884. */
  62885. cs: number;
  62886. /**
  62887. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62888. */
  62889. ch: number;
  62890. /**
  62891. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62892. */
  62893. walkableSlopeAngle: number;
  62894. /**
  62895. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62896. * be considered walkable. [Limit: >= 3] [Units: vx]
  62897. */
  62898. walkableHeight: number;
  62899. /**
  62900. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62901. */
  62902. walkableClimb: number;
  62903. /**
  62904. * The distance to erode/shrink the walkable area of the heightfield away from
  62905. * obstructions. [Limit: >=0] [Units: vx]
  62906. */
  62907. walkableRadius: number;
  62908. /**
  62909. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62910. */
  62911. maxEdgeLen: number;
  62912. /**
  62913. * The maximum distance a simplfied contour's border edges should deviate
  62914. * the original raw contour. [Limit: >=0] [Units: vx]
  62915. */
  62916. maxSimplificationError: number;
  62917. /**
  62918. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62919. */
  62920. minRegionArea: number;
  62921. /**
  62922. * Any regions with a span count smaller than this value will, if possible,
  62923. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62924. */
  62925. mergeRegionArea: number;
  62926. /**
  62927. * The maximum number of vertices allowed for polygons generated during the
  62928. * contour to polygon conversion process. [Limit: >= 3]
  62929. */
  62930. maxVertsPerPoly: number;
  62931. /**
  62932. * Sets the sampling distance to use when generating the detail mesh.
  62933. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62934. */
  62935. detailSampleDist: number;
  62936. /**
  62937. * The maximum distance the detail mesh surface should deviate from heightfield
  62938. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62939. */
  62940. detailSampleMaxError: number;
  62941. }
  62942. }
  62943. declare module BABYLON {
  62944. /**
  62945. * RecastJS navigation plugin
  62946. */
  62947. export class RecastJSPlugin implements INavigationEnginePlugin {
  62948. /**
  62949. * Reference to the Recast library
  62950. */
  62951. bjsRECAST: any;
  62952. /**
  62953. * plugin name
  62954. */
  62955. name: string;
  62956. /**
  62957. * the first navmesh created. We might extend this to support multiple navmeshes
  62958. */
  62959. navMesh: any;
  62960. /**
  62961. * Initializes the recastJS plugin
  62962. * @param recastInjection can be used to inject your own recast reference
  62963. */
  62964. constructor(recastInjection?: any);
  62965. /**
  62966. * Creates a navigation mesh
  62967. * @param meshes array of all the geometry used to compute the navigatio mesh
  62968. * @param parameters bunch of parameters used to filter geometry
  62969. */
  62970. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62971. /**
  62972. * Create a navigation mesh debug mesh
  62973. * @param scene is where the mesh will be added
  62974. * @returns debug display mesh
  62975. */
  62976. createDebugNavMesh(scene: Scene): Mesh;
  62977. /**
  62978. * Get a navigation mesh constrained position, closest to the parameter position
  62979. * @param position world position
  62980. * @returns the closest point to position constrained by the navigation mesh
  62981. */
  62982. getClosestPoint(position: Vector3): Vector3;
  62983. /**
  62984. * Get a navigation mesh constrained position, closest to the parameter position
  62985. * @param position world position
  62986. * @param result output the closest point to position constrained by the navigation mesh
  62987. */
  62988. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62989. /**
  62990. * Get a navigation mesh constrained position, within a particular radius
  62991. * @param position world position
  62992. * @param maxRadius the maximum distance to the constrained world position
  62993. * @returns the closest point to position constrained by the navigation mesh
  62994. */
  62995. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62996. /**
  62997. * Get a navigation mesh constrained position, within a particular radius
  62998. * @param position world position
  62999. * @param maxRadius the maximum distance to the constrained world position
  63000. * @param result output the closest point to position constrained by the navigation mesh
  63001. */
  63002. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  63003. /**
  63004. * Compute the final position from a segment made of destination-position
  63005. * @param position world position
  63006. * @param destination world position
  63007. * @returns the resulting point along the navmesh
  63008. */
  63009. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63010. /**
  63011. * Compute the final position from a segment made of destination-position
  63012. * @param position world position
  63013. * @param destination world position
  63014. * @param result output the resulting point along the navmesh
  63015. */
  63016. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  63017. /**
  63018. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63019. * @param start world position
  63020. * @param end world position
  63021. * @returns array containing world position composing the path
  63022. */
  63023. computePath(start: Vector3, end: Vector3): Vector3[];
  63024. /**
  63025. * Create a new Crowd so you can add agents
  63026. * @param maxAgents the maximum agent count in the crowd
  63027. * @param maxAgentRadius the maximum radius an agent can have
  63028. * @param scene to attach the crowd to
  63029. * @returns the crowd you can add agents to
  63030. */
  63031. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63032. /**
  63033. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63034. * The queries will try to find a solution within those bounds
  63035. * default is (1,1,1)
  63036. * @param extent x,y,z value that define the extent around the queries point of reference
  63037. */
  63038. setDefaultQueryExtent(extent: Vector3): void;
  63039. /**
  63040. * Get the Bounding box extent specified by setDefaultQueryExtent
  63041. * @returns the box extent values
  63042. */
  63043. getDefaultQueryExtent(): Vector3;
  63044. /**
  63045. * build the navmesh from a previously saved state using getNavmeshData
  63046. * @param data the Uint8Array returned by getNavmeshData
  63047. */
  63048. buildFromNavmeshData(data: Uint8Array): void;
  63049. /**
  63050. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  63051. * @returns data the Uint8Array that can be saved and reused
  63052. */
  63053. getNavmeshData(): Uint8Array;
  63054. /**
  63055. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63056. * @param result output the box extent values
  63057. */
  63058. getDefaultQueryExtentToRef(result: Vector3): void;
  63059. /**
  63060. * Disposes
  63061. */
  63062. dispose(): void;
  63063. /**
  63064. * If this plugin is supported
  63065. * @returns true if plugin is supported
  63066. */
  63067. isSupported(): boolean;
  63068. }
  63069. /**
  63070. * Recast detour crowd implementation
  63071. */
  63072. export class RecastJSCrowd implements ICrowd {
  63073. /**
  63074. * Recast/detour plugin
  63075. */
  63076. bjsRECASTPlugin: RecastJSPlugin;
  63077. /**
  63078. * Link to the detour crowd
  63079. */
  63080. recastCrowd: any;
  63081. /**
  63082. * One transform per agent
  63083. */
  63084. transforms: TransformNode[];
  63085. /**
  63086. * All agents created
  63087. */
  63088. agents: number[];
  63089. /**
  63090. * Link to the scene is kept to unregister the crowd from the scene
  63091. */
  63092. private _scene;
  63093. /**
  63094. * Observer for crowd updates
  63095. */
  63096. private _onBeforeAnimationsObserver;
  63097. /**
  63098. * Constructor
  63099. * @param plugin recastJS plugin
  63100. * @param maxAgents the maximum agent count in the crowd
  63101. * @param maxAgentRadius the maximum radius an agent can have
  63102. * @param scene to attach the crowd to
  63103. * @returns the crowd you can add agents to
  63104. */
  63105. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63106. /**
  63107. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63108. * You can attach anything to that node. The node position is updated in the scene update tick.
  63109. * @param pos world position that will be constrained by the navigation mesh
  63110. * @param parameters agent parameters
  63111. * @param transform hooked to the agent that will be update by the scene
  63112. * @returns agent index
  63113. */
  63114. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63115. /**
  63116. * Returns the agent position in world space
  63117. * @param index agent index returned by addAgent
  63118. * @returns world space position
  63119. */
  63120. getAgentPosition(index: number): Vector3;
  63121. /**
  63122. * Returns the agent position result in world space
  63123. * @param index agent index returned by addAgent
  63124. * @param result output world space position
  63125. */
  63126. getAgentPositionToRef(index: number, result: Vector3): void;
  63127. /**
  63128. * Returns the agent velocity in world space
  63129. * @param index agent index returned by addAgent
  63130. * @returns world space velocity
  63131. */
  63132. getAgentVelocity(index: number): Vector3;
  63133. /**
  63134. * Returns the agent velocity result in world space
  63135. * @param index agent index returned by addAgent
  63136. * @param result output world space velocity
  63137. */
  63138. getAgentVelocityToRef(index: number, result: Vector3): void;
  63139. /**
  63140. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63141. * @param index agent index returned by addAgent
  63142. * @param destination targeted world position
  63143. */
  63144. agentGoto(index: number, destination: Vector3): void;
  63145. /**
  63146. * Teleport the agent to a new position
  63147. * @param index agent index returned by addAgent
  63148. * @param destination targeted world position
  63149. */
  63150. agentTeleport(index: number, destination: Vector3): void;
  63151. /**
  63152. * Update agent parameters
  63153. * @param index agent index returned by addAgent
  63154. * @param parameters agent parameters
  63155. */
  63156. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  63157. /**
  63158. * remove a particular agent previously created
  63159. * @param index agent index returned by addAgent
  63160. */
  63161. removeAgent(index: number): void;
  63162. /**
  63163. * get the list of all agents attached to this crowd
  63164. * @returns list of agent indices
  63165. */
  63166. getAgents(): number[];
  63167. /**
  63168. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63169. * @param deltaTime in seconds
  63170. */
  63171. update(deltaTime: number): void;
  63172. /**
  63173. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63174. * The queries will try to find a solution within those bounds
  63175. * default is (1,1,1)
  63176. * @param extent x,y,z value that define the extent around the queries point of reference
  63177. */
  63178. setDefaultQueryExtent(extent: Vector3): void;
  63179. /**
  63180. * Get the Bounding box extent specified by setDefaultQueryExtent
  63181. * @returns the box extent values
  63182. */
  63183. getDefaultQueryExtent(): Vector3;
  63184. /**
  63185. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63186. * @param result output the box extent values
  63187. */
  63188. getDefaultQueryExtentToRef(result: Vector3): void;
  63189. /**
  63190. * Release all resources
  63191. */
  63192. dispose(): void;
  63193. }
  63194. }
  63195. declare module BABYLON {
  63196. /**
  63197. * Class used to enable access to IndexedDB
  63198. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63199. */
  63200. export class Database implements IOfflineProvider {
  63201. private _callbackManifestChecked;
  63202. private _currentSceneUrl;
  63203. private _db;
  63204. private _enableSceneOffline;
  63205. private _enableTexturesOffline;
  63206. private _manifestVersionFound;
  63207. private _mustUpdateRessources;
  63208. private _hasReachedQuota;
  63209. private _isSupported;
  63210. private _idbFactory;
  63211. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63212. private static IsUASupportingBlobStorage;
  63213. /**
  63214. * Gets a boolean indicating if Database storate is enabled (off by default)
  63215. */
  63216. static IDBStorageEnabled: boolean;
  63217. /**
  63218. * Gets a boolean indicating if scene must be saved in the database
  63219. */
  63220. get enableSceneOffline(): boolean;
  63221. /**
  63222. * Gets a boolean indicating if textures must be saved in the database
  63223. */
  63224. get enableTexturesOffline(): boolean;
  63225. /**
  63226. * Creates a new Database
  63227. * @param urlToScene defines the url to load the scene
  63228. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63229. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63230. */
  63231. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63232. private static _ParseURL;
  63233. private static _ReturnFullUrlLocation;
  63234. private _checkManifestFile;
  63235. /**
  63236. * Open the database and make it available
  63237. * @param successCallback defines the callback to call on success
  63238. * @param errorCallback defines the callback to call on error
  63239. */
  63240. open(successCallback: () => void, errorCallback: () => void): void;
  63241. /**
  63242. * Loads an image from the database
  63243. * @param url defines the url to load from
  63244. * @param image defines the target DOM image
  63245. */
  63246. loadImage(url: string, image: HTMLImageElement): void;
  63247. private _loadImageFromDBAsync;
  63248. private _saveImageIntoDBAsync;
  63249. private _checkVersionFromDB;
  63250. private _loadVersionFromDBAsync;
  63251. private _saveVersionIntoDBAsync;
  63252. /**
  63253. * Loads a file from database
  63254. * @param url defines the URL to load from
  63255. * @param sceneLoaded defines a callback to call on success
  63256. * @param progressCallBack defines a callback to call when progress changed
  63257. * @param errorCallback defines a callback to call on error
  63258. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63259. */
  63260. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63261. private _loadFileAsync;
  63262. private _saveFileAsync;
  63263. /**
  63264. * Validates if xhr data is correct
  63265. * @param xhr defines the request to validate
  63266. * @param dataType defines the expected data type
  63267. * @returns true if data is correct
  63268. */
  63269. private static _ValidateXHRData;
  63270. }
  63271. }
  63272. declare module BABYLON {
  63273. /** @hidden */
  63274. export var gpuUpdateParticlesPixelShader: {
  63275. name: string;
  63276. shader: string;
  63277. };
  63278. }
  63279. declare module BABYLON {
  63280. /** @hidden */
  63281. export var gpuUpdateParticlesVertexShader: {
  63282. name: string;
  63283. shader: string;
  63284. };
  63285. }
  63286. declare module BABYLON {
  63287. /** @hidden */
  63288. export var clipPlaneFragmentDeclaration2: {
  63289. name: string;
  63290. shader: string;
  63291. };
  63292. }
  63293. declare module BABYLON {
  63294. /** @hidden */
  63295. export var gpuRenderParticlesPixelShader: {
  63296. name: string;
  63297. shader: string;
  63298. };
  63299. }
  63300. declare module BABYLON {
  63301. /** @hidden */
  63302. export var clipPlaneVertexDeclaration2: {
  63303. name: string;
  63304. shader: string;
  63305. };
  63306. }
  63307. declare module BABYLON {
  63308. /** @hidden */
  63309. export var gpuRenderParticlesVertexShader: {
  63310. name: string;
  63311. shader: string;
  63312. };
  63313. }
  63314. declare module BABYLON {
  63315. /**
  63316. * This represents a GPU particle system in Babylon
  63317. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63318. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63319. */
  63320. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63321. /**
  63322. * The layer mask we are rendering the particles through.
  63323. */
  63324. layerMask: number;
  63325. private _capacity;
  63326. private _activeCount;
  63327. private _currentActiveCount;
  63328. private _accumulatedCount;
  63329. private _renderEffect;
  63330. private _updateEffect;
  63331. private _buffer0;
  63332. private _buffer1;
  63333. private _spriteBuffer;
  63334. private _updateVAO;
  63335. private _renderVAO;
  63336. private _targetIndex;
  63337. private _sourceBuffer;
  63338. private _targetBuffer;
  63339. private _engine;
  63340. private _currentRenderId;
  63341. private _started;
  63342. private _stopped;
  63343. private _timeDelta;
  63344. private _randomTexture;
  63345. private _randomTexture2;
  63346. private _attributesStrideSize;
  63347. private _updateEffectOptions;
  63348. private _randomTextureSize;
  63349. private _actualFrame;
  63350. private readonly _rawTextureWidth;
  63351. /**
  63352. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63353. */
  63354. static get IsSupported(): boolean;
  63355. /**
  63356. * An event triggered when the system is disposed.
  63357. */
  63358. onDisposeObservable: Observable<GPUParticleSystem>;
  63359. /**
  63360. * Gets the maximum number of particles active at the same time.
  63361. * @returns The max number of active particles.
  63362. */
  63363. getCapacity(): number;
  63364. /**
  63365. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63366. * to override the particles.
  63367. */
  63368. forceDepthWrite: boolean;
  63369. /**
  63370. * Gets or set the number of active particles
  63371. */
  63372. get activeParticleCount(): number;
  63373. set activeParticleCount(value: number);
  63374. private _preWarmDone;
  63375. /**
  63376. * Specifies if the particles are updated in emitter local space or world space.
  63377. * This is always false for GPU particles
  63378. */
  63379. get isLocal(): boolean;
  63380. set isLocal(value: boolean);
  63381. /**
  63382. * Is this system ready to be used/rendered
  63383. * @return true if the system is ready
  63384. */
  63385. isReady(): boolean;
  63386. /**
  63387. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63388. * @returns True if it has been started, otherwise false.
  63389. */
  63390. isStarted(): boolean;
  63391. /**
  63392. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63393. * @returns True if it has been stopped, otherwise false.
  63394. */
  63395. isStopped(): boolean;
  63396. /**
  63397. * Gets a boolean indicating that the system is stopping
  63398. * @returns true if the system is currently stopping
  63399. */
  63400. isStopping(): boolean;
  63401. /**
  63402. * Gets the number of particles active at the same time.
  63403. * @returns The number of active particles.
  63404. */
  63405. getActiveCount(): number;
  63406. /**
  63407. * Starts the particle system and begins to emit
  63408. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63409. */
  63410. start(delay?: number): void;
  63411. /**
  63412. * Stops the particle system.
  63413. */
  63414. stop(): void;
  63415. /**
  63416. * Remove all active particles
  63417. */
  63418. reset(): void;
  63419. /**
  63420. * Returns the string "GPUParticleSystem"
  63421. * @returns a string containing the class name
  63422. */
  63423. getClassName(): string;
  63424. private _colorGradientsTexture;
  63425. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63426. /**
  63427. * Adds a new color gradient
  63428. * @param gradient defines the gradient to use (between 0 and 1)
  63429. * @param color1 defines the color to affect to the specified gradient
  63430. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63431. * @returns the current particle system
  63432. */
  63433. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63434. private _refreshColorGradient;
  63435. /** Force the system to rebuild all gradients that need to be resync */
  63436. forceRefreshGradients(): void;
  63437. /**
  63438. * Remove a specific color gradient
  63439. * @param gradient defines the gradient to remove
  63440. * @returns the current particle system
  63441. */
  63442. removeColorGradient(gradient: number): GPUParticleSystem;
  63443. private _angularSpeedGradientsTexture;
  63444. private _sizeGradientsTexture;
  63445. private _velocityGradientsTexture;
  63446. private _limitVelocityGradientsTexture;
  63447. private _dragGradientsTexture;
  63448. private _addFactorGradient;
  63449. /**
  63450. * Adds a new size gradient
  63451. * @param gradient defines the gradient to use (between 0 and 1)
  63452. * @param factor defines the size factor to affect to the specified gradient
  63453. * @returns the current particle system
  63454. */
  63455. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63456. /**
  63457. * Remove a specific size gradient
  63458. * @param gradient defines the gradient to remove
  63459. * @returns the current particle system
  63460. */
  63461. removeSizeGradient(gradient: number): GPUParticleSystem;
  63462. private _refreshFactorGradient;
  63463. /**
  63464. * Adds a new angular speed gradient
  63465. * @param gradient defines the gradient to use (between 0 and 1)
  63466. * @param factor defines the angular speed to affect to the specified gradient
  63467. * @returns the current particle system
  63468. */
  63469. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63470. /**
  63471. * Remove a specific angular speed gradient
  63472. * @param gradient defines the gradient to remove
  63473. * @returns the current particle system
  63474. */
  63475. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63476. /**
  63477. * Adds a new velocity gradient
  63478. * @param gradient defines the gradient to use (between 0 and 1)
  63479. * @param factor defines the velocity to affect to the specified gradient
  63480. * @returns the current particle system
  63481. */
  63482. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63483. /**
  63484. * Remove a specific velocity gradient
  63485. * @param gradient defines the gradient to remove
  63486. * @returns the current particle system
  63487. */
  63488. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63489. /**
  63490. * Adds a new limit velocity gradient
  63491. * @param gradient defines the gradient to use (between 0 and 1)
  63492. * @param factor defines the limit velocity value to affect to the specified gradient
  63493. * @returns the current particle system
  63494. */
  63495. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63496. /**
  63497. * Remove a specific limit velocity gradient
  63498. * @param gradient defines the gradient to remove
  63499. * @returns the current particle system
  63500. */
  63501. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63502. /**
  63503. * Adds a new drag gradient
  63504. * @param gradient defines the gradient to use (between 0 and 1)
  63505. * @param factor defines the drag value to affect to the specified gradient
  63506. * @returns the current particle system
  63507. */
  63508. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63509. /**
  63510. * Remove a specific drag gradient
  63511. * @param gradient defines the gradient to remove
  63512. * @returns the current particle system
  63513. */
  63514. removeDragGradient(gradient: number): GPUParticleSystem;
  63515. /**
  63516. * Not supported by GPUParticleSystem
  63517. * @param gradient defines the gradient to use (between 0 and 1)
  63518. * @param factor defines the emit rate value to affect to the specified gradient
  63519. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63520. * @returns the current particle system
  63521. */
  63522. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63523. /**
  63524. * Not supported by GPUParticleSystem
  63525. * @param gradient defines the gradient to remove
  63526. * @returns the current particle system
  63527. */
  63528. removeEmitRateGradient(gradient: number): IParticleSystem;
  63529. /**
  63530. * Not supported by GPUParticleSystem
  63531. * @param gradient defines the gradient to use (between 0 and 1)
  63532. * @param factor defines the start size value to affect to the specified gradient
  63533. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63534. * @returns the current particle system
  63535. */
  63536. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63537. /**
  63538. * Not supported by GPUParticleSystem
  63539. * @param gradient defines the gradient to remove
  63540. * @returns the current particle system
  63541. */
  63542. removeStartSizeGradient(gradient: number): IParticleSystem;
  63543. /**
  63544. * Not supported by GPUParticleSystem
  63545. * @param gradient defines the gradient to use (between 0 and 1)
  63546. * @param min defines the color remap minimal range
  63547. * @param max defines the color remap maximal range
  63548. * @returns the current particle system
  63549. */
  63550. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63551. /**
  63552. * Not supported by GPUParticleSystem
  63553. * @param gradient defines the gradient to remove
  63554. * @returns the current particle system
  63555. */
  63556. removeColorRemapGradient(): IParticleSystem;
  63557. /**
  63558. * Not supported by GPUParticleSystem
  63559. * @param gradient defines the gradient to use (between 0 and 1)
  63560. * @param min defines the alpha remap minimal range
  63561. * @param max defines the alpha remap maximal range
  63562. * @returns the current particle system
  63563. */
  63564. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63565. /**
  63566. * Not supported by GPUParticleSystem
  63567. * @param gradient defines the gradient to remove
  63568. * @returns the current particle system
  63569. */
  63570. removeAlphaRemapGradient(): IParticleSystem;
  63571. /**
  63572. * Not supported by GPUParticleSystem
  63573. * @param gradient defines the gradient to use (between 0 and 1)
  63574. * @param color defines the color to affect to the specified gradient
  63575. * @returns the current particle system
  63576. */
  63577. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63578. /**
  63579. * Not supported by GPUParticleSystem
  63580. * @param gradient defines the gradient to remove
  63581. * @returns the current particle system
  63582. */
  63583. removeRampGradient(): IParticleSystem;
  63584. /**
  63585. * Not supported by GPUParticleSystem
  63586. * @returns the list of ramp gradients
  63587. */
  63588. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63589. /**
  63590. * Not supported by GPUParticleSystem
  63591. * Gets or sets a boolean indicating that ramp gradients must be used
  63592. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63593. */
  63594. get useRampGradients(): boolean;
  63595. set useRampGradients(value: boolean);
  63596. /**
  63597. * Not supported by GPUParticleSystem
  63598. * @param gradient defines the gradient to use (between 0 and 1)
  63599. * @param factor defines the life time factor to affect to the specified gradient
  63600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63601. * @returns the current particle system
  63602. */
  63603. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63604. /**
  63605. * Not supported by GPUParticleSystem
  63606. * @param gradient defines the gradient to remove
  63607. * @returns the current particle system
  63608. */
  63609. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63610. /**
  63611. * Instantiates a GPU particle system.
  63612. * 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.
  63613. * @param name The name of the particle system
  63614. * @param options The options used to create the system
  63615. * @param scene The scene the particle system belongs to
  63616. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63617. */
  63618. constructor(name: string, options: Partial<{
  63619. capacity: number;
  63620. randomTextureSize: number;
  63621. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63622. protected _reset(): void;
  63623. private _createUpdateVAO;
  63624. private _createRenderVAO;
  63625. private _initialize;
  63626. /** @hidden */
  63627. _recreateUpdateEffect(): void;
  63628. /** @hidden */
  63629. _recreateRenderEffect(): void;
  63630. /**
  63631. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63632. * @param preWarm defines if we are in the pre-warmimg phase
  63633. */
  63634. animate(preWarm?: boolean): void;
  63635. private _createFactorGradientTexture;
  63636. private _createSizeGradientTexture;
  63637. private _createAngularSpeedGradientTexture;
  63638. private _createVelocityGradientTexture;
  63639. private _createLimitVelocityGradientTexture;
  63640. private _createDragGradientTexture;
  63641. private _createColorGradientTexture;
  63642. /**
  63643. * Renders the particle system in its current state
  63644. * @param preWarm defines if the system should only update the particles but not render them
  63645. * @returns the current number of particles
  63646. */
  63647. render(preWarm?: boolean): number;
  63648. /**
  63649. * Rebuilds the particle system
  63650. */
  63651. rebuild(): void;
  63652. private _releaseBuffers;
  63653. private _releaseVAOs;
  63654. /**
  63655. * Disposes the particle system and free the associated resources
  63656. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63657. */
  63658. dispose(disposeTexture?: boolean): void;
  63659. /**
  63660. * Clones the particle system.
  63661. * @param name The name of the cloned object
  63662. * @param newEmitter The new emitter to use
  63663. * @returns the cloned particle system
  63664. */
  63665. clone(name: string, newEmitter: any): GPUParticleSystem;
  63666. /**
  63667. * Serializes the particle system to a JSON object
  63668. * @param serializeTexture defines if the texture must be serialized as well
  63669. * @returns the JSON object
  63670. */
  63671. serialize(serializeTexture?: boolean): any;
  63672. /**
  63673. * Parses a JSON object to create a GPU particle system.
  63674. * @param parsedParticleSystem The JSON object to parse
  63675. * @param scene The scene to create the particle system in
  63676. * @param rootUrl The root url to use to load external dependencies like texture
  63677. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63678. * @returns the parsed GPU particle system
  63679. */
  63680. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63681. }
  63682. }
  63683. declare module BABYLON {
  63684. /**
  63685. * Represents a set of particle systems working together to create a specific effect
  63686. */
  63687. export class ParticleSystemSet implements IDisposable {
  63688. /**
  63689. * Gets or sets base Assets URL
  63690. */
  63691. static BaseAssetsUrl: string;
  63692. private _emitterCreationOptions;
  63693. private _emitterNode;
  63694. /**
  63695. * Gets the particle system list
  63696. */
  63697. systems: IParticleSystem[];
  63698. /**
  63699. * Gets the emitter node used with this set
  63700. */
  63701. get emitterNode(): Nullable<TransformNode>;
  63702. /**
  63703. * Creates a new emitter mesh as a sphere
  63704. * @param options defines the options used to create the sphere
  63705. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63706. * @param scene defines the hosting scene
  63707. */
  63708. setEmitterAsSphere(options: {
  63709. diameter: number;
  63710. segments: number;
  63711. color: Color3;
  63712. }, renderingGroupId: number, scene: Scene): void;
  63713. /**
  63714. * Starts all particle systems of the set
  63715. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63716. */
  63717. start(emitter?: AbstractMesh): void;
  63718. /**
  63719. * Release all associated resources
  63720. */
  63721. dispose(): void;
  63722. /**
  63723. * Serialize the set into a JSON compatible object
  63724. * @param serializeTexture defines if the texture must be serialized as well
  63725. * @returns a JSON compatible representation of the set
  63726. */
  63727. serialize(serializeTexture?: boolean): any;
  63728. /**
  63729. * Parse a new ParticleSystemSet from a serialized source
  63730. * @param data defines a JSON compatible representation of the set
  63731. * @param scene defines the hosting scene
  63732. * @param gpu defines if we want GPU particles or CPU particles
  63733. * @returns a new ParticleSystemSet
  63734. */
  63735. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63736. }
  63737. }
  63738. declare module BABYLON {
  63739. /**
  63740. * This class is made for on one-liner static method to help creating particle system set.
  63741. */
  63742. export class ParticleHelper {
  63743. /**
  63744. * Gets or sets base Assets URL
  63745. */
  63746. static BaseAssetsUrl: string;
  63747. /** Define the Url to load snippets */
  63748. static SnippetUrl: string;
  63749. /**
  63750. * Create a default particle system that you can tweak
  63751. * @param emitter defines the emitter to use
  63752. * @param capacity defines the system capacity (default is 500 particles)
  63753. * @param scene defines the hosting scene
  63754. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63755. * @returns the new Particle system
  63756. */
  63757. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63758. /**
  63759. * This is the main static method (one-liner) of this helper to create different particle systems
  63760. * @param type This string represents the type to the particle system to create
  63761. * @param scene The scene where the particle system should live
  63762. * @param gpu If the system will use gpu
  63763. * @returns the ParticleSystemSet created
  63764. */
  63765. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63766. /**
  63767. * Static function used to export a particle system to a ParticleSystemSet variable.
  63768. * Please note that the emitter shape is not exported
  63769. * @param systems defines the particle systems to export
  63770. * @returns the created particle system set
  63771. */
  63772. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63773. /**
  63774. * Creates a particle system from a snippet saved in a remote file
  63775. * @param name defines the name of the particle system to create
  63776. * @param url defines the url to load from
  63777. * @param scene defines the hosting scene
  63778. * @param gpu If the system will use gpu
  63779. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63780. * @returns a promise that will resolve to the new particle system
  63781. */
  63782. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63783. /**
  63784. * Creates a particle system from a snippet saved by the particle system editor
  63785. * @param snippetId defines the snippet to load
  63786. * @param scene defines the hosting scene
  63787. * @param gpu If the system will use gpu
  63788. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63789. * @returns a promise that will resolve to the new particle system
  63790. */
  63791. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63792. }
  63793. }
  63794. declare module BABYLON {
  63795. interface Engine {
  63796. /**
  63797. * Create an effect to use with particle systems.
  63798. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63799. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63800. * @param uniformsNames defines a list of attribute names
  63801. * @param samplers defines an array of string used to represent textures
  63802. * @param defines defines the string containing the defines to use to compile the shaders
  63803. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63804. * @param onCompiled defines a function to call when the effect creation is successful
  63805. * @param onError defines a function to call when the effect creation has failed
  63806. * @returns the new Effect
  63807. */
  63808. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63809. }
  63810. interface Mesh {
  63811. /**
  63812. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63813. * @returns an array of IParticleSystem
  63814. */
  63815. getEmittedParticleSystems(): IParticleSystem[];
  63816. /**
  63817. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63818. * @returns an array of IParticleSystem
  63819. */
  63820. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63821. }
  63822. /**
  63823. * @hidden
  63824. */
  63825. export var _IDoNeedToBeInTheBuild: number;
  63826. }
  63827. declare module BABYLON {
  63828. /** Defines the 4 color options */
  63829. export enum PointColor {
  63830. /** color value */
  63831. Color = 2,
  63832. /** uv value */
  63833. UV = 1,
  63834. /** random value */
  63835. Random = 0,
  63836. /** stated value */
  63837. Stated = 3
  63838. }
  63839. /**
  63840. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63841. * 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.
  63842. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63843. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63844. *
  63845. * Full documentation here : TO BE ENTERED
  63846. */
  63847. export class PointsCloudSystem implements IDisposable {
  63848. /**
  63849. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63850. * Example : var p = SPS.particles[i];
  63851. */
  63852. particles: CloudPoint[];
  63853. /**
  63854. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63855. */
  63856. nbParticles: number;
  63857. /**
  63858. * This a counter for your own usage. It's not set by any SPS functions.
  63859. */
  63860. counter: number;
  63861. /**
  63862. * The PCS name. This name is also given to the underlying mesh.
  63863. */
  63864. name: string;
  63865. /**
  63866. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63867. */
  63868. mesh: Mesh;
  63869. /**
  63870. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63871. * Please read :
  63872. */
  63873. vars: any;
  63874. /**
  63875. * @hidden
  63876. */
  63877. _size: number;
  63878. private _scene;
  63879. private _promises;
  63880. private _positions;
  63881. private _indices;
  63882. private _normals;
  63883. private _colors;
  63884. private _uvs;
  63885. private _indices32;
  63886. private _positions32;
  63887. private _colors32;
  63888. private _uvs32;
  63889. private _updatable;
  63890. private _isVisibilityBoxLocked;
  63891. private _alwaysVisible;
  63892. private _groups;
  63893. private _groupCounter;
  63894. private _computeParticleColor;
  63895. private _computeParticleTexture;
  63896. private _computeParticleRotation;
  63897. private _computeBoundingBox;
  63898. private _isReady;
  63899. /**
  63900. * Creates a PCS (Points Cloud System) object
  63901. * @param name (String) is the PCS name, this will be the underlying mesh name
  63902. * @param pointSize (number) is the size for each point
  63903. * @param scene (Scene) is the scene in which the PCS is added
  63904. * @param options defines the options of the PCS e.g.
  63905. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63906. */
  63907. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63908. updatable?: boolean;
  63909. });
  63910. /**
  63911. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63912. * If no points were added to the PCS, the returned mesh is just a single point.
  63913. * @returns a promise for the created mesh
  63914. */
  63915. buildMeshAsync(): Promise<Mesh>;
  63916. /**
  63917. * @hidden
  63918. */
  63919. private _buildMesh;
  63920. private _addParticle;
  63921. private _randomUnitVector;
  63922. private _getColorIndicesForCoord;
  63923. private _setPointsColorOrUV;
  63924. private _colorFromTexture;
  63925. private _calculateDensity;
  63926. /**
  63927. * Adds points to the PCS in random positions within a unit sphere
  63928. * @param nb (positive integer) the number of particles to be created from this model
  63929. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63930. * @returns the number of groups in the system
  63931. */
  63932. addPoints(nb: number, pointFunction?: any): number;
  63933. /**
  63934. * Adds points to the PCS from the surface of the model shape
  63935. * @param mesh is any Mesh object that will be used as a surface model for the points
  63936. * @param nb (positive integer) the number of particles to be created from this model
  63937. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63938. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63939. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63940. * @returns the number of groups in the system
  63941. */
  63942. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63943. /**
  63944. * Adds points to the PCS inside the model shape
  63945. * @param mesh is any Mesh object that will be used as a surface model for the points
  63946. * @param nb (positive integer) the number of particles to be created from this model
  63947. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63948. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63949. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63950. * @returns the number of groups in the system
  63951. */
  63952. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63953. /**
  63954. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63955. * This method calls `updateParticle()` for each particle of the SPS.
  63956. * For an animated SPS, it is usually called within the render loop.
  63957. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63958. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63959. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63960. * @returns the PCS.
  63961. */
  63962. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63963. /**
  63964. * Disposes the PCS.
  63965. */
  63966. dispose(): void;
  63967. /**
  63968. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63969. * doc :
  63970. * @returns the PCS.
  63971. */
  63972. refreshVisibleSize(): PointsCloudSystem;
  63973. /**
  63974. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63975. * @param size the size (float) of the visibility box
  63976. * note : this doesn't lock the PCS mesh bounding box.
  63977. * doc :
  63978. */
  63979. setVisibilityBox(size: number): void;
  63980. /**
  63981. * Gets whether the PCS is always visible or not
  63982. * doc :
  63983. */
  63984. get isAlwaysVisible(): boolean;
  63985. /**
  63986. * Sets the PCS as always visible or not
  63987. * doc :
  63988. */
  63989. set isAlwaysVisible(val: boolean);
  63990. /**
  63991. * Tells to `setParticles()` to compute the particle rotations or not
  63992. * Default value : false. The PCS is faster when it's set to false
  63993. * Note : particle rotations are only applied to parent particles
  63994. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63995. */
  63996. set computeParticleRotation(val: boolean);
  63997. /**
  63998. * Tells to `setParticles()` to compute the particle colors or not.
  63999. * Default value : true. The PCS is faster when it's set to false.
  64000. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64001. */
  64002. set computeParticleColor(val: boolean);
  64003. set computeParticleTexture(val: boolean);
  64004. /**
  64005. * Gets if `setParticles()` computes the particle colors or not.
  64006. * Default value : false. The PCS is faster when it's set to false.
  64007. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64008. */
  64009. get computeParticleColor(): boolean;
  64010. /**
  64011. * Gets if `setParticles()` computes the particle textures or not.
  64012. * Default value : false. The PCS is faster when it's set to false.
  64013. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  64014. */
  64015. get computeParticleTexture(): boolean;
  64016. /**
  64017. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  64018. */
  64019. set computeBoundingBox(val: boolean);
  64020. /**
  64021. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  64022. */
  64023. get computeBoundingBox(): boolean;
  64024. /**
  64025. * This function does nothing. It may be overwritten to set all the particle first values.
  64026. * The PCS doesn't call this function, you may have to call it by your own.
  64027. * doc :
  64028. */
  64029. initParticles(): void;
  64030. /**
  64031. * This function does nothing. It may be overwritten to recycle a particle
  64032. * The PCS doesn't call this function, you can to call it
  64033. * doc :
  64034. * @param particle The particle to recycle
  64035. * @returns the recycled particle
  64036. */
  64037. recycleParticle(particle: CloudPoint): CloudPoint;
  64038. /**
  64039. * Updates a particle : this function should be overwritten by the user.
  64040. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  64041. * doc :
  64042. * @example : just set a particle position or velocity and recycle conditions
  64043. * @param particle The particle to update
  64044. * @returns the updated particle
  64045. */
  64046. updateParticle(particle: CloudPoint): CloudPoint;
  64047. /**
  64048. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64049. * This does nothing and may be overwritten by the user.
  64050. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64051. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64052. * @param update the boolean update value actually passed to setParticles()
  64053. */
  64054. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64055. /**
  64056. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64057. * This will be passed three parameters.
  64058. * This does nothing and may be overwritten by the user.
  64059. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64060. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64061. * @param update the boolean update value actually passed to setParticles()
  64062. */
  64063. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64064. }
  64065. }
  64066. declare module BABYLON {
  64067. /**
  64068. * Represents one particle of a points cloud system.
  64069. */
  64070. export class CloudPoint {
  64071. /**
  64072. * particle global index
  64073. */
  64074. idx: number;
  64075. /**
  64076. * The color of the particle
  64077. */
  64078. color: Nullable<Color4>;
  64079. /**
  64080. * The world space position of the particle.
  64081. */
  64082. position: Vector3;
  64083. /**
  64084. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64085. */
  64086. rotation: Vector3;
  64087. /**
  64088. * The world space rotation quaternion of the particle.
  64089. */
  64090. rotationQuaternion: Nullable<Quaternion>;
  64091. /**
  64092. * The uv of the particle.
  64093. */
  64094. uv: Nullable<Vector2>;
  64095. /**
  64096. * The current speed of the particle.
  64097. */
  64098. velocity: Vector3;
  64099. /**
  64100. * The pivot point in the particle local space.
  64101. */
  64102. pivot: Vector3;
  64103. /**
  64104. * Must the particle be translated from its pivot point in its local space ?
  64105. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64106. * Default : false
  64107. */
  64108. translateFromPivot: boolean;
  64109. /**
  64110. * Index of this particle in the global "positions" array (Internal use)
  64111. * @hidden
  64112. */
  64113. _pos: number;
  64114. /**
  64115. * @hidden Index of this particle in the global "indices" array (Internal use)
  64116. */
  64117. _ind: number;
  64118. /**
  64119. * Group this particle belongs to
  64120. */
  64121. _group: PointsGroup;
  64122. /**
  64123. * Group id of this particle
  64124. */
  64125. groupId: number;
  64126. /**
  64127. * Index of the particle in its group id (Internal use)
  64128. */
  64129. idxInGroup: number;
  64130. /**
  64131. * @hidden Particle BoundingInfo object (Internal use)
  64132. */
  64133. _boundingInfo: BoundingInfo;
  64134. /**
  64135. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64136. */
  64137. _pcs: PointsCloudSystem;
  64138. /**
  64139. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64140. */
  64141. _stillInvisible: boolean;
  64142. /**
  64143. * @hidden Last computed particle rotation matrix
  64144. */
  64145. _rotationMatrix: number[];
  64146. /**
  64147. * Parent particle Id, if any.
  64148. * Default null.
  64149. */
  64150. parentId: Nullable<number>;
  64151. /**
  64152. * @hidden Internal global position in the PCS.
  64153. */
  64154. _globalPosition: Vector3;
  64155. /**
  64156. * Creates a Point Cloud object.
  64157. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64158. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64159. * @param group (PointsGroup) is the group the particle belongs to
  64160. * @param groupId (integer) is the group identifier in the PCS.
  64161. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64162. * @param pcs defines the PCS it is associated to
  64163. */
  64164. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64165. /**
  64166. * get point size
  64167. */
  64168. get size(): Vector3;
  64169. /**
  64170. * Set point size
  64171. */
  64172. set size(scale: Vector3);
  64173. /**
  64174. * Legacy support, changed quaternion to rotationQuaternion
  64175. */
  64176. get quaternion(): Nullable<Quaternion>;
  64177. /**
  64178. * Legacy support, changed quaternion to rotationQuaternion
  64179. */
  64180. set quaternion(q: Nullable<Quaternion>);
  64181. /**
  64182. * Returns a boolean. True if the particle intersects a mesh, else false
  64183. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64184. * @param target is the object (point or mesh) what the intersection is computed against
  64185. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64186. * @returns true if it intersects
  64187. */
  64188. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64189. /**
  64190. * get the rotation matrix of the particle
  64191. * @hidden
  64192. */
  64193. getRotationMatrix(m: Matrix): void;
  64194. }
  64195. /**
  64196. * Represents a group of points in a points cloud system
  64197. * * PCS internal tool, don't use it manually.
  64198. */
  64199. export class PointsGroup {
  64200. /**
  64201. * The group id
  64202. * @hidden
  64203. */
  64204. groupID: number;
  64205. /**
  64206. * image data for group (internal use)
  64207. * @hidden
  64208. */
  64209. _groupImageData: Nullable<ArrayBufferView>;
  64210. /**
  64211. * Image Width (internal use)
  64212. * @hidden
  64213. */
  64214. _groupImgWidth: number;
  64215. /**
  64216. * Image Height (internal use)
  64217. * @hidden
  64218. */
  64219. _groupImgHeight: number;
  64220. /**
  64221. * Custom position function (internal use)
  64222. * @hidden
  64223. */
  64224. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64225. /**
  64226. * density per facet for surface points
  64227. * @hidden
  64228. */
  64229. _groupDensity: number[];
  64230. /**
  64231. * Only when points are colored by texture carries pointer to texture list array
  64232. * @hidden
  64233. */
  64234. _textureNb: number;
  64235. /**
  64236. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64237. * PCS internal tool, don't use it manually.
  64238. * @hidden
  64239. */
  64240. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64241. }
  64242. }
  64243. declare module BABYLON {
  64244. interface Scene {
  64245. /** @hidden (Backing field) */
  64246. _physicsEngine: Nullable<IPhysicsEngine>;
  64247. /** @hidden */
  64248. _physicsTimeAccumulator: number;
  64249. /**
  64250. * Gets the current physics engine
  64251. * @returns a IPhysicsEngine or null if none attached
  64252. */
  64253. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64254. /**
  64255. * Enables physics to the current scene
  64256. * @param gravity defines the scene's gravity for the physics engine
  64257. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64258. * @return a boolean indicating if the physics engine was initialized
  64259. */
  64260. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64261. /**
  64262. * Disables and disposes the physics engine associated with the scene
  64263. */
  64264. disablePhysicsEngine(): void;
  64265. /**
  64266. * Gets a boolean indicating if there is an active physics engine
  64267. * @returns a boolean indicating if there is an active physics engine
  64268. */
  64269. isPhysicsEnabled(): boolean;
  64270. /**
  64271. * Deletes a physics compound impostor
  64272. * @param compound defines the compound to delete
  64273. */
  64274. deleteCompoundImpostor(compound: any): void;
  64275. /**
  64276. * An event triggered when physic simulation is about to be run
  64277. */
  64278. onBeforePhysicsObservable: Observable<Scene>;
  64279. /**
  64280. * An event triggered when physic simulation has been done
  64281. */
  64282. onAfterPhysicsObservable: Observable<Scene>;
  64283. }
  64284. interface AbstractMesh {
  64285. /** @hidden */
  64286. _physicsImpostor: Nullable<PhysicsImpostor>;
  64287. /**
  64288. * Gets or sets impostor used for physic simulation
  64289. * @see http://doc.babylonjs.com/features/physics_engine
  64290. */
  64291. physicsImpostor: Nullable<PhysicsImpostor>;
  64292. /**
  64293. * Gets the current physics impostor
  64294. * @see http://doc.babylonjs.com/features/physics_engine
  64295. * @returns a physics impostor or null
  64296. */
  64297. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64298. /** Apply a physic impulse to the mesh
  64299. * @param force defines the force to apply
  64300. * @param contactPoint defines where to apply the force
  64301. * @returns the current mesh
  64302. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64303. */
  64304. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64305. /**
  64306. * Creates a physic joint between two meshes
  64307. * @param otherMesh defines the other mesh to use
  64308. * @param pivot1 defines the pivot to use on this mesh
  64309. * @param pivot2 defines the pivot to use on the other mesh
  64310. * @param options defines additional options (can be plugin dependent)
  64311. * @returns the current mesh
  64312. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64313. */
  64314. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64315. /** @hidden */
  64316. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64317. }
  64318. /**
  64319. * Defines the physics engine scene component responsible to manage a physics engine
  64320. */
  64321. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64322. /**
  64323. * The component name helpful to identify the component in the list of scene components.
  64324. */
  64325. readonly name: string;
  64326. /**
  64327. * The scene the component belongs to.
  64328. */
  64329. scene: Scene;
  64330. /**
  64331. * Creates a new instance of the component for the given scene
  64332. * @param scene Defines the scene to register the component in
  64333. */
  64334. constructor(scene: Scene);
  64335. /**
  64336. * Registers the component in a given scene
  64337. */
  64338. register(): void;
  64339. /**
  64340. * Rebuilds the elements related to this component in case of
  64341. * context lost for instance.
  64342. */
  64343. rebuild(): void;
  64344. /**
  64345. * Disposes the component and the associated ressources
  64346. */
  64347. dispose(): void;
  64348. }
  64349. }
  64350. declare module BABYLON {
  64351. /**
  64352. * A helper for physics simulations
  64353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64354. */
  64355. export class PhysicsHelper {
  64356. private _scene;
  64357. private _physicsEngine;
  64358. /**
  64359. * Initializes the Physics helper
  64360. * @param scene Babylon.js scene
  64361. */
  64362. constructor(scene: Scene);
  64363. /**
  64364. * Applies a radial explosion impulse
  64365. * @param origin the origin of the explosion
  64366. * @param radiusOrEventOptions the radius or the options of radial explosion
  64367. * @param strength the explosion strength
  64368. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64369. * @returns A physics radial explosion event, or null
  64370. */
  64371. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64372. /**
  64373. * Applies a radial explosion force
  64374. * @param origin the origin of the explosion
  64375. * @param radiusOrEventOptions the radius or the options of radial explosion
  64376. * @param strength the explosion strength
  64377. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64378. * @returns A physics radial explosion event, or null
  64379. */
  64380. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64381. /**
  64382. * Creates a gravitational field
  64383. * @param origin the origin of the explosion
  64384. * @param radiusOrEventOptions the radius or the options of radial explosion
  64385. * @param strength the explosion strength
  64386. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64387. * @returns A physics gravitational field event, or null
  64388. */
  64389. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64390. /**
  64391. * Creates a physics updraft event
  64392. * @param origin the origin of the updraft
  64393. * @param radiusOrEventOptions the radius or the options of the updraft
  64394. * @param strength the strength of the updraft
  64395. * @param height the height of the updraft
  64396. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64397. * @returns A physics updraft event, or null
  64398. */
  64399. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64400. /**
  64401. * Creates a physics vortex event
  64402. * @param origin the of the vortex
  64403. * @param radiusOrEventOptions the radius or the options of the vortex
  64404. * @param strength the strength of the vortex
  64405. * @param height the height of the vortex
  64406. * @returns a Physics vortex event, or null
  64407. * A physics vortex event or null
  64408. */
  64409. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64410. }
  64411. /**
  64412. * Represents a physics radial explosion event
  64413. */
  64414. class PhysicsRadialExplosionEvent {
  64415. private _scene;
  64416. private _options;
  64417. private _sphere;
  64418. private _dataFetched;
  64419. /**
  64420. * Initializes a radial explosioin event
  64421. * @param _scene BabylonJS scene
  64422. * @param _options The options for the vortex event
  64423. */
  64424. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64425. /**
  64426. * Returns the data related to the radial explosion event (sphere).
  64427. * @returns The radial explosion event data
  64428. */
  64429. getData(): PhysicsRadialExplosionEventData;
  64430. /**
  64431. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64432. * @param impostor A physics imposter
  64433. * @param origin the origin of the explosion
  64434. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64435. */
  64436. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64437. /**
  64438. * Triggers affecterd impostors callbacks
  64439. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64440. */
  64441. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64442. /**
  64443. * Disposes the sphere.
  64444. * @param force Specifies if the sphere should be disposed by force
  64445. */
  64446. dispose(force?: boolean): void;
  64447. /*** Helpers ***/
  64448. private _prepareSphere;
  64449. private _intersectsWithSphere;
  64450. }
  64451. /**
  64452. * Represents a gravitational field event
  64453. */
  64454. class PhysicsGravitationalFieldEvent {
  64455. private _physicsHelper;
  64456. private _scene;
  64457. private _origin;
  64458. private _options;
  64459. private _tickCallback;
  64460. private _sphere;
  64461. private _dataFetched;
  64462. /**
  64463. * Initializes the physics gravitational field event
  64464. * @param _physicsHelper A physics helper
  64465. * @param _scene BabylonJS scene
  64466. * @param _origin The origin position of the gravitational field event
  64467. * @param _options The options for the vortex event
  64468. */
  64469. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64470. /**
  64471. * Returns the data related to the gravitational field event (sphere).
  64472. * @returns A gravitational field event
  64473. */
  64474. getData(): PhysicsGravitationalFieldEventData;
  64475. /**
  64476. * Enables the gravitational field.
  64477. */
  64478. enable(): void;
  64479. /**
  64480. * Disables the gravitational field.
  64481. */
  64482. disable(): void;
  64483. /**
  64484. * Disposes the sphere.
  64485. * @param force The force to dispose from the gravitational field event
  64486. */
  64487. dispose(force?: boolean): void;
  64488. private _tick;
  64489. }
  64490. /**
  64491. * Represents a physics updraft event
  64492. */
  64493. class PhysicsUpdraftEvent {
  64494. private _scene;
  64495. private _origin;
  64496. private _options;
  64497. private _physicsEngine;
  64498. private _originTop;
  64499. private _originDirection;
  64500. private _tickCallback;
  64501. private _cylinder;
  64502. private _cylinderPosition;
  64503. private _dataFetched;
  64504. /**
  64505. * Initializes the physics updraft event
  64506. * @param _scene BabylonJS scene
  64507. * @param _origin The origin position of the updraft
  64508. * @param _options The options for the updraft event
  64509. */
  64510. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64511. /**
  64512. * Returns the data related to the updraft event (cylinder).
  64513. * @returns A physics updraft event
  64514. */
  64515. getData(): PhysicsUpdraftEventData;
  64516. /**
  64517. * Enables the updraft.
  64518. */
  64519. enable(): void;
  64520. /**
  64521. * Disables the updraft.
  64522. */
  64523. disable(): void;
  64524. /**
  64525. * Disposes the cylinder.
  64526. * @param force Specifies if the updraft should be disposed by force
  64527. */
  64528. dispose(force?: boolean): void;
  64529. private getImpostorHitData;
  64530. private _tick;
  64531. /*** Helpers ***/
  64532. private _prepareCylinder;
  64533. private _intersectsWithCylinder;
  64534. }
  64535. /**
  64536. * Represents a physics vortex event
  64537. */
  64538. class PhysicsVortexEvent {
  64539. private _scene;
  64540. private _origin;
  64541. private _options;
  64542. private _physicsEngine;
  64543. private _originTop;
  64544. private _tickCallback;
  64545. private _cylinder;
  64546. private _cylinderPosition;
  64547. private _dataFetched;
  64548. /**
  64549. * Initializes the physics vortex event
  64550. * @param _scene The BabylonJS scene
  64551. * @param _origin The origin position of the vortex
  64552. * @param _options The options for the vortex event
  64553. */
  64554. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64555. /**
  64556. * Returns the data related to the vortex event (cylinder).
  64557. * @returns The physics vortex event data
  64558. */
  64559. getData(): PhysicsVortexEventData;
  64560. /**
  64561. * Enables the vortex.
  64562. */
  64563. enable(): void;
  64564. /**
  64565. * Disables the cortex.
  64566. */
  64567. disable(): void;
  64568. /**
  64569. * Disposes the sphere.
  64570. * @param force
  64571. */
  64572. dispose(force?: boolean): void;
  64573. private getImpostorHitData;
  64574. private _tick;
  64575. /*** Helpers ***/
  64576. private _prepareCylinder;
  64577. private _intersectsWithCylinder;
  64578. }
  64579. /**
  64580. * Options fot the radial explosion event
  64581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64582. */
  64583. export class PhysicsRadialExplosionEventOptions {
  64584. /**
  64585. * The radius of the sphere for the radial explosion.
  64586. */
  64587. radius: number;
  64588. /**
  64589. * The strenth of the explosion.
  64590. */
  64591. strength: number;
  64592. /**
  64593. * The strenght of the force in correspondence to the distance of the affected object
  64594. */
  64595. falloff: PhysicsRadialImpulseFalloff;
  64596. /**
  64597. * Sphere options for the radial explosion.
  64598. */
  64599. sphere: {
  64600. segments: number;
  64601. diameter: number;
  64602. };
  64603. /**
  64604. * Sphere options for the radial explosion.
  64605. */
  64606. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64607. }
  64608. /**
  64609. * Options fot the updraft event
  64610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64611. */
  64612. export class PhysicsUpdraftEventOptions {
  64613. /**
  64614. * The radius of the cylinder for the vortex
  64615. */
  64616. radius: number;
  64617. /**
  64618. * The strenth of the updraft.
  64619. */
  64620. strength: number;
  64621. /**
  64622. * The height of the cylinder for the updraft.
  64623. */
  64624. height: number;
  64625. /**
  64626. * The mode for the the updraft.
  64627. */
  64628. updraftMode: PhysicsUpdraftMode;
  64629. }
  64630. /**
  64631. * Options fot the vortex event
  64632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64633. */
  64634. export class PhysicsVortexEventOptions {
  64635. /**
  64636. * The radius of the cylinder for the vortex
  64637. */
  64638. radius: number;
  64639. /**
  64640. * The strenth of the vortex.
  64641. */
  64642. strength: number;
  64643. /**
  64644. * The height of the cylinder for the vortex.
  64645. */
  64646. height: number;
  64647. /**
  64648. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64649. */
  64650. centripetalForceThreshold: number;
  64651. /**
  64652. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64653. */
  64654. centripetalForceMultiplier: number;
  64655. /**
  64656. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64657. */
  64658. centrifugalForceMultiplier: number;
  64659. /**
  64660. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64661. */
  64662. updraftForceMultiplier: number;
  64663. }
  64664. /**
  64665. * The strenght of the force in correspondence to the distance of the affected object
  64666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64667. */
  64668. export enum PhysicsRadialImpulseFalloff {
  64669. /** Defines that impulse is constant in strength across it's whole radius */
  64670. Constant = 0,
  64671. /** Defines that impulse gets weaker if it's further from the origin */
  64672. Linear = 1
  64673. }
  64674. /**
  64675. * The strength of the force in correspondence to the distance of the affected object
  64676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64677. */
  64678. export enum PhysicsUpdraftMode {
  64679. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64680. Center = 0,
  64681. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64682. Perpendicular = 1
  64683. }
  64684. /**
  64685. * Interface for a physics hit data
  64686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64687. */
  64688. export interface PhysicsHitData {
  64689. /**
  64690. * The force applied at the contact point
  64691. */
  64692. force: Vector3;
  64693. /**
  64694. * The contact point
  64695. */
  64696. contactPoint: Vector3;
  64697. /**
  64698. * The distance from the origin to the contact point
  64699. */
  64700. distanceFromOrigin: number;
  64701. }
  64702. /**
  64703. * Interface for radial explosion event data
  64704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64705. */
  64706. export interface PhysicsRadialExplosionEventData {
  64707. /**
  64708. * A sphere used for the radial explosion event
  64709. */
  64710. sphere: Mesh;
  64711. }
  64712. /**
  64713. * Interface for gravitational field event data
  64714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64715. */
  64716. export interface PhysicsGravitationalFieldEventData {
  64717. /**
  64718. * A sphere mesh used for the gravitational field event
  64719. */
  64720. sphere: Mesh;
  64721. }
  64722. /**
  64723. * Interface for updraft event data
  64724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64725. */
  64726. export interface PhysicsUpdraftEventData {
  64727. /**
  64728. * A cylinder used for the updraft event
  64729. */
  64730. cylinder: Mesh;
  64731. }
  64732. /**
  64733. * Interface for vortex event data
  64734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64735. */
  64736. export interface PhysicsVortexEventData {
  64737. /**
  64738. * A cylinder used for the vortex event
  64739. */
  64740. cylinder: Mesh;
  64741. }
  64742. /**
  64743. * Interface for an affected physics impostor
  64744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64745. */
  64746. export interface PhysicsAffectedImpostorWithData {
  64747. /**
  64748. * The impostor affected by the effect
  64749. */
  64750. impostor: PhysicsImpostor;
  64751. /**
  64752. * The data about the hit/horce from the explosion
  64753. */
  64754. hitData: PhysicsHitData;
  64755. }
  64756. }
  64757. declare module BABYLON {
  64758. /** @hidden */
  64759. export var blackAndWhitePixelShader: {
  64760. name: string;
  64761. shader: string;
  64762. };
  64763. }
  64764. declare module BABYLON {
  64765. /**
  64766. * Post process used to render in black and white
  64767. */
  64768. export class BlackAndWhitePostProcess extends PostProcess {
  64769. /**
  64770. * Linear about to convert he result to black and white (default: 1)
  64771. */
  64772. degree: number;
  64773. /**
  64774. * Creates a black and white post process
  64775. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64776. * @param name The name of the effect.
  64777. * @param options The required width/height ratio to downsize to before computing the render pass.
  64778. * @param camera The camera to apply the render pass to.
  64779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64780. * @param engine The engine which the post process will be applied. (default: current engine)
  64781. * @param reusable If the post process can be reused on the same frame. (default: false)
  64782. */
  64783. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64784. }
  64785. }
  64786. declare module BABYLON {
  64787. /**
  64788. * This represents a set of one or more post processes in Babylon.
  64789. * A post process can be used to apply a shader to a texture after it is rendered.
  64790. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64791. */
  64792. export class PostProcessRenderEffect {
  64793. private _postProcesses;
  64794. private _getPostProcesses;
  64795. private _singleInstance;
  64796. private _cameras;
  64797. private _indicesForCamera;
  64798. /**
  64799. * Name of the effect
  64800. * @hidden
  64801. */
  64802. _name: string;
  64803. /**
  64804. * Instantiates a post process render effect.
  64805. * A post process can be used to apply a shader to a texture after it is rendered.
  64806. * @param engine The engine the effect is tied to
  64807. * @param name The name of the effect
  64808. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64809. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64810. */
  64811. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64812. /**
  64813. * Checks if all the post processes in the effect are supported.
  64814. */
  64815. get isSupported(): boolean;
  64816. /**
  64817. * Updates the current state of the effect
  64818. * @hidden
  64819. */
  64820. _update(): void;
  64821. /**
  64822. * Attaches the effect on cameras
  64823. * @param cameras The camera to attach to.
  64824. * @hidden
  64825. */
  64826. _attachCameras(cameras: Camera): void;
  64827. /**
  64828. * Attaches the effect on cameras
  64829. * @param cameras The camera to attach to.
  64830. * @hidden
  64831. */
  64832. _attachCameras(cameras: Camera[]): void;
  64833. /**
  64834. * Detaches the effect on cameras
  64835. * @param cameras The camera to detatch from.
  64836. * @hidden
  64837. */
  64838. _detachCameras(cameras: Camera): void;
  64839. /**
  64840. * Detatches the effect on cameras
  64841. * @param cameras The camera to detatch from.
  64842. * @hidden
  64843. */
  64844. _detachCameras(cameras: Camera[]): void;
  64845. /**
  64846. * Enables the effect on given cameras
  64847. * @param cameras The camera to enable.
  64848. * @hidden
  64849. */
  64850. _enable(cameras: Camera): void;
  64851. /**
  64852. * Enables the effect on given cameras
  64853. * @param cameras The camera to enable.
  64854. * @hidden
  64855. */
  64856. _enable(cameras: Nullable<Camera[]>): void;
  64857. /**
  64858. * Disables the effect on the given cameras
  64859. * @param cameras The camera to disable.
  64860. * @hidden
  64861. */
  64862. _disable(cameras: Camera): void;
  64863. /**
  64864. * Disables the effect on the given cameras
  64865. * @param cameras The camera to disable.
  64866. * @hidden
  64867. */
  64868. _disable(cameras: Nullable<Camera[]>): void;
  64869. /**
  64870. * Gets a list of the post processes contained in the effect.
  64871. * @param camera The camera to get the post processes on.
  64872. * @returns The list of the post processes in the effect.
  64873. */
  64874. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64875. }
  64876. }
  64877. declare module BABYLON {
  64878. /** @hidden */
  64879. export var extractHighlightsPixelShader: {
  64880. name: string;
  64881. shader: string;
  64882. };
  64883. }
  64884. declare module BABYLON {
  64885. /**
  64886. * 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.
  64887. */
  64888. export class ExtractHighlightsPostProcess extends PostProcess {
  64889. /**
  64890. * The luminance threshold, pixels below this value will be set to black.
  64891. */
  64892. threshold: number;
  64893. /** @hidden */
  64894. _exposure: number;
  64895. /**
  64896. * Post process which has the input texture to be used when performing highlight extraction
  64897. * @hidden
  64898. */
  64899. _inputPostProcess: Nullable<PostProcess>;
  64900. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64901. }
  64902. }
  64903. declare module BABYLON {
  64904. /** @hidden */
  64905. export var bloomMergePixelShader: {
  64906. name: string;
  64907. shader: string;
  64908. };
  64909. }
  64910. declare module BABYLON {
  64911. /**
  64912. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64913. */
  64914. export class BloomMergePostProcess extends PostProcess {
  64915. /** Weight of the bloom to be added to the original input. */
  64916. weight: number;
  64917. /**
  64918. * Creates a new instance of @see BloomMergePostProcess
  64919. * @param name The name of the effect.
  64920. * @param originalFromInput Post process which's input will be used for the merge.
  64921. * @param blurred Blurred highlights post process which's output will be used.
  64922. * @param weight Weight of the bloom to be added to the original input.
  64923. * @param options The required width/height ratio to downsize to before computing the render pass.
  64924. * @param camera The camera to apply the render pass to.
  64925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64926. * @param engine The engine which the post process will be applied. (default: current engine)
  64927. * @param reusable If the post process can be reused on the same frame. (default: false)
  64928. * @param textureType Type of textures used when performing the post process. (default: 0)
  64929. * @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)
  64930. */
  64931. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64932. /** Weight of the bloom to be added to the original input. */
  64933. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64934. }
  64935. }
  64936. declare module BABYLON {
  64937. /**
  64938. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64939. */
  64940. export class BloomEffect extends PostProcessRenderEffect {
  64941. private bloomScale;
  64942. /**
  64943. * @hidden Internal
  64944. */
  64945. _effects: Array<PostProcess>;
  64946. /**
  64947. * @hidden Internal
  64948. */
  64949. _downscale: ExtractHighlightsPostProcess;
  64950. private _blurX;
  64951. private _blurY;
  64952. private _merge;
  64953. /**
  64954. * The luminance threshold to find bright areas of the image to bloom.
  64955. */
  64956. get threshold(): number;
  64957. set threshold(value: number);
  64958. /**
  64959. * The strength of the bloom.
  64960. */
  64961. get weight(): number;
  64962. set weight(value: number);
  64963. /**
  64964. * Specifies the size of the bloom blur kernel, relative to the final output size
  64965. */
  64966. get kernel(): number;
  64967. set kernel(value: number);
  64968. /**
  64969. * Creates a new instance of @see BloomEffect
  64970. * @param scene The scene the effect belongs to.
  64971. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64972. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64973. * @param bloomWeight The the strength of bloom.
  64974. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64975. * @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)
  64976. */
  64977. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64978. /**
  64979. * Disposes each of the internal effects for a given camera.
  64980. * @param camera The camera to dispose the effect on.
  64981. */
  64982. disposeEffects(camera: Camera): void;
  64983. /**
  64984. * @hidden Internal
  64985. */
  64986. _updateEffects(): void;
  64987. /**
  64988. * Internal
  64989. * @returns if all the contained post processes are ready.
  64990. * @hidden
  64991. */
  64992. _isReady(): boolean;
  64993. }
  64994. }
  64995. declare module BABYLON {
  64996. /** @hidden */
  64997. export var chromaticAberrationPixelShader: {
  64998. name: string;
  64999. shader: string;
  65000. };
  65001. }
  65002. declare module BABYLON {
  65003. /**
  65004. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  65005. */
  65006. export class ChromaticAberrationPostProcess extends PostProcess {
  65007. /**
  65008. * The amount of seperation of rgb channels (default: 30)
  65009. */
  65010. aberrationAmount: number;
  65011. /**
  65012. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  65013. */
  65014. radialIntensity: number;
  65015. /**
  65016. * 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))
  65017. */
  65018. direction: Vector2;
  65019. /**
  65020. * 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))
  65021. */
  65022. centerPosition: Vector2;
  65023. /**
  65024. * Creates a new instance ChromaticAberrationPostProcess
  65025. * @param name The name of the effect.
  65026. * @param screenWidth The width of the screen to apply the effect on.
  65027. * @param screenHeight The height of the screen to apply the effect on.
  65028. * @param options The required width/height ratio to downsize to before computing the render pass.
  65029. * @param camera The camera to apply the render pass to.
  65030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65031. * @param engine The engine which the post process will be applied. (default: current engine)
  65032. * @param reusable If the post process can be reused on the same frame. (default: false)
  65033. * @param textureType Type of textures used when performing the post process. (default: 0)
  65034. * @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)
  65035. */
  65036. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65037. }
  65038. }
  65039. declare module BABYLON {
  65040. /** @hidden */
  65041. export var circleOfConfusionPixelShader: {
  65042. name: string;
  65043. shader: string;
  65044. };
  65045. }
  65046. declare module BABYLON {
  65047. /**
  65048. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65049. */
  65050. export class CircleOfConfusionPostProcess extends PostProcess {
  65051. /**
  65052. * 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.
  65053. */
  65054. lensSize: number;
  65055. /**
  65056. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65057. */
  65058. fStop: number;
  65059. /**
  65060. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65061. */
  65062. focusDistance: number;
  65063. /**
  65064. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65065. */
  65066. focalLength: number;
  65067. private _depthTexture;
  65068. /**
  65069. * Creates a new instance CircleOfConfusionPostProcess
  65070. * @param name The name of the effect.
  65071. * @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.
  65072. * @param options The required width/height ratio to downsize to before computing the render pass.
  65073. * @param camera The camera to apply the render pass to.
  65074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65075. * @param engine The engine which the post process will be applied. (default: current engine)
  65076. * @param reusable If the post process can be reused on the same frame. (default: false)
  65077. * @param textureType Type of textures used when performing the post process. (default: 0)
  65078. * @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)
  65079. */
  65080. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65081. /**
  65082. * 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.
  65083. */
  65084. set depthTexture(value: RenderTargetTexture);
  65085. }
  65086. }
  65087. declare module BABYLON {
  65088. /** @hidden */
  65089. export var colorCorrectionPixelShader: {
  65090. name: string;
  65091. shader: string;
  65092. };
  65093. }
  65094. declare module BABYLON {
  65095. /**
  65096. *
  65097. * This post-process allows the modification of rendered colors by using
  65098. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65099. *
  65100. * The object needs to be provided an url to a texture containing the color
  65101. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65102. * Use an image editing software to tweak the LUT to match your needs.
  65103. *
  65104. * For an example of a color LUT, see here:
  65105. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65106. * For explanations on color grading, see here:
  65107. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65108. *
  65109. */
  65110. export class ColorCorrectionPostProcess extends PostProcess {
  65111. private _colorTableTexture;
  65112. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65113. }
  65114. }
  65115. declare module BABYLON {
  65116. /** @hidden */
  65117. export var convolutionPixelShader: {
  65118. name: string;
  65119. shader: string;
  65120. };
  65121. }
  65122. declare module BABYLON {
  65123. /**
  65124. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65125. * input texture to perform effects such as edge detection or sharpening
  65126. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65127. */
  65128. export class ConvolutionPostProcess extends PostProcess {
  65129. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65130. kernel: number[];
  65131. /**
  65132. * Creates a new instance ConvolutionPostProcess
  65133. * @param name The name of the effect.
  65134. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65135. * @param options The required width/height ratio to downsize to before computing the render pass.
  65136. * @param camera The camera to apply the render pass to.
  65137. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65138. * @param engine The engine which the post process will be applied. (default: current engine)
  65139. * @param reusable If the post process can be reused on the same frame. (default: false)
  65140. * @param textureType Type of textures used when performing the post process. (default: 0)
  65141. */
  65142. constructor(name: string,
  65143. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65144. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65145. /**
  65146. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65147. */
  65148. static EdgeDetect0Kernel: number[];
  65149. /**
  65150. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65151. */
  65152. static EdgeDetect1Kernel: number[];
  65153. /**
  65154. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65155. */
  65156. static EdgeDetect2Kernel: number[];
  65157. /**
  65158. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65159. */
  65160. static SharpenKernel: number[];
  65161. /**
  65162. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65163. */
  65164. static EmbossKernel: number[];
  65165. /**
  65166. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65167. */
  65168. static GaussianKernel: number[];
  65169. }
  65170. }
  65171. declare module BABYLON {
  65172. /**
  65173. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65174. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65175. * based on samples that have a large difference in distance than the center pixel.
  65176. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65177. */
  65178. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65179. direction: Vector2;
  65180. /**
  65181. * Creates a new instance CircleOfConfusionPostProcess
  65182. * @param name The name of the effect.
  65183. * @param scene The scene the effect belongs to.
  65184. * @param direction The direction the blur should be applied.
  65185. * @param kernel The size of the kernel used to blur.
  65186. * @param options The required width/height ratio to downsize to before computing the render pass.
  65187. * @param camera The camera to apply the render pass to.
  65188. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65189. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65191. * @param engine The engine which the post process will be applied. (default: current engine)
  65192. * @param reusable If the post process can be reused on the same frame. (default: false)
  65193. * @param textureType Type of textures used when performing the post process. (default: 0)
  65194. * @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)
  65195. */
  65196. 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);
  65197. }
  65198. }
  65199. declare module BABYLON {
  65200. /** @hidden */
  65201. export var depthOfFieldMergePixelShader: {
  65202. name: string;
  65203. shader: string;
  65204. };
  65205. }
  65206. declare module BABYLON {
  65207. /**
  65208. * Options to be set when merging outputs from the default pipeline.
  65209. */
  65210. export class DepthOfFieldMergePostProcessOptions {
  65211. /**
  65212. * The original image to merge on top of
  65213. */
  65214. originalFromInput: PostProcess;
  65215. /**
  65216. * Parameters to perform the merge of the depth of field effect
  65217. */
  65218. depthOfField?: {
  65219. circleOfConfusion: PostProcess;
  65220. blurSteps: Array<PostProcess>;
  65221. };
  65222. /**
  65223. * Parameters to perform the merge of bloom effect
  65224. */
  65225. bloom?: {
  65226. blurred: PostProcess;
  65227. weight: number;
  65228. };
  65229. }
  65230. /**
  65231. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65232. */
  65233. export class DepthOfFieldMergePostProcess extends PostProcess {
  65234. private blurSteps;
  65235. /**
  65236. * Creates a new instance of DepthOfFieldMergePostProcess
  65237. * @param name The name of the effect.
  65238. * @param originalFromInput Post process which's input will be used for the merge.
  65239. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65240. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65241. * @param options The required width/height ratio to downsize to before computing the render pass.
  65242. * @param camera The camera to apply the render pass to.
  65243. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65244. * @param engine The engine which the post process will be applied. (default: current engine)
  65245. * @param reusable If the post process can be reused on the same frame. (default: false)
  65246. * @param textureType Type of textures used when performing the post process. (default: 0)
  65247. * @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)
  65248. */
  65249. 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);
  65250. /**
  65251. * Updates the effect with the current post process compile time values and recompiles the shader.
  65252. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65253. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65254. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65255. * @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
  65256. * @param onCompiled Called when the shader has been compiled.
  65257. * @param onError Called if there is an error when compiling a shader.
  65258. */
  65259. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65260. }
  65261. }
  65262. declare module BABYLON {
  65263. /**
  65264. * Specifies the level of max blur that should be applied when using the depth of field effect
  65265. */
  65266. export enum DepthOfFieldEffectBlurLevel {
  65267. /**
  65268. * Subtle blur
  65269. */
  65270. Low = 0,
  65271. /**
  65272. * Medium blur
  65273. */
  65274. Medium = 1,
  65275. /**
  65276. * Large blur
  65277. */
  65278. High = 2
  65279. }
  65280. /**
  65281. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65282. */
  65283. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65284. private _circleOfConfusion;
  65285. /**
  65286. * @hidden Internal, blurs from high to low
  65287. */
  65288. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65289. private _depthOfFieldBlurY;
  65290. private _dofMerge;
  65291. /**
  65292. * @hidden Internal post processes in depth of field effect
  65293. */
  65294. _effects: Array<PostProcess>;
  65295. /**
  65296. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65297. */
  65298. set focalLength(value: number);
  65299. get focalLength(): number;
  65300. /**
  65301. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65302. */
  65303. set fStop(value: number);
  65304. get fStop(): number;
  65305. /**
  65306. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65307. */
  65308. set focusDistance(value: number);
  65309. get focusDistance(): number;
  65310. /**
  65311. * 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.
  65312. */
  65313. set lensSize(value: number);
  65314. get lensSize(): number;
  65315. /**
  65316. * Creates a new instance DepthOfFieldEffect
  65317. * @param scene The scene the effect belongs to.
  65318. * @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.
  65319. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65320. * @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)
  65321. */
  65322. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65323. /**
  65324. * Get the current class name of the current effet
  65325. * @returns "DepthOfFieldEffect"
  65326. */
  65327. getClassName(): string;
  65328. /**
  65329. * 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.
  65330. */
  65331. set depthTexture(value: RenderTargetTexture);
  65332. /**
  65333. * Disposes each of the internal effects for a given camera.
  65334. * @param camera The camera to dispose the effect on.
  65335. */
  65336. disposeEffects(camera: Camera): void;
  65337. /**
  65338. * @hidden Internal
  65339. */
  65340. _updateEffects(): void;
  65341. /**
  65342. * Internal
  65343. * @returns if all the contained post processes are ready.
  65344. * @hidden
  65345. */
  65346. _isReady(): boolean;
  65347. }
  65348. }
  65349. declare module BABYLON {
  65350. /** @hidden */
  65351. export var displayPassPixelShader: {
  65352. name: string;
  65353. shader: string;
  65354. };
  65355. }
  65356. declare module BABYLON {
  65357. /**
  65358. * DisplayPassPostProcess which produces an output the same as it's input
  65359. */
  65360. export class DisplayPassPostProcess extends PostProcess {
  65361. /**
  65362. * Creates the DisplayPassPostProcess
  65363. * @param name The name of the effect.
  65364. * @param options The required width/height ratio to downsize to before computing the render pass.
  65365. * @param camera The camera to apply the render pass to.
  65366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65367. * @param engine The engine which the post process will be applied. (default: current engine)
  65368. * @param reusable If the post process can be reused on the same frame. (default: false)
  65369. */
  65370. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65371. }
  65372. }
  65373. declare module BABYLON {
  65374. /** @hidden */
  65375. export var filterPixelShader: {
  65376. name: string;
  65377. shader: string;
  65378. };
  65379. }
  65380. declare module BABYLON {
  65381. /**
  65382. * Applies a kernel filter to the image
  65383. */
  65384. export class FilterPostProcess extends PostProcess {
  65385. /** The matrix to be applied to the image */
  65386. kernelMatrix: Matrix;
  65387. /**
  65388. *
  65389. * @param name The name of the effect.
  65390. * @param kernelMatrix The matrix to be applied to the image
  65391. * @param options The required width/height ratio to downsize to before computing the render pass.
  65392. * @param camera The camera to apply the render pass to.
  65393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65394. * @param engine The engine which the post process will be applied. (default: current engine)
  65395. * @param reusable If the post process can be reused on the same frame. (default: false)
  65396. */
  65397. constructor(name: string,
  65398. /** The matrix to be applied to the image */
  65399. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65400. }
  65401. }
  65402. declare module BABYLON {
  65403. /** @hidden */
  65404. export var fxaaPixelShader: {
  65405. name: string;
  65406. shader: string;
  65407. };
  65408. }
  65409. declare module BABYLON {
  65410. /** @hidden */
  65411. export var fxaaVertexShader: {
  65412. name: string;
  65413. shader: string;
  65414. };
  65415. }
  65416. declare module BABYLON {
  65417. /**
  65418. * Fxaa post process
  65419. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65420. */
  65421. export class FxaaPostProcess extends PostProcess {
  65422. /** @hidden */
  65423. texelWidth: number;
  65424. /** @hidden */
  65425. texelHeight: number;
  65426. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65427. private _getDefines;
  65428. }
  65429. }
  65430. declare module BABYLON {
  65431. /** @hidden */
  65432. export var grainPixelShader: {
  65433. name: string;
  65434. shader: string;
  65435. };
  65436. }
  65437. declare module BABYLON {
  65438. /**
  65439. * The GrainPostProcess adds noise to the image at mid luminance levels
  65440. */
  65441. export class GrainPostProcess extends PostProcess {
  65442. /**
  65443. * The intensity of the grain added (default: 30)
  65444. */
  65445. intensity: number;
  65446. /**
  65447. * If the grain should be randomized on every frame
  65448. */
  65449. animated: boolean;
  65450. /**
  65451. * Creates a new instance of @see GrainPostProcess
  65452. * @param name The name of the effect.
  65453. * @param options The required width/height ratio to downsize to before computing the render pass.
  65454. * @param camera The camera to apply the render pass to.
  65455. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65456. * @param engine The engine which the post process will be applied. (default: current engine)
  65457. * @param reusable If the post process can be reused on the same frame. (default: false)
  65458. * @param textureType Type of textures used when performing the post process. (default: 0)
  65459. * @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)
  65460. */
  65461. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65462. }
  65463. }
  65464. declare module BABYLON {
  65465. /** @hidden */
  65466. export var highlightsPixelShader: {
  65467. name: string;
  65468. shader: string;
  65469. };
  65470. }
  65471. declare module BABYLON {
  65472. /**
  65473. * Extracts highlights from the image
  65474. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65475. */
  65476. export class HighlightsPostProcess extends PostProcess {
  65477. /**
  65478. * Extracts highlights from the image
  65479. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65480. * @param name The name of the effect.
  65481. * @param options The required width/height ratio to downsize to before computing the render pass.
  65482. * @param camera The camera to apply the render pass to.
  65483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65484. * @param engine The engine which the post process will be applied. (default: current engine)
  65485. * @param reusable If the post process can be reused on the same frame. (default: false)
  65486. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65487. */
  65488. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65489. }
  65490. }
  65491. declare module BABYLON {
  65492. /** @hidden */
  65493. export var mrtFragmentDeclaration: {
  65494. name: string;
  65495. shader: string;
  65496. };
  65497. }
  65498. declare module BABYLON {
  65499. /** @hidden */
  65500. export var geometryPixelShader: {
  65501. name: string;
  65502. shader: string;
  65503. };
  65504. }
  65505. declare module BABYLON {
  65506. /** @hidden */
  65507. export var geometryVertexShader: {
  65508. name: string;
  65509. shader: string;
  65510. };
  65511. }
  65512. declare module BABYLON {
  65513. /** @hidden */
  65514. interface ISavedTransformationMatrix {
  65515. world: Matrix;
  65516. viewProjection: Matrix;
  65517. }
  65518. /**
  65519. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65520. */
  65521. export class GeometryBufferRenderer {
  65522. /**
  65523. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65524. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65525. */
  65526. static readonly POSITION_TEXTURE_TYPE: number;
  65527. /**
  65528. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65529. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65530. */
  65531. static readonly VELOCITY_TEXTURE_TYPE: number;
  65532. /**
  65533. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65534. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65535. */
  65536. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65537. /**
  65538. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65539. * in order to compute objects velocities when enableVelocity is set to "true"
  65540. * @hidden
  65541. */
  65542. _previousTransformationMatrices: {
  65543. [index: number]: ISavedTransformationMatrix;
  65544. };
  65545. /**
  65546. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65547. * in order to compute objects velocities when enableVelocity is set to "true"
  65548. * @hidden
  65549. */
  65550. _previousBonesTransformationMatrices: {
  65551. [index: number]: Float32Array;
  65552. };
  65553. /**
  65554. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65555. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65556. */
  65557. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65558. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65559. renderTransparentMeshes: boolean;
  65560. private _scene;
  65561. private _multiRenderTarget;
  65562. private _ratio;
  65563. private _enablePosition;
  65564. private _enableVelocity;
  65565. private _enableReflectivity;
  65566. private _positionIndex;
  65567. private _velocityIndex;
  65568. private _reflectivityIndex;
  65569. protected _effect: Effect;
  65570. protected _cachedDefines: string;
  65571. /**
  65572. * Set the render list (meshes to be rendered) used in the G buffer.
  65573. */
  65574. set renderList(meshes: Mesh[]);
  65575. /**
  65576. * Gets wether or not G buffer are supported by the running hardware.
  65577. * This requires draw buffer supports
  65578. */
  65579. get isSupported(): boolean;
  65580. /**
  65581. * Returns the index of the given texture type in the G-Buffer textures array
  65582. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65583. * @returns the index of the given texture type in the G-Buffer textures array
  65584. */
  65585. getTextureIndex(textureType: number): number;
  65586. /**
  65587. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65588. */
  65589. get enablePosition(): boolean;
  65590. /**
  65591. * Sets whether or not objects positions are enabled for the G buffer.
  65592. */
  65593. set enablePosition(enable: boolean);
  65594. /**
  65595. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65596. */
  65597. get enableVelocity(): boolean;
  65598. /**
  65599. * Sets wether or not objects velocities are enabled for the G buffer.
  65600. */
  65601. set enableVelocity(enable: boolean);
  65602. /**
  65603. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65604. */
  65605. get enableReflectivity(): boolean;
  65606. /**
  65607. * Sets wether or not objects roughness are enabled for the G buffer.
  65608. */
  65609. set enableReflectivity(enable: boolean);
  65610. /**
  65611. * Gets the scene associated with the buffer.
  65612. */
  65613. get scene(): Scene;
  65614. /**
  65615. * Gets the ratio used by the buffer during its creation.
  65616. * How big is the buffer related to the main canvas.
  65617. */
  65618. get ratio(): number;
  65619. /** @hidden */
  65620. static _SceneComponentInitialization: (scene: Scene) => void;
  65621. /**
  65622. * Creates a new G Buffer for the scene
  65623. * @param scene The scene the buffer belongs to
  65624. * @param ratio How big is the buffer related to the main canvas.
  65625. */
  65626. constructor(scene: Scene, ratio?: number);
  65627. /**
  65628. * Checks wether everything is ready to render a submesh to the G buffer.
  65629. * @param subMesh the submesh to check readiness for
  65630. * @param useInstances is the mesh drawn using instance or not
  65631. * @returns true if ready otherwise false
  65632. */
  65633. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65634. /**
  65635. * Gets the current underlying G Buffer.
  65636. * @returns the buffer
  65637. */
  65638. getGBuffer(): MultiRenderTarget;
  65639. /**
  65640. * Gets the number of samples used to render the buffer (anti aliasing).
  65641. */
  65642. get samples(): number;
  65643. /**
  65644. * Sets the number of samples used to render the buffer (anti aliasing).
  65645. */
  65646. set samples(value: number);
  65647. /**
  65648. * Disposes the renderer and frees up associated resources.
  65649. */
  65650. dispose(): void;
  65651. protected _createRenderTargets(): void;
  65652. private _copyBonesTransformationMatrices;
  65653. }
  65654. }
  65655. declare module BABYLON {
  65656. interface Scene {
  65657. /** @hidden (Backing field) */
  65658. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65659. /**
  65660. * Gets or Sets the current geometry buffer associated to the scene.
  65661. */
  65662. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65663. /**
  65664. * Enables a GeometryBufferRender and associates it with the scene
  65665. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65666. * @returns the GeometryBufferRenderer
  65667. */
  65668. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65669. /**
  65670. * Disables the GeometryBufferRender associated with the scene
  65671. */
  65672. disableGeometryBufferRenderer(): void;
  65673. }
  65674. /**
  65675. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65676. * in several rendering techniques.
  65677. */
  65678. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65679. /**
  65680. * The component name helpful to identify the component in the list of scene components.
  65681. */
  65682. readonly name: string;
  65683. /**
  65684. * The scene the component belongs to.
  65685. */
  65686. scene: Scene;
  65687. /**
  65688. * Creates a new instance of the component for the given scene
  65689. * @param scene Defines the scene to register the component in
  65690. */
  65691. constructor(scene: Scene);
  65692. /**
  65693. * Registers the component in a given scene
  65694. */
  65695. register(): void;
  65696. /**
  65697. * Rebuilds the elements related to this component in case of
  65698. * context lost for instance.
  65699. */
  65700. rebuild(): void;
  65701. /**
  65702. * Disposes the component and the associated ressources
  65703. */
  65704. dispose(): void;
  65705. private _gatherRenderTargets;
  65706. }
  65707. }
  65708. declare module BABYLON {
  65709. /** @hidden */
  65710. export var motionBlurPixelShader: {
  65711. name: string;
  65712. shader: string;
  65713. };
  65714. }
  65715. declare module BABYLON {
  65716. /**
  65717. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65718. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65719. * As an example, all you have to do is to create the post-process:
  65720. * var mb = new BABYLON.MotionBlurPostProcess(
  65721. * 'mb', // The name of the effect.
  65722. * scene, // The scene containing the objects to blur according to their velocity.
  65723. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65724. * camera // The camera to apply the render pass to.
  65725. * );
  65726. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65727. */
  65728. export class MotionBlurPostProcess extends PostProcess {
  65729. /**
  65730. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65731. */
  65732. motionStrength: number;
  65733. /**
  65734. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65735. */
  65736. get motionBlurSamples(): number;
  65737. /**
  65738. * Sets the number of iterations to be used for motion blur quality
  65739. */
  65740. set motionBlurSamples(samples: number);
  65741. private _motionBlurSamples;
  65742. private _geometryBufferRenderer;
  65743. /**
  65744. * Creates a new instance MotionBlurPostProcess
  65745. * @param name The name of the effect.
  65746. * @param scene The scene containing the objects to blur according to their velocity.
  65747. * @param options The required width/height ratio to downsize to before computing the render pass.
  65748. * @param camera The camera to apply the render pass to.
  65749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65750. * @param engine The engine which the post process will be applied. (default: current engine)
  65751. * @param reusable If the post process can be reused on the same frame. (default: false)
  65752. * @param textureType Type of textures used when performing the post process. (default: 0)
  65753. * @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)
  65754. */
  65755. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65756. /**
  65757. * Excludes the given skinned mesh from computing bones velocities.
  65758. * 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.
  65759. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65760. */
  65761. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65762. /**
  65763. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65764. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65765. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65766. */
  65767. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65768. /**
  65769. * Disposes the post process.
  65770. * @param camera The camera to dispose the post process on.
  65771. */
  65772. dispose(camera?: Camera): void;
  65773. }
  65774. }
  65775. declare module BABYLON {
  65776. /** @hidden */
  65777. export var refractionPixelShader: {
  65778. name: string;
  65779. shader: string;
  65780. };
  65781. }
  65782. declare module BABYLON {
  65783. /**
  65784. * Post process which applies a refractin texture
  65785. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65786. */
  65787. export class RefractionPostProcess extends PostProcess {
  65788. /** the base color of the refraction (used to taint the rendering) */
  65789. color: Color3;
  65790. /** simulated refraction depth */
  65791. depth: number;
  65792. /** the coefficient of the base color (0 to remove base color tainting) */
  65793. colorLevel: number;
  65794. private _refTexture;
  65795. private _ownRefractionTexture;
  65796. /**
  65797. * Gets or sets the refraction texture
  65798. * Please note that you are responsible for disposing the texture if you set it manually
  65799. */
  65800. get refractionTexture(): Texture;
  65801. set refractionTexture(value: Texture);
  65802. /**
  65803. * Initializes the RefractionPostProcess
  65804. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65805. * @param name The name of the effect.
  65806. * @param refractionTextureUrl Url of the refraction texture to use
  65807. * @param color the base color of the refraction (used to taint the rendering)
  65808. * @param depth simulated refraction depth
  65809. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65810. * @param camera The camera to apply the render pass to.
  65811. * @param options The required width/height ratio to downsize to before computing the render pass.
  65812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65813. * @param engine The engine which the post process will be applied. (default: current engine)
  65814. * @param reusable If the post process can be reused on the same frame. (default: false)
  65815. */
  65816. constructor(name: string, refractionTextureUrl: string,
  65817. /** the base color of the refraction (used to taint the rendering) */
  65818. color: Color3,
  65819. /** simulated refraction depth */
  65820. depth: number,
  65821. /** the coefficient of the base color (0 to remove base color tainting) */
  65822. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65823. /**
  65824. * Disposes of the post process
  65825. * @param camera Camera to dispose post process on
  65826. */
  65827. dispose(camera: Camera): void;
  65828. }
  65829. }
  65830. declare module BABYLON {
  65831. /** @hidden */
  65832. export var sharpenPixelShader: {
  65833. name: string;
  65834. shader: string;
  65835. };
  65836. }
  65837. declare module BABYLON {
  65838. /**
  65839. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65840. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65841. */
  65842. export class SharpenPostProcess extends PostProcess {
  65843. /**
  65844. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65845. */
  65846. colorAmount: number;
  65847. /**
  65848. * How much sharpness should be applied (default: 0.3)
  65849. */
  65850. edgeAmount: number;
  65851. /**
  65852. * Creates a new instance ConvolutionPostProcess
  65853. * @param name The name of the effect.
  65854. * @param options The required width/height ratio to downsize to before computing the render pass.
  65855. * @param camera The camera to apply the render pass to.
  65856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65857. * @param engine The engine which the post process will be applied. (default: current engine)
  65858. * @param reusable If the post process can be reused on the same frame. (default: false)
  65859. * @param textureType Type of textures used when performing the post process. (default: 0)
  65860. * @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)
  65861. */
  65862. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65863. }
  65864. }
  65865. declare module BABYLON {
  65866. /**
  65867. * PostProcessRenderPipeline
  65868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65869. */
  65870. export class PostProcessRenderPipeline {
  65871. private engine;
  65872. private _renderEffects;
  65873. private _renderEffectsForIsolatedPass;
  65874. /**
  65875. * List of inspectable custom properties (used by the Inspector)
  65876. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65877. */
  65878. inspectableCustomProperties: IInspectable[];
  65879. /**
  65880. * @hidden
  65881. */
  65882. protected _cameras: Camera[];
  65883. /** @hidden */
  65884. _name: string;
  65885. /**
  65886. * Gets pipeline name
  65887. */
  65888. get name(): string;
  65889. /** Gets the list of attached cameras */
  65890. get cameras(): Camera[];
  65891. /**
  65892. * Initializes a PostProcessRenderPipeline
  65893. * @param engine engine to add the pipeline to
  65894. * @param name name of the pipeline
  65895. */
  65896. constructor(engine: Engine, name: string);
  65897. /**
  65898. * Gets the class name
  65899. * @returns "PostProcessRenderPipeline"
  65900. */
  65901. getClassName(): string;
  65902. /**
  65903. * If all the render effects in the pipeline are supported
  65904. */
  65905. get isSupported(): boolean;
  65906. /**
  65907. * Adds an effect to the pipeline
  65908. * @param renderEffect the effect to add
  65909. */
  65910. addEffect(renderEffect: PostProcessRenderEffect): void;
  65911. /** @hidden */
  65912. _rebuild(): void;
  65913. /** @hidden */
  65914. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65915. /** @hidden */
  65916. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65917. /** @hidden */
  65918. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65919. /** @hidden */
  65920. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65921. /** @hidden */
  65922. _attachCameras(cameras: Camera, unique: boolean): void;
  65923. /** @hidden */
  65924. _attachCameras(cameras: Camera[], unique: boolean): void;
  65925. /** @hidden */
  65926. _detachCameras(cameras: Camera): void;
  65927. /** @hidden */
  65928. _detachCameras(cameras: Nullable<Camera[]>): void;
  65929. /** @hidden */
  65930. _update(): void;
  65931. /** @hidden */
  65932. _reset(): void;
  65933. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65934. /**
  65935. * Disposes of the pipeline
  65936. */
  65937. dispose(): void;
  65938. }
  65939. }
  65940. declare module BABYLON {
  65941. /**
  65942. * PostProcessRenderPipelineManager class
  65943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65944. */
  65945. export class PostProcessRenderPipelineManager {
  65946. private _renderPipelines;
  65947. /**
  65948. * Initializes a PostProcessRenderPipelineManager
  65949. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65950. */
  65951. constructor();
  65952. /**
  65953. * Gets the list of supported render pipelines
  65954. */
  65955. get supportedPipelines(): PostProcessRenderPipeline[];
  65956. /**
  65957. * Adds a pipeline to the manager
  65958. * @param renderPipeline The pipeline to add
  65959. */
  65960. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65961. /**
  65962. * Attaches a camera to the pipeline
  65963. * @param renderPipelineName The name of the pipeline to attach to
  65964. * @param cameras the camera to attach
  65965. * @param unique if the camera can be attached multiple times to the pipeline
  65966. */
  65967. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65968. /**
  65969. * Detaches a camera from the pipeline
  65970. * @param renderPipelineName The name of the pipeline to detach from
  65971. * @param cameras the camera to detach
  65972. */
  65973. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65974. /**
  65975. * Enables an effect by name on a pipeline
  65976. * @param renderPipelineName the name of the pipeline to enable the effect in
  65977. * @param renderEffectName the name of the effect to enable
  65978. * @param cameras the cameras that the effect should be enabled on
  65979. */
  65980. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65981. /**
  65982. * Disables an effect by name on a pipeline
  65983. * @param renderPipelineName the name of the pipeline to disable the effect in
  65984. * @param renderEffectName the name of the effect to disable
  65985. * @param cameras the cameras that the effect should be disabled on
  65986. */
  65987. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65988. /**
  65989. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65990. */
  65991. update(): void;
  65992. /** @hidden */
  65993. _rebuild(): void;
  65994. /**
  65995. * Disposes of the manager and pipelines
  65996. */
  65997. dispose(): void;
  65998. }
  65999. }
  66000. declare module BABYLON {
  66001. interface Scene {
  66002. /** @hidden (Backing field) */
  66003. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66004. /**
  66005. * Gets the postprocess render pipeline manager
  66006. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66007. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66008. */
  66009. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66010. }
  66011. /**
  66012. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66013. */
  66014. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66015. /**
  66016. * The component name helpfull to identify the component in the list of scene components.
  66017. */
  66018. readonly name: string;
  66019. /**
  66020. * The scene the component belongs to.
  66021. */
  66022. scene: Scene;
  66023. /**
  66024. * Creates a new instance of the component for the given scene
  66025. * @param scene Defines the scene to register the component in
  66026. */
  66027. constructor(scene: Scene);
  66028. /**
  66029. * Registers the component in a given scene
  66030. */
  66031. register(): void;
  66032. /**
  66033. * Rebuilds the elements related to this component in case of
  66034. * context lost for instance.
  66035. */
  66036. rebuild(): void;
  66037. /**
  66038. * Disposes the component and the associated ressources
  66039. */
  66040. dispose(): void;
  66041. private _gatherRenderTargets;
  66042. }
  66043. }
  66044. declare module BABYLON {
  66045. /**
  66046. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66047. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66048. */
  66049. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66050. private _scene;
  66051. private _camerasToBeAttached;
  66052. /**
  66053. * ID of the sharpen post process,
  66054. */
  66055. private readonly SharpenPostProcessId;
  66056. /**
  66057. * @ignore
  66058. * ID of the image processing post process;
  66059. */
  66060. readonly ImageProcessingPostProcessId: string;
  66061. /**
  66062. * @ignore
  66063. * ID of the Fast Approximate Anti-Aliasing post process;
  66064. */
  66065. readonly FxaaPostProcessId: string;
  66066. /**
  66067. * ID of the chromatic aberration post process,
  66068. */
  66069. private readonly ChromaticAberrationPostProcessId;
  66070. /**
  66071. * ID of the grain post process
  66072. */
  66073. private readonly GrainPostProcessId;
  66074. /**
  66075. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66076. */
  66077. sharpen: SharpenPostProcess;
  66078. private _sharpenEffect;
  66079. private bloom;
  66080. /**
  66081. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66082. */
  66083. depthOfField: DepthOfFieldEffect;
  66084. /**
  66085. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66086. */
  66087. fxaa: FxaaPostProcess;
  66088. /**
  66089. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66090. */
  66091. imageProcessing: ImageProcessingPostProcess;
  66092. /**
  66093. * Chromatic aberration post process which will shift rgb colors in the image
  66094. */
  66095. chromaticAberration: ChromaticAberrationPostProcess;
  66096. private _chromaticAberrationEffect;
  66097. /**
  66098. * Grain post process which add noise to the image
  66099. */
  66100. grain: GrainPostProcess;
  66101. private _grainEffect;
  66102. /**
  66103. * Glow post process which adds a glow to emissive areas of the image
  66104. */
  66105. private _glowLayer;
  66106. /**
  66107. * Animations which can be used to tweak settings over a period of time
  66108. */
  66109. animations: Animation[];
  66110. private _imageProcessingConfigurationObserver;
  66111. private _sharpenEnabled;
  66112. private _bloomEnabled;
  66113. private _depthOfFieldEnabled;
  66114. private _depthOfFieldBlurLevel;
  66115. private _fxaaEnabled;
  66116. private _imageProcessingEnabled;
  66117. private _defaultPipelineTextureType;
  66118. private _bloomScale;
  66119. private _chromaticAberrationEnabled;
  66120. private _grainEnabled;
  66121. private _buildAllowed;
  66122. /**
  66123. * Gets active scene
  66124. */
  66125. get scene(): Scene;
  66126. /**
  66127. * Enable or disable the sharpen process from the pipeline
  66128. */
  66129. set sharpenEnabled(enabled: boolean);
  66130. get sharpenEnabled(): boolean;
  66131. private _resizeObserver;
  66132. private _hardwareScaleLevel;
  66133. private _bloomKernel;
  66134. /**
  66135. * Specifies the size of the bloom blur kernel, relative to the final output size
  66136. */
  66137. get bloomKernel(): number;
  66138. set bloomKernel(value: number);
  66139. /**
  66140. * Specifies the weight of the bloom in the final rendering
  66141. */
  66142. private _bloomWeight;
  66143. /**
  66144. * Specifies the luma threshold for the area that will be blurred by the bloom
  66145. */
  66146. private _bloomThreshold;
  66147. private _hdr;
  66148. /**
  66149. * The strength of the bloom.
  66150. */
  66151. set bloomWeight(value: number);
  66152. get bloomWeight(): number;
  66153. /**
  66154. * The strength of the bloom.
  66155. */
  66156. set bloomThreshold(value: number);
  66157. get bloomThreshold(): number;
  66158. /**
  66159. * The scale of the bloom, lower value will provide better performance.
  66160. */
  66161. set bloomScale(value: number);
  66162. get bloomScale(): number;
  66163. /**
  66164. * Enable or disable the bloom from the pipeline
  66165. */
  66166. set bloomEnabled(enabled: boolean);
  66167. get bloomEnabled(): boolean;
  66168. private _rebuildBloom;
  66169. /**
  66170. * If the depth of field is enabled.
  66171. */
  66172. get depthOfFieldEnabled(): boolean;
  66173. set depthOfFieldEnabled(enabled: boolean);
  66174. /**
  66175. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66176. */
  66177. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66178. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66179. /**
  66180. * If the anti aliasing is enabled.
  66181. */
  66182. set fxaaEnabled(enabled: boolean);
  66183. get fxaaEnabled(): boolean;
  66184. private _samples;
  66185. /**
  66186. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66187. */
  66188. set samples(sampleCount: number);
  66189. get samples(): number;
  66190. /**
  66191. * If image processing is enabled.
  66192. */
  66193. set imageProcessingEnabled(enabled: boolean);
  66194. get imageProcessingEnabled(): boolean;
  66195. /**
  66196. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66197. */
  66198. set glowLayerEnabled(enabled: boolean);
  66199. get glowLayerEnabled(): boolean;
  66200. /**
  66201. * Gets the glow layer (or null if not defined)
  66202. */
  66203. get glowLayer(): Nullable<GlowLayer>;
  66204. /**
  66205. * Enable or disable the chromaticAberration process from the pipeline
  66206. */
  66207. set chromaticAberrationEnabled(enabled: boolean);
  66208. get chromaticAberrationEnabled(): boolean;
  66209. /**
  66210. * Enable or disable the grain process from the pipeline
  66211. */
  66212. set grainEnabled(enabled: boolean);
  66213. get grainEnabled(): boolean;
  66214. /**
  66215. * @constructor
  66216. * @param name - The rendering pipeline name (default: "")
  66217. * @param hdr - If high dynamic range textures should be used (default: true)
  66218. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66219. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66220. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66221. */
  66222. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66223. /**
  66224. * Get the class name
  66225. * @returns "DefaultRenderingPipeline"
  66226. */
  66227. getClassName(): string;
  66228. /**
  66229. * Force the compilation of the entire pipeline.
  66230. */
  66231. prepare(): void;
  66232. private _hasCleared;
  66233. private _prevPostProcess;
  66234. private _prevPrevPostProcess;
  66235. private _setAutoClearAndTextureSharing;
  66236. private _depthOfFieldSceneObserver;
  66237. private _buildPipeline;
  66238. private _disposePostProcesses;
  66239. /**
  66240. * Adds a camera to the pipeline
  66241. * @param camera the camera to be added
  66242. */
  66243. addCamera(camera: Camera): void;
  66244. /**
  66245. * Removes a camera from the pipeline
  66246. * @param camera the camera to remove
  66247. */
  66248. removeCamera(camera: Camera): void;
  66249. /**
  66250. * Dispose of the pipeline and stop all post processes
  66251. */
  66252. dispose(): void;
  66253. /**
  66254. * Serialize the rendering pipeline (Used when exporting)
  66255. * @returns the serialized object
  66256. */
  66257. serialize(): any;
  66258. /**
  66259. * Parse the serialized pipeline
  66260. * @param source Source pipeline.
  66261. * @param scene The scene to load the pipeline to.
  66262. * @param rootUrl The URL of the serialized pipeline.
  66263. * @returns An instantiated pipeline from the serialized object.
  66264. */
  66265. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66266. }
  66267. }
  66268. declare module BABYLON {
  66269. /** @hidden */
  66270. export var lensHighlightsPixelShader: {
  66271. name: string;
  66272. shader: string;
  66273. };
  66274. }
  66275. declare module BABYLON {
  66276. /** @hidden */
  66277. export var depthOfFieldPixelShader: {
  66278. name: string;
  66279. shader: string;
  66280. };
  66281. }
  66282. declare module BABYLON {
  66283. /**
  66284. * BABYLON.JS Chromatic Aberration GLSL Shader
  66285. * Author: Olivier Guyot
  66286. * Separates very slightly R, G and B colors on the edges of the screen
  66287. * Inspired by Francois Tarlier & Martins Upitis
  66288. */
  66289. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66290. /**
  66291. * @ignore
  66292. * The chromatic aberration PostProcess id in the pipeline
  66293. */
  66294. LensChromaticAberrationEffect: string;
  66295. /**
  66296. * @ignore
  66297. * The highlights enhancing PostProcess id in the pipeline
  66298. */
  66299. HighlightsEnhancingEffect: string;
  66300. /**
  66301. * @ignore
  66302. * The depth-of-field PostProcess id in the pipeline
  66303. */
  66304. LensDepthOfFieldEffect: string;
  66305. private _scene;
  66306. private _depthTexture;
  66307. private _grainTexture;
  66308. private _chromaticAberrationPostProcess;
  66309. private _highlightsPostProcess;
  66310. private _depthOfFieldPostProcess;
  66311. private _edgeBlur;
  66312. private _grainAmount;
  66313. private _chromaticAberration;
  66314. private _distortion;
  66315. private _highlightsGain;
  66316. private _highlightsThreshold;
  66317. private _dofDistance;
  66318. private _dofAperture;
  66319. private _dofDarken;
  66320. private _dofPentagon;
  66321. private _blurNoise;
  66322. /**
  66323. * @constructor
  66324. *
  66325. * Effect parameters are as follow:
  66326. * {
  66327. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66328. * edge_blur: number; // from 0 to x (1 for realism)
  66329. * distortion: number; // from 0 to x (1 for realism)
  66330. * grain_amount: number; // from 0 to 1
  66331. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66332. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66333. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66334. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66335. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66336. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66337. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66338. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66339. * }
  66340. * Note: if an effect parameter is unset, effect is disabled
  66341. *
  66342. * @param name The rendering pipeline name
  66343. * @param parameters - An object containing all parameters (see above)
  66344. * @param scene The scene linked to this pipeline
  66345. * @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)
  66346. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66347. */
  66348. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66349. /**
  66350. * Get the class name
  66351. * @returns "LensRenderingPipeline"
  66352. */
  66353. getClassName(): string;
  66354. /**
  66355. * Gets associated scene
  66356. */
  66357. get scene(): Scene;
  66358. /**
  66359. * Gets or sets the edge blur
  66360. */
  66361. get edgeBlur(): number;
  66362. set edgeBlur(value: number);
  66363. /**
  66364. * Gets or sets the grain amount
  66365. */
  66366. get grainAmount(): number;
  66367. set grainAmount(value: number);
  66368. /**
  66369. * Gets or sets the chromatic aberration amount
  66370. */
  66371. get chromaticAberration(): number;
  66372. set chromaticAberration(value: number);
  66373. /**
  66374. * Gets or sets the depth of field aperture
  66375. */
  66376. get dofAperture(): number;
  66377. set dofAperture(value: number);
  66378. /**
  66379. * Gets or sets the edge distortion
  66380. */
  66381. get edgeDistortion(): number;
  66382. set edgeDistortion(value: number);
  66383. /**
  66384. * Gets or sets the depth of field distortion
  66385. */
  66386. get dofDistortion(): number;
  66387. set dofDistortion(value: number);
  66388. /**
  66389. * Gets or sets the darken out of focus amount
  66390. */
  66391. get darkenOutOfFocus(): number;
  66392. set darkenOutOfFocus(value: number);
  66393. /**
  66394. * Gets or sets a boolean indicating if blur noise is enabled
  66395. */
  66396. get blurNoise(): boolean;
  66397. set blurNoise(value: boolean);
  66398. /**
  66399. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66400. */
  66401. get pentagonBokeh(): boolean;
  66402. set pentagonBokeh(value: boolean);
  66403. /**
  66404. * Gets or sets the highlight grain amount
  66405. */
  66406. get highlightsGain(): number;
  66407. set highlightsGain(value: number);
  66408. /**
  66409. * Gets or sets the highlight threshold
  66410. */
  66411. get highlightsThreshold(): number;
  66412. set highlightsThreshold(value: number);
  66413. /**
  66414. * Sets the amount of blur at the edges
  66415. * @param amount blur amount
  66416. */
  66417. setEdgeBlur(amount: number): void;
  66418. /**
  66419. * Sets edge blur to 0
  66420. */
  66421. disableEdgeBlur(): void;
  66422. /**
  66423. * Sets the amout of grain
  66424. * @param amount Amount of grain
  66425. */
  66426. setGrainAmount(amount: number): void;
  66427. /**
  66428. * Set grain amount to 0
  66429. */
  66430. disableGrain(): void;
  66431. /**
  66432. * Sets the chromatic aberration amount
  66433. * @param amount amount of chromatic aberration
  66434. */
  66435. setChromaticAberration(amount: number): void;
  66436. /**
  66437. * Sets chromatic aberration amount to 0
  66438. */
  66439. disableChromaticAberration(): void;
  66440. /**
  66441. * Sets the EdgeDistortion amount
  66442. * @param amount amount of EdgeDistortion
  66443. */
  66444. setEdgeDistortion(amount: number): void;
  66445. /**
  66446. * Sets edge distortion to 0
  66447. */
  66448. disableEdgeDistortion(): void;
  66449. /**
  66450. * Sets the FocusDistance amount
  66451. * @param amount amount of FocusDistance
  66452. */
  66453. setFocusDistance(amount: number): void;
  66454. /**
  66455. * Disables depth of field
  66456. */
  66457. disableDepthOfField(): void;
  66458. /**
  66459. * Sets the Aperture amount
  66460. * @param amount amount of Aperture
  66461. */
  66462. setAperture(amount: number): void;
  66463. /**
  66464. * Sets the DarkenOutOfFocus amount
  66465. * @param amount amount of DarkenOutOfFocus
  66466. */
  66467. setDarkenOutOfFocus(amount: number): void;
  66468. private _pentagonBokehIsEnabled;
  66469. /**
  66470. * Creates a pentagon bokeh effect
  66471. */
  66472. enablePentagonBokeh(): void;
  66473. /**
  66474. * Disables the pentagon bokeh effect
  66475. */
  66476. disablePentagonBokeh(): void;
  66477. /**
  66478. * Enables noise blur
  66479. */
  66480. enableNoiseBlur(): void;
  66481. /**
  66482. * Disables noise blur
  66483. */
  66484. disableNoiseBlur(): void;
  66485. /**
  66486. * Sets the HighlightsGain amount
  66487. * @param amount amount of HighlightsGain
  66488. */
  66489. setHighlightsGain(amount: number): void;
  66490. /**
  66491. * Sets the HighlightsThreshold amount
  66492. * @param amount amount of HighlightsThreshold
  66493. */
  66494. setHighlightsThreshold(amount: number): void;
  66495. /**
  66496. * Disables highlights
  66497. */
  66498. disableHighlights(): void;
  66499. /**
  66500. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66501. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66502. */
  66503. dispose(disableDepthRender?: boolean): void;
  66504. private _createChromaticAberrationPostProcess;
  66505. private _createHighlightsPostProcess;
  66506. private _createDepthOfFieldPostProcess;
  66507. private _createGrainTexture;
  66508. }
  66509. }
  66510. declare module BABYLON {
  66511. /** @hidden */
  66512. export var ssao2PixelShader: {
  66513. name: string;
  66514. shader: string;
  66515. };
  66516. }
  66517. declare module BABYLON {
  66518. /** @hidden */
  66519. export var ssaoCombinePixelShader: {
  66520. name: string;
  66521. shader: string;
  66522. };
  66523. }
  66524. declare module BABYLON {
  66525. /**
  66526. * Render pipeline to produce ssao effect
  66527. */
  66528. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66529. /**
  66530. * @ignore
  66531. * The PassPostProcess id in the pipeline that contains the original scene color
  66532. */
  66533. SSAOOriginalSceneColorEffect: string;
  66534. /**
  66535. * @ignore
  66536. * The SSAO PostProcess id in the pipeline
  66537. */
  66538. SSAORenderEffect: string;
  66539. /**
  66540. * @ignore
  66541. * The horizontal blur PostProcess id in the pipeline
  66542. */
  66543. SSAOBlurHRenderEffect: string;
  66544. /**
  66545. * @ignore
  66546. * The vertical blur PostProcess id in the pipeline
  66547. */
  66548. SSAOBlurVRenderEffect: string;
  66549. /**
  66550. * @ignore
  66551. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66552. */
  66553. SSAOCombineRenderEffect: string;
  66554. /**
  66555. * The output strength of the SSAO post-process. Default value is 1.0.
  66556. */
  66557. totalStrength: number;
  66558. /**
  66559. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66560. */
  66561. maxZ: number;
  66562. /**
  66563. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66564. */
  66565. minZAspect: number;
  66566. private _samples;
  66567. /**
  66568. * Number of samples used for the SSAO calculations. Default value is 8
  66569. */
  66570. set samples(n: number);
  66571. get samples(): number;
  66572. private _textureSamples;
  66573. /**
  66574. * Number of samples to use for antialiasing
  66575. */
  66576. set textureSamples(n: number);
  66577. get textureSamples(): number;
  66578. /**
  66579. * Ratio object used for SSAO ratio and blur ratio
  66580. */
  66581. private _ratio;
  66582. /**
  66583. * Dynamically generated sphere sampler.
  66584. */
  66585. private _sampleSphere;
  66586. /**
  66587. * Blur filter offsets
  66588. */
  66589. private _samplerOffsets;
  66590. private _expensiveBlur;
  66591. /**
  66592. * If bilateral blur should be used
  66593. */
  66594. set expensiveBlur(b: boolean);
  66595. get expensiveBlur(): boolean;
  66596. /**
  66597. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66598. */
  66599. radius: number;
  66600. /**
  66601. * The base color of the SSAO post-process
  66602. * The final result is "base + ssao" between [0, 1]
  66603. */
  66604. base: number;
  66605. /**
  66606. * Support test.
  66607. */
  66608. static get IsSupported(): boolean;
  66609. private _scene;
  66610. private _depthTexture;
  66611. private _normalTexture;
  66612. private _randomTexture;
  66613. private _originalColorPostProcess;
  66614. private _ssaoPostProcess;
  66615. private _blurHPostProcess;
  66616. private _blurVPostProcess;
  66617. private _ssaoCombinePostProcess;
  66618. /**
  66619. * Gets active scene
  66620. */
  66621. get scene(): Scene;
  66622. /**
  66623. * @constructor
  66624. * @param name The rendering pipeline name
  66625. * @param scene The scene linked to this pipeline
  66626. * @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 }
  66627. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66628. */
  66629. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66630. /**
  66631. * Get the class name
  66632. * @returns "SSAO2RenderingPipeline"
  66633. */
  66634. getClassName(): string;
  66635. /**
  66636. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66637. */
  66638. dispose(disableGeometryBufferRenderer?: boolean): void;
  66639. private _createBlurPostProcess;
  66640. /** @hidden */
  66641. _rebuild(): void;
  66642. private _bits;
  66643. private _radicalInverse_VdC;
  66644. private _hammersley;
  66645. private _hemisphereSample_uniform;
  66646. private _generateHemisphere;
  66647. private _createSSAOPostProcess;
  66648. private _createSSAOCombinePostProcess;
  66649. private _createRandomTexture;
  66650. /**
  66651. * Serialize the rendering pipeline (Used when exporting)
  66652. * @returns the serialized object
  66653. */
  66654. serialize(): any;
  66655. /**
  66656. * Parse the serialized pipeline
  66657. * @param source Source pipeline.
  66658. * @param scene The scene to load the pipeline to.
  66659. * @param rootUrl The URL of the serialized pipeline.
  66660. * @returns An instantiated pipeline from the serialized object.
  66661. */
  66662. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66663. }
  66664. }
  66665. declare module BABYLON {
  66666. /** @hidden */
  66667. export var ssaoPixelShader: {
  66668. name: string;
  66669. shader: string;
  66670. };
  66671. }
  66672. declare module BABYLON {
  66673. /**
  66674. * Render pipeline to produce ssao effect
  66675. */
  66676. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66677. /**
  66678. * @ignore
  66679. * The PassPostProcess id in the pipeline that contains the original scene color
  66680. */
  66681. SSAOOriginalSceneColorEffect: string;
  66682. /**
  66683. * @ignore
  66684. * The SSAO PostProcess id in the pipeline
  66685. */
  66686. SSAORenderEffect: string;
  66687. /**
  66688. * @ignore
  66689. * The horizontal blur PostProcess id in the pipeline
  66690. */
  66691. SSAOBlurHRenderEffect: string;
  66692. /**
  66693. * @ignore
  66694. * The vertical blur PostProcess id in the pipeline
  66695. */
  66696. SSAOBlurVRenderEffect: string;
  66697. /**
  66698. * @ignore
  66699. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66700. */
  66701. SSAOCombineRenderEffect: string;
  66702. /**
  66703. * The output strength of the SSAO post-process. Default value is 1.0.
  66704. */
  66705. totalStrength: number;
  66706. /**
  66707. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66708. */
  66709. radius: number;
  66710. /**
  66711. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66712. * Must not be equal to fallOff and superior to fallOff.
  66713. * Default value is 0.0075
  66714. */
  66715. area: number;
  66716. /**
  66717. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66718. * Must not be equal to area and inferior to area.
  66719. * Default value is 0.000001
  66720. */
  66721. fallOff: number;
  66722. /**
  66723. * The base color of the SSAO post-process
  66724. * The final result is "base + ssao" between [0, 1]
  66725. */
  66726. base: number;
  66727. private _scene;
  66728. private _depthTexture;
  66729. private _randomTexture;
  66730. private _originalColorPostProcess;
  66731. private _ssaoPostProcess;
  66732. private _blurHPostProcess;
  66733. private _blurVPostProcess;
  66734. private _ssaoCombinePostProcess;
  66735. private _firstUpdate;
  66736. /**
  66737. * Gets active scene
  66738. */
  66739. get scene(): Scene;
  66740. /**
  66741. * @constructor
  66742. * @param name - The rendering pipeline name
  66743. * @param scene - The scene linked to this pipeline
  66744. * @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 }
  66745. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66746. */
  66747. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66748. /**
  66749. * Get the class name
  66750. * @returns "SSAORenderingPipeline"
  66751. */
  66752. getClassName(): string;
  66753. /**
  66754. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66755. */
  66756. dispose(disableDepthRender?: boolean): void;
  66757. private _createBlurPostProcess;
  66758. /** @hidden */
  66759. _rebuild(): void;
  66760. private _createSSAOPostProcess;
  66761. private _createSSAOCombinePostProcess;
  66762. private _createRandomTexture;
  66763. }
  66764. }
  66765. declare module BABYLON {
  66766. /** @hidden */
  66767. export var screenSpaceReflectionPixelShader: {
  66768. name: string;
  66769. shader: string;
  66770. };
  66771. }
  66772. declare module BABYLON {
  66773. /**
  66774. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66775. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66776. */
  66777. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66778. /**
  66779. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66780. */
  66781. threshold: number;
  66782. /**
  66783. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66784. */
  66785. strength: number;
  66786. /**
  66787. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66788. */
  66789. reflectionSpecularFalloffExponent: number;
  66790. /**
  66791. * 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]
  66792. */
  66793. step: number;
  66794. /**
  66795. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66796. */
  66797. roughnessFactor: number;
  66798. private _geometryBufferRenderer;
  66799. private _enableSmoothReflections;
  66800. private _reflectionSamples;
  66801. private _smoothSteps;
  66802. /**
  66803. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66804. * @param name The name of the effect.
  66805. * @param scene The scene containing the objects to calculate reflections.
  66806. * @param options The required width/height ratio to downsize to before computing the render pass.
  66807. * @param camera The camera to apply the render pass to.
  66808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66809. * @param engine The engine which the post process will be applied. (default: current engine)
  66810. * @param reusable If the post process can be reused on the same frame. (default: false)
  66811. * @param textureType Type of textures used when performing the post process. (default: 0)
  66812. * @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)
  66813. */
  66814. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66815. /**
  66816. * Gets wether or not smoothing reflections is enabled.
  66817. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66818. */
  66819. get enableSmoothReflections(): boolean;
  66820. /**
  66821. * Sets wether or not smoothing reflections is enabled.
  66822. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66823. */
  66824. set enableSmoothReflections(enabled: boolean);
  66825. /**
  66826. * Gets the number of samples taken while computing reflections. More samples count is high,
  66827. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66828. */
  66829. get reflectionSamples(): number;
  66830. /**
  66831. * Sets the number of samples taken while computing reflections. More samples count is high,
  66832. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66833. */
  66834. set reflectionSamples(samples: number);
  66835. /**
  66836. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66837. * more the post-process will require GPU power and can generate a drop in FPS.
  66838. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66839. */
  66840. get smoothSteps(): number;
  66841. set smoothSteps(steps: number);
  66842. private _updateEffectDefines;
  66843. }
  66844. }
  66845. declare module BABYLON {
  66846. /** @hidden */
  66847. export var standardPixelShader: {
  66848. name: string;
  66849. shader: string;
  66850. };
  66851. }
  66852. declare module BABYLON {
  66853. /**
  66854. * Standard rendering pipeline
  66855. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66856. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66857. */
  66858. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66859. /**
  66860. * Public members
  66861. */
  66862. /**
  66863. * Post-process which contains the original scene color before the pipeline applies all the effects
  66864. */
  66865. originalPostProcess: Nullable<PostProcess>;
  66866. /**
  66867. * Post-process used to down scale an image x4
  66868. */
  66869. downSampleX4PostProcess: Nullable<PostProcess>;
  66870. /**
  66871. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66872. */
  66873. brightPassPostProcess: Nullable<PostProcess>;
  66874. /**
  66875. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66876. */
  66877. blurHPostProcesses: PostProcess[];
  66878. /**
  66879. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66880. */
  66881. blurVPostProcesses: PostProcess[];
  66882. /**
  66883. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66884. */
  66885. textureAdderPostProcess: Nullable<PostProcess>;
  66886. /**
  66887. * Post-process used to create volumetric lighting effect
  66888. */
  66889. volumetricLightPostProcess: Nullable<PostProcess>;
  66890. /**
  66891. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66892. */
  66893. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66894. /**
  66895. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66896. */
  66897. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66898. /**
  66899. * Post-process used to merge the volumetric light effect and the real scene color
  66900. */
  66901. volumetricLightMergePostProces: Nullable<PostProcess>;
  66902. /**
  66903. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66904. */
  66905. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66906. /**
  66907. * Base post-process used to calculate the average luminance of the final image for HDR
  66908. */
  66909. luminancePostProcess: Nullable<PostProcess>;
  66910. /**
  66911. * Post-processes used to create down sample post-processes in order to get
  66912. * the average luminance of the final image for HDR
  66913. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66914. */
  66915. luminanceDownSamplePostProcesses: PostProcess[];
  66916. /**
  66917. * Post-process used to create a HDR effect (light adaptation)
  66918. */
  66919. hdrPostProcess: Nullable<PostProcess>;
  66920. /**
  66921. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66922. */
  66923. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66924. /**
  66925. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66926. */
  66927. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66928. /**
  66929. * Post-process used to merge the final HDR post-process and the real scene color
  66930. */
  66931. hdrFinalPostProcess: Nullable<PostProcess>;
  66932. /**
  66933. * Post-process used to create a lens flare effect
  66934. */
  66935. lensFlarePostProcess: Nullable<PostProcess>;
  66936. /**
  66937. * Post-process that merges the result of the lens flare post-process and the real scene color
  66938. */
  66939. lensFlareComposePostProcess: Nullable<PostProcess>;
  66940. /**
  66941. * Post-process used to create a motion blur effect
  66942. */
  66943. motionBlurPostProcess: Nullable<PostProcess>;
  66944. /**
  66945. * Post-process used to create a depth of field effect
  66946. */
  66947. depthOfFieldPostProcess: Nullable<PostProcess>;
  66948. /**
  66949. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66950. */
  66951. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66952. /**
  66953. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66954. */
  66955. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66956. /**
  66957. * Represents the brightness threshold in order to configure the illuminated surfaces
  66958. */
  66959. brightThreshold: number;
  66960. /**
  66961. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66962. */
  66963. blurWidth: number;
  66964. /**
  66965. * Sets if the blur for highlighted surfaces must be only horizontal
  66966. */
  66967. horizontalBlur: boolean;
  66968. /**
  66969. * Gets the overall exposure used by the pipeline
  66970. */
  66971. get exposure(): number;
  66972. /**
  66973. * Sets the overall exposure used by the pipeline
  66974. */
  66975. set exposure(value: number);
  66976. /**
  66977. * Texture used typically to simulate "dirty" on camera lens
  66978. */
  66979. lensTexture: Nullable<Texture>;
  66980. /**
  66981. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66982. */
  66983. volumetricLightCoefficient: number;
  66984. /**
  66985. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66986. */
  66987. volumetricLightPower: number;
  66988. /**
  66989. * Used the set the blur intensity to smooth the volumetric lights
  66990. */
  66991. volumetricLightBlurScale: number;
  66992. /**
  66993. * Light (spot or directional) used to generate the volumetric lights rays
  66994. * The source light must have a shadow generate so the pipeline can get its
  66995. * depth map
  66996. */
  66997. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66998. /**
  66999. * For eye adaptation, represents the minimum luminance the eye can see
  67000. */
  67001. hdrMinimumLuminance: number;
  67002. /**
  67003. * For eye adaptation, represents the decrease luminance speed
  67004. */
  67005. hdrDecreaseRate: number;
  67006. /**
  67007. * For eye adaptation, represents the increase luminance speed
  67008. */
  67009. hdrIncreaseRate: number;
  67010. /**
  67011. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67012. */
  67013. get hdrAutoExposure(): boolean;
  67014. /**
  67015. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67016. */
  67017. set hdrAutoExposure(value: boolean);
  67018. /**
  67019. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  67020. */
  67021. lensColorTexture: Nullable<Texture>;
  67022. /**
  67023. * The overall strengh for the lens flare effect
  67024. */
  67025. lensFlareStrength: number;
  67026. /**
  67027. * Dispersion coefficient for lens flare ghosts
  67028. */
  67029. lensFlareGhostDispersal: number;
  67030. /**
  67031. * Main lens flare halo width
  67032. */
  67033. lensFlareHaloWidth: number;
  67034. /**
  67035. * Based on the lens distortion effect, defines how much the lens flare result
  67036. * is distorted
  67037. */
  67038. lensFlareDistortionStrength: number;
  67039. /**
  67040. * Configures the blur intensity used for for lens flare (halo)
  67041. */
  67042. lensFlareBlurWidth: number;
  67043. /**
  67044. * Lens star texture must be used to simulate rays on the flares and is available
  67045. * in the documentation
  67046. */
  67047. lensStarTexture: Nullable<Texture>;
  67048. /**
  67049. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67050. * flare effect by taking account of the dirt texture
  67051. */
  67052. lensFlareDirtTexture: Nullable<Texture>;
  67053. /**
  67054. * Represents the focal length for the depth of field effect
  67055. */
  67056. depthOfFieldDistance: number;
  67057. /**
  67058. * Represents the blur intensity for the blurred part of the depth of field effect
  67059. */
  67060. depthOfFieldBlurWidth: number;
  67061. /**
  67062. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67063. */
  67064. get motionStrength(): number;
  67065. /**
  67066. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67067. */
  67068. set motionStrength(strength: number);
  67069. /**
  67070. * Gets wether or not the motion blur post-process is object based or screen based.
  67071. */
  67072. get objectBasedMotionBlur(): boolean;
  67073. /**
  67074. * Sets wether or not the motion blur post-process should be object based or screen based
  67075. */
  67076. set objectBasedMotionBlur(value: boolean);
  67077. /**
  67078. * List of animations for the pipeline (IAnimatable implementation)
  67079. */
  67080. animations: Animation[];
  67081. /**
  67082. * Private members
  67083. */
  67084. private _scene;
  67085. private _currentDepthOfFieldSource;
  67086. private _basePostProcess;
  67087. private _fixedExposure;
  67088. private _currentExposure;
  67089. private _hdrAutoExposure;
  67090. private _hdrCurrentLuminance;
  67091. private _motionStrength;
  67092. private _isObjectBasedMotionBlur;
  67093. private _floatTextureType;
  67094. private _camerasToBeAttached;
  67095. private _ratio;
  67096. private _bloomEnabled;
  67097. private _depthOfFieldEnabled;
  67098. private _vlsEnabled;
  67099. private _lensFlareEnabled;
  67100. private _hdrEnabled;
  67101. private _motionBlurEnabled;
  67102. private _fxaaEnabled;
  67103. private _screenSpaceReflectionsEnabled;
  67104. private _motionBlurSamples;
  67105. private _volumetricLightStepsCount;
  67106. private _samples;
  67107. /**
  67108. * @ignore
  67109. * Specifies if the bloom pipeline is enabled
  67110. */
  67111. get BloomEnabled(): boolean;
  67112. set BloomEnabled(enabled: boolean);
  67113. /**
  67114. * @ignore
  67115. * Specifies if the depth of field pipeline is enabed
  67116. */
  67117. get DepthOfFieldEnabled(): boolean;
  67118. set DepthOfFieldEnabled(enabled: boolean);
  67119. /**
  67120. * @ignore
  67121. * Specifies if the lens flare pipeline is enabed
  67122. */
  67123. get LensFlareEnabled(): boolean;
  67124. set LensFlareEnabled(enabled: boolean);
  67125. /**
  67126. * @ignore
  67127. * Specifies if the HDR pipeline is enabled
  67128. */
  67129. get HDREnabled(): boolean;
  67130. set HDREnabled(enabled: boolean);
  67131. /**
  67132. * @ignore
  67133. * Specifies if the volumetric lights scattering effect is enabled
  67134. */
  67135. get VLSEnabled(): boolean;
  67136. set VLSEnabled(enabled: boolean);
  67137. /**
  67138. * @ignore
  67139. * Specifies if the motion blur effect is enabled
  67140. */
  67141. get MotionBlurEnabled(): boolean;
  67142. set MotionBlurEnabled(enabled: boolean);
  67143. /**
  67144. * Specifies if anti-aliasing is enabled
  67145. */
  67146. get fxaaEnabled(): boolean;
  67147. set fxaaEnabled(enabled: boolean);
  67148. /**
  67149. * Specifies if screen space reflections are enabled.
  67150. */
  67151. get screenSpaceReflectionsEnabled(): boolean;
  67152. set screenSpaceReflectionsEnabled(enabled: boolean);
  67153. /**
  67154. * Specifies the number of steps used to calculate the volumetric lights
  67155. * Typically in interval [50, 200]
  67156. */
  67157. get volumetricLightStepsCount(): number;
  67158. set volumetricLightStepsCount(count: number);
  67159. /**
  67160. * Specifies the number of samples used for the motion blur effect
  67161. * Typically in interval [16, 64]
  67162. */
  67163. get motionBlurSamples(): number;
  67164. set motionBlurSamples(samples: number);
  67165. /**
  67166. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67167. */
  67168. get samples(): number;
  67169. set samples(sampleCount: number);
  67170. /**
  67171. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67172. * @constructor
  67173. * @param name The rendering pipeline name
  67174. * @param scene The scene linked to this pipeline
  67175. * @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)
  67176. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67177. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67178. */
  67179. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67180. private _buildPipeline;
  67181. private _createDownSampleX4PostProcess;
  67182. private _createBrightPassPostProcess;
  67183. private _createBlurPostProcesses;
  67184. private _createTextureAdderPostProcess;
  67185. private _createVolumetricLightPostProcess;
  67186. private _createLuminancePostProcesses;
  67187. private _createHdrPostProcess;
  67188. private _createLensFlarePostProcess;
  67189. private _createDepthOfFieldPostProcess;
  67190. private _createMotionBlurPostProcess;
  67191. private _getDepthTexture;
  67192. private _disposePostProcesses;
  67193. /**
  67194. * Dispose of the pipeline and stop all post processes
  67195. */
  67196. dispose(): void;
  67197. /**
  67198. * Serialize the rendering pipeline (Used when exporting)
  67199. * @returns the serialized object
  67200. */
  67201. serialize(): any;
  67202. /**
  67203. * Parse the serialized pipeline
  67204. * @param source Source pipeline.
  67205. * @param scene The scene to load the pipeline to.
  67206. * @param rootUrl The URL of the serialized pipeline.
  67207. * @returns An instantiated pipeline from the serialized object.
  67208. */
  67209. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67210. /**
  67211. * Luminance steps
  67212. */
  67213. static LuminanceSteps: number;
  67214. }
  67215. }
  67216. declare module BABYLON {
  67217. /** @hidden */
  67218. export var tonemapPixelShader: {
  67219. name: string;
  67220. shader: string;
  67221. };
  67222. }
  67223. declare module BABYLON {
  67224. /** Defines operator used for tonemapping */
  67225. export enum TonemappingOperator {
  67226. /** Hable */
  67227. Hable = 0,
  67228. /** Reinhard */
  67229. Reinhard = 1,
  67230. /** HejiDawson */
  67231. HejiDawson = 2,
  67232. /** Photographic */
  67233. Photographic = 3
  67234. }
  67235. /**
  67236. * Defines a post process to apply tone mapping
  67237. */
  67238. export class TonemapPostProcess extends PostProcess {
  67239. private _operator;
  67240. /** Defines the required exposure adjustement */
  67241. exposureAdjustment: number;
  67242. /**
  67243. * Creates a new TonemapPostProcess
  67244. * @param name defines the name of the postprocess
  67245. * @param _operator defines the operator to use
  67246. * @param exposureAdjustment defines the required exposure adjustement
  67247. * @param camera defines the camera to use (can be null)
  67248. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67249. * @param engine defines the hosting engine (can be ignore if camera is set)
  67250. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67251. */
  67252. constructor(name: string, _operator: TonemappingOperator,
  67253. /** Defines the required exposure adjustement */
  67254. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67255. }
  67256. }
  67257. declare module BABYLON {
  67258. /** @hidden */
  67259. export var volumetricLightScatteringPixelShader: {
  67260. name: string;
  67261. shader: string;
  67262. };
  67263. }
  67264. declare module BABYLON {
  67265. /** @hidden */
  67266. export var volumetricLightScatteringPassVertexShader: {
  67267. name: string;
  67268. shader: string;
  67269. };
  67270. }
  67271. declare module BABYLON {
  67272. /** @hidden */
  67273. export var volumetricLightScatteringPassPixelShader: {
  67274. name: string;
  67275. shader: string;
  67276. };
  67277. }
  67278. declare module BABYLON {
  67279. /**
  67280. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67281. */
  67282. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67283. private _volumetricLightScatteringPass;
  67284. private _volumetricLightScatteringRTT;
  67285. private _viewPort;
  67286. private _screenCoordinates;
  67287. private _cachedDefines;
  67288. /**
  67289. * If not undefined, the mesh position is computed from the attached node position
  67290. */
  67291. attachedNode: {
  67292. position: Vector3;
  67293. };
  67294. /**
  67295. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67296. */
  67297. customMeshPosition: Vector3;
  67298. /**
  67299. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67300. */
  67301. useCustomMeshPosition: boolean;
  67302. /**
  67303. * If the post-process should inverse the light scattering direction
  67304. */
  67305. invert: boolean;
  67306. /**
  67307. * The internal mesh used by the post-process
  67308. */
  67309. mesh: Mesh;
  67310. /**
  67311. * @hidden
  67312. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67313. */
  67314. get useDiffuseColor(): boolean;
  67315. set useDiffuseColor(useDiffuseColor: boolean);
  67316. /**
  67317. * Array containing the excluded meshes not rendered in the internal pass
  67318. */
  67319. excludedMeshes: AbstractMesh[];
  67320. /**
  67321. * Controls the overall intensity of the post-process
  67322. */
  67323. exposure: number;
  67324. /**
  67325. * Dissipates each sample's contribution in range [0, 1]
  67326. */
  67327. decay: number;
  67328. /**
  67329. * Controls the overall intensity of each sample
  67330. */
  67331. weight: number;
  67332. /**
  67333. * Controls the density of each sample
  67334. */
  67335. density: number;
  67336. /**
  67337. * @constructor
  67338. * @param name The post-process name
  67339. * @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)
  67340. * @param camera The camera that the post-process will be attached to
  67341. * @param mesh The mesh used to create the light scattering
  67342. * @param samples The post-process quality, default 100
  67343. * @param samplingModeThe post-process filtering mode
  67344. * @param engine The babylon engine
  67345. * @param reusable If the post-process is reusable
  67346. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67347. */
  67348. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67349. /**
  67350. * Returns the string "VolumetricLightScatteringPostProcess"
  67351. * @returns "VolumetricLightScatteringPostProcess"
  67352. */
  67353. getClassName(): string;
  67354. private _isReady;
  67355. /**
  67356. * Sets the new light position for light scattering effect
  67357. * @param position The new custom light position
  67358. */
  67359. setCustomMeshPosition(position: Vector3): void;
  67360. /**
  67361. * Returns the light position for light scattering effect
  67362. * @return Vector3 The custom light position
  67363. */
  67364. getCustomMeshPosition(): Vector3;
  67365. /**
  67366. * Disposes the internal assets and detaches the post-process from the camera
  67367. */
  67368. dispose(camera: Camera): void;
  67369. /**
  67370. * Returns the render target texture used by the post-process
  67371. * @return the render target texture used by the post-process
  67372. */
  67373. getPass(): RenderTargetTexture;
  67374. private _meshExcluded;
  67375. private _createPass;
  67376. private _updateMeshScreenCoordinates;
  67377. /**
  67378. * Creates a default mesh for the Volumeric Light Scattering post-process
  67379. * @param name The mesh name
  67380. * @param scene The scene where to create the mesh
  67381. * @return the default mesh
  67382. */
  67383. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67384. }
  67385. }
  67386. declare module BABYLON {
  67387. interface Scene {
  67388. /** @hidden (Backing field) */
  67389. _boundingBoxRenderer: BoundingBoxRenderer;
  67390. /** @hidden (Backing field) */
  67391. _forceShowBoundingBoxes: boolean;
  67392. /**
  67393. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67394. */
  67395. forceShowBoundingBoxes: boolean;
  67396. /**
  67397. * Gets the bounding box renderer associated with the scene
  67398. * @returns a BoundingBoxRenderer
  67399. */
  67400. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67401. }
  67402. interface AbstractMesh {
  67403. /** @hidden (Backing field) */
  67404. _showBoundingBox: boolean;
  67405. /**
  67406. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67407. */
  67408. showBoundingBox: boolean;
  67409. }
  67410. /**
  67411. * Component responsible of rendering the bounding box of the meshes in a scene.
  67412. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67413. */
  67414. export class BoundingBoxRenderer implements ISceneComponent {
  67415. /**
  67416. * The component name helpfull to identify the component in the list of scene components.
  67417. */
  67418. readonly name: string;
  67419. /**
  67420. * The scene the component belongs to.
  67421. */
  67422. scene: Scene;
  67423. /**
  67424. * Color of the bounding box lines placed in front of an object
  67425. */
  67426. frontColor: Color3;
  67427. /**
  67428. * Color of the bounding box lines placed behind an object
  67429. */
  67430. backColor: Color3;
  67431. /**
  67432. * Defines if the renderer should show the back lines or not
  67433. */
  67434. showBackLines: boolean;
  67435. /**
  67436. * @hidden
  67437. */
  67438. renderList: SmartArray<BoundingBox>;
  67439. private _colorShader;
  67440. private _vertexBuffers;
  67441. private _indexBuffer;
  67442. private _fillIndexBuffer;
  67443. private _fillIndexData;
  67444. /**
  67445. * Instantiates a new bounding box renderer in a scene.
  67446. * @param scene the scene the renderer renders in
  67447. */
  67448. constructor(scene: Scene);
  67449. /**
  67450. * Registers the component in a given scene
  67451. */
  67452. register(): void;
  67453. private _evaluateSubMesh;
  67454. private _activeMesh;
  67455. private _prepareRessources;
  67456. private _createIndexBuffer;
  67457. /**
  67458. * Rebuilds the elements related to this component in case of
  67459. * context lost for instance.
  67460. */
  67461. rebuild(): void;
  67462. /**
  67463. * @hidden
  67464. */
  67465. reset(): void;
  67466. /**
  67467. * Render the bounding boxes of a specific rendering group
  67468. * @param renderingGroupId defines the rendering group to render
  67469. */
  67470. render(renderingGroupId: number): void;
  67471. /**
  67472. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67473. * @param mesh Define the mesh to render the occlusion bounding box for
  67474. */
  67475. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67476. /**
  67477. * Dispose and release the resources attached to this renderer.
  67478. */
  67479. dispose(): void;
  67480. }
  67481. }
  67482. declare module BABYLON {
  67483. interface Scene {
  67484. /** @hidden (Backing field) */
  67485. _depthRenderer: {
  67486. [id: string]: DepthRenderer;
  67487. };
  67488. /**
  67489. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67490. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67491. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67492. * @returns the created depth renderer
  67493. */
  67494. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67495. /**
  67496. * Disables a depth renderer for a given camera
  67497. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67498. */
  67499. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67500. }
  67501. /**
  67502. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67503. * in several rendering techniques.
  67504. */
  67505. export class DepthRendererSceneComponent implements ISceneComponent {
  67506. /**
  67507. * The component name helpfull to identify the component in the list of scene components.
  67508. */
  67509. readonly name: string;
  67510. /**
  67511. * The scene the component belongs to.
  67512. */
  67513. scene: Scene;
  67514. /**
  67515. * Creates a new instance of the component for the given scene
  67516. * @param scene Defines the scene to register the component in
  67517. */
  67518. constructor(scene: Scene);
  67519. /**
  67520. * Registers the component in a given scene
  67521. */
  67522. register(): void;
  67523. /**
  67524. * Rebuilds the elements related to this component in case of
  67525. * context lost for instance.
  67526. */
  67527. rebuild(): void;
  67528. /**
  67529. * Disposes the component and the associated ressources
  67530. */
  67531. dispose(): void;
  67532. private _gatherRenderTargets;
  67533. private _gatherActiveCameraRenderTargets;
  67534. }
  67535. }
  67536. declare module BABYLON {
  67537. /** @hidden */
  67538. export var outlinePixelShader: {
  67539. name: string;
  67540. shader: string;
  67541. };
  67542. }
  67543. declare module BABYLON {
  67544. /** @hidden */
  67545. export var outlineVertexShader: {
  67546. name: string;
  67547. shader: string;
  67548. };
  67549. }
  67550. declare module BABYLON {
  67551. interface Scene {
  67552. /** @hidden */
  67553. _outlineRenderer: OutlineRenderer;
  67554. /**
  67555. * Gets the outline renderer associated with the scene
  67556. * @returns a OutlineRenderer
  67557. */
  67558. getOutlineRenderer(): OutlineRenderer;
  67559. }
  67560. interface AbstractMesh {
  67561. /** @hidden (Backing field) */
  67562. _renderOutline: boolean;
  67563. /**
  67564. * Gets or sets a boolean indicating if the outline must be rendered as well
  67565. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67566. */
  67567. renderOutline: boolean;
  67568. /** @hidden (Backing field) */
  67569. _renderOverlay: boolean;
  67570. /**
  67571. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67572. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67573. */
  67574. renderOverlay: boolean;
  67575. }
  67576. /**
  67577. * This class is responsible to draw bothe outline/overlay of meshes.
  67578. * It should not be used directly but through the available method on mesh.
  67579. */
  67580. export class OutlineRenderer implements ISceneComponent {
  67581. /**
  67582. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67583. */
  67584. private static _StencilReference;
  67585. /**
  67586. * The name of the component. Each component must have a unique name.
  67587. */
  67588. name: string;
  67589. /**
  67590. * The scene the component belongs to.
  67591. */
  67592. scene: Scene;
  67593. /**
  67594. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67595. */
  67596. zOffset: number;
  67597. private _engine;
  67598. private _effect;
  67599. private _cachedDefines;
  67600. private _savedDepthWrite;
  67601. /**
  67602. * Instantiates a new outline renderer. (There could be only one per scene).
  67603. * @param scene Defines the scene it belongs to
  67604. */
  67605. constructor(scene: Scene);
  67606. /**
  67607. * Register the component to one instance of a scene.
  67608. */
  67609. register(): void;
  67610. /**
  67611. * Rebuilds the elements related to this component in case of
  67612. * context lost for instance.
  67613. */
  67614. rebuild(): void;
  67615. /**
  67616. * Disposes the component and the associated ressources.
  67617. */
  67618. dispose(): void;
  67619. /**
  67620. * Renders the outline in the canvas.
  67621. * @param subMesh Defines the sumesh to render
  67622. * @param batch Defines the batch of meshes in case of instances
  67623. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67624. */
  67625. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67626. /**
  67627. * Returns whether or not the outline renderer is ready for a given submesh.
  67628. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67629. * @param subMesh Defines the submesh to check readyness for
  67630. * @param useInstances Defines wheter wee are trying to render instances or not
  67631. * @returns true if ready otherwise false
  67632. */
  67633. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67634. private _beforeRenderingMesh;
  67635. private _afterRenderingMesh;
  67636. }
  67637. }
  67638. declare module BABYLON {
  67639. /**
  67640. * Defines the basic options interface of a Sprite Frame Source Size.
  67641. */
  67642. export interface ISpriteJSONSpriteSourceSize {
  67643. /**
  67644. * number of the original width of the Frame
  67645. */
  67646. w: number;
  67647. /**
  67648. * number of the original height of the Frame
  67649. */
  67650. h: number;
  67651. }
  67652. /**
  67653. * Defines the basic options interface of a Sprite Frame Data.
  67654. */
  67655. export interface ISpriteJSONSpriteFrameData {
  67656. /**
  67657. * number of the x offset of the Frame
  67658. */
  67659. x: number;
  67660. /**
  67661. * number of the y offset of the Frame
  67662. */
  67663. y: number;
  67664. /**
  67665. * number of the width of the Frame
  67666. */
  67667. w: number;
  67668. /**
  67669. * number of the height of the Frame
  67670. */
  67671. h: number;
  67672. }
  67673. /**
  67674. * Defines the basic options interface of a JSON Sprite.
  67675. */
  67676. export interface ISpriteJSONSprite {
  67677. /**
  67678. * string name of the Frame
  67679. */
  67680. filename: string;
  67681. /**
  67682. * ISpriteJSONSpriteFrame basic object of the frame data
  67683. */
  67684. frame: ISpriteJSONSpriteFrameData;
  67685. /**
  67686. * boolean to flag is the frame was rotated.
  67687. */
  67688. rotated: boolean;
  67689. /**
  67690. * boolean to flag is the frame was trimmed.
  67691. */
  67692. trimmed: boolean;
  67693. /**
  67694. * ISpriteJSONSpriteFrame basic object of the source data
  67695. */
  67696. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67697. /**
  67698. * ISpriteJSONSpriteFrame basic object of the source data
  67699. */
  67700. sourceSize: ISpriteJSONSpriteSourceSize;
  67701. }
  67702. /**
  67703. * Defines the basic options interface of a JSON atlas.
  67704. */
  67705. export interface ISpriteJSONAtlas {
  67706. /**
  67707. * Array of objects that contain the frame data.
  67708. */
  67709. frames: Array<ISpriteJSONSprite>;
  67710. /**
  67711. * object basic object containing the sprite meta data.
  67712. */
  67713. meta?: object;
  67714. }
  67715. }
  67716. declare module BABYLON {
  67717. /** @hidden */
  67718. export var spriteMapPixelShader: {
  67719. name: string;
  67720. shader: string;
  67721. };
  67722. }
  67723. declare module BABYLON {
  67724. /** @hidden */
  67725. export var spriteMapVertexShader: {
  67726. name: string;
  67727. shader: string;
  67728. };
  67729. }
  67730. declare module BABYLON {
  67731. /**
  67732. * Defines the basic options interface of a SpriteMap
  67733. */
  67734. export interface ISpriteMapOptions {
  67735. /**
  67736. * Vector2 of the number of cells in the grid.
  67737. */
  67738. stageSize?: Vector2;
  67739. /**
  67740. * Vector2 of the size of the output plane in World Units.
  67741. */
  67742. outputSize?: Vector2;
  67743. /**
  67744. * Vector3 of the position of the output plane in World Units.
  67745. */
  67746. outputPosition?: Vector3;
  67747. /**
  67748. * Vector3 of the rotation of the output plane.
  67749. */
  67750. outputRotation?: Vector3;
  67751. /**
  67752. * number of layers that the system will reserve in resources.
  67753. */
  67754. layerCount?: number;
  67755. /**
  67756. * number of max animation frames a single cell will reserve in resources.
  67757. */
  67758. maxAnimationFrames?: number;
  67759. /**
  67760. * number cell index of the base tile when the system compiles.
  67761. */
  67762. baseTile?: number;
  67763. /**
  67764. * boolean flip the sprite after its been repositioned by the framing data.
  67765. */
  67766. flipU?: boolean;
  67767. /**
  67768. * Vector3 scalar of the global RGB values of the SpriteMap.
  67769. */
  67770. colorMultiply?: Vector3;
  67771. }
  67772. /**
  67773. * Defines the IDisposable interface in order to be cleanable from resources.
  67774. */
  67775. export interface ISpriteMap extends IDisposable {
  67776. /**
  67777. * String name of the SpriteMap.
  67778. */
  67779. name: string;
  67780. /**
  67781. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67782. */
  67783. atlasJSON: ISpriteJSONAtlas;
  67784. /**
  67785. * Texture of the SpriteMap.
  67786. */
  67787. spriteSheet: Texture;
  67788. /**
  67789. * The parameters to initialize the SpriteMap with.
  67790. */
  67791. options: ISpriteMapOptions;
  67792. }
  67793. /**
  67794. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67795. */
  67796. export class SpriteMap implements ISpriteMap {
  67797. /** The Name of the spriteMap */
  67798. name: string;
  67799. /** The JSON file with the frame and meta data */
  67800. atlasJSON: ISpriteJSONAtlas;
  67801. /** The systems Sprite Sheet Texture */
  67802. spriteSheet: Texture;
  67803. /** Arguments passed with the Constructor */
  67804. options: ISpriteMapOptions;
  67805. /** Public Sprite Storage array, parsed from atlasJSON */
  67806. sprites: Array<ISpriteJSONSprite>;
  67807. /** Returns the Number of Sprites in the System */
  67808. get spriteCount(): number;
  67809. /** Returns the Position of Output Plane*/
  67810. get position(): Vector3;
  67811. /** Returns the Position of Output Plane*/
  67812. set position(v: Vector3);
  67813. /** Returns the Rotation of Output Plane*/
  67814. get rotation(): Vector3;
  67815. /** Returns the Rotation of Output Plane*/
  67816. set rotation(v: Vector3);
  67817. /** Sets the AnimationMap*/
  67818. get animationMap(): RawTexture;
  67819. /** Sets the AnimationMap*/
  67820. set animationMap(v: RawTexture);
  67821. /** Scene that the SpriteMap was created in */
  67822. private _scene;
  67823. /** Texture Buffer of Float32 that holds tile frame data*/
  67824. private _frameMap;
  67825. /** Texture Buffers of Float32 that holds tileMap data*/
  67826. private _tileMaps;
  67827. /** Texture Buffer of Float32 that holds Animation Data*/
  67828. private _animationMap;
  67829. /** Custom ShaderMaterial Central to the System*/
  67830. private _material;
  67831. /** Custom ShaderMaterial Central to the System*/
  67832. private _output;
  67833. /** Systems Time Ticker*/
  67834. private _time;
  67835. /**
  67836. * Creates a new SpriteMap
  67837. * @param name defines the SpriteMaps Name
  67838. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67839. * @param spriteSheet is the Texture that the Sprites are on.
  67840. * @param options a basic deployment configuration
  67841. * @param scene The Scene that the map is deployed on
  67842. */
  67843. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67844. /**
  67845. * Returns tileID location
  67846. * @returns Vector2 the cell position ID
  67847. */
  67848. getTileID(): Vector2;
  67849. /**
  67850. * Gets the UV location of the mouse over the SpriteMap.
  67851. * @returns Vector2 the UV position of the mouse interaction
  67852. */
  67853. getMousePosition(): Vector2;
  67854. /**
  67855. * Creates the "frame" texture Buffer
  67856. * -------------------------------------
  67857. * Structure of frames
  67858. * "filename": "Falling-Water-2.png",
  67859. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67860. * "rotated": true,
  67861. * "trimmed": true,
  67862. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67863. * "sourceSize": {"w":32,"h":32}
  67864. * @returns RawTexture of the frameMap
  67865. */
  67866. private _createFrameBuffer;
  67867. /**
  67868. * Creates the tileMap texture Buffer
  67869. * @param buffer normally and array of numbers, or a false to generate from scratch
  67870. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67871. * @returns RawTexture of the tileMap
  67872. */
  67873. private _createTileBuffer;
  67874. /**
  67875. * Modifies the data of the tileMaps
  67876. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67877. * @param pos is the iVector2 Coordinates of the Tile
  67878. * @param tile The SpriteIndex of the new Tile
  67879. */
  67880. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67881. /**
  67882. * Creates the animationMap texture Buffer
  67883. * @param buffer normally and array of numbers, or a false to generate from scratch
  67884. * @returns RawTexture of the animationMap
  67885. */
  67886. private _createTileAnimationBuffer;
  67887. /**
  67888. * Modifies the data of the animationMap
  67889. * @param cellID is the Index of the Sprite
  67890. * @param _frame is the target Animation frame
  67891. * @param toCell is the Target Index of the next frame of the animation
  67892. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67893. * @param speed is a global scalar of the time variable on the map.
  67894. */
  67895. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67896. /**
  67897. * Exports the .tilemaps file
  67898. */
  67899. saveTileMaps(): void;
  67900. /**
  67901. * Imports the .tilemaps file
  67902. * @param url of the .tilemaps file
  67903. */
  67904. loadTileMaps(url: string): void;
  67905. /**
  67906. * Release associated resources
  67907. */
  67908. dispose(): void;
  67909. }
  67910. }
  67911. declare module BABYLON {
  67912. /**
  67913. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67914. * @see http://doc.babylonjs.com/babylon101/sprites
  67915. */
  67916. export class SpritePackedManager extends SpriteManager {
  67917. /** defines the packed manager's name */
  67918. name: string;
  67919. /**
  67920. * Creates a new sprite manager from a packed sprite sheet
  67921. * @param name defines the manager's name
  67922. * @param imgUrl defines the sprite sheet url
  67923. * @param capacity defines the maximum allowed number of sprites
  67924. * @param scene defines the hosting scene
  67925. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67926. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67927. * @param samplingMode defines the smapling mode to use with spritesheet
  67928. * @param fromPacked set to true; do not alter
  67929. */
  67930. constructor(
  67931. /** defines the packed manager's name */
  67932. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67933. }
  67934. }
  67935. declare module BABYLON {
  67936. /**
  67937. * Defines the list of states available for a task inside a AssetsManager
  67938. */
  67939. export enum AssetTaskState {
  67940. /**
  67941. * Initialization
  67942. */
  67943. INIT = 0,
  67944. /**
  67945. * Running
  67946. */
  67947. RUNNING = 1,
  67948. /**
  67949. * Done
  67950. */
  67951. DONE = 2,
  67952. /**
  67953. * Error
  67954. */
  67955. ERROR = 3
  67956. }
  67957. /**
  67958. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67959. */
  67960. export abstract class AbstractAssetTask {
  67961. /**
  67962. * Task name
  67963. */ name: string;
  67964. /**
  67965. * Callback called when the task is successful
  67966. */
  67967. onSuccess: (task: any) => void;
  67968. /**
  67969. * Callback called when the task is not successful
  67970. */
  67971. onError: (task: any, message?: string, exception?: any) => void;
  67972. /**
  67973. * Creates a new AssetsManager
  67974. * @param name defines the name of the task
  67975. */
  67976. constructor(
  67977. /**
  67978. * Task name
  67979. */ name: string);
  67980. private _isCompleted;
  67981. private _taskState;
  67982. private _errorObject;
  67983. /**
  67984. * Get if the task is completed
  67985. */
  67986. get isCompleted(): boolean;
  67987. /**
  67988. * Gets the current state of the task
  67989. */
  67990. get taskState(): AssetTaskState;
  67991. /**
  67992. * Gets the current error object (if task is in error)
  67993. */
  67994. get errorObject(): {
  67995. message?: string;
  67996. exception?: any;
  67997. };
  67998. /**
  67999. * Internal only
  68000. * @hidden
  68001. */
  68002. _setErrorObject(message?: string, exception?: any): void;
  68003. /**
  68004. * Execute the current task
  68005. * @param scene defines the scene where you want your assets to be loaded
  68006. * @param onSuccess is a callback called when the task is successfully executed
  68007. * @param onError is a callback called if an error occurs
  68008. */
  68009. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68010. /**
  68011. * Execute the current task
  68012. * @param scene defines the scene where you want your assets to be loaded
  68013. * @param onSuccess is a callback called when the task is successfully executed
  68014. * @param onError is a callback called if an error occurs
  68015. */
  68016. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68017. /**
  68018. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68019. * This can be used with failed tasks that have the reason for failure fixed.
  68020. */
  68021. reset(): void;
  68022. private onErrorCallback;
  68023. private onDoneCallback;
  68024. }
  68025. /**
  68026. * Define the interface used by progress events raised during assets loading
  68027. */
  68028. export interface IAssetsProgressEvent {
  68029. /**
  68030. * Defines the number of remaining tasks to process
  68031. */
  68032. remainingCount: number;
  68033. /**
  68034. * Defines the total number of tasks
  68035. */
  68036. totalCount: number;
  68037. /**
  68038. * Defines the task that was just processed
  68039. */
  68040. task: AbstractAssetTask;
  68041. }
  68042. /**
  68043. * Class used to share progress information about assets loading
  68044. */
  68045. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68046. /**
  68047. * Defines the number of remaining tasks to process
  68048. */
  68049. remainingCount: number;
  68050. /**
  68051. * Defines the total number of tasks
  68052. */
  68053. totalCount: number;
  68054. /**
  68055. * Defines the task that was just processed
  68056. */
  68057. task: AbstractAssetTask;
  68058. /**
  68059. * Creates a AssetsProgressEvent
  68060. * @param remainingCount defines the number of remaining tasks to process
  68061. * @param totalCount defines the total number of tasks
  68062. * @param task defines the task that was just processed
  68063. */
  68064. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68065. }
  68066. /**
  68067. * Define a task used by AssetsManager to load meshes
  68068. */
  68069. export class MeshAssetTask extends AbstractAssetTask {
  68070. /**
  68071. * Defines the name of the task
  68072. */
  68073. name: string;
  68074. /**
  68075. * Defines the list of mesh's names you want to load
  68076. */
  68077. meshesNames: any;
  68078. /**
  68079. * Defines the root url to use as a base to load your meshes and associated resources
  68080. */
  68081. rootUrl: string;
  68082. /**
  68083. * Defines the filename of the scene to load from
  68084. */
  68085. sceneFilename: string;
  68086. /**
  68087. * Gets the list of loaded meshes
  68088. */
  68089. loadedMeshes: Array<AbstractMesh>;
  68090. /**
  68091. * Gets the list of loaded particle systems
  68092. */
  68093. loadedParticleSystems: Array<IParticleSystem>;
  68094. /**
  68095. * Gets the list of loaded skeletons
  68096. */
  68097. loadedSkeletons: Array<Skeleton>;
  68098. /**
  68099. * Gets the list of loaded animation groups
  68100. */
  68101. loadedAnimationGroups: Array<AnimationGroup>;
  68102. /**
  68103. * Callback called when the task is successful
  68104. */
  68105. onSuccess: (task: MeshAssetTask) => void;
  68106. /**
  68107. * Callback called when the task is successful
  68108. */
  68109. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68110. /**
  68111. * Creates a new MeshAssetTask
  68112. * @param name defines the name of the task
  68113. * @param meshesNames defines the list of mesh's names you want to load
  68114. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68115. * @param sceneFilename defines the filename of the scene to load from
  68116. */
  68117. constructor(
  68118. /**
  68119. * Defines the name of the task
  68120. */
  68121. name: string,
  68122. /**
  68123. * Defines the list of mesh's names you want to load
  68124. */
  68125. meshesNames: any,
  68126. /**
  68127. * Defines the root url to use as a base to load your meshes and associated resources
  68128. */
  68129. rootUrl: string,
  68130. /**
  68131. * Defines the filename of the scene to load from
  68132. */
  68133. sceneFilename: string);
  68134. /**
  68135. * Execute the current task
  68136. * @param scene defines the scene where you want your assets to be loaded
  68137. * @param onSuccess is a callback called when the task is successfully executed
  68138. * @param onError is a callback called if an error occurs
  68139. */
  68140. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68141. }
  68142. /**
  68143. * Define a task used by AssetsManager to load text content
  68144. */
  68145. export class TextFileAssetTask extends AbstractAssetTask {
  68146. /**
  68147. * Defines the name of the task
  68148. */
  68149. name: string;
  68150. /**
  68151. * Defines the location of the file to load
  68152. */
  68153. url: string;
  68154. /**
  68155. * Gets the loaded text string
  68156. */
  68157. text: string;
  68158. /**
  68159. * Callback called when the task is successful
  68160. */
  68161. onSuccess: (task: TextFileAssetTask) => void;
  68162. /**
  68163. * Callback called when the task is successful
  68164. */
  68165. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68166. /**
  68167. * Creates a new TextFileAssetTask object
  68168. * @param name defines the name of the task
  68169. * @param url defines the location of the file to load
  68170. */
  68171. constructor(
  68172. /**
  68173. * Defines the name of the task
  68174. */
  68175. name: string,
  68176. /**
  68177. * Defines the location of the file to load
  68178. */
  68179. url: string);
  68180. /**
  68181. * Execute the current task
  68182. * @param scene defines the scene where you want your assets to be loaded
  68183. * @param onSuccess is a callback called when the task is successfully executed
  68184. * @param onError is a callback called if an error occurs
  68185. */
  68186. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68187. }
  68188. /**
  68189. * Define a task used by AssetsManager to load binary data
  68190. */
  68191. export class BinaryFileAssetTask extends AbstractAssetTask {
  68192. /**
  68193. * Defines the name of the task
  68194. */
  68195. name: string;
  68196. /**
  68197. * Defines the location of the file to load
  68198. */
  68199. url: string;
  68200. /**
  68201. * Gets the lodaded data (as an array buffer)
  68202. */
  68203. data: ArrayBuffer;
  68204. /**
  68205. * Callback called when the task is successful
  68206. */
  68207. onSuccess: (task: BinaryFileAssetTask) => void;
  68208. /**
  68209. * Callback called when the task is successful
  68210. */
  68211. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68212. /**
  68213. * Creates a new BinaryFileAssetTask object
  68214. * @param name defines the name of the new task
  68215. * @param url defines the location of the file to load
  68216. */
  68217. constructor(
  68218. /**
  68219. * Defines the name of the task
  68220. */
  68221. name: string,
  68222. /**
  68223. * Defines the location of the file to load
  68224. */
  68225. url: string);
  68226. /**
  68227. * Execute the current task
  68228. * @param scene defines the scene where you want your assets to be loaded
  68229. * @param onSuccess is a callback called when the task is successfully executed
  68230. * @param onError is a callback called if an error occurs
  68231. */
  68232. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68233. }
  68234. /**
  68235. * Define a task used by AssetsManager to load images
  68236. */
  68237. export class ImageAssetTask extends AbstractAssetTask {
  68238. /**
  68239. * Defines the name of the task
  68240. */
  68241. name: string;
  68242. /**
  68243. * Defines the location of the image to load
  68244. */
  68245. url: string;
  68246. /**
  68247. * Gets the loaded images
  68248. */
  68249. image: HTMLImageElement;
  68250. /**
  68251. * Callback called when the task is successful
  68252. */
  68253. onSuccess: (task: ImageAssetTask) => void;
  68254. /**
  68255. * Callback called when the task is successful
  68256. */
  68257. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68258. /**
  68259. * Creates a new ImageAssetTask
  68260. * @param name defines the name of the task
  68261. * @param url defines the location of the image to load
  68262. */
  68263. constructor(
  68264. /**
  68265. * Defines the name of the task
  68266. */
  68267. name: string,
  68268. /**
  68269. * Defines the location of the image to load
  68270. */
  68271. url: string);
  68272. /**
  68273. * Execute the current task
  68274. * @param scene defines the scene where you want your assets to be loaded
  68275. * @param onSuccess is a callback called when the task is successfully executed
  68276. * @param onError is a callback called if an error occurs
  68277. */
  68278. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68279. }
  68280. /**
  68281. * Defines the interface used by texture loading tasks
  68282. */
  68283. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68284. /**
  68285. * Gets the loaded texture
  68286. */
  68287. texture: TEX;
  68288. }
  68289. /**
  68290. * Define a task used by AssetsManager to load 2D textures
  68291. */
  68292. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68293. /**
  68294. * Defines the name of the task
  68295. */
  68296. name: string;
  68297. /**
  68298. * Defines the location of the file to load
  68299. */
  68300. url: string;
  68301. /**
  68302. * Defines if mipmap should not be generated (default is false)
  68303. */
  68304. noMipmap?: boolean | undefined;
  68305. /**
  68306. * Defines if texture must be inverted on Y axis (default is true)
  68307. */
  68308. invertY: boolean;
  68309. /**
  68310. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68311. */
  68312. samplingMode: number;
  68313. /**
  68314. * Gets the loaded texture
  68315. */
  68316. texture: Texture;
  68317. /**
  68318. * Callback called when the task is successful
  68319. */
  68320. onSuccess: (task: TextureAssetTask) => void;
  68321. /**
  68322. * Callback called when the task is successful
  68323. */
  68324. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68325. /**
  68326. * Creates a new TextureAssetTask object
  68327. * @param name defines the name of the task
  68328. * @param url defines the location of the file to load
  68329. * @param noMipmap defines if mipmap should not be generated (default is false)
  68330. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68331. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68332. */
  68333. constructor(
  68334. /**
  68335. * Defines the name of the task
  68336. */
  68337. name: string,
  68338. /**
  68339. * Defines the location of the file to load
  68340. */
  68341. url: string,
  68342. /**
  68343. * Defines if mipmap should not be generated (default is false)
  68344. */
  68345. noMipmap?: boolean | undefined,
  68346. /**
  68347. * Defines if texture must be inverted on Y axis (default is true)
  68348. */
  68349. invertY?: boolean,
  68350. /**
  68351. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68352. */
  68353. samplingMode?: number);
  68354. /**
  68355. * Execute the current task
  68356. * @param scene defines the scene where you want your assets to be loaded
  68357. * @param onSuccess is a callback called when the task is successfully executed
  68358. * @param onError is a callback called if an error occurs
  68359. */
  68360. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68361. }
  68362. /**
  68363. * Define a task used by AssetsManager to load cube textures
  68364. */
  68365. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68366. /**
  68367. * Defines the name of the task
  68368. */
  68369. name: string;
  68370. /**
  68371. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68372. */
  68373. url: string;
  68374. /**
  68375. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68376. */
  68377. extensions?: string[] | undefined;
  68378. /**
  68379. * Defines if mipmaps should not be generated (default is false)
  68380. */
  68381. noMipmap?: boolean | undefined;
  68382. /**
  68383. * Defines the explicit list of files (undefined by default)
  68384. */
  68385. files?: string[] | undefined;
  68386. /**
  68387. * Gets the loaded texture
  68388. */
  68389. texture: CubeTexture;
  68390. /**
  68391. * Callback called when the task is successful
  68392. */
  68393. onSuccess: (task: CubeTextureAssetTask) => void;
  68394. /**
  68395. * Callback called when the task is successful
  68396. */
  68397. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68398. /**
  68399. * Creates a new CubeTextureAssetTask
  68400. * @param name defines the name of the task
  68401. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68402. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68403. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68404. * @param files defines the explicit list of files (undefined by default)
  68405. */
  68406. constructor(
  68407. /**
  68408. * Defines the name of the task
  68409. */
  68410. name: string,
  68411. /**
  68412. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68413. */
  68414. url: string,
  68415. /**
  68416. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68417. */
  68418. extensions?: string[] | undefined,
  68419. /**
  68420. * Defines if mipmaps should not be generated (default is false)
  68421. */
  68422. noMipmap?: boolean | undefined,
  68423. /**
  68424. * Defines the explicit list of files (undefined by default)
  68425. */
  68426. files?: string[] | undefined);
  68427. /**
  68428. * Execute the current task
  68429. * @param scene defines the scene where you want your assets to be loaded
  68430. * @param onSuccess is a callback called when the task is successfully executed
  68431. * @param onError is a callback called if an error occurs
  68432. */
  68433. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68434. }
  68435. /**
  68436. * Define a task used by AssetsManager to load HDR cube textures
  68437. */
  68438. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68439. /**
  68440. * Defines the name of the task
  68441. */
  68442. name: string;
  68443. /**
  68444. * Defines the location of the file to load
  68445. */
  68446. url: string;
  68447. /**
  68448. * Defines the desired size (the more it increases the longer the generation will be)
  68449. */
  68450. size: number;
  68451. /**
  68452. * Defines if mipmaps should not be generated (default is false)
  68453. */
  68454. noMipmap: boolean;
  68455. /**
  68456. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68457. */
  68458. generateHarmonics: boolean;
  68459. /**
  68460. * 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)
  68461. */
  68462. gammaSpace: boolean;
  68463. /**
  68464. * Internal Use Only
  68465. */
  68466. reserved: boolean;
  68467. /**
  68468. * Gets the loaded texture
  68469. */
  68470. texture: HDRCubeTexture;
  68471. /**
  68472. * Callback called when the task is successful
  68473. */
  68474. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68475. /**
  68476. * Callback called when the task is successful
  68477. */
  68478. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68479. /**
  68480. * Creates a new HDRCubeTextureAssetTask object
  68481. * @param name defines the name of the task
  68482. * @param url defines the location of the file to load
  68483. * @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.
  68484. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68485. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68486. * @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)
  68487. * @param reserved Internal use only
  68488. */
  68489. constructor(
  68490. /**
  68491. * Defines the name of the task
  68492. */
  68493. name: string,
  68494. /**
  68495. * Defines the location of the file to load
  68496. */
  68497. url: string,
  68498. /**
  68499. * Defines the desired size (the more it increases the longer the generation will be)
  68500. */
  68501. size: number,
  68502. /**
  68503. * Defines if mipmaps should not be generated (default is false)
  68504. */
  68505. noMipmap?: boolean,
  68506. /**
  68507. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68508. */
  68509. generateHarmonics?: boolean,
  68510. /**
  68511. * 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)
  68512. */
  68513. gammaSpace?: boolean,
  68514. /**
  68515. * Internal Use Only
  68516. */
  68517. reserved?: boolean);
  68518. /**
  68519. * Execute the current task
  68520. * @param scene defines the scene where you want your assets to be loaded
  68521. * @param onSuccess is a callback called when the task is successfully executed
  68522. * @param onError is a callback called if an error occurs
  68523. */
  68524. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68525. }
  68526. /**
  68527. * Define a task used by AssetsManager to load Equirectangular cube textures
  68528. */
  68529. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68530. /**
  68531. * Defines the name of the task
  68532. */
  68533. name: string;
  68534. /**
  68535. * Defines the location of the file to load
  68536. */
  68537. url: string;
  68538. /**
  68539. * Defines the desired size (the more it increases the longer the generation will be)
  68540. */
  68541. size: number;
  68542. /**
  68543. * Defines if mipmaps should not be generated (default is false)
  68544. */
  68545. noMipmap: boolean;
  68546. /**
  68547. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68548. * but the standard material would require them in Gamma space) (default is true)
  68549. */
  68550. gammaSpace: boolean;
  68551. /**
  68552. * Gets the loaded texture
  68553. */
  68554. texture: EquiRectangularCubeTexture;
  68555. /**
  68556. * Callback called when the task is successful
  68557. */
  68558. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68559. /**
  68560. * Callback called when the task is successful
  68561. */
  68562. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68563. /**
  68564. * Creates a new EquiRectangularCubeTextureAssetTask object
  68565. * @param name defines the name of the task
  68566. * @param url defines the location of the file to load
  68567. * @param size defines the desired size (the more it increases the longer the generation will be)
  68568. * If the size is omitted this implies you are using a preprocessed cubemap.
  68569. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68570. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68571. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68572. * (default is true)
  68573. */
  68574. constructor(
  68575. /**
  68576. * Defines the name of the task
  68577. */
  68578. name: string,
  68579. /**
  68580. * Defines the location of the file to load
  68581. */
  68582. url: string,
  68583. /**
  68584. * Defines the desired size (the more it increases the longer the generation will be)
  68585. */
  68586. size: number,
  68587. /**
  68588. * Defines if mipmaps should not be generated (default is false)
  68589. */
  68590. noMipmap?: boolean,
  68591. /**
  68592. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68593. * but the standard material would require them in Gamma space) (default is true)
  68594. */
  68595. gammaSpace?: boolean);
  68596. /**
  68597. * Execute the current task
  68598. * @param scene defines the scene where you want your assets to be loaded
  68599. * @param onSuccess is a callback called when the task is successfully executed
  68600. * @param onError is a callback called if an error occurs
  68601. */
  68602. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68603. }
  68604. /**
  68605. * This class can be used to easily import assets into a scene
  68606. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68607. */
  68608. export class AssetsManager {
  68609. private _scene;
  68610. private _isLoading;
  68611. protected _tasks: AbstractAssetTask[];
  68612. protected _waitingTasksCount: number;
  68613. protected _totalTasksCount: number;
  68614. /**
  68615. * Callback called when all tasks are processed
  68616. */
  68617. onFinish: (tasks: AbstractAssetTask[]) => void;
  68618. /**
  68619. * Callback called when a task is successful
  68620. */
  68621. onTaskSuccess: (task: AbstractAssetTask) => void;
  68622. /**
  68623. * Callback called when a task had an error
  68624. */
  68625. onTaskError: (task: AbstractAssetTask) => void;
  68626. /**
  68627. * Callback called when a task is done (whatever the result is)
  68628. */
  68629. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68630. /**
  68631. * Observable called when all tasks are processed
  68632. */
  68633. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68634. /**
  68635. * Observable called when a task had an error
  68636. */
  68637. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68638. /**
  68639. * Observable called when all tasks were executed
  68640. */
  68641. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68642. /**
  68643. * Observable called when a task is done (whatever the result is)
  68644. */
  68645. onProgressObservable: Observable<IAssetsProgressEvent>;
  68646. /**
  68647. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68648. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68649. */
  68650. useDefaultLoadingScreen: boolean;
  68651. /**
  68652. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68653. * when all assets have been downloaded.
  68654. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68655. */
  68656. autoHideLoadingUI: boolean;
  68657. /**
  68658. * Creates a new AssetsManager
  68659. * @param scene defines the scene to work on
  68660. */
  68661. constructor(scene: Scene);
  68662. /**
  68663. * Add a MeshAssetTask to the list of active tasks
  68664. * @param taskName defines the name of the new task
  68665. * @param meshesNames defines the name of meshes to load
  68666. * @param rootUrl defines the root url to use to locate files
  68667. * @param sceneFilename defines the filename of the scene file
  68668. * @returns a new MeshAssetTask object
  68669. */
  68670. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68671. /**
  68672. * Add a TextFileAssetTask to the list of active tasks
  68673. * @param taskName defines the name of the new task
  68674. * @param url defines the url of the file to load
  68675. * @returns a new TextFileAssetTask object
  68676. */
  68677. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68678. /**
  68679. * Add a BinaryFileAssetTask to the list of active tasks
  68680. * @param taskName defines the name of the new task
  68681. * @param url defines the url of the file to load
  68682. * @returns a new BinaryFileAssetTask object
  68683. */
  68684. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68685. /**
  68686. * Add a ImageAssetTask to the list of active tasks
  68687. * @param taskName defines the name of the new task
  68688. * @param url defines the url of the file to load
  68689. * @returns a new ImageAssetTask object
  68690. */
  68691. addImageTask(taskName: string, url: string): ImageAssetTask;
  68692. /**
  68693. * Add a TextureAssetTask to the list of active tasks
  68694. * @param taskName defines the name of the new task
  68695. * @param url defines the url of the file to load
  68696. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68697. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68698. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68699. * @returns a new TextureAssetTask object
  68700. */
  68701. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68702. /**
  68703. * Add a CubeTextureAssetTask to the list of active tasks
  68704. * @param taskName defines the name of the new task
  68705. * @param url defines the url of the file to load
  68706. * @param extensions defines the extension to use to load the cube map (can be null)
  68707. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68708. * @param files defines the list of files to load (can be null)
  68709. * @returns a new CubeTextureAssetTask object
  68710. */
  68711. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68712. /**
  68713. *
  68714. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68715. * @param taskName defines the name of the new task
  68716. * @param url defines the url of the file to load
  68717. * @param size defines the size you want for the cubemap (can be null)
  68718. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68719. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68720. * @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)
  68721. * @param reserved Internal use only
  68722. * @returns a new HDRCubeTextureAssetTask object
  68723. */
  68724. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68725. /**
  68726. *
  68727. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68728. * @param taskName defines the name of the new task
  68729. * @param url defines the url of the file to load
  68730. * @param size defines the size you want for the cubemap (can be null)
  68731. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68732. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68733. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68734. * @returns a new EquiRectangularCubeTextureAssetTask object
  68735. */
  68736. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68737. /**
  68738. * Remove a task from the assets manager.
  68739. * @param task the task to remove
  68740. */
  68741. removeTask(task: AbstractAssetTask): void;
  68742. private _decreaseWaitingTasksCount;
  68743. private _runTask;
  68744. /**
  68745. * Reset the AssetsManager and remove all tasks
  68746. * @return the current instance of the AssetsManager
  68747. */
  68748. reset(): AssetsManager;
  68749. /**
  68750. * Start the loading process
  68751. * @return the current instance of the AssetsManager
  68752. */
  68753. load(): AssetsManager;
  68754. /**
  68755. * Start the loading process as an async operation
  68756. * @return a promise returning the list of failed tasks
  68757. */
  68758. loadAsync(): Promise<void>;
  68759. }
  68760. }
  68761. declare module BABYLON {
  68762. /**
  68763. * Wrapper class for promise with external resolve and reject.
  68764. */
  68765. export class Deferred<T> {
  68766. /**
  68767. * The promise associated with this deferred object.
  68768. */
  68769. readonly promise: Promise<T>;
  68770. private _resolve;
  68771. private _reject;
  68772. /**
  68773. * The resolve method of the promise associated with this deferred object.
  68774. */
  68775. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68776. /**
  68777. * The reject method of the promise associated with this deferred object.
  68778. */
  68779. get reject(): (reason?: any) => void;
  68780. /**
  68781. * Constructor for this deferred object.
  68782. */
  68783. constructor();
  68784. }
  68785. }
  68786. declare module BABYLON {
  68787. /**
  68788. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68789. */
  68790. export class MeshExploder {
  68791. private _centerMesh;
  68792. private _meshes;
  68793. private _meshesOrigins;
  68794. private _toCenterVectors;
  68795. private _scaledDirection;
  68796. private _newPosition;
  68797. private _centerPosition;
  68798. /**
  68799. * Explodes meshes from a center mesh.
  68800. * @param meshes The meshes to explode.
  68801. * @param centerMesh The mesh to be center of explosion.
  68802. */
  68803. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68804. private _setCenterMesh;
  68805. /**
  68806. * Get class name
  68807. * @returns "MeshExploder"
  68808. */
  68809. getClassName(): string;
  68810. /**
  68811. * "Exploded meshes"
  68812. * @returns Array of meshes with the centerMesh at index 0.
  68813. */
  68814. getMeshes(): Array<Mesh>;
  68815. /**
  68816. * Explodes meshes giving a specific direction
  68817. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68818. */
  68819. explode(direction?: number): void;
  68820. }
  68821. }
  68822. declare module BABYLON {
  68823. /**
  68824. * Class used to help managing file picking and drag'n'drop
  68825. */
  68826. export class FilesInput {
  68827. /**
  68828. * List of files ready to be loaded
  68829. */
  68830. static get FilesToLoad(): {
  68831. [key: string]: File;
  68832. };
  68833. /**
  68834. * Callback called when a file is processed
  68835. */
  68836. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68837. private _engine;
  68838. private _currentScene;
  68839. private _sceneLoadedCallback;
  68840. private _progressCallback;
  68841. private _additionalRenderLoopLogicCallback;
  68842. private _textureLoadingCallback;
  68843. private _startingProcessingFilesCallback;
  68844. private _onReloadCallback;
  68845. private _errorCallback;
  68846. private _elementToMonitor;
  68847. private _sceneFileToLoad;
  68848. private _filesToLoad;
  68849. /**
  68850. * Creates a new FilesInput
  68851. * @param engine defines the rendering engine
  68852. * @param scene defines the hosting scene
  68853. * @param sceneLoadedCallback callback called when scene is loaded
  68854. * @param progressCallback callback called to track progress
  68855. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68856. * @param textureLoadingCallback callback called when a texture is loading
  68857. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68858. * @param onReloadCallback callback called when a reload is requested
  68859. * @param errorCallback callback call if an error occurs
  68860. */
  68861. 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);
  68862. private _dragEnterHandler;
  68863. private _dragOverHandler;
  68864. private _dropHandler;
  68865. /**
  68866. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68867. * @param elementToMonitor defines the DOM element to track
  68868. */
  68869. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68870. /**
  68871. * Release all associated resources
  68872. */
  68873. dispose(): void;
  68874. private renderFunction;
  68875. private drag;
  68876. private drop;
  68877. private _traverseFolder;
  68878. private _processFiles;
  68879. /**
  68880. * Load files from a drop event
  68881. * @param event defines the drop event to use as source
  68882. */
  68883. loadFiles(event: any): void;
  68884. private _processReload;
  68885. /**
  68886. * Reload the current scene from the loaded files
  68887. */
  68888. reload(): void;
  68889. }
  68890. }
  68891. declare module BABYLON {
  68892. /**
  68893. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68894. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68895. */
  68896. export class SceneOptimization {
  68897. /**
  68898. * Defines the priority of this optimization (0 by default which means first in the list)
  68899. */
  68900. priority: number;
  68901. /**
  68902. * Gets a string describing the action executed by the current optimization
  68903. * @returns description string
  68904. */
  68905. getDescription(): string;
  68906. /**
  68907. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68908. * @param scene defines the current scene where to apply this optimization
  68909. * @param optimizer defines the current optimizer
  68910. * @returns true if everything that can be done was applied
  68911. */
  68912. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68913. /**
  68914. * Creates the SceneOptimization object
  68915. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68916. * @param desc defines the description associated with the optimization
  68917. */
  68918. constructor(
  68919. /**
  68920. * Defines the priority of this optimization (0 by default which means first in the list)
  68921. */
  68922. priority?: number);
  68923. }
  68924. /**
  68925. * Defines an optimization used to reduce the size of render target textures
  68926. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68927. */
  68928. export class TextureOptimization extends SceneOptimization {
  68929. /**
  68930. * Defines the priority of this optimization (0 by default which means first in the list)
  68931. */
  68932. priority: number;
  68933. /**
  68934. * 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
  68935. */
  68936. maximumSize: number;
  68937. /**
  68938. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68939. */
  68940. step: number;
  68941. /**
  68942. * Gets a string describing the action executed by the current optimization
  68943. * @returns description string
  68944. */
  68945. getDescription(): string;
  68946. /**
  68947. * Creates the TextureOptimization object
  68948. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68949. * @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
  68950. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68951. */
  68952. constructor(
  68953. /**
  68954. * Defines the priority of this optimization (0 by default which means first in the list)
  68955. */
  68956. priority?: number,
  68957. /**
  68958. * 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
  68959. */
  68960. maximumSize?: number,
  68961. /**
  68962. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68963. */
  68964. step?: number);
  68965. /**
  68966. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68967. * @param scene defines the current scene where to apply this optimization
  68968. * @param optimizer defines the current optimizer
  68969. * @returns true if everything that can be done was applied
  68970. */
  68971. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68972. }
  68973. /**
  68974. * Defines an optimization used to increase or decrease the rendering resolution
  68975. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68976. */
  68977. export class HardwareScalingOptimization extends SceneOptimization {
  68978. /**
  68979. * Defines the priority of this optimization (0 by default which means first in the list)
  68980. */
  68981. priority: number;
  68982. /**
  68983. * Defines the maximum scale to use (2 by default)
  68984. */
  68985. maximumScale: number;
  68986. /**
  68987. * Defines the step to use between two passes (0.5 by default)
  68988. */
  68989. step: number;
  68990. private _currentScale;
  68991. private _directionOffset;
  68992. /**
  68993. * Gets a string describing the action executed by the current optimization
  68994. * @return description string
  68995. */
  68996. getDescription(): string;
  68997. /**
  68998. * Creates the HardwareScalingOptimization object
  68999. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69000. * @param maximumScale defines the maximum scale to use (2 by default)
  69001. * @param step defines the step to use between two passes (0.5 by default)
  69002. */
  69003. constructor(
  69004. /**
  69005. * Defines the priority of this optimization (0 by default which means first in the list)
  69006. */
  69007. priority?: number,
  69008. /**
  69009. * Defines the maximum scale to use (2 by default)
  69010. */
  69011. maximumScale?: number,
  69012. /**
  69013. * Defines the step to use between two passes (0.5 by default)
  69014. */
  69015. step?: number);
  69016. /**
  69017. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69018. * @param scene defines the current scene where to apply this optimization
  69019. * @param optimizer defines the current optimizer
  69020. * @returns true if everything that can be done was applied
  69021. */
  69022. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69023. }
  69024. /**
  69025. * Defines an optimization used to remove shadows
  69026. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69027. */
  69028. export class ShadowsOptimization extends SceneOptimization {
  69029. /**
  69030. * Gets a string describing the action executed by the current optimization
  69031. * @return description string
  69032. */
  69033. getDescription(): string;
  69034. /**
  69035. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69036. * @param scene defines the current scene where to apply this optimization
  69037. * @param optimizer defines the current optimizer
  69038. * @returns true if everything that can be done was applied
  69039. */
  69040. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69041. }
  69042. /**
  69043. * Defines an optimization used to turn post-processes off
  69044. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69045. */
  69046. export class PostProcessesOptimization extends SceneOptimization {
  69047. /**
  69048. * Gets a string describing the action executed by the current optimization
  69049. * @return description string
  69050. */
  69051. getDescription(): string;
  69052. /**
  69053. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69054. * @param scene defines the current scene where to apply this optimization
  69055. * @param optimizer defines the current optimizer
  69056. * @returns true if everything that can be done was applied
  69057. */
  69058. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69059. }
  69060. /**
  69061. * Defines an optimization used to turn lens flares off
  69062. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69063. */
  69064. export class LensFlaresOptimization extends SceneOptimization {
  69065. /**
  69066. * Gets a string describing the action executed by the current optimization
  69067. * @return description string
  69068. */
  69069. getDescription(): string;
  69070. /**
  69071. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69072. * @param scene defines the current scene where to apply this optimization
  69073. * @param optimizer defines the current optimizer
  69074. * @returns true if everything that can be done was applied
  69075. */
  69076. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69077. }
  69078. /**
  69079. * Defines an optimization based on user defined callback.
  69080. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69081. */
  69082. export class CustomOptimization extends SceneOptimization {
  69083. /**
  69084. * Callback called to apply the custom optimization.
  69085. */
  69086. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69087. /**
  69088. * Callback called to get custom description
  69089. */
  69090. onGetDescription: () => string;
  69091. /**
  69092. * Gets a string describing the action executed by the current optimization
  69093. * @returns description string
  69094. */
  69095. getDescription(): string;
  69096. /**
  69097. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69098. * @param scene defines the current scene where to apply this optimization
  69099. * @param optimizer defines the current optimizer
  69100. * @returns true if everything that can be done was applied
  69101. */
  69102. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69103. }
  69104. /**
  69105. * Defines an optimization used to turn particles off
  69106. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69107. */
  69108. export class ParticlesOptimization extends SceneOptimization {
  69109. /**
  69110. * Gets a string describing the action executed by the current optimization
  69111. * @return description string
  69112. */
  69113. getDescription(): string;
  69114. /**
  69115. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69116. * @param scene defines the current scene where to apply this optimization
  69117. * @param optimizer defines the current optimizer
  69118. * @returns true if everything that can be done was applied
  69119. */
  69120. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69121. }
  69122. /**
  69123. * Defines an optimization used to turn render targets off
  69124. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69125. */
  69126. export class RenderTargetsOptimization extends SceneOptimization {
  69127. /**
  69128. * Gets a string describing the action executed by the current optimization
  69129. * @return description string
  69130. */
  69131. getDescription(): string;
  69132. /**
  69133. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69134. * @param scene defines the current scene where to apply this optimization
  69135. * @param optimizer defines the current optimizer
  69136. * @returns true if everything that can be done was applied
  69137. */
  69138. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69139. }
  69140. /**
  69141. * Defines an optimization used to merge meshes with compatible materials
  69142. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69143. */
  69144. export class MergeMeshesOptimization extends SceneOptimization {
  69145. private static _UpdateSelectionTree;
  69146. /**
  69147. * Gets or sets a boolean which defines if optimization octree has to be updated
  69148. */
  69149. static get UpdateSelectionTree(): boolean;
  69150. /**
  69151. * Gets or sets a boolean which defines if optimization octree has to be updated
  69152. */
  69153. static set UpdateSelectionTree(value: boolean);
  69154. /**
  69155. * Gets a string describing the action executed by the current optimization
  69156. * @return description string
  69157. */
  69158. getDescription(): string;
  69159. private _canBeMerged;
  69160. /**
  69161. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69162. * @param scene defines the current scene where to apply this optimization
  69163. * @param optimizer defines the current optimizer
  69164. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69165. * @returns true if everything that can be done was applied
  69166. */
  69167. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69168. }
  69169. /**
  69170. * Defines a list of options used by SceneOptimizer
  69171. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69172. */
  69173. export class SceneOptimizerOptions {
  69174. /**
  69175. * Defines the target frame rate to reach (60 by default)
  69176. */
  69177. targetFrameRate: number;
  69178. /**
  69179. * Defines the interval between two checkes (2000ms by default)
  69180. */
  69181. trackerDuration: number;
  69182. /**
  69183. * Gets the list of optimizations to apply
  69184. */
  69185. optimizations: SceneOptimization[];
  69186. /**
  69187. * Creates a new list of options used by SceneOptimizer
  69188. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69189. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69190. */
  69191. constructor(
  69192. /**
  69193. * Defines the target frame rate to reach (60 by default)
  69194. */
  69195. targetFrameRate?: number,
  69196. /**
  69197. * Defines the interval between two checkes (2000ms by default)
  69198. */
  69199. trackerDuration?: number);
  69200. /**
  69201. * Add a new optimization
  69202. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69203. * @returns the current SceneOptimizerOptions
  69204. */
  69205. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69206. /**
  69207. * Add a new custom optimization
  69208. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69209. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69210. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69211. * @returns the current SceneOptimizerOptions
  69212. */
  69213. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69214. /**
  69215. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69216. * @param targetFrameRate defines the target frame rate (60 by default)
  69217. * @returns a SceneOptimizerOptions object
  69218. */
  69219. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69220. /**
  69221. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69222. * @param targetFrameRate defines the target frame rate (60 by default)
  69223. * @returns a SceneOptimizerOptions object
  69224. */
  69225. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69226. /**
  69227. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69228. * @param targetFrameRate defines the target frame rate (60 by default)
  69229. * @returns a SceneOptimizerOptions object
  69230. */
  69231. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69232. }
  69233. /**
  69234. * Class used to run optimizations in order to reach a target frame rate
  69235. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69236. */
  69237. export class SceneOptimizer implements IDisposable {
  69238. private _isRunning;
  69239. private _options;
  69240. private _scene;
  69241. private _currentPriorityLevel;
  69242. private _targetFrameRate;
  69243. private _trackerDuration;
  69244. private _currentFrameRate;
  69245. private _sceneDisposeObserver;
  69246. private _improvementMode;
  69247. /**
  69248. * Defines an observable called when the optimizer reaches the target frame rate
  69249. */
  69250. onSuccessObservable: Observable<SceneOptimizer>;
  69251. /**
  69252. * Defines an observable called when the optimizer enables an optimization
  69253. */
  69254. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69255. /**
  69256. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69257. */
  69258. onFailureObservable: Observable<SceneOptimizer>;
  69259. /**
  69260. * Gets a boolean indicating if the optimizer is in improvement mode
  69261. */
  69262. get isInImprovementMode(): boolean;
  69263. /**
  69264. * Gets the current priority level (0 at start)
  69265. */
  69266. get currentPriorityLevel(): number;
  69267. /**
  69268. * Gets the current frame rate checked by the SceneOptimizer
  69269. */
  69270. get currentFrameRate(): number;
  69271. /**
  69272. * Gets or sets the current target frame rate (60 by default)
  69273. */
  69274. get targetFrameRate(): number;
  69275. /**
  69276. * Gets or sets the current target frame rate (60 by default)
  69277. */
  69278. set targetFrameRate(value: number);
  69279. /**
  69280. * Gets or sets the current interval between two checks (every 2000ms by default)
  69281. */
  69282. get trackerDuration(): number;
  69283. /**
  69284. * Gets or sets the current interval between two checks (every 2000ms by default)
  69285. */
  69286. set trackerDuration(value: number);
  69287. /**
  69288. * Gets the list of active optimizations
  69289. */
  69290. get optimizations(): SceneOptimization[];
  69291. /**
  69292. * Creates a new SceneOptimizer
  69293. * @param scene defines the scene to work on
  69294. * @param options defines the options to use with the SceneOptimizer
  69295. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69296. * @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)
  69297. */
  69298. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69299. /**
  69300. * Stops the current optimizer
  69301. */
  69302. stop(): void;
  69303. /**
  69304. * Reset the optimizer to initial step (current priority level = 0)
  69305. */
  69306. reset(): void;
  69307. /**
  69308. * Start the optimizer. By default it will try to reach a specific framerate
  69309. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69310. */
  69311. start(): void;
  69312. private _checkCurrentState;
  69313. /**
  69314. * Release all resources
  69315. */
  69316. dispose(): void;
  69317. /**
  69318. * Helper function to create a SceneOptimizer with one single line of code
  69319. * @param scene defines the scene to work on
  69320. * @param options defines the options to use with the SceneOptimizer
  69321. * @param onSuccess defines a callback to call on success
  69322. * @param onFailure defines a callback to call on failure
  69323. * @returns the new SceneOptimizer object
  69324. */
  69325. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69326. }
  69327. }
  69328. declare module BABYLON {
  69329. /**
  69330. * Class used to serialize a scene into a string
  69331. */
  69332. export class SceneSerializer {
  69333. /**
  69334. * Clear cache used by a previous serialization
  69335. */
  69336. static ClearCache(): void;
  69337. /**
  69338. * Serialize a scene into a JSON compatible object
  69339. * @param scene defines the scene to serialize
  69340. * @returns a JSON compatible object
  69341. */
  69342. static Serialize(scene: Scene): any;
  69343. /**
  69344. * Serialize a mesh into a JSON compatible object
  69345. * @param toSerialize defines the mesh to serialize
  69346. * @param withParents defines if parents must be serialized as well
  69347. * @param withChildren defines if children must be serialized as well
  69348. * @returns a JSON compatible object
  69349. */
  69350. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69351. }
  69352. }
  69353. declare module BABYLON {
  69354. /**
  69355. * Class used to host texture specific utilities
  69356. */
  69357. export class TextureTools {
  69358. /**
  69359. * Uses the GPU to create a copy texture rescaled at a given size
  69360. * @param texture Texture to copy from
  69361. * @param width defines the desired width
  69362. * @param height defines the desired height
  69363. * @param useBilinearMode defines if bilinear mode has to be used
  69364. * @return the generated texture
  69365. */
  69366. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69367. }
  69368. }
  69369. declare module BABYLON {
  69370. /**
  69371. * This represents the different options available for the video capture.
  69372. */
  69373. export interface VideoRecorderOptions {
  69374. /** Defines the mime type of the video. */
  69375. mimeType: string;
  69376. /** Defines the FPS the video should be recorded at. */
  69377. fps: number;
  69378. /** Defines the chunk size for the recording data. */
  69379. recordChunckSize: number;
  69380. /** The audio tracks to attach to the recording. */
  69381. audioTracks?: MediaStreamTrack[];
  69382. }
  69383. /**
  69384. * This can help with recording videos from BabylonJS.
  69385. * This is based on the available WebRTC functionalities of the browser.
  69386. *
  69387. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69388. */
  69389. export class VideoRecorder {
  69390. private static readonly _defaultOptions;
  69391. /**
  69392. * Returns whether or not the VideoRecorder is available in your browser.
  69393. * @param engine Defines the Babylon Engine.
  69394. * @returns true if supported otherwise false.
  69395. */
  69396. static IsSupported(engine: Engine): boolean;
  69397. private readonly _options;
  69398. private _canvas;
  69399. private _mediaRecorder;
  69400. private _recordedChunks;
  69401. private _fileName;
  69402. private _resolve;
  69403. private _reject;
  69404. /**
  69405. * True when a recording is already in progress.
  69406. */
  69407. get isRecording(): boolean;
  69408. /**
  69409. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69410. * @param engine Defines the BabylonJS Engine you wish to record.
  69411. * @param options Defines options that can be used to customize the capture.
  69412. */
  69413. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69414. /**
  69415. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69416. */
  69417. stopRecording(): void;
  69418. /**
  69419. * Starts recording the canvas for a max duration specified in parameters.
  69420. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69421. * If null no automatic download will start and you can rely on the promise to get the data back.
  69422. * @param maxDuration Defines the maximum recording time in seconds.
  69423. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69424. * @return A promise callback at the end of the recording with the video data in Blob.
  69425. */
  69426. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69427. /**
  69428. * Releases internal resources used during the recording.
  69429. */
  69430. dispose(): void;
  69431. private _handleDataAvailable;
  69432. private _handleError;
  69433. private _handleStop;
  69434. }
  69435. }
  69436. declare module BABYLON {
  69437. /**
  69438. * Class containing a set of static utilities functions for screenshots
  69439. */
  69440. export class ScreenshotTools {
  69441. /**
  69442. * Captures a screenshot of the current rendering
  69443. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69444. * @param engine defines the rendering engine
  69445. * @param camera defines the source camera
  69446. * @param size This parameter can be set to a single number or to an object with the
  69447. * following (optional) properties: precision, width, height. If a single number is passed,
  69448. * it will be used for both width and height. If an object is passed, the screenshot size
  69449. * will be derived from the parameters. The precision property is a multiplier allowing
  69450. * rendering at a higher or lower resolution
  69451. * @param successCallback defines the callback receives a single parameter which contains the
  69452. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69453. * src parameter of an <img> to display it
  69454. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69455. * Check your browser for supported MIME types
  69456. */
  69457. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69458. /**
  69459. * Captures a screenshot of the current rendering
  69460. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69461. * @param engine defines the rendering engine
  69462. * @param camera defines the source camera
  69463. * @param size This parameter can be set to a single number or to an object with the
  69464. * following (optional) properties: precision, width, height. If a single number is passed,
  69465. * it will be used for both width and height. If an object is passed, the screenshot size
  69466. * will be derived from the parameters. The precision property is a multiplier allowing
  69467. * rendering at a higher or lower resolution
  69468. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69469. * Check your browser for supported MIME types
  69470. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69471. * to the src parameter of an <img> to display it
  69472. */
  69473. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69474. /**
  69475. * Generates an image screenshot from the specified camera.
  69476. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69477. * @param engine The engine to use for rendering
  69478. * @param camera The camera to use for rendering
  69479. * @param size This parameter can be set to a single number or to an object with the
  69480. * following (optional) properties: precision, width, height. If a single number is passed,
  69481. * it will be used for both width and height. If an object is passed, the screenshot size
  69482. * will be derived from the parameters. The precision property is a multiplier allowing
  69483. * rendering at a higher or lower resolution
  69484. * @param successCallback The callback receives a single parameter which contains the
  69485. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69486. * src parameter of an <img> to display it
  69487. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69488. * Check your browser for supported MIME types
  69489. * @param samples Texture samples (default: 1)
  69490. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69491. * @param fileName A name for for the downloaded file.
  69492. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69493. */
  69494. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69495. /**
  69496. * Generates an image screenshot from the specified camera.
  69497. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69498. * @param engine The engine to use for rendering
  69499. * @param camera The camera to use for rendering
  69500. * @param size This parameter can be set to a single number or to an object with the
  69501. * following (optional) properties: precision, width, height. If a single number is passed,
  69502. * it will be used for both width and height. If an object is passed, the screenshot size
  69503. * will be derived from the parameters. The precision property is a multiplier allowing
  69504. * rendering at a higher or lower resolution
  69505. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69506. * Check your browser for supported MIME types
  69507. * @param samples Texture samples (default: 1)
  69508. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69509. * @param fileName A name for for the downloaded file.
  69510. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69511. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69512. * to the src parameter of an <img> to display it
  69513. */
  69514. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69515. /**
  69516. * Gets height and width for screenshot size
  69517. * @private
  69518. */
  69519. private static _getScreenshotSize;
  69520. }
  69521. }
  69522. declare module BABYLON {
  69523. /**
  69524. * Interface for a data buffer
  69525. */
  69526. export interface IDataBuffer {
  69527. /**
  69528. * Reads bytes from the data buffer.
  69529. * @param byteOffset The byte offset to read
  69530. * @param byteLength The byte length to read
  69531. * @returns A promise that resolves when the bytes are read
  69532. */
  69533. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69534. /**
  69535. * The byte length of the buffer.
  69536. */
  69537. readonly byteLength: number;
  69538. }
  69539. /**
  69540. * Utility class for reading from a data buffer
  69541. */
  69542. export class DataReader {
  69543. /**
  69544. * The data buffer associated with this data reader.
  69545. */
  69546. readonly buffer: IDataBuffer;
  69547. /**
  69548. * The current byte offset from the beginning of the data buffer.
  69549. */
  69550. byteOffset: number;
  69551. private _dataView;
  69552. private _dataByteOffset;
  69553. /**
  69554. * Constructor
  69555. * @param buffer The buffer to read
  69556. */
  69557. constructor(buffer: IDataBuffer);
  69558. /**
  69559. * Loads the given byte length.
  69560. * @param byteLength The byte length to load
  69561. * @returns A promise that resolves when the load is complete
  69562. */
  69563. loadAsync(byteLength: number): Promise<void>;
  69564. /**
  69565. * Read a unsigned 32-bit integer from the currently loaded data range.
  69566. * @returns The 32-bit integer read
  69567. */
  69568. readUint32(): number;
  69569. /**
  69570. * Read a byte array from the currently loaded data range.
  69571. * @param byteLength The byte length to read
  69572. * @returns The byte array read
  69573. */
  69574. readUint8Array(byteLength: number): Uint8Array;
  69575. /**
  69576. * Read a string from the currently loaded data range.
  69577. * @param byteLength The byte length to read
  69578. * @returns The string read
  69579. */
  69580. readString(byteLength: number): string;
  69581. /**
  69582. * Skips the given byte length the currently loaded data range.
  69583. * @param byteLength The byte length to skip
  69584. */
  69585. skipBytes(byteLength: number): void;
  69586. }
  69587. }
  69588. declare module BABYLON {
  69589. /**
  69590. * Class for storing data to local storage if available or in-memory storage otherwise
  69591. */
  69592. export class DataStorage {
  69593. private static _Storage;
  69594. private static _GetStorage;
  69595. /**
  69596. * Reads a string from the data storage
  69597. * @param key The key to read
  69598. * @param defaultValue The value if the key doesn't exist
  69599. * @returns The string value
  69600. */
  69601. static ReadString(key: string, defaultValue: string): string;
  69602. /**
  69603. * Writes a string to the data storage
  69604. * @param key The key to write
  69605. * @param value The value to write
  69606. */
  69607. static WriteString(key: string, value: string): void;
  69608. /**
  69609. * Reads a boolean from the data storage
  69610. * @param key The key to read
  69611. * @param defaultValue The value if the key doesn't exist
  69612. * @returns The boolean value
  69613. */
  69614. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69615. /**
  69616. * Writes a boolean to the data storage
  69617. * @param key The key to write
  69618. * @param value The value to write
  69619. */
  69620. static WriteBoolean(key: string, value: boolean): void;
  69621. /**
  69622. * Reads a number from the data storage
  69623. * @param key The key to read
  69624. * @param defaultValue The value if the key doesn't exist
  69625. * @returns The number value
  69626. */
  69627. static ReadNumber(key: string, defaultValue: number): number;
  69628. /**
  69629. * Writes a number to the data storage
  69630. * @param key The key to write
  69631. * @param value The value to write
  69632. */
  69633. static WriteNumber(key: string, value: number): void;
  69634. }
  69635. }
  69636. declare module BABYLON {
  69637. /**
  69638. * Options used for hit testing
  69639. */
  69640. export interface IWebXRLegacyHitTestOptions {
  69641. /**
  69642. * Only test when user interacted with the scene. Default - hit test every frame
  69643. */
  69644. testOnPointerDownOnly?: boolean;
  69645. /**
  69646. * The node to use to transform the local results to world coordinates
  69647. */
  69648. worldParentNode?: TransformNode;
  69649. }
  69650. /**
  69651. * Interface defining the babylon result of raycasting/hit-test
  69652. */
  69653. export interface IWebXRLegacyHitResult {
  69654. /**
  69655. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69656. */
  69657. transformationMatrix: Matrix;
  69658. /**
  69659. * The native hit test result
  69660. */
  69661. xrHitResult: XRHitResult | XRHitTestResult;
  69662. }
  69663. /**
  69664. * The currently-working hit-test module.
  69665. * Hit test (or Ray-casting) is used to interact with the real world.
  69666. * For further information read here - https://github.com/immersive-web/hit-test
  69667. */
  69668. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69669. /**
  69670. * options to use when constructing this feature
  69671. */
  69672. readonly options: IWebXRLegacyHitTestOptions;
  69673. private _direction;
  69674. private _mat;
  69675. private _onSelectEnabled;
  69676. private _origin;
  69677. /**
  69678. * The module's name
  69679. */
  69680. static readonly Name: string;
  69681. /**
  69682. * The (Babylon) version of this module.
  69683. * This is an integer representing the implementation version.
  69684. * This number does not correspond to the WebXR specs version
  69685. */
  69686. static readonly Version: number;
  69687. /**
  69688. * Populated with the last native XR Hit Results
  69689. */
  69690. lastNativeXRHitResults: XRHitResult[];
  69691. /**
  69692. * Triggered when new babylon (transformed) hit test results are available
  69693. */
  69694. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69695. /**
  69696. * Creates a new instance of the (legacy version) hit test feature
  69697. * @param _xrSessionManager an instance of WebXRSessionManager
  69698. * @param options options to use when constructing this feature
  69699. */
  69700. constructor(_xrSessionManager: WebXRSessionManager,
  69701. /**
  69702. * options to use when constructing this feature
  69703. */
  69704. options?: IWebXRLegacyHitTestOptions);
  69705. /**
  69706. * execute a hit test with an XR Ray
  69707. *
  69708. * @param xrSession a native xrSession that will execute this hit test
  69709. * @param xrRay the ray (position and direction) to use for ray-casting
  69710. * @param referenceSpace native XR reference space to use for the hit-test
  69711. * @param filter filter function that will filter the results
  69712. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69713. */
  69714. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69715. /**
  69716. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69717. * @param event the (select) event to use to select with
  69718. * @param referenceSpace the reference space to use for this hit test
  69719. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69720. */
  69721. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69722. /**
  69723. * attach this feature
  69724. * Will usually be called by the features manager
  69725. *
  69726. * @returns true if successful.
  69727. */
  69728. attach(): boolean;
  69729. /**
  69730. * detach this feature.
  69731. * Will usually be called by the features manager
  69732. *
  69733. * @returns true if successful.
  69734. */
  69735. detach(): boolean;
  69736. /**
  69737. * Dispose this feature and all of the resources attached
  69738. */
  69739. dispose(): void;
  69740. protected _onXRFrame(frame: XRFrame): void;
  69741. private _onHitTestResults;
  69742. private _onSelect;
  69743. }
  69744. }
  69745. declare module BABYLON {
  69746. /**
  69747. * Options used in the plane detector module
  69748. */
  69749. export interface IWebXRPlaneDetectorOptions {
  69750. /**
  69751. * The node to use to transform the local results to world coordinates
  69752. */
  69753. worldParentNode?: TransformNode;
  69754. }
  69755. /**
  69756. * A babylon interface for a WebXR plane.
  69757. * A Plane is actually a polygon, built from N points in space
  69758. *
  69759. * Supported in chrome 79, not supported in canary 81 ATM
  69760. */
  69761. export interface IWebXRPlane {
  69762. /**
  69763. * a babylon-assigned ID for this polygon
  69764. */
  69765. id: number;
  69766. /**
  69767. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69768. */
  69769. polygonDefinition: Array<Vector3>;
  69770. /**
  69771. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69772. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69773. */
  69774. transformationMatrix: Matrix;
  69775. /**
  69776. * the native xr-plane object
  69777. */
  69778. xrPlane: XRPlane;
  69779. }
  69780. /**
  69781. * The plane detector is used to detect planes in the real world when in AR
  69782. * For more information see https://github.com/immersive-web/real-world-geometry/
  69783. */
  69784. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69785. private _options;
  69786. private _detectedPlanes;
  69787. private _enabled;
  69788. private _lastFrameDetected;
  69789. /**
  69790. * The module's name
  69791. */
  69792. static readonly Name: string;
  69793. /**
  69794. * The (Babylon) version of this module.
  69795. * This is an integer representing the implementation version.
  69796. * This number does not correspond to the WebXR specs version
  69797. */
  69798. static readonly Version: number;
  69799. /**
  69800. * Observers registered here will be executed when a new plane was added to the session
  69801. */
  69802. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69803. /**
  69804. * Observers registered here will be executed when a plane is no longer detected in the session
  69805. */
  69806. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69807. /**
  69808. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69809. * This can execute N times every frame
  69810. */
  69811. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69812. /**
  69813. * construct a new Plane Detector
  69814. * @param _xrSessionManager an instance of xr Session manager
  69815. * @param _options configuration to use when constructing this feature
  69816. */
  69817. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69818. /**
  69819. * Dispose this feature and all of the resources attached
  69820. */
  69821. dispose(): void;
  69822. protected _onXRFrame(frame: XRFrame): void;
  69823. private _init;
  69824. private _updatePlaneWithXRPlane;
  69825. /**
  69826. * avoiding using Array.find for global support.
  69827. * @param xrPlane the plane to find in the array
  69828. */
  69829. private findIndexInPlaneArray;
  69830. }
  69831. }
  69832. declare module BABYLON {
  69833. /**
  69834. * Configuration options of the anchor system
  69835. */
  69836. export interface IWebXRAnchorSystemOptions {
  69837. /**
  69838. * Should a new anchor be added every time a select event is triggered
  69839. */
  69840. addAnchorOnSelect?: boolean;
  69841. /**
  69842. * should the anchor system use plane detection.
  69843. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69844. */
  69845. usePlaneDetection?: boolean;
  69846. /**
  69847. * a node that will be used to convert local to world coordinates
  69848. */
  69849. worldParentNode?: TransformNode;
  69850. }
  69851. /**
  69852. * A babylon container for an XR Anchor
  69853. */
  69854. export interface IWebXRAnchor {
  69855. /**
  69856. * A babylon-assigned ID for this anchor
  69857. */
  69858. id: number;
  69859. /**
  69860. * Transformation matrix to apply to an object attached to this anchor
  69861. */
  69862. transformationMatrix: Matrix;
  69863. /**
  69864. * The native anchor object
  69865. */
  69866. xrAnchor: XRAnchor;
  69867. }
  69868. /**
  69869. * An implementation of the anchor system of WebXR.
  69870. * Note that the current documented implementation is not available in any browser. Future implementations
  69871. * will use the frame to create an anchor and not the session or a detected plane
  69872. * For further information see https://github.com/immersive-web/anchors/
  69873. */
  69874. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69875. private _options;
  69876. private _enabled;
  69877. private _hitTestModule;
  69878. private _lastFrameDetected;
  69879. private _onSelect;
  69880. private _planeDetector;
  69881. private _trackedAnchors;
  69882. /**
  69883. * The module's name
  69884. */
  69885. static readonly Name: string;
  69886. /**
  69887. * The (Babylon) version of this module.
  69888. * This is an integer representing the implementation version.
  69889. * This number does not correspond to the WebXR specs version
  69890. */
  69891. static readonly Version: number;
  69892. /**
  69893. * Observers registered here will be executed when a new anchor was added to the session
  69894. */
  69895. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69896. /**
  69897. * Observers registered here will be executed when an anchor was removed from the session
  69898. */
  69899. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69900. /**
  69901. * Observers registered here will be executed when an existing anchor updates
  69902. * This can execute N times every frame
  69903. */
  69904. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69905. /**
  69906. * constructs a new anchor system
  69907. * @param _xrSessionManager an instance of WebXRSessionManager
  69908. * @param _options configuration object for this feature
  69909. */
  69910. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69911. /**
  69912. * Add anchor at a specific XR point.
  69913. *
  69914. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69915. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69916. * @returns a promise the fulfills when the anchor was created
  69917. */
  69918. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69919. /**
  69920. * attach this feature
  69921. * Will usually be called by the features manager
  69922. *
  69923. * @returns true if successful.
  69924. */
  69925. attach(): boolean;
  69926. /**
  69927. * detach this feature.
  69928. * Will usually be called by the features manager
  69929. *
  69930. * @returns true if successful.
  69931. */
  69932. detach(): boolean;
  69933. /**
  69934. * Dispose this feature and all of the resources attached
  69935. */
  69936. dispose(): void;
  69937. /**
  69938. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69939. * @param hitTestModule the hit-test module to use.
  69940. */
  69941. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69942. /**
  69943. * set the plane detector to use in order to create anchors from frames
  69944. * @param planeDetector the plane-detector module to use
  69945. * @param enable enable plane-anchors. default is true
  69946. */
  69947. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69948. protected _onXRFrame(frame: XRFrame): void;
  69949. /**
  69950. * avoiding using Array.find for global support.
  69951. * @param xrAnchor the plane to find in the array
  69952. */
  69953. private _findIndexInAnchorArray;
  69954. private _updateAnchorWithXRFrame;
  69955. }
  69956. }
  69957. declare module BABYLON {
  69958. /**
  69959. * Options interface for the background remover plugin
  69960. */
  69961. export interface IWebXRBackgroundRemoverOptions {
  69962. /**
  69963. * Further background meshes to disable when entering AR
  69964. */
  69965. backgroundMeshes?: AbstractMesh[];
  69966. /**
  69967. * flags to configure the removal of the environment helper.
  69968. * If not set, the entire background will be removed. If set, flags should be set as well.
  69969. */
  69970. environmentHelperRemovalFlags?: {
  69971. /**
  69972. * Should the skybox be removed (default false)
  69973. */
  69974. skyBox?: boolean;
  69975. /**
  69976. * Should the ground be removed (default false)
  69977. */
  69978. ground?: boolean;
  69979. };
  69980. /**
  69981. * don't disable the environment helper
  69982. */
  69983. ignoreEnvironmentHelper?: boolean;
  69984. }
  69985. /**
  69986. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69987. */
  69988. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69989. /**
  69990. * read-only options to be used in this module
  69991. */
  69992. readonly options: IWebXRBackgroundRemoverOptions;
  69993. /**
  69994. * The module's name
  69995. */
  69996. static readonly Name: string;
  69997. /**
  69998. * The (Babylon) version of this module.
  69999. * This is an integer representing the implementation version.
  70000. * This number does not correspond to the WebXR specs version
  70001. */
  70002. static readonly Version: number;
  70003. /**
  70004. * registered observers will be triggered when the background state changes
  70005. */
  70006. onBackgroundStateChangedObservable: Observable<boolean>;
  70007. /**
  70008. * constructs a new background remover module
  70009. * @param _xrSessionManager the session manager for this module
  70010. * @param options read-only options to be used in this module
  70011. */
  70012. constructor(_xrSessionManager: WebXRSessionManager,
  70013. /**
  70014. * read-only options to be used in this module
  70015. */
  70016. options?: IWebXRBackgroundRemoverOptions);
  70017. /**
  70018. * attach this feature
  70019. * Will usually be called by the features manager
  70020. *
  70021. * @returns true if successful.
  70022. */
  70023. attach(): boolean;
  70024. /**
  70025. * detach this feature.
  70026. * Will usually be called by the features manager
  70027. *
  70028. * @returns true if successful.
  70029. */
  70030. detach(): boolean;
  70031. /**
  70032. * Dispose this feature and all of the resources attached
  70033. */
  70034. dispose(): void;
  70035. protected _onXRFrame(_xrFrame: XRFrame): void;
  70036. private _setBackgroundState;
  70037. }
  70038. }
  70039. declare module BABYLON {
  70040. /**
  70041. * Options for the controller physics feature
  70042. */
  70043. export class IWebXRControllerPhysicsOptions {
  70044. /**
  70045. * Should the headset get its own impostor
  70046. */
  70047. enableHeadsetImpostor?: boolean;
  70048. /**
  70049. * Optional parameters for the headset impostor
  70050. */
  70051. headsetImpostorParams?: {
  70052. /**
  70053. * The type of impostor to create. Default is sphere
  70054. */
  70055. impostorType: number;
  70056. /**
  70057. * the size of the impostor. Defaults to 10cm
  70058. */
  70059. impostorSize?: number | {
  70060. width: number;
  70061. height: number;
  70062. depth: number;
  70063. };
  70064. /**
  70065. * Friction definitions
  70066. */
  70067. friction?: number;
  70068. /**
  70069. * Restitution
  70070. */
  70071. restitution?: number;
  70072. };
  70073. /**
  70074. * The physics properties of the future impostors
  70075. */
  70076. physicsProperties?: {
  70077. /**
  70078. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  70079. * Note that this requires a physics engine that supports mesh impostors!
  70080. */
  70081. useControllerMesh?: boolean;
  70082. /**
  70083. * The type of impostor to create. Default is sphere
  70084. */
  70085. impostorType?: number;
  70086. /**
  70087. * the size of the impostor. Defaults to 10cm
  70088. */
  70089. impostorSize?: number | {
  70090. width: number;
  70091. height: number;
  70092. depth: number;
  70093. };
  70094. /**
  70095. * Friction definitions
  70096. */
  70097. friction?: number;
  70098. /**
  70099. * Restitution
  70100. */
  70101. restitution?: number;
  70102. };
  70103. /**
  70104. * the xr input to use with this pointer selection
  70105. */
  70106. xrInput: WebXRInput;
  70107. }
  70108. /**
  70109. * Add physics impostor to your webxr controllers,
  70110. * including naive calculation of their linear and angular velocity
  70111. */
  70112. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  70113. private readonly _options;
  70114. private _attachController;
  70115. private _controllers;
  70116. private _debugMode;
  70117. private _delta;
  70118. private _headsetImpostor?;
  70119. private _headsetMesh?;
  70120. private _lastTimestamp;
  70121. private _tmpQuaternion;
  70122. private _tmpVector;
  70123. /**
  70124. * The module's name
  70125. */
  70126. static readonly Name: string;
  70127. /**
  70128. * The (Babylon) version of this module.
  70129. * This is an integer representing the implementation version.
  70130. * This number does not correspond to the webxr specs version
  70131. */
  70132. static readonly Version: number;
  70133. /**
  70134. * Construct a new Controller Physics Feature
  70135. * @param _xrSessionManager the corresponding xr session manager
  70136. * @param _options options to create this feature with
  70137. */
  70138. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  70139. /**
  70140. * @hidden
  70141. * enable debugging - will show console outputs and the impostor mesh
  70142. */
  70143. _enablePhysicsDebug(): void;
  70144. /**
  70145. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  70146. * @param xrController the controller to add
  70147. */
  70148. addController(xrController: WebXRInputSource): void;
  70149. /**
  70150. * attach this feature
  70151. * Will usually be called by the features manager
  70152. *
  70153. * @returns true if successful.
  70154. */
  70155. attach(): boolean;
  70156. /**
  70157. * detach this feature.
  70158. * Will usually be called by the features manager
  70159. *
  70160. * @returns true if successful.
  70161. */
  70162. detach(): boolean;
  70163. /**
  70164. * Get the headset impostor, if enabled
  70165. * @returns the impostor
  70166. */
  70167. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70168. /**
  70169. * Get the physics impostor of a specific controller.
  70170. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70171. * @param controller the controller or the controller id of which to get the impostor
  70172. * @returns the impostor or null
  70173. */
  70174. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70175. /**
  70176. * Update the physics properties provided in the constructor
  70177. * @param newProperties the new properties object
  70178. */
  70179. setPhysicsProperties(newProperties: {
  70180. impostorType?: number;
  70181. impostorSize?: number | {
  70182. width: number;
  70183. height: number;
  70184. depth: number;
  70185. };
  70186. friction?: number;
  70187. restitution?: number;
  70188. }): void;
  70189. protected _onXRFrame(_xrFrame: any): void;
  70190. private _detachController;
  70191. }
  70192. }
  70193. declare module BABYLON {
  70194. /**
  70195. * Options used for hit testing (version 2)
  70196. */
  70197. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70198. /**
  70199. * Do not create a permanent hit test. Will usually be used when only
  70200. * transient inputs are needed.
  70201. */
  70202. disablePermanentHitTest?: boolean;
  70203. /**
  70204. * Enable transient (for example touch-based) hit test inspections
  70205. */
  70206. enableTransientHitTest?: boolean;
  70207. /**
  70208. * Offset ray for the permanent hit test
  70209. */
  70210. offsetRay?: Vector3;
  70211. /**
  70212. * Offset ray for the transient hit test
  70213. */
  70214. transientOffsetRay?: Vector3;
  70215. /**
  70216. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70217. */
  70218. useReferenceSpace?: boolean;
  70219. }
  70220. /**
  70221. * Interface defining the babylon result of hit-test
  70222. */
  70223. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70224. /**
  70225. * The input source that generated this hit test (if transient)
  70226. */
  70227. inputSource?: XRInputSource;
  70228. /**
  70229. * Is this a transient hit test
  70230. */
  70231. isTransient?: boolean;
  70232. /**
  70233. * Position of the hit test result
  70234. */
  70235. position: Vector3;
  70236. /**
  70237. * Rotation of the hit test result
  70238. */
  70239. rotationQuaternion: Quaternion;
  70240. }
  70241. /**
  70242. * The currently-working hit-test module.
  70243. * Hit test (or Ray-casting) is used to interact with the real world.
  70244. * For further information read here - https://github.com/immersive-web/hit-test
  70245. *
  70246. * Tested on chrome (mobile) 80.
  70247. */
  70248. export class WebXRHitTest extends WebXRAbstractFeature {
  70249. /**
  70250. * options to use when constructing this feature
  70251. */
  70252. readonly options: IWebXRHitTestOptions;
  70253. private _tmpMat;
  70254. private _tmpPos;
  70255. private _tmpQuat;
  70256. private _transientXrHitTestSource;
  70257. private _xrHitTestSource;
  70258. private initHitTestSource;
  70259. /**
  70260. * The module's name
  70261. */
  70262. static readonly Name: string;
  70263. /**
  70264. * The (Babylon) version of this module.
  70265. * This is an integer representing the implementation version.
  70266. * This number does not correspond to the WebXR specs version
  70267. */
  70268. static readonly Version: number;
  70269. /**
  70270. * When set to true, each hit test will have its own position/rotation objects
  70271. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70272. * the developers will clone them or copy them as they see fit.
  70273. */
  70274. autoCloneTransformation: boolean;
  70275. /**
  70276. * Populated with the last native XR Hit Results
  70277. */
  70278. lastNativeXRHitResults: XRHitResult[];
  70279. /**
  70280. * Triggered when new babylon (transformed) hit test results are available
  70281. */
  70282. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70283. /**
  70284. * Use this to temporarily pause hit test checks.
  70285. */
  70286. paused: boolean;
  70287. /**
  70288. * Creates a new instance of the hit test feature
  70289. * @param _xrSessionManager an instance of WebXRSessionManager
  70290. * @param options options to use when constructing this feature
  70291. */
  70292. constructor(_xrSessionManager: WebXRSessionManager,
  70293. /**
  70294. * options to use when constructing this feature
  70295. */
  70296. options?: IWebXRHitTestOptions);
  70297. /**
  70298. * attach this feature
  70299. * Will usually be called by the features manager
  70300. *
  70301. * @returns true if successful.
  70302. */
  70303. attach(): boolean;
  70304. /**
  70305. * detach this feature.
  70306. * Will usually be called by the features manager
  70307. *
  70308. * @returns true if successful.
  70309. */
  70310. detach(): boolean;
  70311. /**
  70312. * Dispose this feature and all of the resources attached
  70313. */
  70314. dispose(): void;
  70315. protected _onXRFrame(frame: XRFrame): void;
  70316. private _processWebXRHitTestResult;
  70317. }
  70318. }
  70319. declare module BABYLON {
  70320. /**
  70321. * The motion controller class for all microsoft mixed reality controllers
  70322. */
  70323. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70324. protected readonly _mapping: {
  70325. defaultButton: {
  70326. valueNodeName: string;
  70327. unpressedNodeName: string;
  70328. pressedNodeName: string;
  70329. };
  70330. defaultAxis: {
  70331. valueNodeName: string;
  70332. minNodeName: string;
  70333. maxNodeName: string;
  70334. };
  70335. buttons: {
  70336. "xr-standard-trigger": {
  70337. rootNodeName: string;
  70338. componentProperty: string;
  70339. states: string[];
  70340. };
  70341. "xr-standard-squeeze": {
  70342. rootNodeName: string;
  70343. componentProperty: string;
  70344. states: string[];
  70345. };
  70346. "xr-standard-touchpad": {
  70347. rootNodeName: string;
  70348. labelAnchorNodeName: string;
  70349. touchPointNodeName: string;
  70350. };
  70351. "xr-standard-thumbstick": {
  70352. rootNodeName: string;
  70353. componentProperty: string;
  70354. states: string[];
  70355. };
  70356. };
  70357. axes: {
  70358. "xr-standard-touchpad": {
  70359. "x-axis": {
  70360. rootNodeName: string;
  70361. };
  70362. "y-axis": {
  70363. rootNodeName: string;
  70364. };
  70365. };
  70366. "xr-standard-thumbstick": {
  70367. "x-axis": {
  70368. rootNodeName: string;
  70369. };
  70370. "y-axis": {
  70371. rootNodeName: string;
  70372. };
  70373. };
  70374. };
  70375. };
  70376. /**
  70377. * The base url used to load the left and right controller models
  70378. */
  70379. static MODEL_BASE_URL: string;
  70380. /**
  70381. * The name of the left controller model file
  70382. */
  70383. static MODEL_LEFT_FILENAME: string;
  70384. /**
  70385. * The name of the right controller model file
  70386. */
  70387. static MODEL_RIGHT_FILENAME: string;
  70388. profileId: string;
  70389. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70390. protected _getFilenameAndPath(): {
  70391. filename: string;
  70392. path: string;
  70393. };
  70394. protected _getModelLoadingConstraints(): boolean;
  70395. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70396. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70397. protected _updateModel(): void;
  70398. }
  70399. }
  70400. declare module BABYLON {
  70401. /**
  70402. * The motion controller class for oculus touch (quest, rift).
  70403. * This class supports legacy mapping as well the standard xr mapping
  70404. */
  70405. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70406. private _forceLegacyControllers;
  70407. private _modelRootNode;
  70408. /**
  70409. * The base url used to load the left and right controller models
  70410. */
  70411. static MODEL_BASE_URL: string;
  70412. /**
  70413. * The name of the left controller model file
  70414. */
  70415. static MODEL_LEFT_FILENAME: string;
  70416. /**
  70417. * The name of the right controller model file
  70418. */
  70419. static MODEL_RIGHT_FILENAME: string;
  70420. /**
  70421. * Base Url for the Quest controller model.
  70422. */
  70423. static QUEST_MODEL_BASE_URL: string;
  70424. profileId: string;
  70425. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70426. protected _getFilenameAndPath(): {
  70427. filename: string;
  70428. path: string;
  70429. };
  70430. protected _getModelLoadingConstraints(): boolean;
  70431. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70432. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70433. protected _updateModel(): void;
  70434. /**
  70435. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70436. * between the touch and touch 2.
  70437. */
  70438. private _isQuest;
  70439. }
  70440. }
  70441. declare module BABYLON {
  70442. /**
  70443. * The motion controller class for the standard HTC-Vive controllers
  70444. */
  70445. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70446. private _modelRootNode;
  70447. /**
  70448. * The base url used to load the left and right controller models
  70449. */
  70450. static MODEL_BASE_URL: string;
  70451. /**
  70452. * File name for the controller model.
  70453. */
  70454. static MODEL_FILENAME: string;
  70455. profileId: string;
  70456. /**
  70457. * Create a new Vive motion controller object
  70458. * @param scene the scene to use to create this controller
  70459. * @param gamepadObject the corresponding gamepad object
  70460. * @param handness the handness of the controller
  70461. */
  70462. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70463. protected _getFilenameAndPath(): {
  70464. filename: string;
  70465. path: string;
  70466. };
  70467. protected _getModelLoadingConstraints(): boolean;
  70468. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70469. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70470. protected _updateModel(): void;
  70471. }
  70472. }
  70473. declare module BABYLON {
  70474. /**
  70475. * A cursor which tracks a point on a path
  70476. */
  70477. export class PathCursor {
  70478. private path;
  70479. /**
  70480. * Stores path cursor callbacks for when an onchange event is triggered
  70481. */
  70482. private _onchange;
  70483. /**
  70484. * The value of the path cursor
  70485. */
  70486. value: number;
  70487. /**
  70488. * The animation array of the path cursor
  70489. */
  70490. animations: Animation[];
  70491. /**
  70492. * Initializes the path cursor
  70493. * @param path The path to track
  70494. */
  70495. constructor(path: Path2);
  70496. /**
  70497. * Gets the cursor point on the path
  70498. * @returns A point on the path cursor at the cursor location
  70499. */
  70500. getPoint(): Vector3;
  70501. /**
  70502. * Moves the cursor ahead by the step amount
  70503. * @param step The amount to move the cursor forward
  70504. * @returns This path cursor
  70505. */
  70506. moveAhead(step?: number): PathCursor;
  70507. /**
  70508. * Moves the cursor behind by the step amount
  70509. * @param step The amount to move the cursor back
  70510. * @returns This path cursor
  70511. */
  70512. moveBack(step?: number): PathCursor;
  70513. /**
  70514. * Moves the cursor by the step amount
  70515. * If the step amount is greater than one, an exception is thrown
  70516. * @param step The amount to move the cursor
  70517. * @returns This path cursor
  70518. */
  70519. move(step: number): PathCursor;
  70520. /**
  70521. * Ensures that the value is limited between zero and one
  70522. * @returns This path cursor
  70523. */
  70524. private ensureLimits;
  70525. /**
  70526. * Runs onchange callbacks on change (used by the animation engine)
  70527. * @returns This path cursor
  70528. */
  70529. private raiseOnChange;
  70530. /**
  70531. * Executes a function on change
  70532. * @param f A path cursor onchange callback
  70533. * @returns This path cursor
  70534. */
  70535. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70536. }
  70537. }
  70538. declare module BABYLON {
  70539. /** @hidden */
  70540. export var blurPixelShader: {
  70541. name: string;
  70542. shader: string;
  70543. };
  70544. }
  70545. declare module BABYLON {
  70546. /** @hidden */
  70547. export var pointCloudVertexDeclaration: {
  70548. name: string;
  70549. shader: string;
  70550. };
  70551. }
  70552. // Mixins
  70553. interface Window {
  70554. mozIndexedDB: IDBFactory;
  70555. webkitIndexedDB: IDBFactory;
  70556. msIndexedDB: IDBFactory;
  70557. webkitURL: typeof URL;
  70558. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70559. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70560. WebGLRenderingContext: WebGLRenderingContext;
  70561. MSGesture: MSGesture;
  70562. CANNON: any;
  70563. AudioContext: AudioContext;
  70564. webkitAudioContext: AudioContext;
  70565. PointerEvent: any;
  70566. Math: Math;
  70567. Uint8Array: Uint8ArrayConstructor;
  70568. Float32Array: Float32ArrayConstructor;
  70569. mozURL: typeof URL;
  70570. msURL: typeof URL;
  70571. VRFrameData: any; // WebVR, from specs 1.1
  70572. DracoDecoderModule: any;
  70573. setImmediate(handler: (...args: any[]) => void): number;
  70574. }
  70575. interface HTMLCanvasElement {
  70576. requestPointerLock(): void;
  70577. msRequestPointerLock?(): void;
  70578. mozRequestPointerLock?(): void;
  70579. webkitRequestPointerLock?(): void;
  70580. /** Track wether a record is in progress */
  70581. isRecording: boolean;
  70582. /** Capture Stream method defined by some browsers */
  70583. captureStream(fps?: number): MediaStream;
  70584. }
  70585. interface CanvasRenderingContext2D {
  70586. msImageSmoothingEnabled: boolean;
  70587. }
  70588. interface MouseEvent {
  70589. mozMovementX: number;
  70590. mozMovementY: number;
  70591. webkitMovementX: number;
  70592. webkitMovementY: number;
  70593. msMovementX: number;
  70594. msMovementY: number;
  70595. }
  70596. interface Navigator {
  70597. mozGetVRDevices: (any: any) => any;
  70598. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70599. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70600. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70601. webkitGetGamepads(): Gamepad[];
  70602. msGetGamepads(): Gamepad[];
  70603. webkitGamepads(): Gamepad[];
  70604. }
  70605. interface HTMLVideoElement {
  70606. mozSrcObject: any;
  70607. }
  70608. interface Math {
  70609. fround(x: number): number;
  70610. imul(a: number, b: number): number;
  70611. }
  70612. interface WebGLRenderingContext {
  70613. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70614. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70615. vertexAttribDivisor(index: number, divisor: number): void;
  70616. createVertexArray(): any;
  70617. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70618. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70619. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70620. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70621. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70622. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70623. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70624. // Queries
  70625. createQuery(): WebGLQuery;
  70626. deleteQuery(query: WebGLQuery): void;
  70627. beginQuery(target: number, query: WebGLQuery): void;
  70628. endQuery(target: number): void;
  70629. getQueryParameter(query: WebGLQuery, pname: number): any;
  70630. getQuery(target: number, pname: number): any;
  70631. MAX_SAMPLES: number;
  70632. RGBA8: number;
  70633. READ_FRAMEBUFFER: number;
  70634. DRAW_FRAMEBUFFER: number;
  70635. UNIFORM_BUFFER: number;
  70636. HALF_FLOAT_OES: number;
  70637. RGBA16F: number;
  70638. RGBA32F: number;
  70639. R32F: number;
  70640. RG32F: number;
  70641. RGB32F: number;
  70642. R16F: number;
  70643. RG16F: number;
  70644. RGB16F: number;
  70645. RED: number;
  70646. RG: number;
  70647. R8: number;
  70648. RG8: number;
  70649. UNSIGNED_INT_24_8: number;
  70650. DEPTH24_STENCIL8: number;
  70651. MIN: number;
  70652. MAX: number;
  70653. /* Multiple Render Targets */
  70654. drawBuffers(buffers: number[]): void;
  70655. readBuffer(src: number): void;
  70656. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70657. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70658. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70659. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70660. // Occlusion Query
  70661. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70662. ANY_SAMPLES_PASSED: number;
  70663. QUERY_RESULT_AVAILABLE: number;
  70664. QUERY_RESULT: number;
  70665. }
  70666. interface WebGLProgram {
  70667. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70668. }
  70669. interface EXT_disjoint_timer_query {
  70670. QUERY_COUNTER_BITS_EXT: number;
  70671. TIME_ELAPSED_EXT: number;
  70672. TIMESTAMP_EXT: number;
  70673. GPU_DISJOINT_EXT: number;
  70674. QUERY_RESULT_EXT: number;
  70675. QUERY_RESULT_AVAILABLE_EXT: number;
  70676. queryCounterEXT(query: WebGLQuery, target: number): void;
  70677. createQueryEXT(): WebGLQuery;
  70678. beginQueryEXT(target: number, query: WebGLQuery): void;
  70679. endQueryEXT(target: number): void;
  70680. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70681. deleteQueryEXT(query: WebGLQuery): void;
  70682. }
  70683. interface WebGLUniformLocation {
  70684. _currentState: any;
  70685. }
  70686. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70687. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70688. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70689. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70690. interface WebGLRenderingContext {
  70691. readonly RASTERIZER_DISCARD: number;
  70692. readonly DEPTH_COMPONENT24: number;
  70693. readonly TEXTURE_3D: number;
  70694. readonly TEXTURE_2D_ARRAY: number;
  70695. readonly TEXTURE_COMPARE_FUNC: number;
  70696. readonly TEXTURE_COMPARE_MODE: number;
  70697. readonly COMPARE_REF_TO_TEXTURE: number;
  70698. readonly TEXTURE_WRAP_R: number;
  70699. readonly HALF_FLOAT: number;
  70700. readonly RGB8: number;
  70701. readonly RED_INTEGER: number;
  70702. readonly RG_INTEGER: number;
  70703. readonly RGB_INTEGER: number;
  70704. readonly RGBA_INTEGER: number;
  70705. readonly R8_SNORM: number;
  70706. readonly RG8_SNORM: number;
  70707. readonly RGB8_SNORM: number;
  70708. readonly RGBA8_SNORM: number;
  70709. readonly R8I: number;
  70710. readonly RG8I: number;
  70711. readonly RGB8I: number;
  70712. readonly RGBA8I: number;
  70713. readonly R8UI: number;
  70714. readonly RG8UI: number;
  70715. readonly RGB8UI: number;
  70716. readonly RGBA8UI: number;
  70717. readonly R16I: number;
  70718. readonly RG16I: number;
  70719. readonly RGB16I: number;
  70720. readonly RGBA16I: number;
  70721. readonly R16UI: number;
  70722. readonly RG16UI: number;
  70723. readonly RGB16UI: number;
  70724. readonly RGBA16UI: number;
  70725. readonly R32I: number;
  70726. readonly RG32I: number;
  70727. readonly RGB32I: number;
  70728. readonly RGBA32I: number;
  70729. readonly R32UI: number;
  70730. readonly RG32UI: number;
  70731. readonly RGB32UI: number;
  70732. readonly RGBA32UI: number;
  70733. readonly RGB10_A2UI: number;
  70734. readonly R11F_G11F_B10F: number;
  70735. readonly RGB9_E5: number;
  70736. readonly RGB10_A2: number;
  70737. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70738. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70739. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70740. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70741. readonly DEPTH_COMPONENT32F: number;
  70742. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70743. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70744. 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;
  70745. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70746. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70747. readonly TRANSFORM_FEEDBACK: number;
  70748. readonly INTERLEAVED_ATTRIBS: number;
  70749. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70750. createTransformFeedback(): WebGLTransformFeedback;
  70751. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70752. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70753. beginTransformFeedback(primitiveMode: number): void;
  70754. endTransformFeedback(): void;
  70755. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70756. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70757. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70758. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70759. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70760. }
  70761. interface ImageBitmap {
  70762. readonly width: number;
  70763. readonly height: number;
  70764. close(): void;
  70765. }
  70766. interface WebGLQuery extends WebGLObject {
  70767. }
  70768. declare var WebGLQuery: {
  70769. prototype: WebGLQuery;
  70770. new(): WebGLQuery;
  70771. };
  70772. interface WebGLSampler extends WebGLObject {
  70773. }
  70774. declare var WebGLSampler: {
  70775. prototype: WebGLSampler;
  70776. new(): WebGLSampler;
  70777. };
  70778. interface WebGLSync extends WebGLObject {
  70779. }
  70780. declare var WebGLSync: {
  70781. prototype: WebGLSync;
  70782. new(): WebGLSync;
  70783. };
  70784. interface WebGLTransformFeedback extends WebGLObject {
  70785. }
  70786. declare var WebGLTransformFeedback: {
  70787. prototype: WebGLTransformFeedback;
  70788. new(): WebGLTransformFeedback;
  70789. };
  70790. interface WebGLVertexArrayObject extends WebGLObject {
  70791. }
  70792. declare var WebGLVertexArrayObject: {
  70793. prototype: WebGLVertexArrayObject;
  70794. new(): WebGLVertexArrayObject;
  70795. };
  70796. // Type definitions for WebVR API
  70797. // Project: https://w3c.github.io/webvr/
  70798. // Definitions by: six a <https://github.com/lostfictions>
  70799. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70800. interface VRDisplay extends EventTarget {
  70801. /**
  70802. * Dictionary of capabilities describing the VRDisplay.
  70803. */
  70804. readonly capabilities: VRDisplayCapabilities;
  70805. /**
  70806. * z-depth defining the far plane of the eye view frustum
  70807. * enables mapping of values in the render target depth
  70808. * attachment to scene coordinates. Initially set to 10000.0.
  70809. */
  70810. depthFar: number;
  70811. /**
  70812. * z-depth defining the near plane of the eye view frustum
  70813. * enables mapping of values in the render target depth
  70814. * attachment to scene coordinates. Initially set to 0.01.
  70815. */
  70816. depthNear: number;
  70817. /**
  70818. * An identifier for this distinct VRDisplay. Used as an
  70819. * association point in the Gamepad API.
  70820. */
  70821. readonly displayId: number;
  70822. /**
  70823. * A display name, a user-readable name identifying it.
  70824. */
  70825. readonly displayName: string;
  70826. readonly isConnected: boolean;
  70827. readonly isPresenting: boolean;
  70828. /**
  70829. * If this VRDisplay supports room-scale experiences, the optional
  70830. * stage attribute contains details on the room-scale parameters.
  70831. */
  70832. readonly stageParameters: VRStageParameters | null;
  70833. /**
  70834. * Passing the value returned by `requestAnimationFrame` to
  70835. * `cancelAnimationFrame` will unregister the callback.
  70836. * @param handle Define the hanle of the request to cancel
  70837. */
  70838. cancelAnimationFrame(handle: number): void;
  70839. /**
  70840. * Stops presenting to the VRDisplay.
  70841. * @returns a promise to know when it stopped
  70842. */
  70843. exitPresent(): Promise<void>;
  70844. /**
  70845. * Return the current VREyeParameters for the given eye.
  70846. * @param whichEye Define the eye we want the parameter for
  70847. * @returns the eye parameters
  70848. */
  70849. getEyeParameters(whichEye: string): VREyeParameters;
  70850. /**
  70851. * Populates the passed VRFrameData with the information required to render
  70852. * the current frame.
  70853. * @param frameData Define the data structure to populate
  70854. * @returns true if ok otherwise false
  70855. */
  70856. getFrameData(frameData: VRFrameData): boolean;
  70857. /**
  70858. * Get the layers currently being presented.
  70859. * @returns the list of VR layers
  70860. */
  70861. getLayers(): VRLayer[];
  70862. /**
  70863. * Return a VRPose containing the future predicted pose of the VRDisplay
  70864. * when the current frame will be presented. The value returned will not
  70865. * change until JavaScript has returned control to the browser.
  70866. *
  70867. * The VRPose will contain the position, orientation, velocity,
  70868. * and acceleration of each of these properties.
  70869. * @returns the pose object
  70870. */
  70871. getPose(): VRPose;
  70872. /**
  70873. * Return the current instantaneous pose of the VRDisplay, with no
  70874. * prediction applied.
  70875. * @returns the current instantaneous pose
  70876. */
  70877. getImmediatePose(): VRPose;
  70878. /**
  70879. * The callback passed to `requestAnimationFrame` will be called
  70880. * any time a new frame should be rendered. When the VRDisplay is
  70881. * presenting the callback will be called at the native refresh
  70882. * rate of the HMD. When not presenting this function acts
  70883. * identically to how window.requestAnimationFrame acts. Content should
  70884. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70885. * asynchronously from other displays and at differing refresh rates.
  70886. * @param callback Define the eaction to run next frame
  70887. * @returns the request handle it
  70888. */
  70889. requestAnimationFrame(callback: FrameRequestCallback): number;
  70890. /**
  70891. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70892. * Repeat calls while already presenting will update the VRLayers being displayed.
  70893. * @param layers Define the list of layer to present
  70894. * @returns a promise to know when the request has been fulfilled
  70895. */
  70896. requestPresent(layers: VRLayer[]): Promise<void>;
  70897. /**
  70898. * Reset the pose for this display, treating its current position and
  70899. * orientation as the "origin/zero" values. VRPose.position,
  70900. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70901. * updated when calling resetPose(). This should be called in only
  70902. * sitting-space experiences.
  70903. */
  70904. resetPose(): void;
  70905. /**
  70906. * The VRLayer provided to the VRDisplay will be captured and presented
  70907. * in the HMD. Calling this function has the same effect on the source
  70908. * canvas as any other operation that uses its source image, and canvases
  70909. * created without preserveDrawingBuffer set to true will be cleared.
  70910. * @param pose Define the pose to submit
  70911. */
  70912. submitFrame(pose?: VRPose): void;
  70913. }
  70914. declare var VRDisplay: {
  70915. prototype: VRDisplay;
  70916. new(): VRDisplay;
  70917. };
  70918. interface VRLayer {
  70919. leftBounds?: number[] | Float32Array | null;
  70920. rightBounds?: number[] | Float32Array | null;
  70921. source?: HTMLCanvasElement | null;
  70922. }
  70923. interface VRDisplayCapabilities {
  70924. readonly canPresent: boolean;
  70925. readonly hasExternalDisplay: boolean;
  70926. readonly hasOrientation: boolean;
  70927. readonly hasPosition: boolean;
  70928. readonly maxLayers: number;
  70929. }
  70930. interface VREyeParameters {
  70931. /** @deprecated */
  70932. readonly fieldOfView: VRFieldOfView;
  70933. readonly offset: Float32Array;
  70934. readonly renderHeight: number;
  70935. readonly renderWidth: number;
  70936. }
  70937. interface VRFieldOfView {
  70938. readonly downDegrees: number;
  70939. readonly leftDegrees: number;
  70940. readonly rightDegrees: number;
  70941. readonly upDegrees: number;
  70942. }
  70943. interface VRFrameData {
  70944. readonly leftProjectionMatrix: Float32Array;
  70945. readonly leftViewMatrix: Float32Array;
  70946. readonly pose: VRPose;
  70947. readonly rightProjectionMatrix: Float32Array;
  70948. readonly rightViewMatrix: Float32Array;
  70949. readonly timestamp: number;
  70950. }
  70951. interface VRPose {
  70952. readonly angularAcceleration: Float32Array | null;
  70953. readonly angularVelocity: Float32Array | null;
  70954. readonly linearAcceleration: Float32Array | null;
  70955. readonly linearVelocity: Float32Array | null;
  70956. readonly orientation: Float32Array | null;
  70957. readonly position: Float32Array | null;
  70958. readonly timestamp: number;
  70959. }
  70960. interface VRStageParameters {
  70961. sittingToStandingTransform?: Float32Array;
  70962. sizeX?: number;
  70963. sizeY?: number;
  70964. }
  70965. interface Navigator {
  70966. getVRDisplays(): Promise<VRDisplay[]>;
  70967. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70968. }
  70969. interface Window {
  70970. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70971. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70972. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70973. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70974. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70975. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70976. }
  70977. interface Gamepad {
  70978. readonly displayId: number;
  70979. }
  70980. type XRSessionMode =
  70981. | "inline"
  70982. | "immersive-vr"
  70983. | "immersive-ar";
  70984. type XRReferenceSpaceType =
  70985. | "viewer"
  70986. | "local"
  70987. | "local-floor"
  70988. | "bounded-floor"
  70989. | "unbounded";
  70990. type XREnvironmentBlendMode =
  70991. | "opaque"
  70992. | "additive"
  70993. | "alpha-blend";
  70994. type XRVisibilityState =
  70995. | "visible"
  70996. | "visible-blurred"
  70997. | "hidden";
  70998. type XRHandedness =
  70999. | "none"
  71000. | "left"
  71001. | "right";
  71002. type XRTargetRayMode =
  71003. | "gaze"
  71004. | "tracked-pointer"
  71005. | "screen";
  71006. type XREye =
  71007. | "none"
  71008. | "left"
  71009. | "right";
  71010. interface XRSpace extends EventTarget {
  71011. }
  71012. interface XRRenderState {
  71013. depthNear?: number;
  71014. depthFar?: number;
  71015. inlineVerticalFieldOfView?: number;
  71016. baseLayer?: XRWebGLLayer;
  71017. }
  71018. interface XRInputSource {
  71019. handedness: XRHandedness;
  71020. targetRayMode: XRTargetRayMode;
  71021. targetRaySpace: XRSpace;
  71022. gripSpace: XRSpace | undefined;
  71023. gamepad: Gamepad | undefined;
  71024. profiles: Array<string>;
  71025. }
  71026. interface XRSessionInit {
  71027. optionalFeatures?: XRReferenceSpaceType[];
  71028. requiredFeatures?: XRReferenceSpaceType[];
  71029. }
  71030. interface XRSession extends XRAnchorCreator {
  71031. addEventListener: Function;
  71032. removeEventListener: Function;
  71033. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  71034. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  71035. requestAnimationFrame: Function;
  71036. end(): Promise<void>;
  71037. renderState: XRRenderState;
  71038. inputSources: Array<XRInputSource>;
  71039. // hit test
  71040. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  71041. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  71042. // legacy AR hit test
  71043. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  71044. // legacy plane detection
  71045. updateWorldTrackingState(options: {
  71046. planeDetectionState?: { enabled: boolean; }
  71047. }): void;
  71048. }
  71049. interface XRReferenceSpace extends XRSpace {
  71050. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  71051. onreset: any;
  71052. }
  71053. type XRPlaneSet = Set<XRPlane>;
  71054. type XRAnchorSet = Set<XRAnchor>;
  71055. interface XRFrame {
  71056. session: XRSession;
  71057. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  71058. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  71059. // AR
  71060. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  71061. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  71062. // Anchors
  71063. trackedAnchors?: XRAnchorSet;
  71064. // Planes
  71065. worldInformation: {
  71066. detectedPlanes?: XRPlaneSet;
  71067. };
  71068. }
  71069. interface XRViewerPose extends XRPose {
  71070. views: Array<XRView>;
  71071. }
  71072. interface XRPose {
  71073. transform: XRRigidTransform;
  71074. emulatedPosition: boolean;
  71075. }
  71076. interface XRWebGLLayerOptions {
  71077. antialias?: boolean;
  71078. depth?: boolean;
  71079. stencil?: boolean;
  71080. alpha?: boolean;
  71081. multiview?: boolean;
  71082. framebufferScaleFactor?: number;
  71083. }
  71084. declare var XRWebGLLayer: {
  71085. prototype: XRWebGLLayer;
  71086. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  71087. };
  71088. interface XRWebGLLayer {
  71089. framebuffer: WebGLFramebuffer;
  71090. framebufferWidth: number;
  71091. framebufferHeight: number;
  71092. getViewport: Function;
  71093. }
  71094. declare class XRRigidTransform {
  71095. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  71096. position: DOMPointReadOnly;
  71097. orientation: DOMPointReadOnly;
  71098. matrix: Float32Array;
  71099. inverse: XRRigidTransform;
  71100. }
  71101. interface XRView {
  71102. eye: XREye;
  71103. projectionMatrix: Float32Array;
  71104. transform: XRRigidTransform;
  71105. }
  71106. interface XRInputSourceChangeEvent {
  71107. session: XRSession;
  71108. removed: Array<XRInputSource>;
  71109. added: Array<XRInputSource>;
  71110. }
  71111. interface XRInputSourceEvent extends Event {
  71112. readonly frame: XRFrame;
  71113. readonly inputSource: XRInputSource;
  71114. }
  71115. // Experimental(er) features
  71116. declare class XRRay {
  71117. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  71118. origin: DOMPointReadOnly;
  71119. direction: DOMPointReadOnly;
  71120. matrix: Float32Array;
  71121. }
  71122. declare enum XRHitTestTrackableType {
  71123. "point",
  71124. "plane"
  71125. }
  71126. interface XRHitResult {
  71127. hitMatrix: Float32Array;
  71128. }
  71129. interface XRTransientInputHitTestResult {
  71130. readonly inputSource: XRInputSource;
  71131. readonly results: Array<XRHitTestResult>;
  71132. }
  71133. interface XRHitTestResult {
  71134. getPose(baseSpace: XRSpace): XRPose | undefined;
  71135. }
  71136. interface XRHitTestSource {
  71137. cancel(): void;
  71138. }
  71139. interface XRTransientInputHitTestSource {
  71140. cancel(): void;
  71141. }
  71142. interface XRHitTestOptionsInit {
  71143. space: XRSpace;
  71144. entityTypes?: Array<XRHitTestTrackableType>;
  71145. offsetRay?: XRRay;
  71146. }
  71147. interface XRTransientInputHitTestOptionsInit {
  71148. profile: string;
  71149. entityTypes?: Array<XRHitTestTrackableType>;
  71150. offsetRay?: XRRay;
  71151. }
  71152. interface XRAnchor {
  71153. // remove?
  71154. id?: string;
  71155. anchorSpace: XRSpace;
  71156. lastChangedTime: number;
  71157. detach(): void;
  71158. }
  71159. interface XRPlane extends XRAnchorCreator {
  71160. orientation: "Horizontal" | "Vertical";
  71161. planeSpace: XRSpace;
  71162. polygon: Array<DOMPointReadOnly>;
  71163. lastChangedTime: number;
  71164. }
  71165. interface XRAnchorCreator {
  71166. // AR Anchors
  71167. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71168. }
  71169. /**
  71170. * @ignore
  71171. */
  71172. declare module BABYLON.GLTF2.Exporter {
  71173. }
  71174. /**
  71175. * @ignore
  71176. */
  71177. declare module BABYLON.GLTF1 {
  71178. }
  71179. declare module BABYLON.GUI {
  71180. /**
  71181. * Class used to specific a value and its associated unit
  71182. */
  71183. export class ValueAndUnit {
  71184. /** defines the unit to store */
  71185. unit: number;
  71186. /** defines a boolean indicating if the value can be negative */
  71187. negativeValueAllowed: boolean;
  71188. private _value;
  71189. private _originalUnit;
  71190. /**
  71191. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  71192. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71193. */
  71194. ignoreAdaptiveScaling: boolean;
  71195. /**
  71196. * Creates a new ValueAndUnit
  71197. * @param value defines the value to store
  71198. * @param unit defines the unit to store
  71199. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  71200. */
  71201. constructor(value: number,
  71202. /** defines the unit to store */
  71203. unit?: number,
  71204. /** defines a boolean indicating if the value can be negative */
  71205. negativeValueAllowed?: boolean);
  71206. /** Gets a boolean indicating if the value is a percentage */
  71207. get isPercentage(): boolean;
  71208. /** Gets a boolean indicating if the value is store as pixel */
  71209. get isPixel(): boolean;
  71210. /** Gets direct internal value */
  71211. get internalValue(): number;
  71212. /**
  71213. * Gets value as pixel
  71214. * @param host defines the root host
  71215. * @param refValue defines the reference value for percentages
  71216. * @returns the value as pixel
  71217. */
  71218. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  71219. /**
  71220. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  71221. * @param value defines the value to store
  71222. * @param unit defines the unit to store
  71223. * @returns the current ValueAndUnit
  71224. */
  71225. updateInPlace(value: number, unit?: number): ValueAndUnit;
  71226. /**
  71227. * Gets the value accordingly to its unit
  71228. * @param host defines the root host
  71229. * @returns the value
  71230. */
  71231. getValue(host: AdvancedDynamicTexture): number;
  71232. /**
  71233. * Gets a string representation of the value
  71234. * @param host defines the root host
  71235. * @param decimals defines an optional number of decimals to display
  71236. * @returns a string
  71237. */
  71238. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  71239. /**
  71240. * Store a value parsed from a string
  71241. * @param source defines the source string
  71242. * @returns true if the value was successfully parsed
  71243. */
  71244. fromString(source: string | number): boolean;
  71245. private static _Regex;
  71246. private static _UNITMODE_PERCENTAGE;
  71247. private static _UNITMODE_PIXEL;
  71248. /** UNITMODE_PERCENTAGE */
  71249. static get UNITMODE_PERCENTAGE(): number;
  71250. /** UNITMODE_PIXEL */
  71251. static get UNITMODE_PIXEL(): number;
  71252. }
  71253. }
  71254. declare module BABYLON.GUI {
  71255. /**
  71256. * Define a style used by control to automatically setup properties based on a template.
  71257. * Only support font related properties so far
  71258. */
  71259. export class Style implements BABYLON.IDisposable {
  71260. private _fontFamily;
  71261. private _fontStyle;
  71262. private _fontWeight;
  71263. /** @hidden */
  71264. _host: AdvancedDynamicTexture;
  71265. /** @hidden */
  71266. _fontSize: ValueAndUnit;
  71267. /**
  71268. * BABYLON.Observable raised when the style values are changed
  71269. */
  71270. onChangedObservable: BABYLON.Observable<Style>;
  71271. /**
  71272. * Creates a new style object
  71273. * @param host defines the AdvancedDynamicTexture which hosts this style
  71274. */
  71275. constructor(host: AdvancedDynamicTexture);
  71276. /**
  71277. * Gets or sets the font size
  71278. */
  71279. get fontSize(): string | number;
  71280. set fontSize(value: string | number);
  71281. /**
  71282. * Gets or sets the font family
  71283. */
  71284. get fontFamily(): string;
  71285. set fontFamily(value: string);
  71286. /**
  71287. * Gets or sets the font style
  71288. */
  71289. get fontStyle(): string;
  71290. set fontStyle(value: string);
  71291. /** Gets or sets font weight */
  71292. get fontWeight(): string;
  71293. set fontWeight(value: string);
  71294. /** Dispose all associated resources */
  71295. dispose(): void;
  71296. }
  71297. }
  71298. declare module BABYLON.GUI {
  71299. /**
  71300. * Class used to transport BABYLON.Vector2 information for pointer events
  71301. */
  71302. export class Vector2WithInfo extends BABYLON.Vector2 {
  71303. /** defines the current mouse button index */
  71304. buttonIndex: number;
  71305. /**
  71306. * Creates a new Vector2WithInfo
  71307. * @param source defines the vector2 data to transport
  71308. * @param buttonIndex defines the current mouse button index
  71309. */
  71310. constructor(source: BABYLON.Vector2,
  71311. /** defines the current mouse button index */
  71312. buttonIndex?: number);
  71313. }
  71314. /** Class used to provide 2D matrix features */
  71315. export class Matrix2D {
  71316. /** Gets the internal array of 6 floats used to store matrix data */
  71317. m: Float32Array;
  71318. /**
  71319. * Creates a new matrix
  71320. * @param m00 defines value for (0, 0)
  71321. * @param m01 defines value for (0, 1)
  71322. * @param m10 defines value for (1, 0)
  71323. * @param m11 defines value for (1, 1)
  71324. * @param m20 defines value for (2, 0)
  71325. * @param m21 defines value for (2, 1)
  71326. */
  71327. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  71328. /**
  71329. * Fills the matrix from direct values
  71330. * @param m00 defines value for (0, 0)
  71331. * @param m01 defines value for (0, 1)
  71332. * @param m10 defines value for (1, 0)
  71333. * @param m11 defines value for (1, 1)
  71334. * @param m20 defines value for (2, 0)
  71335. * @param m21 defines value for (2, 1)
  71336. * @returns the current modified matrix
  71337. */
  71338. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  71339. /**
  71340. * Gets matrix determinant
  71341. * @returns the determinant
  71342. */
  71343. determinant(): number;
  71344. /**
  71345. * Inverses the matrix and stores it in a target matrix
  71346. * @param result defines the target matrix
  71347. * @returns the current matrix
  71348. */
  71349. invertToRef(result: Matrix2D): Matrix2D;
  71350. /**
  71351. * Multiplies the current matrix with another one
  71352. * @param other defines the second operand
  71353. * @param result defines the target matrix
  71354. * @returns the current matrix
  71355. */
  71356. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71357. /**
  71358. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71359. * @param x defines the x coordinate to transform
  71360. * @param y defines the x coordinate to transform
  71361. * @param result defines the target vector2
  71362. * @returns the current matrix
  71363. */
  71364. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71365. /**
  71366. * Creates an identity matrix
  71367. * @returns a new matrix
  71368. */
  71369. static Identity(): Matrix2D;
  71370. /**
  71371. * Creates a translation matrix and stores it in a target matrix
  71372. * @param x defines the x coordinate of the translation
  71373. * @param y defines the y coordinate of the translation
  71374. * @param result defines the target matrix
  71375. */
  71376. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71377. /**
  71378. * Creates a scaling matrix and stores it in a target matrix
  71379. * @param x defines the x coordinate of the scaling
  71380. * @param y defines the y coordinate of the scaling
  71381. * @param result defines the target matrix
  71382. */
  71383. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71384. /**
  71385. * Creates a rotation matrix and stores it in a target matrix
  71386. * @param angle defines the rotation angle
  71387. * @param result defines the target matrix
  71388. */
  71389. static RotationToRef(angle: number, result: Matrix2D): void;
  71390. private static _TempPreTranslationMatrix;
  71391. private static _TempPostTranslationMatrix;
  71392. private static _TempRotationMatrix;
  71393. private static _TempScalingMatrix;
  71394. private static _TempCompose0;
  71395. private static _TempCompose1;
  71396. private static _TempCompose2;
  71397. /**
  71398. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71399. * @param tx defines the x coordinate of the translation
  71400. * @param ty defines the y coordinate of the translation
  71401. * @param angle defines the rotation angle
  71402. * @param scaleX defines the x coordinate of the scaling
  71403. * @param scaleY defines the y coordinate of the scaling
  71404. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71405. * @param result defines the target matrix
  71406. */
  71407. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71408. }
  71409. }
  71410. declare module BABYLON.GUI {
  71411. /**
  71412. * Class used to store 2D control sizes
  71413. */
  71414. export class Measure {
  71415. /** defines left coordinate */
  71416. left: number;
  71417. /** defines top coordinate */
  71418. top: number;
  71419. /** defines width dimension */
  71420. width: number;
  71421. /** defines height dimension */
  71422. height: number;
  71423. /**
  71424. * Creates a new measure
  71425. * @param left defines left coordinate
  71426. * @param top defines top coordinate
  71427. * @param width defines width dimension
  71428. * @param height defines height dimension
  71429. */
  71430. constructor(
  71431. /** defines left coordinate */
  71432. left: number,
  71433. /** defines top coordinate */
  71434. top: number,
  71435. /** defines width dimension */
  71436. width: number,
  71437. /** defines height dimension */
  71438. height: number);
  71439. /**
  71440. * Copy from another measure
  71441. * @param other defines the other measure to copy from
  71442. */
  71443. copyFrom(other: Measure): void;
  71444. /**
  71445. * Copy from a group of 4 floats
  71446. * @param left defines left coordinate
  71447. * @param top defines top coordinate
  71448. * @param width defines width dimension
  71449. * @param height defines height dimension
  71450. */
  71451. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71452. /**
  71453. * Computes the axis aligned bounding box measure for two given measures
  71454. * @param a Input measure
  71455. * @param b Input measure
  71456. * @param result the resulting bounding measure
  71457. */
  71458. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71459. /**
  71460. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71461. * @param transform the matrix to transform the measure before computing the AABB
  71462. * @param result the resulting AABB
  71463. */
  71464. transformToRef(transform: Matrix2D, result: Measure): void;
  71465. /**
  71466. * Check equality between this measure and another one
  71467. * @param other defines the other measures
  71468. * @returns true if both measures are equals
  71469. */
  71470. isEqualsTo(other: Measure): boolean;
  71471. /**
  71472. * Creates an empty measure
  71473. * @returns a new measure
  71474. */
  71475. static Empty(): Measure;
  71476. }
  71477. }
  71478. declare module BABYLON.GUI {
  71479. /**
  71480. * Interface used to define a control that can receive focus
  71481. */
  71482. export interface IFocusableControl {
  71483. /**
  71484. * Function called when the control receives the focus
  71485. */
  71486. onFocus(): void;
  71487. /**
  71488. * Function called when the control loses the focus
  71489. */
  71490. onBlur(): void;
  71491. /**
  71492. * Function called to let the control handle keyboard events
  71493. * @param evt defines the current keyboard event
  71494. */
  71495. processKeyboard(evt: KeyboardEvent): void;
  71496. /**
  71497. * Function called to get the list of controls that should not steal the focus from this control
  71498. * @returns an array of controls
  71499. */
  71500. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71501. }
  71502. /**
  71503. * Class used to create texture to support 2D GUI elements
  71504. * @see http://doc.babylonjs.com/how_to/gui
  71505. */
  71506. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71507. private _isDirty;
  71508. private _renderObserver;
  71509. private _resizeObserver;
  71510. private _preKeyboardObserver;
  71511. private _pointerMoveObserver;
  71512. private _pointerObserver;
  71513. private _canvasPointerOutObserver;
  71514. private _background;
  71515. /** @hidden */
  71516. _rootContainer: Container;
  71517. /** @hidden */
  71518. _lastPickedControl: Control;
  71519. /** @hidden */
  71520. _lastControlOver: {
  71521. [pointerId: number]: Control;
  71522. };
  71523. /** @hidden */
  71524. _lastControlDown: {
  71525. [pointerId: number]: Control;
  71526. };
  71527. /** @hidden */
  71528. _capturingControl: {
  71529. [pointerId: number]: Control;
  71530. };
  71531. /** @hidden */
  71532. _shouldBlockPointer: boolean;
  71533. /** @hidden */
  71534. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71535. /** @hidden */
  71536. _linkedControls: Control[];
  71537. private _isFullscreen;
  71538. private _fullscreenViewport;
  71539. private _idealWidth;
  71540. private _idealHeight;
  71541. private _useSmallestIdeal;
  71542. private _renderAtIdealSize;
  71543. private _focusedControl;
  71544. private _blockNextFocusCheck;
  71545. private _renderScale;
  71546. private _rootElement;
  71547. private _cursorChanged;
  71548. private _defaultMousePointerId;
  71549. /** @hidden */
  71550. _numLayoutCalls: number;
  71551. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71552. get numLayoutCalls(): number;
  71553. /** @hidden */
  71554. _numRenderCalls: number;
  71555. /** Gets the number of render calls made the last time the ADT has been rendered */
  71556. get numRenderCalls(): number;
  71557. /**
  71558. * Define type to string to ensure compatibility across browsers
  71559. * Safari doesn't support DataTransfer constructor
  71560. */
  71561. private _clipboardData;
  71562. /**
  71563. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71564. */
  71565. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71566. /**
  71567. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71568. */
  71569. onControlPickedObservable: BABYLON.Observable<Control>;
  71570. /**
  71571. * BABYLON.Observable event triggered before layout is evaluated
  71572. */
  71573. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71574. /**
  71575. * BABYLON.Observable event triggered after the layout was evaluated
  71576. */
  71577. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71578. /**
  71579. * BABYLON.Observable event triggered before the texture is rendered
  71580. */
  71581. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71582. /**
  71583. * BABYLON.Observable event triggered after the texture was rendered
  71584. */
  71585. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71586. /**
  71587. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71588. */
  71589. premulAlpha: boolean;
  71590. /**
  71591. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71592. * Useful when you want more antialiasing
  71593. */
  71594. get renderScale(): number;
  71595. set renderScale(value: number);
  71596. /** Gets or sets the background color */
  71597. get background(): string;
  71598. set background(value: string);
  71599. /**
  71600. * Gets or sets the ideal width used to design controls.
  71601. * The GUI will then rescale everything accordingly
  71602. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71603. */
  71604. get idealWidth(): number;
  71605. set idealWidth(value: number);
  71606. /**
  71607. * Gets or sets the ideal height used to design controls.
  71608. * The GUI will then rescale everything accordingly
  71609. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71610. */
  71611. get idealHeight(): number;
  71612. set idealHeight(value: number);
  71613. /**
  71614. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71615. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71616. */
  71617. get useSmallestIdeal(): boolean;
  71618. set useSmallestIdeal(value: boolean);
  71619. /**
  71620. * Gets or sets a boolean indicating if adaptive scaling must be used
  71621. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71622. */
  71623. get renderAtIdealSize(): boolean;
  71624. set renderAtIdealSize(value: boolean);
  71625. /**
  71626. * Gets the ratio used when in "ideal mode"
  71627. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71628. * */
  71629. get idealRatio(): number;
  71630. /**
  71631. * Gets the underlying layer used to render the texture when in fullscreen mode
  71632. */
  71633. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71634. /**
  71635. * Gets the root container control
  71636. */
  71637. get rootContainer(): Container;
  71638. /**
  71639. * Returns an array containing the root container.
  71640. * This is mostly used to let the Inspector introspects the ADT
  71641. * @returns an array containing the rootContainer
  71642. */
  71643. getChildren(): Array<Container>;
  71644. /**
  71645. * Will return all controls that are inside this texture
  71646. * @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
  71647. * @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
  71648. * @return all child controls
  71649. */
  71650. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71651. /**
  71652. * Gets or sets the current focused control
  71653. */
  71654. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71655. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71656. /**
  71657. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71658. */
  71659. get isForeground(): boolean;
  71660. set isForeground(value: boolean);
  71661. /**
  71662. * Gets or set information about clipboardData
  71663. */
  71664. get clipboardData(): string;
  71665. set clipboardData(value: string);
  71666. /**
  71667. * Creates a new AdvancedDynamicTexture
  71668. * @param name defines the name of the texture
  71669. * @param width defines the width of the texture
  71670. * @param height defines the height of the texture
  71671. * @param scene defines the hosting scene
  71672. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71673. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71674. */
  71675. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71676. /**
  71677. * Get the current class name of the texture useful for serialization or dynamic coding.
  71678. * @returns "AdvancedDynamicTexture"
  71679. */
  71680. getClassName(): string;
  71681. /**
  71682. * Function used to execute a function on all controls
  71683. * @param func defines the function to execute
  71684. * @param container defines the container where controls belong. If null the root container will be used
  71685. */
  71686. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71687. private _useInvalidateRectOptimization;
  71688. /**
  71689. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71690. */
  71691. get useInvalidateRectOptimization(): boolean;
  71692. set useInvalidateRectOptimization(value: boolean);
  71693. private _invalidatedRectangle;
  71694. /**
  71695. * Invalidates a rectangle area on the gui texture
  71696. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71697. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71698. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71699. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71700. */
  71701. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71702. /**
  71703. * Marks the texture as dirty forcing a complete update
  71704. */
  71705. markAsDirty(): void;
  71706. /**
  71707. * Helper function used to create a new style
  71708. * @returns a new style
  71709. * @see http://doc.babylonjs.com/how_to/gui#styles
  71710. */
  71711. createStyle(): Style;
  71712. /**
  71713. * Adds a new control to the root container
  71714. * @param control defines the control to add
  71715. * @returns the current texture
  71716. */
  71717. addControl(control: Control): AdvancedDynamicTexture;
  71718. /**
  71719. * Removes a control from the root container
  71720. * @param control defines the control to remove
  71721. * @returns the current texture
  71722. */
  71723. removeControl(control: Control): AdvancedDynamicTexture;
  71724. /**
  71725. * Release all resources
  71726. */
  71727. dispose(): void;
  71728. private _onResize;
  71729. /** @hidden */
  71730. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71731. /**
  71732. * Get screen coordinates for a vector3
  71733. * @param position defines the position to project
  71734. * @param worldMatrix defines the world matrix to use
  71735. * @returns the projected position
  71736. */
  71737. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71738. private _checkUpdate;
  71739. private _clearMeasure;
  71740. private _render;
  71741. /** @hidden */
  71742. _changeCursor(cursor: string): void;
  71743. /** @hidden */
  71744. _registerLastControlDown(control: Control, pointerId: number): void;
  71745. private _doPicking;
  71746. /** @hidden */
  71747. _cleanControlAfterRemovalFromList(list: {
  71748. [pointerId: number]: Control;
  71749. }, control: Control): void;
  71750. /** @hidden */
  71751. _cleanControlAfterRemoval(control: Control): void;
  71752. /** Attach to all scene events required to support pointer events */
  71753. attach(): void;
  71754. /** @hidden */
  71755. private onClipboardCopy;
  71756. /** @hidden */
  71757. private onClipboardCut;
  71758. /** @hidden */
  71759. private onClipboardPaste;
  71760. /**
  71761. * Register the clipboard Events onto the canvas
  71762. */
  71763. registerClipboardEvents(): void;
  71764. /**
  71765. * Unregister the clipboard Events from the canvas
  71766. */
  71767. unRegisterClipboardEvents(): void;
  71768. /**
  71769. * Connect the texture to a hosting mesh to enable interactions
  71770. * @param mesh defines the mesh to attach to
  71771. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71772. */
  71773. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71774. /**
  71775. * Move the focus to a specific control
  71776. * @param control defines the control which will receive the focus
  71777. */
  71778. moveFocusToControl(control: IFocusableControl): void;
  71779. private _manageFocus;
  71780. private _attachToOnPointerOut;
  71781. /**
  71782. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71783. * @param mesh defines the mesh which will receive the texture
  71784. * @param width defines the texture width (1024 by default)
  71785. * @param height defines the texture height (1024 by default)
  71786. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71787. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71788. * @returns a new AdvancedDynamicTexture
  71789. */
  71790. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71791. /**
  71792. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71793. * In this mode the texture will rely on a layer for its rendering.
  71794. * This allows it to be treated like any other layer.
  71795. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71796. * LayerMask is set through advancedTexture.layer.layerMask
  71797. * @param name defines name for the texture
  71798. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71799. * @param scene defines the hsoting scene
  71800. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71801. * @returns a new AdvancedDynamicTexture
  71802. */
  71803. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71804. }
  71805. }
  71806. declare module BABYLON.GUI {
  71807. /**
  71808. * Root class used for all 2D controls
  71809. * @see http://doc.babylonjs.com/how_to/gui#controls
  71810. */
  71811. export class Control {
  71812. /** defines the name of the control */
  71813. name?: string | undefined;
  71814. /**
  71815. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71816. */
  71817. static AllowAlphaInheritance: boolean;
  71818. private _alpha;
  71819. private _alphaSet;
  71820. private _zIndex;
  71821. /** @hidden */
  71822. _host: AdvancedDynamicTexture;
  71823. /** Gets or sets the control parent */
  71824. parent: BABYLON.Nullable<Container>;
  71825. /** @hidden */
  71826. _currentMeasure: Measure;
  71827. private _fontFamily;
  71828. private _fontStyle;
  71829. private _fontWeight;
  71830. private _fontSize;
  71831. private _font;
  71832. /** @hidden */
  71833. _width: ValueAndUnit;
  71834. /** @hidden */
  71835. _height: ValueAndUnit;
  71836. /** @hidden */
  71837. protected _fontOffset: {
  71838. ascent: number;
  71839. height: number;
  71840. descent: number;
  71841. };
  71842. private _color;
  71843. private _style;
  71844. private _styleObserver;
  71845. /** @hidden */
  71846. protected _horizontalAlignment: number;
  71847. /** @hidden */
  71848. protected _verticalAlignment: number;
  71849. /** @hidden */
  71850. protected _isDirty: boolean;
  71851. /** @hidden */
  71852. protected _wasDirty: boolean;
  71853. /** @hidden */
  71854. _tempParentMeasure: Measure;
  71855. /** @hidden */
  71856. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71857. /** @hidden */
  71858. protected _cachedParentMeasure: Measure;
  71859. private _paddingLeft;
  71860. private _paddingRight;
  71861. private _paddingTop;
  71862. private _paddingBottom;
  71863. /** @hidden */
  71864. _left: ValueAndUnit;
  71865. /** @hidden */
  71866. _top: ValueAndUnit;
  71867. private _scaleX;
  71868. private _scaleY;
  71869. private _rotation;
  71870. private _transformCenterX;
  71871. private _transformCenterY;
  71872. /** @hidden */
  71873. _transformMatrix: Matrix2D;
  71874. /** @hidden */
  71875. protected _invertTransformMatrix: Matrix2D;
  71876. /** @hidden */
  71877. protected _transformedPosition: BABYLON.Vector2;
  71878. private _isMatrixDirty;
  71879. private _cachedOffsetX;
  71880. private _cachedOffsetY;
  71881. private _isVisible;
  71882. private _isHighlighted;
  71883. /** @hidden */
  71884. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71885. private _fontSet;
  71886. private _dummyVector2;
  71887. private _downCount;
  71888. private _enterCount;
  71889. private _doNotRender;
  71890. private _downPointerIds;
  71891. protected _isEnabled: boolean;
  71892. protected _disabledColor: string;
  71893. protected _disabledColorItem: string;
  71894. /** @hidden */
  71895. protected _rebuildLayout: boolean;
  71896. /** @hidden */
  71897. _customData: any;
  71898. /** @hidden */
  71899. _isClipped: boolean;
  71900. /** @hidden */
  71901. _automaticSize: boolean;
  71902. /** @hidden */
  71903. _tag: any;
  71904. /**
  71905. * 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
  71906. */
  71907. uniqueId: number;
  71908. /**
  71909. * Gets or sets an object used to store user defined information for the node
  71910. */
  71911. metadata: any;
  71912. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71913. isHitTestVisible: boolean;
  71914. /** Gets or sets a boolean indicating if the control can block pointer events */
  71915. isPointerBlocker: boolean;
  71916. /** Gets or sets a boolean indicating if the control can be focusable */
  71917. isFocusInvisible: boolean;
  71918. /**
  71919. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71920. * 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
  71921. */
  71922. clipChildren: boolean;
  71923. /**
  71924. * Gets or sets a boolean indicating that control content must be clipped
  71925. * 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
  71926. */
  71927. clipContent: boolean;
  71928. /**
  71929. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71930. */
  71931. useBitmapCache: boolean;
  71932. private _cacheData;
  71933. private _shadowOffsetX;
  71934. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71935. get shadowOffsetX(): number;
  71936. set shadowOffsetX(value: number);
  71937. private _shadowOffsetY;
  71938. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71939. get shadowOffsetY(): number;
  71940. set shadowOffsetY(value: number);
  71941. private _shadowBlur;
  71942. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71943. get shadowBlur(): number;
  71944. set shadowBlur(value: number);
  71945. private _shadowColor;
  71946. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71947. get shadowColor(): string;
  71948. set shadowColor(value: string);
  71949. /** Gets or sets the cursor to use when the control is hovered */
  71950. hoverCursor: string;
  71951. /** @hidden */
  71952. protected _linkOffsetX: ValueAndUnit;
  71953. /** @hidden */
  71954. protected _linkOffsetY: ValueAndUnit;
  71955. /** Gets the control type name */
  71956. get typeName(): string;
  71957. /**
  71958. * Get the current class name of the control.
  71959. * @returns current class name
  71960. */
  71961. getClassName(): string;
  71962. /**
  71963. * An event triggered when pointer wheel is scrolled
  71964. */
  71965. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71966. /**
  71967. * An event triggered when the pointer move over the control.
  71968. */
  71969. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71970. /**
  71971. * An event triggered when the pointer move out of the control.
  71972. */
  71973. onPointerOutObservable: BABYLON.Observable<Control>;
  71974. /**
  71975. * An event triggered when the pointer taps the control
  71976. */
  71977. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71978. /**
  71979. * An event triggered when pointer up
  71980. */
  71981. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71982. /**
  71983. * An event triggered when a control is clicked on
  71984. */
  71985. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71986. /**
  71987. * An event triggered when pointer enters the control
  71988. */
  71989. onPointerEnterObservable: BABYLON.Observable<Control>;
  71990. /**
  71991. * An event triggered when the control is marked as dirty
  71992. */
  71993. onDirtyObservable: BABYLON.Observable<Control>;
  71994. /**
  71995. * An event triggered before drawing the control
  71996. */
  71997. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71998. /**
  71999. * An event triggered after the control was drawn
  72000. */
  72001. onAfterDrawObservable: BABYLON.Observable<Control>;
  72002. /**
  72003. * Get the hosting AdvancedDynamicTexture
  72004. */
  72005. get host(): AdvancedDynamicTexture;
  72006. /** Gets or set information about font offsets (used to render and align text) */
  72007. get fontOffset(): {
  72008. ascent: number;
  72009. height: number;
  72010. descent: number;
  72011. };
  72012. set fontOffset(offset: {
  72013. ascent: number;
  72014. height: number;
  72015. descent: number;
  72016. });
  72017. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  72018. get alpha(): number;
  72019. set alpha(value: number);
  72020. /**
  72021. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  72022. */
  72023. get isHighlighted(): boolean;
  72024. set isHighlighted(value: boolean);
  72025. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  72026. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72027. */
  72028. get scaleX(): number;
  72029. set scaleX(value: number);
  72030. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  72031. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72032. */
  72033. get scaleY(): number;
  72034. set scaleY(value: number);
  72035. /** Gets or sets the rotation angle (0 by default)
  72036. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72037. */
  72038. get rotation(): number;
  72039. set rotation(value: number);
  72040. /** Gets or sets the transformation center on Y axis (0 by default)
  72041. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72042. */
  72043. get transformCenterY(): number;
  72044. set transformCenterY(value: number);
  72045. /** Gets or sets the transformation center on X axis (0 by default)
  72046. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72047. */
  72048. get transformCenterX(): number;
  72049. set transformCenterX(value: number);
  72050. /**
  72051. * Gets or sets the horizontal alignment
  72052. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72053. */
  72054. get horizontalAlignment(): number;
  72055. set horizontalAlignment(value: number);
  72056. /**
  72057. * Gets or sets the vertical alignment
  72058. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72059. */
  72060. get verticalAlignment(): number;
  72061. set verticalAlignment(value: number);
  72062. /**
  72063. * Gets or sets control width
  72064. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72065. */
  72066. get width(): string | number;
  72067. set width(value: string | number);
  72068. /**
  72069. * Gets or sets the control width in pixel
  72070. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72071. */
  72072. get widthInPixels(): number;
  72073. set widthInPixels(value: number);
  72074. /**
  72075. * Gets or sets control height
  72076. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72077. */
  72078. get height(): string | number;
  72079. set height(value: string | number);
  72080. /**
  72081. * Gets or sets control height in pixel
  72082. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72083. */
  72084. get heightInPixels(): number;
  72085. set heightInPixels(value: number);
  72086. /** Gets or set font family */
  72087. get fontFamily(): string;
  72088. set fontFamily(value: string);
  72089. /** Gets or sets font style */
  72090. get fontStyle(): string;
  72091. set fontStyle(value: string);
  72092. /** Gets or sets font weight */
  72093. get fontWeight(): string;
  72094. set fontWeight(value: string);
  72095. /**
  72096. * Gets or sets style
  72097. * @see http://doc.babylonjs.com/how_to/gui#styles
  72098. */
  72099. get style(): BABYLON.Nullable<Style>;
  72100. set style(value: BABYLON.Nullable<Style>);
  72101. /** @hidden */
  72102. get _isFontSizeInPercentage(): boolean;
  72103. /** Gets or sets font size in pixels */
  72104. get fontSizeInPixels(): number;
  72105. set fontSizeInPixels(value: number);
  72106. /** Gets or sets font size */
  72107. get fontSize(): string | number;
  72108. set fontSize(value: string | number);
  72109. /** Gets or sets foreground color */
  72110. get color(): string;
  72111. set color(value: string);
  72112. /** Gets or sets z index which is used to reorder controls on the z axis */
  72113. get zIndex(): number;
  72114. set zIndex(value: number);
  72115. /** Gets or sets a boolean indicating if the control can be rendered */
  72116. get notRenderable(): boolean;
  72117. set notRenderable(value: boolean);
  72118. /** Gets or sets a boolean indicating if the control is visible */
  72119. get isVisible(): boolean;
  72120. set isVisible(value: boolean);
  72121. /** Gets a boolean indicating that the control needs to update its rendering */
  72122. get isDirty(): boolean;
  72123. /**
  72124. * Gets the current linked mesh (or null if none)
  72125. */
  72126. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72127. /**
  72128. * Gets or sets a value indicating the padding to use on the left of the control
  72129. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72130. */
  72131. get paddingLeft(): string | number;
  72132. set paddingLeft(value: string | number);
  72133. /**
  72134. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  72135. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72136. */
  72137. get paddingLeftInPixels(): number;
  72138. set paddingLeftInPixels(value: number);
  72139. /**
  72140. * Gets or sets a value indicating the padding to use on the right of the control
  72141. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72142. */
  72143. get paddingRight(): string | number;
  72144. set paddingRight(value: string | number);
  72145. /**
  72146. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  72147. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72148. */
  72149. get paddingRightInPixels(): number;
  72150. set paddingRightInPixels(value: number);
  72151. /**
  72152. * Gets or sets a value indicating the padding to use on the top of the control
  72153. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72154. */
  72155. get paddingTop(): string | number;
  72156. set paddingTop(value: string | number);
  72157. /**
  72158. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  72159. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72160. */
  72161. get paddingTopInPixels(): number;
  72162. set paddingTopInPixels(value: number);
  72163. /**
  72164. * Gets or sets a value indicating the padding to use on the bottom of the control
  72165. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72166. */
  72167. get paddingBottom(): string | number;
  72168. set paddingBottom(value: string | number);
  72169. /**
  72170. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  72171. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72172. */
  72173. get paddingBottomInPixels(): number;
  72174. set paddingBottomInPixels(value: number);
  72175. /**
  72176. * Gets or sets a value indicating the left coordinate of the control
  72177. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72178. */
  72179. get left(): string | number;
  72180. set left(value: string | number);
  72181. /**
  72182. * Gets or sets a value indicating the left coordinate in pixels of the control
  72183. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72184. */
  72185. get leftInPixels(): number;
  72186. set leftInPixels(value: number);
  72187. /**
  72188. * Gets or sets a value indicating the top coordinate of the control
  72189. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72190. */
  72191. get top(): string | number;
  72192. set top(value: string | number);
  72193. /**
  72194. * Gets or sets a value indicating the top coordinate in pixels of the control
  72195. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72196. */
  72197. get topInPixels(): number;
  72198. set topInPixels(value: number);
  72199. /**
  72200. * Gets or sets a value indicating the offset on X axis to the linked mesh
  72201. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72202. */
  72203. get linkOffsetX(): string | number;
  72204. set linkOffsetX(value: string | number);
  72205. /**
  72206. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  72207. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72208. */
  72209. get linkOffsetXInPixels(): number;
  72210. set linkOffsetXInPixels(value: number);
  72211. /**
  72212. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  72213. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72214. */
  72215. get linkOffsetY(): string | number;
  72216. set linkOffsetY(value: string | number);
  72217. /**
  72218. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  72219. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72220. */
  72221. get linkOffsetYInPixels(): number;
  72222. set linkOffsetYInPixels(value: number);
  72223. /** Gets the center coordinate on X axis */
  72224. get centerX(): number;
  72225. /** Gets the center coordinate on Y axis */
  72226. get centerY(): number;
  72227. /** Gets or sets if control is Enabled*/
  72228. get isEnabled(): boolean;
  72229. set isEnabled(value: boolean);
  72230. /** Gets or sets background color of control if it's disabled*/
  72231. get disabledColor(): string;
  72232. set disabledColor(value: string);
  72233. /** Gets or sets front color of control if it's disabled*/
  72234. get disabledColorItem(): string;
  72235. set disabledColorItem(value: string);
  72236. /**
  72237. * Creates a new control
  72238. * @param name defines the name of the control
  72239. */
  72240. constructor(
  72241. /** defines the name of the control */
  72242. name?: string | undefined);
  72243. /** @hidden */
  72244. protected _getTypeName(): string;
  72245. /**
  72246. * Gets the first ascendant in the hierarchy of the given type
  72247. * @param className defines the required type
  72248. * @returns the ascendant or null if not found
  72249. */
  72250. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  72251. /** @hidden */
  72252. _resetFontCache(): void;
  72253. /**
  72254. * Determines if a container is an ascendant of the current control
  72255. * @param container defines the container to look for
  72256. * @returns true if the container is one of the ascendant of the control
  72257. */
  72258. isAscendant(container: Control): boolean;
  72259. /**
  72260. * Gets coordinates in local control space
  72261. * @param globalCoordinates defines the coordinates to transform
  72262. * @returns the new coordinates in local space
  72263. */
  72264. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72265. /**
  72266. * Gets coordinates in local control space
  72267. * @param globalCoordinates defines the coordinates to transform
  72268. * @param result defines the target vector2 where to store the result
  72269. * @returns the current control
  72270. */
  72271. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  72272. /**
  72273. * Gets coordinates in parent local control space
  72274. * @param globalCoordinates defines the coordinates to transform
  72275. * @returns the new coordinates in parent local space
  72276. */
  72277. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72278. /**
  72279. * Move the current control to a vector3 position projected onto the screen.
  72280. * @param position defines the target position
  72281. * @param scene defines the hosting scene
  72282. */
  72283. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  72284. /**
  72285. * Will store all controls that have this control as ascendant in a given array
  72286. * @param results defines the array where to store the descendants
  72287. * @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
  72288. * @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
  72289. */
  72290. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72291. /**
  72292. * Will return all controls that have this control as ascendant
  72293. * @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
  72294. * @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
  72295. * @return all child controls
  72296. */
  72297. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72298. /**
  72299. * Link current control with a target mesh
  72300. * @param mesh defines the mesh to link with
  72301. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72302. */
  72303. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  72304. /** @hidden */
  72305. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  72306. /** @hidden */
  72307. _offsetLeft(offset: number): void;
  72308. /** @hidden */
  72309. _offsetTop(offset: number): void;
  72310. /** @hidden */
  72311. _markMatrixAsDirty(): void;
  72312. /** @hidden */
  72313. _flagDescendantsAsMatrixDirty(): void;
  72314. /** @hidden */
  72315. _intersectsRect(rect: Measure): boolean;
  72316. /** @hidden */
  72317. protected invalidateRect(): void;
  72318. /** @hidden */
  72319. _markAsDirty(force?: boolean): void;
  72320. /** @hidden */
  72321. _markAllAsDirty(): void;
  72322. /** @hidden */
  72323. _link(host: AdvancedDynamicTexture): void;
  72324. /** @hidden */
  72325. protected _transform(context?: CanvasRenderingContext2D): void;
  72326. /** @hidden */
  72327. _renderHighlight(context: CanvasRenderingContext2D): void;
  72328. /** @hidden */
  72329. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72330. /** @hidden */
  72331. protected _applyStates(context: CanvasRenderingContext2D): void;
  72332. /** @hidden */
  72333. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72334. /** @hidden */
  72335. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72336. protected _evaluateClippingState(parentMeasure: Measure): void;
  72337. /** @hidden */
  72338. _measure(): void;
  72339. /** @hidden */
  72340. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72341. /** @hidden */
  72342. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72343. /** @hidden */
  72344. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72345. /** @hidden */
  72346. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72347. private static _ClipMeasure;
  72348. private _tmpMeasureA;
  72349. private _clip;
  72350. /** @hidden */
  72351. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72352. /** @hidden */
  72353. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72354. /**
  72355. * Tests if a given coordinates belong to the current control
  72356. * @param x defines x coordinate to test
  72357. * @param y defines y coordinate to test
  72358. * @returns true if the coordinates are inside the control
  72359. */
  72360. contains(x: number, y: number): boolean;
  72361. /** @hidden */
  72362. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72363. /** @hidden */
  72364. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72365. /** @hidden */
  72366. _onPointerEnter(target: Control): boolean;
  72367. /** @hidden */
  72368. _onPointerOut(target: Control, force?: boolean): void;
  72369. /** @hidden */
  72370. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72371. /** @hidden */
  72372. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72373. /** @hidden */
  72374. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72375. /** @hidden */
  72376. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72377. /** @hidden */
  72378. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72379. private _prepareFont;
  72380. /** Releases associated resources */
  72381. dispose(): void;
  72382. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72383. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72384. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72385. private static _VERTICAL_ALIGNMENT_TOP;
  72386. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72387. private static _VERTICAL_ALIGNMENT_CENTER;
  72388. /** HORIZONTAL_ALIGNMENT_LEFT */
  72389. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72390. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72391. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72392. /** HORIZONTAL_ALIGNMENT_CENTER */
  72393. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72394. /** VERTICAL_ALIGNMENT_TOP */
  72395. static get VERTICAL_ALIGNMENT_TOP(): number;
  72396. /** VERTICAL_ALIGNMENT_BOTTOM */
  72397. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72398. /** VERTICAL_ALIGNMENT_CENTER */
  72399. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72400. private static _FontHeightSizes;
  72401. /** @hidden */
  72402. static _GetFontOffset(font: string): {
  72403. ascent: number;
  72404. height: number;
  72405. descent: number;
  72406. };
  72407. /**
  72408. * Creates a stack panel that can be used to render headers
  72409. * @param control defines the control to associate with the header
  72410. * @param text defines the text of the header
  72411. * @param size defines the size of the header
  72412. * @param options defines options used to configure the header
  72413. * @returns a new StackPanel
  72414. * @ignore
  72415. * @hidden
  72416. */
  72417. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72418. isHorizontal: boolean;
  72419. controlFirst: boolean;
  72420. }) => any;
  72421. /** @hidden */
  72422. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72423. }
  72424. }
  72425. declare module BABYLON.GUI {
  72426. /**
  72427. * Root class for 2D containers
  72428. * @see http://doc.babylonjs.com/how_to/gui#containers
  72429. */
  72430. export class Container extends Control {
  72431. name?: string | undefined;
  72432. /** @hidden */
  72433. _children: Control[];
  72434. /** @hidden */
  72435. protected _measureForChildren: Measure;
  72436. /** @hidden */
  72437. protected _background: string;
  72438. /** @hidden */
  72439. protected _adaptWidthToChildren: boolean;
  72440. /** @hidden */
  72441. protected _adaptHeightToChildren: boolean;
  72442. /**
  72443. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72444. */
  72445. logLayoutCycleErrors: boolean;
  72446. /**
  72447. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72448. */
  72449. maxLayoutCycle: number;
  72450. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72451. get adaptHeightToChildren(): boolean;
  72452. set adaptHeightToChildren(value: boolean);
  72453. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72454. get adaptWidthToChildren(): boolean;
  72455. set adaptWidthToChildren(value: boolean);
  72456. /** Gets or sets background color */
  72457. get background(): string;
  72458. set background(value: string);
  72459. /** Gets the list of children */
  72460. get children(): Control[];
  72461. /**
  72462. * Creates a new Container
  72463. * @param name defines the name of the container
  72464. */
  72465. constructor(name?: string | undefined);
  72466. protected _getTypeName(): string;
  72467. _flagDescendantsAsMatrixDirty(): void;
  72468. /**
  72469. * Gets a child using its name
  72470. * @param name defines the child name to look for
  72471. * @returns the child control if found
  72472. */
  72473. getChildByName(name: string): BABYLON.Nullable<Control>;
  72474. /**
  72475. * Gets a child using its type and its name
  72476. * @param name defines the child name to look for
  72477. * @param type defines the child type to look for
  72478. * @returns the child control if found
  72479. */
  72480. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72481. /**
  72482. * Search for a specific control in children
  72483. * @param control defines the control to look for
  72484. * @returns true if the control is in child list
  72485. */
  72486. containsControl(control: Control): boolean;
  72487. /**
  72488. * Adds a new control to the current container
  72489. * @param control defines the control to add
  72490. * @returns the current container
  72491. */
  72492. addControl(control: BABYLON.Nullable<Control>): Container;
  72493. /**
  72494. * Removes all controls from the current container
  72495. * @returns the current container
  72496. */
  72497. clearControls(): Container;
  72498. /**
  72499. * Removes a control from the current container
  72500. * @param control defines the control to remove
  72501. * @returns the current container
  72502. */
  72503. removeControl(control: Control): Container;
  72504. /** @hidden */
  72505. _reOrderControl(control: Control): void;
  72506. /** @hidden */
  72507. _offsetLeft(offset: number): void;
  72508. /** @hidden */
  72509. _offsetTop(offset: number): void;
  72510. /** @hidden */
  72511. _markAllAsDirty(): void;
  72512. /** @hidden */
  72513. protected _localDraw(context: CanvasRenderingContext2D): void;
  72514. /** @hidden */
  72515. _link(host: AdvancedDynamicTexture): void;
  72516. /** @hidden */
  72517. protected _beforeLayout(): void;
  72518. /** @hidden */
  72519. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72520. /** @hidden */
  72521. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72522. protected _postMeasure(): void;
  72523. /** @hidden */
  72524. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72525. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72526. /** @hidden */
  72527. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72528. /** @hidden */
  72529. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72530. /** Releases associated resources */
  72531. dispose(): void;
  72532. }
  72533. }
  72534. declare module BABYLON.GUI {
  72535. /** Class used to create rectangle container */
  72536. export class Rectangle extends Container {
  72537. name?: string | undefined;
  72538. private _thickness;
  72539. private _cornerRadius;
  72540. /** Gets or sets border thickness */
  72541. get thickness(): number;
  72542. set thickness(value: number);
  72543. /** Gets or sets the corner radius angle */
  72544. get cornerRadius(): number;
  72545. set cornerRadius(value: number);
  72546. /**
  72547. * Creates a new Rectangle
  72548. * @param name defines the control name
  72549. */
  72550. constructor(name?: string | undefined);
  72551. protected _getTypeName(): string;
  72552. protected _localDraw(context: CanvasRenderingContext2D): void;
  72553. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72554. private _drawRoundedRect;
  72555. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72556. }
  72557. }
  72558. declare module BABYLON.GUI {
  72559. /**
  72560. * Enum that determines the text-wrapping mode to use.
  72561. */
  72562. export enum TextWrapping {
  72563. /**
  72564. * Clip the text when it's larger than Control.width; this is the default mode.
  72565. */
  72566. Clip = 0,
  72567. /**
  72568. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72569. */
  72570. WordWrap = 1,
  72571. /**
  72572. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72573. */
  72574. Ellipsis = 2
  72575. }
  72576. /**
  72577. * Class used to create text block control
  72578. */
  72579. export class TextBlock extends Control {
  72580. /**
  72581. * Defines the name of the control
  72582. */
  72583. name?: string | undefined;
  72584. private _text;
  72585. private _textWrapping;
  72586. private _textHorizontalAlignment;
  72587. private _textVerticalAlignment;
  72588. private _lines;
  72589. private _resizeToFit;
  72590. private _lineSpacing;
  72591. private _outlineWidth;
  72592. private _outlineColor;
  72593. /**
  72594. * An event triggered after the text is changed
  72595. */
  72596. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72597. /**
  72598. * An event triggered after the text was broken up into lines
  72599. */
  72600. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72601. /**
  72602. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72603. */
  72604. get lines(): any[];
  72605. /**
  72606. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72607. */
  72608. get resizeToFit(): boolean;
  72609. /**
  72610. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72611. */
  72612. set resizeToFit(value: boolean);
  72613. /**
  72614. * Gets or sets a boolean indicating if text must be wrapped
  72615. */
  72616. get textWrapping(): TextWrapping | boolean;
  72617. /**
  72618. * Gets or sets a boolean indicating if text must be wrapped
  72619. */
  72620. set textWrapping(value: TextWrapping | boolean);
  72621. /**
  72622. * Gets or sets text to display
  72623. */
  72624. get text(): string;
  72625. /**
  72626. * Gets or sets text to display
  72627. */
  72628. set text(value: string);
  72629. /**
  72630. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72631. */
  72632. get textHorizontalAlignment(): number;
  72633. /**
  72634. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72635. */
  72636. set textHorizontalAlignment(value: number);
  72637. /**
  72638. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72639. */
  72640. get textVerticalAlignment(): number;
  72641. /**
  72642. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72643. */
  72644. set textVerticalAlignment(value: number);
  72645. /**
  72646. * Gets or sets line spacing value
  72647. */
  72648. set lineSpacing(value: string | number);
  72649. /**
  72650. * Gets or sets line spacing value
  72651. */
  72652. get lineSpacing(): string | number;
  72653. /**
  72654. * Gets or sets outlineWidth of the text to display
  72655. */
  72656. get outlineWidth(): number;
  72657. /**
  72658. * Gets or sets outlineWidth of the text to display
  72659. */
  72660. set outlineWidth(value: number);
  72661. /**
  72662. * Gets or sets outlineColor of the text to display
  72663. */
  72664. get outlineColor(): string;
  72665. /**
  72666. * Gets or sets outlineColor of the text to display
  72667. */
  72668. set outlineColor(value: string);
  72669. /**
  72670. * Creates a new TextBlock object
  72671. * @param name defines the name of the control
  72672. * @param text defines the text to display (emptry string by default)
  72673. */
  72674. constructor(
  72675. /**
  72676. * Defines the name of the control
  72677. */
  72678. name?: string | undefined, text?: string);
  72679. protected _getTypeName(): string;
  72680. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72681. private _drawText;
  72682. /** @hidden */
  72683. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72684. protected _applyStates(context: CanvasRenderingContext2D): void;
  72685. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72686. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72687. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72688. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72689. protected _renderLines(context: CanvasRenderingContext2D): void;
  72690. /**
  72691. * Given a width constraint applied on the text block, find the expected height
  72692. * @returns expected height
  72693. */
  72694. computeExpectedHeight(): number;
  72695. dispose(): void;
  72696. }
  72697. }
  72698. declare module BABYLON.GUI {
  72699. /**
  72700. * Class used to create 2D images
  72701. */
  72702. export class Image extends Control {
  72703. name?: string | undefined;
  72704. private _workingCanvas;
  72705. private _domImage;
  72706. private _imageWidth;
  72707. private _imageHeight;
  72708. private _loaded;
  72709. private _stretch;
  72710. private _source;
  72711. private _autoScale;
  72712. private _sourceLeft;
  72713. private _sourceTop;
  72714. private _sourceWidth;
  72715. private _sourceHeight;
  72716. private _svgAttributesComputationCompleted;
  72717. private _isSVG;
  72718. private _cellWidth;
  72719. private _cellHeight;
  72720. private _cellId;
  72721. private _populateNinePatchSlicesFromImage;
  72722. private _sliceLeft;
  72723. private _sliceRight;
  72724. private _sliceTop;
  72725. private _sliceBottom;
  72726. private _detectPointerOnOpaqueOnly;
  72727. /**
  72728. * BABYLON.Observable notified when the content is loaded
  72729. */
  72730. onImageLoadedObservable: BABYLON.Observable<Image>;
  72731. /**
  72732. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72733. */
  72734. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72735. /**
  72736. * Gets a boolean indicating that the content is loaded
  72737. */
  72738. get isLoaded(): boolean;
  72739. /**
  72740. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72741. */
  72742. get populateNinePatchSlicesFromImage(): boolean;
  72743. set populateNinePatchSlicesFromImage(value: boolean);
  72744. /**
  72745. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72746. * Beware using this as this will comsume more memory as the image has to be stored twice
  72747. */
  72748. get detectPointerOnOpaqueOnly(): boolean;
  72749. set detectPointerOnOpaqueOnly(value: boolean);
  72750. /**
  72751. * Gets or sets the left value for slicing (9-patch)
  72752. */
  72753. get sliceLeft(): number;
  72754. set sliceLeft(value: number);
  72755. /**
  72756. * Gets or sets the right value for slicing (9-patch)
  72757. */
  72758. get sliceRight(): number;
  72759. set sliceRight(value: number);
  72760. /**
  72761. * Gets or sets the top value for slicing (9-patch)
  72762. */
  72763. get sliceTop(): number;
  72764. set sliceTop(value: number);
  72765. /**
  72766. * Gets or sets the bottom value for slicing (9-patch)
  72767. */
  72768. get sliceBottom(): number;
  72769. set sliceBottom(value: number);
  72770. /**
  72771. * Gets or sets the left coordinate in the source image
  72772. */
  72773. get sourceLeft(): number;
  72774. set sourceLeft(value: number);
  72775. /**
  72776. * Gets or sets the top coordinate in the source image
  72777. */
  72778. get sourceTop(): number;
  72779. set sourceTop(value: number);
  72780. /**
  72781. * Gets or sets the width to capture in the source image
  72782. */
  72783. get sourceWidth(): number;
  72784. set sourceWidth(value: number);
  72785. /**
  72786. * Gets or sets the height to capture in the source image
  72787. */
  72788. get sourceHeight(): number;
  72789. set sourceHeight(value: number);
  72790. /** Indicates if the format of the image is SVG */
  72791. get isSVG(): boolean;
  72792. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72793. get svgAttributesComputationCompleted(): boolean;
  72794. /**
  72795. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72796. * @see http://doc.babylonjs.com/how_to/gui#image
  72797. */
  72798. get autoScale(): boolean;
  72799. set autoScale(value: boolean);
  72800. /** Gets or sets the streching mode used by the image */
  72801. get stretch(): number;
  72802. set stretch(value: number);
  72803. /** @hidden */
  72804. _rotate90(n: number, preserveProperties?: boolean): Image;
  72805. private _handleRotationForSVGImage;
  72806. private _rotate90SourceProperties;
  72807. /**
  72808. * Gets or sets the internal DOM image used to render the control
  72809. */
  72810. set domImage(value: HTMLImageElement);
  72811. get domImage(): HTMLImageElement;
  72812. private _onImageLoaded;
  72813. private _extractNinePatchSliceDataFromImage;
  72814. /**
  72815. * Gets or sets image source url
  72816. */
  72817. set source(value: BABYLON.Nullable<string>);
  72818. /**
  72819. * Checks for svg document with icon id present
  72820. */
  72821. private _svgCheck;
  72822. /**
  72823. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72824. * given external svg file and icon id
  72825. */
  72826. private _getSVGAttribs;
  72827. /**
  72828. * Gets or sets the cell width to use when animation sheet is enabled
  72829. * @see http://doc.babylonjs.com/how_to/gui#image
  72830. */
  72831. get cellWidth(): number;
  72832. set cellWidth(value: number);
  72833. /**
  72834. * Gets or sets the cell height to use when animation sheet is enabled
  72835. * @see http://doc.babylonjs.com/how_to/gui#image
  72836. */
  72837. get cellHeight(): number;
  72838. set cellHeight(value: number);
  72839. /**
  72840. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72841. * @see http://doc.babylonjs.com/how_to/gui#image
  72842. */
  72843. get cellId(): number;
  72844. set cellId(value: number);
  72845. /**
  72846. * Creates a new Image
  72847. * @param name defines the control name
  72848. * @param url defines the image url
  72849. */
  72850. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72851. /**
  72852. * Tests if a given coordinates belong to the current control
  72853. * @param x defines x coordinate to test
  72854. * @param y defines y coordinate to test
  72855. * @returns true if the coordinates are inside the control
  72856. */
  72857. contains(x: number, y: number): boolean;
  72858. protected _getTypeName(): string;
  72859. /** Force the control to synchronize with its content */
  72860. synchronizeSizeWithContent(): void;
  72861. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72862. private _prepareWorkingCanvasForOpaqueDetection;
  72863. private _drawImage;
  72864. _draw(context: CanvasRenderingContext2D): void;
  72865. private _renderCornerPatch;
  72866. private _renderNinePatch;
  72867. dispose(): void;
  72868. /** STRETCH_NONE */
  72869. static readonly STRETCH_NONE: number;
  72870. /** STRETCH_FILL */
  72871. static readonly STRETCH_FILL: number;
  72872. /** STRETCH_UNIFORM */
  72873. static readonly STRETCH_UNIFORM: number;
  72874. /** STRETCH_EXTEND */
  72875. static readonly STRETCH_EXTEND: number;
  72876. /** NINE_PATCH */
  72877. static readonly STRETCH_NINE_PATCH: number;
  72878. }
  72879. }
  72880. declare module BABYLON.GUI {
  72881. /**
  72882. * Class used to create 2D buttons
  72883. */
  72884. export class Button extends Rectangle {
  72885. name?: string | undefined;
  72886. /**
  72887. * Function called to generate a pointer enter animation
  72888. */
  72889. pointerEnterAnimation: () => void;
  72890. /**
  72891. * Function called to generate a pointer out animation
  72892. */
  72893. pointerOutAnimation: () => void;
  72894. /**
  72895. * Function called to generate a pointer down animation
  72896. */
  72897. pointerDownAnimation: () => void;
  72898. /**
  72899. * Function called to generate a pointer up animation
  72900. */
  72901. pointerUpAnimation: () => void;
  72902. /**
  72903. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72904. */
  72905. delegatePickingToChildren: boolean;
  72906. private _image;
  72907. /**
  72908. * Returns the image part of the button (if any)
  72909. */
  72910. get image(): BABYLON.Nullable<Image>;
  72911. private _textBlock;
  72912. /**
  72913. * Returns the image part of the button (if any)
  72914. */
  72915. get textBlock(): BABYLON.Nullable<TextBlock>;
  72916. /**
  72917. * Creates a new Button
  72918. * @param name defines the name of the button
  72919. */
  72920. constructor(name?: string | undefined);
  72921. protected _getTypeName(): string;
  72922. /** @hidden */
  72923. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72924. /** @hidden */
  72925. _onPointerEnter(target: Control): boolean;
  72926. /** @hidden */
  72927. _onPointerOut(target: Control, force?: boolean): void;
  72928. /** @hidden */
  72929. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72930. /** @hidden */
  72931. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72932. /**
  72933. * Creates a new button made with an image and a text
  72934. * @param name defines the name of the button
  72935. * @param text defines the text of the button
  72936. * @param imageUrl defines the url of the image
  72937. * @returns a new Button
  72938. */
  72939. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72940. /**
  72941. * Creates a new button made with an image
  72942. * @param name defines the name of the button
  72943. * @param imageUrl defines the url of the image
  72944. * @returns a new Button
  72945. */
  72946. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72947. /**
  72948. * Creates a new button made with a text
  72949. * @param name defines the name of the button
  72950. * @param text defines the text of the button
  72951. * @returns a new Button
  72952. */
  72953. static CreateSimpleButton(name: string, text: string): Button;
  72954. /**
  72955. * Creates a new button made with an image and a centered text
  72956. * @param name defines the name of the button
  72957. * @param text defines the text of the button
  72958. * @param imageUrl defines the url of the image
  72959. * @returns a new Button
  72960. */
  72961. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72962. }
  72963. }
  72964. declare module BABYLON.GUI {
  72965. /**
  72966. * Class used to create a 2D stack panel container
  72967. */
  72968. export class StackPanel extends Container {
  72969. name?: string | undefined;
  72970. private _isVertical;
  72971. private _manualWidth;
  72972. private _manualHeight;
  72973. private _doNotTrackManualChanges;
  72974. /**
  72975. * Gets or sets a boolean indicating that layou warnings should be ignored
  72976. */
  72977. ignoreLayoutWarnings: boolean;
  72978. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72979. get isVertical(): boolean;
  72980. set isVertical(value: boolean);
  72981. /**
  72982. * Gets or sets panel width.
  72983. * This value should not be set when in horizontal mode as it will be computed automatically
  72984. */
  72985. set width(value: string | number);
  72986. get width(): string | number;
  72987. /**
  72988. * Gets or sets panel height.
  72989. * This value should not be set when in vertical mode as it will be computed automatically
  72990. */
  72991. set height(value: string | number);
  72992. get height(): string | number;
  72993. /**
  72994. * Creates a new StackPanel
  72995. * @param name defines control name
  72996. */
  72997. constructor(name?: string | undefined);
  72998. protected _getTypeName(): string;
  72999. /** @hidden */
  73000. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73001. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73002. protected _postMeasure(): void;
  73003. }
  73004. }
  73005. declare module BABYLON.GUI {
  73006. /**
  73007. * Class used to represent a 2D checkbox
  73008. */
  73009. export class Checkbox extends Control {
  73010. name?: string | undefined;
  73011. private _isChecked;
  73012. private _background;
  73013. private _checkSizeRatio;
  73014. private _thickness;
  73015. /** Gets or sets border thickness */
  73016. get thickness(): number;
  73017. set thickness(value: number);
  73018. /**
  73019. * BABYLON.Observable raised when isChecked property changes
  73020. */
  73021. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73022. /** Gets or sets a value indicating the ratio between overall size and check size */
  73023. get checkSizeRatio(): number;
  73024. set checkSizeRatio(value: number);
  73025. /** Gets or sets background color */
  73026. get background(): string;
  73027. set background(value: string);
  73028. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73029. get isChecked(): boolean;
  73030. set isChecked(value: boolean);
  73031. /**
  73032. * Creates a new CheckBox
  73033. * @param name defines the control name
  73034. */
  73035. constructor(name?: string | undefined);
  73036. protected _getTypeName(): string;
  73037. /** @hidden */
  73038. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73039. /** @hidden */
  73040. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73041. /**
  73042. * Utility function to easily create a checkbox with a header
  73043. * @param title defines the label to use for the header
  73044. * @param onValueChanged defines the callback to call when value changes
  73045. * @returns a StackPanel containing the checkbox and a textBlock
  73046. */
  73047. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  73048. }
  73049. }
  73050. declare module BABYLON.GUI {
  73051. /**
  73052. * Class used to store key control properties
  73053. */
  73054. export class KeyPropertySet {
  73055. /** Width */
  73056. width?: string;
  73057. /** Height */
  73058. height?: string;
  73059. /** Left padding */
  73060. paddingLeft?: string;
  73061. /** Right padding */
  73062. paddingRight?: string;
  73063. /** Top padding */
  73064. paddingTop?: string;
  73065. /** Bottom padding */
  73066. paddingBottom?: string;
  73067. /** Foreground color */
  73068. color?: string;
  73069. /** Background color */
  73070. background?: string;
  73071. }
  73072. /**
  73073. * Class used to create virtual keyboard
  73074. */
  73075. export class VirtualKeyboard extends StackPanel {
  73076. /** BABYLON.Observable raised when a key is pressed */
  73077. onKeyPressObservable: BABYLON.Observable<string>;
  73078. /** Gets or sets default key button width */
  73079. defaultButtonWidth: string;
  73080. /** Gets or sets default key button height */
  73081. defaultButtonHeight: string;
  73082. /** Gets or sets default key button left padding */
  73083. defaultButtonPaddingLeft: string;
  73084. /** Gets or sets default key button right padding */
  73085. defaultButtonPaddingRight: string;
  73086. /** Gets or sets default key button top padding */
  73087. defaultButtonPaddingTop: string;
  73088. /** Gets or sets default key button bottom padding */
  73089. defaultButtonPaddingBottom: string;
  73090. /** Gets or sets default key button foreground color */
  73091. defaultButtonColor: string;
  73092. /** Gets or sets default key button background color */
  73093. defaultButtonBackground: string;
  73094. /** Gets or sets shift button foreground color */
  73095. shiftButtonColor: string;
  73096. /** Gets or sets shift button thickness*/
  73097. selectedShiftThickness: number;
  73098. /** Gets shift key state */
  73099. shiftState: number;
  73100. protected _getTypeName(): string;
  73101. private _createKey;
  73102. /**
  73103. * Adds a new row of keys
  73104. * @param keys defines the list of keys to add
  73105. * @param propertySets defines the associated property sets
  73106. */
  73107. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  73108. /**
  73109. * Set the shift key to a specific state
  73110. * @param shiftState defines the new shift state
  73111. */
  73112. applyShiftState(shiftState: number): void;
  73113. private _currentlyConnectedInputText;
  73114. private _connectedInputTexts;
  73115. private _onKeyPressObserver;
  73116. /** Gets the input text control currently attached to the keyboard */
  73117. get connectedInputText(): BABYLON.Nullable<InputText>;
  73118. /**
  73119. * Connects the keyboard with an input text control
  73120. *
  73121. * @param input defines the target control
  73122. */
  73123. connect(input: InputText): void;
  73124. /**
  73125. * Disconnects the keyboard from connected InputText controls
  73126. *
  73127. * @param input optionally defines a target control, otherwise all are disconnected
  73128. */
  73129. disconnect(input?: InputText): void;
  73130. private _removeConnectedInputObservables;
  73131. /**
  73132. * Release all resources
  73133. */
  73134. dispose(): void;
  73135. /**
  73136. * Creates a new keyboard using a default layout
  73137. *
  73138. * @param name defines control name
  73139. * @returns a new VirtualKeyboard
  73140. */
  73141. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  73142. }
  73143. }
  73144. declare module BABYLON.GUI {
  73145. /**
  73146. * Class used to create input text control
  73147. */
  73148. export class InputText extends Control implements IFocusableControl {
  73149. name?: string | undefined;
  73150. private _text;
  73151. private _placeholderText;
  73152. private _background;
  73153. private _focusedBackground;
  73154. private _focusedColor;
  73155. private _placeholderColor;
  73156. private _thickness;
  73157. private _margin;
  73158. private _autoStretchWidth;
  73159. private _maxWidth;
  73160. private _isFocused;
  73161. private _blinkTimeout;
  73162. private _blinkIsEven;
  73163. private _cursorOffset;
  73164. private _scrollLeft;
  73165. private _textWidth;
  73166. private _clickedCoordinate;
  73167. private _deadKey;
  73168. private _addKey;
  73169. private _currentKey;
  73170. private _isTextHighlightOn;
  73171. private _textHighlightColor;
  73172. private _highligherOpacity;
  73173. private _highlightedText;
  73174. private _startHighlightIndex;
  73175. private _endHighlightIndex;
  73176. private _cursorIndex;
  73177. private _onFocusSelectAll;
  73178. private _isPointerDown;
  73179. private _onClipboardObserver;
  73180. private _onPointerDblTapObserver;
  73181. /** @hidden */
  73182. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  73183. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  73184. promptMessage: string;
  73185. /** Force disable prompt on mobile device */
  73186. disableMobilePrompt: boolean;
  73187. /** BABYLON.Observable raised when the text changes */
  73188. onTextChangedObservable: BABYLON.Observable<InputText>;
  73189. /** BABYLON.Observable raised just before an entered character is to be added */
  73190. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  73191. /** BABYLON.Observable raised when the control gets the focus */
  73192. onFocusObservable: BABYLON.Observable<InputText>;
  73193. /** BABYLON.Observable raised when the control loses the focus */
  73194. onBlurObservable: BABYLON.Observable<InputText>;
  73195. /**Observable raised when the text is highlighted */
  73196. onTextHighlightObservable: BABYLON.Observable<InputText>;
  73197. /**Observable raised when copy event is triggered */
  73198. onTextCopyObservable: BABYLON.Observable<InputText>;
  73199. /** BABYLON.Observable raised when cut event is triggered */
  73200. onTextCutObservable: BABYLON.Observable<InputText>;
  73201. /** BABYLON.Observable raised when paste event is triggered */
  73202. onTextPasteObservable: BABYLON.Observable<InputText>;
  73203. /** BABYLON.Observable raised when a key event was processed */
  73204. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  73205. /** Gets or sets the maximum width allowed by the control */
  73206. get maxWidth(): string | number;
  73207. /** Gets the maximum width allowed by the control in pixels */
  73208. get maxWidthInPixels(): number;
  73209. set maxWidth(value: string | number);
  73210. /** Gets or sets the text highlighter transparency; default: 0.4 */
  73211. get highligherOpacity(): number;
  73212. set highligherOpacity(value: number);
  73213. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  73214. get onFocusSelectAll(): boolean;
  73215. set onFocusSelectAll(value: boolean);
  73216. /** Gets or sets the text hightlight color */
  73217. get textHighlightColor(): string;
  73218. set textHighlightColor(value: string);
  73219. /** Gets or sets control margin */
  73220. get margin(): string;
  73221. /** Gets control margin in pixels */
  73222. get marginInPixels(): number;
  73223. set margin(value: string);
  73224. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  73225. get autoStretchWidth(): boolean;
  73226. set autoStretchWidth(value: boolean);
  73227. /** Gets or sets border thickness */
  73228. get thickness(): number;
  73229. set thickness(value: number);
  73230. /** Gets or sets the background color when focused */
  73231. get focusedBackground(): string;
  73232. set focusedBackground(value: string);
  73233. /** Gets or sets the background color when focused */
  73234. get focusedColor(): string;
  73235. set focusedColor(value: string);
  73236. /** Gets or sets the background color */
  73237. get background(): string;
  73238. set background(value: string);
  73239. /** Gets or sets the placeholder color */
  73240. get placeholderColor(): string;
  73241. set placeholderColor(value: string);
  73242. /** Gets or sets the text displayed when the control is empty */
  73243. get placeholderText(): string;
  73244. set placeholderText(value: string);
  73245. /** Gets or sets the dead key flag */
  73246. get deadKey(): boolean;
  73247. set deadKey(flag: boolean);
  73248. /** Gets or sets the highlight text */
  73249. get highlightedText(): string;
  73250. set highlightedText(text: string);
  73251. /** Gets or sets if the current key should be added */
  73252. get addKey(): boolean;
  73253. set addKey(flag: boolean);
  73254. /** Gets or sets the value of the current key being entered */
  73255. get currentKey(): string;
  73256. set currentKey(key: string);
  73257. /** Gets or sets the text displayed in the control */
  73258. get text(): string;
  73259. set text(value: string);
  73260. /** Gets or sets control width */
  73261. get width(): string | number;
  73262. set width(value: string | number);
  73263. /**
  73264. * Creates a new InputText
  73265. * @param name defines the control name
  73266. * @param text defines the text of the control
  73267. */
  73268. constructor(name?: string | undefined, text?: string);
  73269. /** @hidden */
  73270. onBlur(): void;
  73271. /** @hidden */
  73272. onFocus(): void;
  73273. protected _getTypeName(): string;
  73274. /**
  73275. * Function called to get the list of controls that should not steal the focus from this control
  73276. * @returns an array of controls
  73277. */
  73278. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73279. /** @hidden */
  73280. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  73281. /** @hidden */
  73282. private _updateValueFromCursorIndex;
  73283. /** @hidden */
  73284. private _processDblClick;
  73285. /** @hidden */
  73286. private _selectAllText;
  73287. /**
  73288. * Handles the keyboard event
  73289. * @param evt Defines the KeyboardEvent
  73290. */
  73291. processKeyboard(evt: KeyboardEvent): void;
  73292. /** @hidden */
  73293. private _onCopyText;
  73294. /** @hidden */
  73295. private _onCutText;
  73296. /** @hidden */
  73297. private _onPasteText;
  73298. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73299. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73300. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73301. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73302. protected _beforeRenderText(text: string): string;
  73303. dispose(): void;
  73304. }
  73305. }
  73306. declare module BABYLON.GUI {
  73307. /**
  73308. * Class used to create a 2D grid container
  73309. */
  73310. export class Grid extends Container {
  73311. name?: string | undefined;
  73312. private _rowDefinitions;
  73313. private _columnDefinitions;
  73314. private _cells;
  73315. private _childControls;
  73316. /**
  73317. * Gets the number of columns
  73318. */
  73319. get columnCount(): number;
  73320. /**
  73321. * Gets the number of rows
  73322. */
  73323. get rowCount(): number;
  73324. /** Gets the list of children */
  73325. get children(): Control[];
  73326. /** Gets the list of cells (e.g. the containers) */
  73327. get cells(): {
  73328. [key: string]: Container;
  73329. };
  73330. /**
  73331. * Gets the definition of a specific row
  73332. * @param index defines the index of the row
  73333. * @returns the row definition
  73334. */
  73335. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73336. /**
  73337. * Gets the definition of a specific column
  73338. * @param index defines the index of the column
  73339. * @returns the column definition
  73340. */
  73341. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73342. /**
  73343. * Adds a new row to the grid
  73344. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73345. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73346. * @returns the current grid
  73347. */
  73348. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73349. /**
  73350. * Adds a new column to the grid
  73351. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73352. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73353. * @returns the current grid
  73354. */
  73355. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73356. /**
  73357. * Update a row definition
  73358. * @param index defines the index of the row to update
  73359. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73360. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73361. * @returns the current grid
  73362. */
  73363. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73364. /**
  73365. * Update a column definition
  73366. * @param index defines the index of the column to update
  73367. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73368. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73369. * @returns the current grid
  73370. */
  73371. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73372. /**
  73373. * Gets the list of children stored in a specific cell
  73374. * @param row defines the row to check
  73375. * @param column defines the column to check
  73376. * @returns the list of controls
  73377. */
  73378. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73379. /**
  73380. * Gets a string representing the child cell info (row x column)
  73381. * @param child defines the control to get info from
  73382. * @returns a string containing the child cell info (row x column)
  73383. */
  73384. getChildCellInfo(child: Control): string;
  73385. private _removeCell;
  73386. private _offsetCell;
  73387. /**
  73388. * Remove a column definition at specified index
  73389. * @param index defines the index of the column to remove
  73390. * @returns the current grid
  73391. */
  73392. removeColumnDefinition(index: number): Grid;
  73393. /**
  73394. * Remove a row definition at specified index
  73395. * @param index defines the index of the row to remove
  73396. * @returns the current grid
  73397. */
  73398. removeRowDefinition(index: number): Grid;
  73399. /**
  73400. * Adds a new control to the current grid
  73401. * @param control defines the control to add
  73402. * @param row defines the row where to add the control (0 by default)
  73403. * @param column defines the column where to add the control (0 by default)
  73404. * @returns the current grid
  73405. */
  73406. addControl(control: Control, row?: number, column?: number): Grid;
  73407. /**
  73408. * Removes a control from the current container
  73409. * @param control defines the control to remove
  73410. * @returns the current container
  73411. */
  73412. removeControl(control: Control): Container;
  73413. /**
  73414. * Creates a new Grid
  73415. * @param name defines control name
  73416. */
  73417. constructor(name?: string | undefined);
  73418. protected _getTypeName(): string;
  73419. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73420. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73421. _flagDescendantsAsMatrixDirty(): void;
  73422. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73423. /** Releases associated resources */
  73424. dispose(): void;
  73425. }
  73426. }
  73427. declare module BABYLON.GUI {
  73428. /** Class used to create color pickers */
  73429. export class ColorPicker extends Control {
  73430. name?: string | undefined;
  73431. private static _Epsilon;
  73432. private _colorWheelCanvas;
  73433. private _value;
  73434. private _tmpColor;
  73435. private _pointerStartedOnSquare;
  73436. private _pointerStartedOnWheel;
  73437. private _squareLeft;
  73438. private _squareTop;
  73439. private _squareSize;
  73440. private _h;
  73441. private _s;
  73442. private _v;
  73443. private _lastPointerDownID;
  73444. /**
  73445. * BABYLON.Observable raised when the value changes
  73446. */
  73447. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73448. /** Gets or sets the color of the color picker */
  73449. get value(): BABYLON.Color3;
  73450. set value(value: BABYLON.Color3);
  73451. /**
  73452. * Gets or sets control width
  73453. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73454. */
  73455. get width(): string | number;
  73456. set width(value: string | number);
  73457. /**
  73458. * Gets or sets control height
  73459. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73460. */
  73461. get height(): string | number;
  73462. /** Gets or sets control height */
  73463. set height(value: string | number);
  73464. /** Gets or sets control size */
  73465. get size(): string | number;
  73466. set size(value: string | number);
  73467. /**
  73468. * Creates a new ColorPicker
  73469. * @param name defines the control name
  73470. */
  73471. constructor(name?: string | undefined);
  73472. protected _getTypeName(): string;
  73473. /** @hidden */
  73474. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73475. private _updateSquareProps;
  73476. private _drawGradientSquare;
  73477. private _drawCircle;
  73478. private _createColorWheelCanvas;
  73479. /** @hidden */
  73480. _draw(context: CanvasRenderingContext2D): void;
  73481. private _pointerIsDown;
  73482. private _updateValueFromPointer;
  73483. private _isPointOnSquare;
  73484. private _isPointOnWheel;
  73485. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73486. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73487. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73488. /**
  73489. * This function expands the color picker by creating a color picker dialog with manual
  73490. * color value input and the ability to save colors into an array to be used later in
  73491. * subsequent launches of the dialogue.
  73492. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73493. * @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.
  73494. * @returns picked color as a hex string and the saved colors array as hex strings.
  73495. */
  73496. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73497. pickerWidth?: string;
  73498. pickerHeight?: string;
  73499. headerHeight?: string;
  73500. lastColor?: string;
  73501. swatchLimit?: number;
  73502. numSwatchesPerLine?: number;
  73503. savedColors?: Array<string>;
  73504. }): Promise<{
  73505. savedColors?: string[];
  73506. pickedColor: string;
  73507. }>;
  73508. }
  73509. }
  73510. declare module BABYLON.GUI {
  73511. /** Class used to create 2D ellipse containers */
  73512. export class Ellipse extends Container {
  73513. name?: string | undefined;
  73514. private _thickness;
  73515. /** Gets or sets border thickness */
  73516. get thickness(): number;
  73517. set thickness(value: number);
  73518. /**
  73519. * Creates a new Ellipse
  73520. * @param name defines the control name
  73521. */
  73522. constructor(name?: string | undefined);
  73523. protected _getTypeName(): string;
  73524. protected _localDraw(context: CanvasRenderingContext2D): void;
  73525. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73526. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73527. }
  73528. }
  73529. declare module BABYLON.GUI {
  73530. /**
  73531. * Class used to create a password control
  73532. */
  73533. export class InputPassword extends InputText {
  73534. protected _beforeRenderText(text: string): string;
  73535. }
  73536. }
  73537. declare module BABYLON.GUI {
  73538. /** Class used to render 2D lines */
  73539. export class Line extends Control {
  73540. name?: string | undefined;
  73541. private _lineWidth;
  73542. private _x1;
  73543. private _y1;
  73544. private _x2;
  73545. private _y2;
  73546. private _dash;
  73547. private _connectedControl;
  73548. private _connectedControlDirtyObserver;
  73549. /** Gets or sets the dash pattern */
  73550. get dash(): Array<number>;
  73551. set dash(value: Array<number>);
  73552. /** Gets or sets the control connected with the line end */
  73553. get connectedControl(): Control;
  73554. set connectedControl(value: Control);
  73555. /** Gets or sets start coordinates on X axis */
  73556. get x1(): string | number;
  73557. set x1(value: string | number);
  73558. /** Gets or sets start coordinates on Y axis */
  73559. get y1(): string | number;
  73560. set y1(value: string | number);
  73561. /** Gets or sets end coordinates on X axis */
  73562. get x2(): string | number;
  73563. set x2(value: string | number);
  73564. /** Gets or sets end coordinates on Y axis */
  73565. get y2(): string | number;
  73566. set y2(value: string | number);
  73567. /** Gets or sets line width */
  73568. get lineWidth(): number;
  73569. set lineWidth(value: number);
  73570. /** Gets or sets horizontal alignment */
  73571. set horizontalAlignment(value: number);
  73572. /** Gets or sets vertical alignment */
  73573. set verticalAlignment(value: number);
  73574. private get _effectiveX2();
  73575. private get _effectiveY2();
  73576. /**
  73577. * Creates a new Line
  73578. * @param name defines the control name
  73579. */
  73580. constructor(name?: string | undefined);
  73581. protected _getTypeName(): string;
  73582. _draw(context: CanvasRenderingContext2D): void;
  73583. _measure(): void;
  73584. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73585. /**
  73586. * Move one end of the line given 3D cartesian coordinates.
  73587. * @param position Targeted world position
  73588. * @param scene BABYLON.Scene
  73589. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73590. */
  73591. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73592. /**
  73593. * Move one end of the line to a position in screen absolute space.
  73594. * @param projectedPosition Position in screen absolute space (X, Y)
  73595. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73596. */
  73597. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73598. }
  73599. }
  73600. declare module BABYLON.GUI {
  73601. /**
  73602. * Class used to store a point for a MultiLine object.
  73603. * The point can be pure 2D coordinates, a mesh or a control
  73604. */
  73605. export class MultiLinePoint {
  73606. private _multiLine;
  73607. private _x;
  73608. private _y;
  73609. private _control;
  73610. private _mesh;
  73611. private _controlObserver;
  73612. private _meshObserver;
  73613. /** @hidden */
  73614. _point: BABYLON.Vector2;
  73615. /**
  73616. * Creates a new MultiLinePoint
  73617. * @param multiLine defines the source MultiLine object
  73618. */
  73619. constructor(multiLine: MultiLine);
  73620. /** Gets or sets x coordinate */
  73621. get x(): string | number;
  73622. set x(value: string | number);
  73623. /** Gets or sets y coordinate */
  73624. get y(): string | number;
  73625. set y(value: string | number);
  73626. /** Gets or sets the control associated with this point */
  73627. get control(): BABYLON.Nullable<Control>;
  73628. set control(value: BABYLON.Nullable<Control>);
  73629. /** Gets or sets the mesh associated with this point */
  73630. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73631. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73632. /** Resets links */
  73633. resetLinks(): void;
  73634. /**
  73635. * Gets a translation vector
  73636. * @returns the translation vector
  73637. */
  73638. translate(): BABYLON.Vector2;
  73639. private _translatePoint;
  73640. /** Release associated resources */
  73641. dispose(): void;
  73642. }
  73643. }
  73644. declare module BABYLON.GUI {
  73645. /**
  73646. * Class used to create multi line control
  73647. */
  73648. export class MultiLine extends Control {
  73649. name?: string | undefined;
  73650. private _lineWidth;
  73651. private _dash;
  73652. private _points;
  73653. private _minX;
  73654. private _minY;
  73655. private _maxX;
  73656. private _maxY;
  73657. /**
  73658. * Creates a new MultiLine
  73659. * @param name defines the control name
  73660. */
  73661. constructor(name?: string | undefined);
  73662. /** Gets or sets dash pattern */
  73663. get dash(): Array<number>;
  73664. set dash(value: Array<number>);
  73665. /**
  73666. * Gets point stored at specified index
  73667. * @param index defines the index to look for
  73668. * @returns the requested point if found
  73669. */
  73670. getAt(index: number): MultiLinePoint;
  73671. /** Function called when a point is updated */
  73672. onPointUpdate: () => void;
  73673. /**
  73674. * Adds new points to the point collection
  73675. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73676. * @returns the list of created MultiLinePoint
  73677. */
  73678. add(...items: (AbstractMesh | Control | {
  73679. x: string | number;
  73680. y: string | number;
  73681. })[]): MultiLinePoint[];
  73682. /**
  73683. * Adds a new point to the point collection
  73684. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73685. * @returns the created MultiLinePoint
  73686. */
  73687. push(item?: (AbstractMesh | Control | {
  73688. x: string | number;
  73689. y: string | number;
  73690. })): MultiLinePoint;
  73691. /**
  73692. * Remove a specific value or point from the active point collection
  73693. * @param value defines the value or point to remove
  73694. */
  73695. remove(value: number | MultiLinePoint): void;
  73696. /**
  73697. * Resets this object to initial state (no point)
  73698. */
  73699. reset(): void;
  73700. /**
  73701. * Resets all links
  73702. */
  73703. resetLinks(): void;
  73704. /** Gets or sets line width */
  73705. get lineWidth(): number;
  73706. set lineWidth(value: number);
  73707. set horizontalAlignment(value: number);
  73708. set verticalAlignment(value: number);
  73709. protected _getTypeName(): string;
  73710. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73711. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73712. _measure(): void;
  73713. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73714. dispose(): void;
  73715. }
  73716. }
  73717. declare module BABYLON.GUI {
  73718. /**
  73719. * Class used to create radio button controls
  73720. */
  73721. export class RadioButton extends Control {
  73722. name?: string | undefined;
  73723. private _isChecked;
  73724. private _background;
  73725. private _checkSizeRatio;
  73726. private _thickness;
  73727. /** Gets or sets border thickness */
  73728. get thickness(): number;
  73729. set thickness(value: number);
  73730. /** Gets or sets group name */
  73731. group: string;
  73732. /** BABYLON.Observable raised when isChecked is changed */
  73733. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73734. /** Gets or sets a value indicating the ratio between overall size and check size */
  73735. get checkSizeRatio(): number;
  73736. set checkSizeRatio(value: number);
  73737. /** Gets or sets background color */
  73738. get background(): string;
  73739. set background(value: string);
  73740. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73741. get isChecked(): boolean;
  73742. set isChecked(value: boolean);
  73743. /**
  73744. * Creates a new RadioButton
  73745. * @param name defines the control name
  73746. */
  73747. constructor(name?: string | undefined);
  73748. protected _getTypeName(): string;
  73749. _draw(context: CanvasRenderingContext2D): void;
  73750. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73751. /**
  73752. * Utility function to easily create a radio button with a header
  73753. * @param title defines the label to use for the header
  73754. * @param group defines the group to use for the radio button
  73755. * @param isChecked defines the initial state of the radio button
  73756. * @param onValueChanged defines the callback to call when value changes
  73757. * @returns a StackPanel containing the radio button and a textBlock
  73758. */
  73759. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73760. }
  73761. }
  73762. declare module BABYLON.GUI {
  73763. /**
  73764. * Class used to create slider controls
  73765. */
  73766. export class BaseSlider extends Control {
  73767. name?: string | undefined;
  73768. protected _thumbWidth: ValueAndUnit;
  73769. private _minimum;
  73770. private _maximum;
  73771. private _value;
  73772. private _isVertical;
  73773. protected _barOffset: ValueAndUnit;
  73774. private _isThumbClamped;
  73775. protected _displayThumb: boolean;
  73776. private _step;
  73777. private _lastPointerDownID;
  73778. protected _effectiveBarOffset: number;
  73779. protected _renderLeft: number;
  73780. protected _renderTop: number;
  73781. protected _renderWidth: number;
  73782. protected _renderHeight: number;
  73783. protected _backgroundBoxLength: number;
  73784. protected _backgroundBoxThickness: number;
  73785. protected _effectiveThumbThickness: number;
  73786. /** BABYLON.Observable raised when the sldier value changes */
  73787. onValueChangedObservable: BABYLON.Observable<number>;
  73788. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73789. get displayThumb(): boolean;
  73790. set displayThumb(value: boolean);
  73791. /** Gets or sets a step to apply to values (0 by default) */
  73792. get step(): number;
  73793. set step(value: number);
  73794. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73795. get barOffset(): string | number;
  73796. /** Gets main bar offset in pixels*/
  73797. get barOffsetInPixels(): number;
  73798. set barOffset(value: string | number);
  73799. /** Gets or sets thumb width */
  73800. get thumbWidth(): string | number;
  73801. /** Gets thumb width in pixels */
  73802. get thumbWidthInPixels(): number;
  73803. set thumbWidth(value: string | number);
  73804. /** Gets or sets minimum value */
  73805. get minimum(): number;
  73806. set minimum(value: number);
  73807. /** Gets or sets maximum value */
  73808. get maximum(): number;
  73809. set maximum(value: number);
  73810. /** Gets or sets current value */
  73811. get value(): number;
  73812. set value(value: number);
  73813. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73814. get isVertical(): boolean;
  73815. set isVertical(value: boolean);
  73816. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73817. get isThumbClamped(): boolean;
  73818. set isThumbClamped(value: boolean);
  73819. /**
  73820. * Creates a new BaseSlider
  73821. * @param name defines the control name
  73822. */
  73823. constructor(name?: string | undefined);
  73824. protected _getTypeName(): string;
  73825. protected _getThumbPosition(): number;
  73826. protected _getThumbThickness(type: string): number;
  73827. protected _prepareRenderingData(type: string): void;
  73828. private _pointerIsDown;
  73829. /** @hidden */
  73830. protected _updateValueFromPointer(x: number, y: number): void;
  73831. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73832. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73833. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73834. }
  73835. }
  73836. declare module BABYLON.GUI {
  73837. /**
  73838. * Class used to create slider controls
  73839. */
  73840. export class Slider extends BaseSlider {
  73841. name?: string | undefined;
  73842. private _background;
  73843. private _borderColor;
  73844. private _isThumbCircle;
  73845. protected _displayValueBar: boolean;
  73846. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73847. get displayValueBar(): boolean;
  73848. set displayValueBar(value: boolean);
  73849. /** Gets or sets border color */
  73850. get borderColor(): string;
  73851. set borderColor(value: string);
  73852. /** Gets or sets background color */
  73853. get background(): string;
  73854. set background(value: string);
  73855. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73856. get isThumbCircle(): boolean;
  73857. set isThumbCircle(value: boolean);
  73858. /**
  73859. * Creates a new Slider
  73860. * @param name defines the control name
  73861. */
  73862. constructor(name?: string | undefined);
  73863. protected _getTypeName(): string;
  73864. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73865. }
  73866. }
  73867. declare module BABYLON.GUI {
  73868. /** Class used to create a RadioGroup
  73869. * which contains groups of radio buttons
  73870. */
  73871. export class SelectorGroup {
  73872. /** name of SelectorGroup */
  73873. name: string;
  73874. private _groupPanel;
  73875. private _selectors;
  73876. private _groupHeader;
  73877. /**
  73878. * Creates a new SelectorGroup
  73879. * @param name of group, used as a group heading
  73880. */
  73881. constructor(
  73882. /** name of SelectorGroup */
  73883. name: string);
  73884. /** Gets the groupPanel of the SelectorGroup */
  73885. get groupPanel(): StackPanel;
  73886. /** Gets the selectors array */
  73887. get selectors(): StackPanel[];
  73888. /** Gets and sets the group header */
  73889. get header(): string;
  73890. set header(label: string);
  73891. /** @hidden */
  73892. private _addGroupHeader;
  73893. /** @hidden*/
  73894. _getSelector(selectorNb: number): StackPanel | undefined;
  73895. /** Removes the selector at the given position
  73896. * @param selectorNb the position of the selector within the group
  73897. */
  73898. removeSelector(selectorNb: number): void;
  73899. }
  73900. /** Class used to create a CheckboxGroup
  73901. * which contains groups of checkbox buttons
  73902. */
  73903. export class CheckboxGroup extends SelectorGroup {
  73904. /** Adds a checkbox as a control
  73905. * @param text is the label for the selector
  73906. * @param func is the function called when the Selector is checked
  73907. * @param checked is true when Selector is checked
  73908. */
  73909. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73910. /** @hidden */
  73911. _setSelectorLabel(selectorNb: number, label: string): void;
  73912. /** @hidden */
  73913. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73914. /** @hidden */
  73915. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73916. /** @hidden */
  73917. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73918. }
  73919. /** Class used to create a RadioGroup
  73920. * which contains groups of radio buttons
  73921. */
  73922. export class RadioGroup extends SelectorGroup {
  73923. private _selectNb;
  73924. /** Adds a radio button as a control
  73925. * @param label is the label for the selector
  73926. * @param func is the function called when the Selector is checked
  73927. * @param checked is true when Selector is checked
  73928. */
  73929. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73930. /** @hidden */
  73931. _setSelectorLabel(selectorNb: number, label: string): void;
  73932. /** @hidden */
  73933. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73934. /** @hidden */
  73935. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73936. /** @hidden */
  73937. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73938. }
  73939. /** Class used to create a SliderGroup
  73940. * which contains groups of slider buttons
  73941. */
  73942. export class SliderGroup extends SelectorGroup {
  73943. /**
  73944. * Adds a slider to the SelectorGroup
  73945. * @param label is the label for the SliderBar
  73946. * @param func is the function called when the Slider moves
  73947. * @param unit is a string describing the units used, eg degrees or metres
  73948. * @param min is the minimum value for the Slider
  73949. * @param max is the maximum value for the Slider
  73950. * @param value is the start value for the Slider between min and max
  73951. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73952. */
  73953. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73954. /** @hidden */
  73955. _setSelectorLabel(selectorNb: number, label: string): void;
  73956. /** @hidden */
  73957. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73958. /** @hidden */
  73959. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73960. /** @hidden */
  73961. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73962. }
  73963. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73964. * @see http://doc.babylonjs.com/how_to/selector
  73965. */
  73966. export class SelectionPanel extends Rectangle {
  73967. /** name of SelectionPanel */
  73968. name: string;
  73969. /** an array of SelectionGroups */
  73970. groups: SelectorGroup[];
  73971. private _panel;
  73972. private _buttonColor;
  73973. private _buttonBackground;
  73974. private _headerColor;
  73975. private _barColor;
  73976. private _barHeight;
  73977. private _spacerHeight;
  73978. private _labelColor;
  73979. private _groups;
  73980. private _bars;
  73981. /**
  73982. * Creates a new SelectionPanel
  73983. * @param name of SelectionPanel
  73984. * @param groups is an array of SelectionGroups
  73985. */
  73986. constructor(
  73987. /** name of SelectionPanel */
  73988. name: string,
  73989. /** an array of SelectionGroups */
  73990. groups?: SelectorGroup[]);
  73991. protected _getTypeName(): string;
  73992. /** Gets or sets the headerColor */
  73993. get headerColor(): string;
  73994. set headerColor(color: string);
  73995. private _setHeaderColor;
  73996. /** Gets or sets the button color */
  73997. get buttonColor(): string;
  73998. set buttonColor(color: string);
  73999. private _setbuttonColor;
  74000. /** Gets or sets the label color */
  74001. get labelColor(): string;
  74002. set labelColor(color: string);
  74003. private _setLabelColor;
  74004. /** Gets or sets the button background */
  74005. get buttonBackground(): string;
  74006. set buttonBackground(color: string);
  74007. private _setButtonBackground;
  74008. /** Gets or sets the color of separator bar */
  74009. get barColor(): string;
  74010. set barColor(color: string);
  74011. private _setBarColor;
  74012. /** Gets or sets the height of separator bar */
  74013. get barHeight(): string;
  74014. set barHeight(value: string);
  74015. private _setBarHeight;
  74016. /** Gets or sets the height of spacers*/
  74017. get spacerHeight(): string;
  74018. set spacerHeight(value: string);
  74019. private _setSpacerHeight;
  74020. /** Adds a bar between groups */
  74021. private _addSpacer;
  74022. /** Add a group to the selection panel
  74023. * @param group is the selector group to add
  74024. */
  74025. addGroup(group: SelectorGroup): void;
  74026. /** Remove the group from the given position
  74027. * @param groupNb is the position of the group in the list
  74028. */
  74029. removeGroup(groupNb: number): void;
  74030. /** Change a group header label
  74031. * @param label is the new group header label
  74032. * @param groupNb is the number of the group to relabel
  74033. * */
  74034. setHeaderName(label: string, groupNb: number): void;
  74035. /** Change selector label to the one given
  74036. * @param label is the new selector label
  74037. * @param groupNb is the number of the groupcontaining the selector
  74038. * @param selectorNb is the number of the selector within a group to relabel
  74039. * */
  74040. relabel(label: string, groupNb: number, selectorNb: number): void;
  74041. /** For a given group position remove the selector at the given position
  74042. * @param groupNb is the number of the group to remove the selector from
  74043. * @param selectorNb is the number of the selector within the group
  74044. */
  74045. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  74046. /** For a given group position of correct type add a checkbox button
  74047. * @param groupNb is the number of the group to remove the selector from
  74048. * @param label is the label for the selector
  74049. * @param func is the function called when the Selector is checked
  74050. * @param checked is true when Selector is checked
  74051. */
  74052. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74053. /** For a given group position of correct type add a radio button
  74054. * @param groupNb is the number of the group to remove the selector from
  74055. * @param label is the label for the selector
  74056. * @param func is the function called when the Selector is checked
  74057. * @param checked is true when Selector is checked
  74058. */
  74059. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74060. /**
  74061. * For a given slider group add a slider
  74062. * @param groupNb is the number of the group to add the slider to
  74063. * @param label is the label for the Slider
  74064. * @param func is the function called when the Slider moves
  74065. * @param unit is a string describing the units used, eg degrees or metres
  74066. * @param min is the minimum value for the Slider
  74067. * @param max is the maximum value for the Slider
  74068. * @param value is the start value for the Slider between min and max
  74069. * @param onVal is the function used to format the value displayed, eg radians to degrees
  74070. */
  74071. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  74072. }
  74073. }
  74074. declare module BABYLON.GUI {
  74075. /**
  74076. * Class used to hold a the container for ScrollViewer
  74077. * @hidden
  74078. */
  74079. export class _ScrollViewerWindow extends Container {
  74080. parentClientWidth: number;
  74081. parentClientHeight: number;
  74082. private _freezeControls;
  74083. private _parentMeasure;
  74084. private _oldLeft;
  74085. private _oldTop;
  74086. get freezeControls(): boolean;
  74087. set freezeControls(value: boolean);
  74088. private _bucketWidth;
  74089. private _bucketHeight;
  74090. private _buckets;
  74091. private _bucketLen;
  74092. get bucketWidth(): number;
  74093. get bucketHeight(): number;
  74094. setBucketSizes(width: number, height: number): void;
  74095. private _useBuckets;
  74096. private _makeBuckets;
  74097. private _dispatchInBuckets;
  74098. private _updateMeasures;
  74099. private _updateChildrenMeasures;
  74100. private _restoreMeasures;
  74101. /**
  74102. * Creates a new ScrollViewerWindow
  74103. * @param name of ScrollViewerWindow
  74104. */
  74105. constructor(name?: string);
  74106. protected _getTypeName(): string;
  74107. /** @hidden */
  74108. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74109. /** @hidden */
  74110. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74111. private _scrollChildren;
  74112. private _scrollChildrenWithBuckets;
  74113. /** @hidden */
  74114. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  74115. protected _postMeasure(): void;
  74116. }
  74117. }
  74118. declare module BABYLON.GUI {
  74119. /**
  74120. * Class used to create slider controls
  74121. */
  74122. export class ScrollBar extends BaseSlider {
  74123. name?: string | undefined;
  74124. private _background;
  74125. private _borderColor;
  74126. private _tempMeasure;
  74127. /** Gets or sets border color */
  74128. get borderColor(): string;
  74129. set borderColor(value: string);
  74130. /** Gets or sets background color */
  74131. get background(): string;
  74132. set background(value: string);
  74133. /**
  74134. * Creates a new Slider
  74135. * @param name defines the control name
  74136. */
  74137. constructor(name?: string | undefined);
  74138. protected _getTypeName(): string;
  74139. protected _getThumbThickness(): number;
  74140. _draw(context: CanvasRenderingContext2D): void;
  74141. private _first;
  74142. private _originX;
  74143. private _originY;
  74144. /** @hidden */
  74145. protected _updateValueFromPointer(x: number, y: number): void;
  74146. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74147. }
  74148. }
  74149. declare module BABYLON.GUI {
  74150. /**
  74151. * Class used to create slider controls
  74152. */
  74153. export class ImageScrollBar extends BaseSlider {
  74154. name?: string | undefined;
  74155. private _backgroundBaseImage;
  74156. private _backgroundImage;
  74157. private _thumbImage;
  74158. private _thumbBaseImage;
  74159. private _thumbLength;
  74160. private _thumbHeight;
  74161. private _barImageHeight;
  74162. private _tempMeasure;
  74163. /** Number of 90° rotation to apply on the images when in vertical mode */
  74164. num90RotationInVerticalMode: number;
  74165. /**
  74166. * Gets or sets the image used to render the background for horizontal bar
  74167. */
  74168. get backgroundImage(): Image;
  74169. set backgroundImage(value: Image);
  74170. /**
  74171. * Gets or sets the image used to render the thumb
  74172. */
  74173. get thumbImage(): Image;
  74174. set thumbImage(value: Image);
  74175. /**
  74176. * Gets or sets the length of the thumb
  74177. */
  74178. get thumbLength(): number;
  74179. set thumbLength(value: number);
  74180. /**
  74181. * Gets or sets the height of the thumb
  74182. */
  74183. get thumbHeight(): number;
  74184. set thumbHeight(value: number);
  74185. /**
  74186. * Gets or sets the height of the bar image
  74187. */
  74188. get barImageHeight(): number;
  74189. set barImageHeight(value: number);
  74190. /**
  74191. * Creates a new ImageScrollBar
  74192. * @param name defines the control name
  74193. */
  74194. constructor(name?: string | undefined);
  74195. protected _getTypeName(): string;
  74196. protected _getThumbThickness(): number;
  74197. _draw(context: CanvasRenderingContext2D): void;
  74198. private _first;
  74199. private _originX;
  74200. private _originY;
  74201. /** @hidden */
  74202. protected _updateValueFromPointer(x: number, y: number): void;
  74203. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74204. }
  74205. }
  74206. declare module BABYLON.GUI {
  74207. /**
  74208. * Class used to hold a viewer window and sliders in a grid
  74209. */
  74210. export class ScrollViewer extends Rectangle {
  74211. private _grid;
  74212. private _horizontalBarSpace;
  74213. private _verticalBarSpace;
  74214. private _dragSpace;
  74215. private _horizontalBar;
  74216. private _verticalBar;
  74217. private _barColor;
  74218. private _barBackground;
  74219. private _barImage;
  74220. private _horizontalBarImage;
  74221. private _verticalBarImage;
  74222. private _barBackgroundImage;
  74223. private _horizontalBarBackgroundImage;
  74224. private _verticalBarBackgroundImage;
  74225. private _barSize;
  74226. private _window;
  74227. private _pointerIsOver;
  74228. private _wheelPrecision;
  74229. private _onWheelObserver;
  74230. private _clientWidth;
  74231. private _clientHeight;
  74232. private _useImageBar;
  74233. private _thumbLength;
  74234. private _thumbHeight;
  74235. private _barImageHeight;
  74236. private _horizontalBarImageHeight;
  74237. private _verticalBarImageHeight;
  74238. private _oldWindowContentsWidth;
  74239. private _oldWindowContentsHeight;
  74240. /**
  74241. * Gets the horizontal scrollbar
  74242. */
  74243. get horizontalBar(): ScrollBar | ImageScrollBar;
  74244. /**
  74245. * Gets the vertical scrollbar
  74246. */
  74247. get verticalBar(): ScrollBar | ImageScrollBar;
  74248. /**
  74249. * Adds a new control to the current container
  74250. * @param control defines the control to add
  74251. * @returns the current container
  74252. */
  74253. addControl(control: BABYLON.Nullable<Control>): Container;
  74254. /**
  74255. * Removes a control from the current container
  74256. * @param control defines the control to remove
  74257. * @returns the current container
  74258. */
  74259. removeControl(control: Control): Container;
  74260. /** Gets the list of children */
  74261. get children(): Control[];
  74262. _flagDescendantsAsMatrixDirty(): void;
  74263. /**
  74264. * Freezes or unfreezes the controls in the window.
  74265. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  74266. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  74267. */
  74268. get freezeControls(): boolean;
  74269. set freezeControls(value: boolean);
  74270. /** Gets the bucket width */
  74271. get bucketWidth(): number;
  74272. /** Gets the bucket height */
  74273. get bucketHeight(): number;
  74274. /**
  74275. * Sets the bucket sizes.
  74276. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  74277. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  74278. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  74279. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  74280. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  74281. * used), that's why it is not enabled by default.
  74282. * @param width width of the bucket
  74283. * @param height height of the bucket
  74284. */
  74285. setBucketSizes(width: number, height: number): void;
  74286. private _forceHorizontalBar;
  74287. private _forceVerticalBar;
  74288. /**
  74289. * Forces the horizontal scroll bar to be displayed
  74290. */
  74291. get forceHorizontalBar(): boolean;
  74292. set forceHorizontalBar(value: boolean);
  74293. /**
  74294. * Forces the vertical scroll bar to be displayed
  74295. */
  74296. get forceVerticalBar(): boolean;
  74297. set forceVerticalBar(value: boolean);
  74298. /**
  74299. * Creates a new ScrollViewer
  74300. * @param name of ScrollViewer
  74301. */
  74302. constructor(name?: string, isImageBased?: boolean);
  74303. /** Reset the scroll viewer window to initial size */
  74304. resetWindow(): void;
  74305. protected _getTypeName(): string;
  74306. private _buildClientSizes;
  74307. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74308. protected _postMeasure(): void;
  74309. /**
  74310. * Gets or sets the mouse wheel precision
  74311. * from 0 to 1 with a default value of 0.05
  74312. * */
  74313. get wheelPrecision(): number;
  74314. set wheelPrecision(value: number);
  74315. /** Gets or sets the scroll bar container background color */
  74316. get scrollBackground(): string;
  74317. set scrollBackground(color: string);
  74318. /** Gets or sets the bar color */
  74319. get barColor(): string;
  74320. set barColor(color: string);
  74321. /** Gets or sets the bar image */
  74322. get thumbImage(): Image;
  74323. set thumbImage(value: Image);
  74324. /** Gets or sets the horizontal bar image */
  74325. get horizontalThumbImage(): Image;
  74326. set horizontalThumbImage(value: Image);
  74327. /** Gets or sets the vertical bar image */
  74328. get verticalThumbImage(): Image;
  74329. set verticalThumbImage(value: Image);
  74330. /** Gets or sets the size of the bar */
  74331. get barSize(): number;
  74332. set barSize(value: number);
  74333. /** Gets or sets the length of the thumb */
  74334. get thumbLength(): number;
  74335. set thumbLength(value: number);
  74336. /** Gets or sets the height of the thumb */
  74337. get thumbHeight(): number;
  74338. set thumbHeight(value: number);
  74339. /** Gets or sets the height of the bar image */
  74340. get barImageHeight(): number;
  74341. set barImageHeight(value: number);
  74342. /** Gets or sets the height of the horizontal bar image */
  74343. get horizontalBarImageHeight(): number;
  74344. set horizontalBarImageHeight(value: number);
  74345. /** Gets or sets the height of the vertical bar image */
  74346. get verticalBarImageHeight(): number;
  74347. set verticalBarImageHeight(value: number);
  74348. /** Gets or sets the bar background */
  74349. get barBackground(): string;
  74350. set barBackground(color: string);
  74351. /** Gets or sets the bar background image */
  74352. get barImage(): Image;
  74353. set barImage(value: Image);
  74354. /** Gets or sets the horizontal bar background image */
  74355. get horizontalBarImage(): Image;
  74356. set horizontalBarImage(value: Image);
  74357. /** Gets or sets the vertical bar background image */
  74358. get verticalBarImage(): Image;
  74359. set verticalBarImage(value: Image);
  74360. private _setWindowPosition;
  74361. /** @hidden */
  74362. private _updateScroller;
  74363. _link(host: AdvancedDynamicTexture): void;
  74364. /** @hidden */
  74365. private _addBar;
  74366. /** @hidden */
  74367. private _attachWheel;
  74368. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74369. /** Releases associated resources */
  74370. dispose(): void;
  74371. }
  74372. }
  74373. declare module BABYLON.GUI {
  74374. /** Class used to render a grid */
  74375. export class DisplayGrid extends Control {
  74376. name?: string | undefined;
  74377. private _cellWidth;
  74378. private _cellHeight;
  74379. private _minorLineTickness;
  74380. private _minorLineColor;
  74381. private _majorLineTickness;
  74382. private _majorLineColor;
  74383. private _majorLineFrequency;
  74384. private _background;
  74385. private _displayMajorLines;
  74386. private _displayMinorLines;
  74387. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74388. get displayMinorLines(): boolean;
  74389. set displayMinorLines(value: boolean);
  74390. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74391. get displayMajorLines(): boolean;
  74392. set displayMajorLines(value: boolean);
  74393. /** Gets or sets background color (Black by default) */
  74394. get background(): string;
  74395. set background(value: string);
  74396. /** Gets or sets the width of each cell (20 by default) */
  74397. get cellWidth(): number;
  74398. set cellWidth(value: number);
  74399. /** Gets or sets the height of each cell (20 by default) */
  74400. get cellHeight(): number;
  74401. set cellHeight(value: number);
  74402. /** Gets or sets the tickness of minor lines (1 by default) */
  74403. get minorLineTickness(): number;
  74404. set minorLineTickness(value: number);
  74405. /** Gets or sets the color of minor lines (DarkGray by default) */
  74406. get minorLineColor(): string;
  74407. set minorLineColor(value: string);
  74408. /** Gets or sets the tickness of major lines (2 by default) */
  74409. get majorLineTickness(): number;
  74410. set majorLineTickness(value: number);
  74411. /** Gets or sets the color of major lines (White by default) */
  74412. get majorLineColor(): string;
  74413. set majorLineColor(value: string);
  74414. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74415. get majorLineFrequency(): number;
  74416. set majorLineFrequency(value: number);
  74417. /**
  74418. * Creates a new GridDisplayRectangle
  74419. * @param name defines the control name
  74420. */
  74421. constructor(name?: string | undefined);
  74422. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74423. protected _getTypeName(): string;
  74424. }
  74425. }
  74426. declare module BABYLON.GUI {
  74427. /**
  74428. * Class used to create slider controls based on images
  74429. */
  74430. export class ImageBasedSlider extends BaseSlider {
  74431. name?: string | undefined;
  74432. private _backgroundImage;
  74433. private _thumbImage;
  74434. private _valueBarImage;
  74435. private _tempMeasure;
  74436. get displayThumb(): boolean;
  74437. set displayThumb(value: boolean);
  74438. /**
  74439. * Gets or sets the image used to render the background
  74440. */
  74441. get backgroundImage(): Image;
  74442. set backgroundImage(value: Image);
  74443. /**
  74444. * Gets or sets the image used to render the value bar
  74445. */
  74446. get valueBarImage(): Image;
  74447. set valueBarImage(value: Image);
  74448. /**
  74449. * Gets or sets the image used to render the thumb
  74450. */
  74451. get thumbImage(): Image;
  74452. set thumbImage(value: Image);
  74453. /**
  74454. * Creates a new ImageBasedSlider
  74455. * @param name defines the control name
  74456. */
  74457. constructor(name?: string | undefined);
  74458. protected _getTypeName(): string;
  74459. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74460. }
  74461. }
  74462. declare module BABYLON.GUI {
  74463. /**
  74464. * Forcing an export so that this code will execute
  74465. * @hidden
  74466. */
  74467. const name = "Statics";
  74468. }
  74469. declare module BABYLON.GUI {
  74470. /**
  74471. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74472. */
  74473. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74474. /**
  74475. * Define the instrumented AdvancedDynamicTexture.
  74476. */
  74477. texture: AdvancedDynamicTexture;
  74478. private _captureRenderTime;
  74479. private _renderTime;
  74480. private _captureLayoutTime;
  74481. private _layoutTime;
  74482. private _onBeginRenderObserver;
  74483. private _onEndRenderObserver;
  74484. private _onBeginLayoutObserver;
  74485. private _onEndLayoutObserver;
  74486. /**
  74487. * Gets the perf counter used to capture render time
  74488. */
  74489. get renderTimeCounter(): BABYLON.PerfCounter;
  74490. /**
  74491. * Gets the perf counter used to capture layout time
  74492. */
  74493. get layoutTimeCounter(): BABYLON.PerfCounter;
  74494. /**
  74495. * Enable or disable the render time capture
  74496. */
  74497. get captureRenderTime(): boolean;
  74498. set captureRenderTime(value: boolean);
  74499. /**
  74500. * Enable or disable the layout time capture
  74501. */
  74502. get captureLayoutTime(): boolean;
  74503. set captureLayoutTime(value: boolean);
  74504. /**
  74505. * Instantiates a new advanced dynamic texture instrumentation.
  74506. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74507. * @param texture Defines the AdvancedDynamicTexture to instrument
  74508. */
  74509. constructor(
  74510. /**
  74511. * Define the instrumented AdvancedDynamicTexture.
  74512. */
  74513. texture: AdvancedDynamicTexture);
  74514. /**
  74515. * Dispose and release associated resources.
  74516. */
  74517. dispose(): void;
  74518. }
  74519. }
  74520. declare module BABYLON.GUI {
  74521. /**
  74522. * Class used to load GUI via XML.
  74523. */
  74524. export class XmlLoader {
  74525. private _nodes;
  74526. private _nodeTypes;
  74527. private _isLoaded;
  74528. private _objectAttributes;
  74529. private _parentClass;
  74530. /**
  74531. * Create a new xml loader
  74532. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74533. */
  74534. constructor(parentClass?: null);
  74535. private _getChainElement;
  74536. private _getClassAttribute;
  74537. private _createGuiElement;
  74538. private _parseGrid;
  74539. private _parseElement;
  74540. private _prepareSourceElement;
  74541. private _parseElementsFromSource;
  74542. private _parseXml;
  74543. /**
  74544. * Gets if the loading has finished.
  74545. * @returns whether the loading has finished or not
  74546. */
  74547. isLoaded(): boolean;
  74548. /**
  74549. * Gets a loaded node / control by id.
  74550. * @param id the Controls id set in the xml
  74551. * @returns element of type Control
  74552. */
  74553. getNodeById(id: string): any;
  74554. /**
  74555. * Gets all loaded nodes / controls
  74556. * @returns Array of controls
  74557. */
  74558. getNodes(): any;
  74559. /**
  74560. * Initiates the xml layout loading
  74561. * @param xmlFile defines the xml layout to load
  74562. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74563. * @param callback defines the callback called on layout load.
  74564. */
  74565. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74566. }
  74567. }
  74568. declare module BABYLON.GUI {
  74569. /**
  74570. * Class used to create containers for controls
  74571. */
  74572. export class Container3D extends Control3D {
  74573. private _blockLayout;
  74574. /**
  74575. * Gets the list of child controls
  74576. */
  74577. protected _children: Control3D[];
  74578. /**
  74579. * Gets the list of child controls
  74580. */
  74581. get children(): Array<Control3D>;
  74582. /**
  74583. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74584. * This is helpful to optimize layout operation when adding multiple children in a row
  74585. */
  74586. get blockLayout(): boolean;
  74587. set blockLayout(value: boolean);
  74588. /**
  74589. * Creates a new container
  74590. * @param name defines the container name
  74591. */
  74592. constructor(name?: string);
  74593. /**
  74594. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74595. * @returns the current container
  74596. */
  74597. updateLayout(): Container3D;
  74598. /**
  74599. * Gets a boolean indicating if the given control is in the children of this control
  74600. * @param control defines the control to check
  74601. * @returns true if the control is in the child list
  74602. */
  74603. containsControl(control: Control3D): boolean;
  74604. /**
  74605. * Adds a control to the children of this control
  74606. * @param control defines the control to add
  74607. * @returns the current container
  74608. */
  74609. addControl(control: Control3D): Container3D;
  74610. /**
  74611. * This function will be called everytime a new control is added
  74612. */
  74613. protected _arrangeChildren(): void;
  74614. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74615. /**
  74616. * Removes a control from the children of this control
  74617. * @param control defines the control to remove
  74618. * @returns the current container
  74619. */
  74620. removeControl(control: Control3D): Container3D;
  74621. protected _getTypeName(): string;
  74622. /**
  74623. * Releases all associated resources
  74624. */
  74625. dispose(): void;
  74626. /** Control rotation will remain unchanged */
  74627. static readonly UNSET_ORIENTATION: number;
  74628. /** Control will rotate to make it look at sphere central axis */
  74629. static readonly FACEORIGIN_ORIENTATION: number;
  74630. /** Control will rotate to make it look back at sphere central axis */
  74631. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74632. /** Control will rotate to look at z axis (0, 0, 1) */
  74633. static readonly FACEFORWARD_ORIENTATION: number;
  74634. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74635. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74636. }
  74637. }
  74638. declare module BABYLON.GUI {
  74639. /**
  74640. * Class used to manage 3D user interface
  74641. * @see http://doc.babylonjs.com/how_to/gui3d
  74642. */
  74643. export class GUI3DManager implements BABYLON.IDisposable {
  74644. private _scene;
  74645. private _sceneDisposeObserver;
  74646. private _utilityLayer;
  74647. private _rootContainer;
  74648. private _pointerObserver;
  74649. private _pointerOutObserver;
  74650. /** @hidden */
  74651. _lastPickedControl: Control3D;
  74652. /** @hidden */
  74653. _lastControlOver: {
  74654. [pointerId: number]: Control3D;
  74655. };
  74656. /** @hidden */
  74657. _lastControlDown: {
  74658. [pointerId: number]: Control3D;
  74659. };
  74660. /**
  74661. * BABYLON.Observable raised when the point picked by the pointer events changed
  74662. */
  74663. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74664. /** @hidden */
  74665. _sharedMaterials: {
  74666. [key: string]: BABYLON.Material;
  74667. };
  74668. /** Gets the hosting scene */
  74669. get scene(): BABYLON.Scene;
  74670. /** Gets associated utility layer */
  74671. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74672. /**
  74673. * Creates a new GUI3DManager
  74674. * @param scene
  74675. */
  74676. constructor(scene?: BABYLON.Scene);
  74677. private _handlePointerOut;
  74678. private _doPicking;
  74679. /**
  74680. * Gets the root container
  74681. */
  74682. get rootContainer(): Container3D;
  74683. /**
  74684. * Gets a boolean indicating if the given control is in the root child list
  74685. * @param control defines the control to check
  74686. * @returns true if the control is in the root child list
  74687. */
  74688. containsControl(control: Control3D): boolean;
  74689. /**
  74690. * Adds a control to the root child list
  74691. * @param control defines the control to add
  74692. * @returns the current manager
  74693. */
  74694. addControl(control: Control3D): GUI3DManager;
  74695. /**
  74696. * Removes a control from the root child list
  74697. * @param control defines the control to remove
  74698. * @returns the current container
  74699. */
  74700. removeControl(control: Control3D): GUI3DManager;
  74701. /**
  74702. * Releases all associated resources
  74703. */
  74704. dispose(): void;
  74705. }
  74706. }
  74707. declare module BABYLON.GUI {
  74708. /**
  74709. * Class used to transport BABYLON.Vector3 information for pointer events
  74710. */
  74711. export class Vector3WithInfo extends BABYLON.Vector3 {
  74712. /** defines the current mouse button index */
  74713. buttonIndex: number;
  74714. /**
  74715. * Creates a new Vector3WithInfo
  74716. * @param source defines the vector3 data to transport
  74717. * @param buttonIndex defines the current mouse button index
  74718. */
  74719. constructor(source: BABYLON.Vector3,
  74720. /** defines the current mouse button index */
  74721. buttonIndex?: number);
  74722. }
  74723. }
  74724. declare module BABYLON.GUI {
  74725. /**
  74726. * Class used as base class for controls
  74727. */
  74728. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74729. /** Defines the control name */
  74730. name?: string | undefined;
  74731. /** @hidden */
  74732. _host: GUI3DManager;
  74733. private _node;
  74734. private _downCount;
  74735. private _enterCount;
  74736. private _downPointerIds;
  74737. private _isVisible;
  74738. /** Gets or sets the control position in world space */
  74739. get position(): BABYLON.Vector3;
  74740. set position(value: BABYLON.Vector3);
  74741. /** Gets or sets the control scaling in world space */
  74742. get scaling(): BABYLON.Vector3;
  74743. set scaling(value: BABYLON.Vector3);
  74744. /** Callback used to start pointer enter animation */
  74745. pointerEnterAnimation: () => void;
  74746. /** Callback used to start pointer out animation */
  74747. pointerOutAnimation: () => void;
  74748. /** Callback used to start pointer down animation */
  74749. pointerDownAnimation: () => void;
  74750. /** Callback used to start pointer up animation */
  74751. pointerUpAnimation: () => void;
  74752. /**
  74753. * An event triggered when the pointer move over the control
  74754. */
  74755. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74756. /**
  74757. * An event triggered when the pointer move out of the control
  74758. */
  74759. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74760. /**
  74761. * An event triggered when the pointer taps the control
  74762. */
  74763. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74764. /**
  74765. * An event triggered when pointer is up
  74766. */
  74767. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74768. /**
  74769. * An event triggered when a control is clicked on (with a mouse)
  74770. */
  74771. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74772. /**
  74773. * An event triggered when pointer enters the control
  74774. */
  74775. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74776. /**
  74777. * Gets or sets the parent container
  74778. */
  74779. parent: BABYLON.Nullable<Container3D>;
  74780. private _behaviors;
  74781. /**
  74782. * Gets the list of attached behaviors
  74783. * @see http://doc.babylonjs.com/features/behaviour
  74784. */
  74785. get behaviors(): BABYLON.Behavior<Control3D>[];
  74786. /**
  74787. * Attach a behavior to the control
  74788. * @see http://doc.babylonjs.com/features/behaviour
  74789. * @param behavior defines the behavior to attach
  74790. * @returns the current control
  74791. */
  74792. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74793. /**
  74794. * Remove an attached behavior
  74795. * @see http://doc.babylonjs.com/features/behaviour
  74796. * @param behavior defines the behavior to attach
  74797. * @returns the current control
  74798. */
  74799. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74800. /**
  74801. * Gets an attached behavior by name
  74802. * @param name defines the name of the behavior to look for
  74803. * @see http://doc.babylonjs.com/features/behaviour
  74804. * @returns null if behavior was not found else the requested behavior
  74805. */
  74806. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74807. /** Gets or sets a boolean indicating if the control is visible */
  74808. get isVisible(): boolean;
  74809. set isVisible(value: boolean);
  74810. /**
  74811. * Creates a new control
  74812. * @param name defines the control name
  74813. */
  74814. constructor(
  74815. /** Defines the control name */
  74816. name?: string | undefined);
  74817. /**
  74818. * Gets a string representing the class name
  74819. */
  74820. get typeName(): string;
  74821. /**
  74822. * Get the current class name of the control.
  74823. * @returns current class name
  74824. */
  74825. getClassName(): string;
  74826. protected _getTypeName(): string;
  74827. /**
  74828. * Gets the transform node used by this control
  74829. */
  74830. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74831. /**
  74832. * Gets the mesh used to render this control
  74833. */
  74834. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74835. /**
  74836. * Link the control as child of the given node
  74837. * @param node defines the node to link to. Use null to unlink the control
  74838. * @returns the current control
  74839. */
  74840. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74841. /** @hidden **/
  74842. _prepareNode(scene: BABYLON.Scene): void;
  74843. /**
  74844. * Node creation.
  74845. * Can be overriden by children
  74846. * @param scene defines the scene where the node must be attached
  74847. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74848. */
  74849. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74850. /**
  74851. * Affect a material to the given mesh
  74852. * @param mesh defines the mesh which will represent the control
  74853. */
  74854. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74855. /** @hidden */
  74856. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74857. /** @hidden */
  74858. _onPointerEnter(target: Control3D): boolean;
  74859. /** @hidden */
  74860. _onPointerOut(target: Control3D): void;
  74861. /** @hidden */
  74862. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74863. /** @hidden */
  74864. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74865. /** @hidden */
  74866. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74867. /** @hidden */
  74868. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74869. /** @hidden */
  74870. _disposeNode(): void;
  74871. /**
  74872. * Releases all associated resources
  74873. */
  74874. dispose(): void;
  74875. }
  74876. }
  74877. declare module BABYLON.GUI {
  74878. /**
  74879. * Class used as a root to all buttons
  74880. */
  74881. export class AbstractButton3D extends Control3D {
  74882. /**
  74883. * Creates a new button
  74884. * @param name defines the control name
  74885. */
  74886. constructor(name?: string);
  74887. protected _getTypeName(): string;
  74888. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74889. }
  74890. }
  74891. declare module BABYLON.GUI {
  74892. /**
  74893. * Class used to create a button in 3D
  74894. */
  74895. export class Button3D extends AbstractButton3D {
  74896. /** @hidden */
  74897. protected _currentMaterial: BABYLON.Material;
  74898. private _facadeTexture;
  74899. private _content;
  74900. private _contentResolution;
  74901. private _contentScaleRatio;
  74902. /**
  74903. * Gets or sets the texture resolution used to render content (512 by default)
  74904. */
  74905. get contentResolution(): BABYLON.int;
  74906. set contentResolution(value: BABYLON.int);
  74907. /**
  74908. * Gets or sets the texture scale ratio used to render content (2 by default)
  74909. */
  74910. get contentScaleRatio(): number;
  74911. set contentScaleRatio(value: number);
  74912. protected _disposeFacadeTexture(): void;
  74913. protected _resetContent(): void;
  74914. /**
  74915. * Creates a new button
  74916. * @param name defines the control name
  74917. */
  74918. constructor(name?: string);
  74919. /**
  74920. * Gets or sets the GUI 2D content used to display the button's facade
  74921. */
  74922. get content(): Control;
  74923. set content(value: Control);
  74924. /**
  74925. * Apply the facade texture (created from the content property).
  74926. * This function can be overloaded by child classes
  74927. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74928. */
  74929. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74930. protected _getTypeName(): string;
  74931. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74932. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74933. /**
  74934. * Releases all associated resources
  74935. */
  74936. dispose(): void;
  74937. }
  74938. }
  74939. declare module BABYLON.GUI {
  74940. /**
  74941. * Abstract class used to create a container panel deployed on the surface of a volume
  74942. */
  74943. export abstract class VolumeBasedPanel extends Container3D {
  74944. private _columns;
  74945. private _rows;
  74946. private _rowThenColum;
  74947. private _orientation;
  74948. protected _cellWidth: number;
  74949. protected _cellHeight: number;
  74950. /**
  74951. * Gets or sets the distance between elements
  74952. */
  74953. margin: number;
  74954. /**
  74955. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74956. * | Value | Type | Description |
  74957. * | ----- | ----------------------------------- | ----------- |
  74958. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74959. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74960. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74961. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74962. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74963. */
  74964. get orientation(): number;
  74965. set orientation(value: number);
  74966. /**
  74967. * Gets or sets the number of columns requested (10 by default).
  74968. * The panel will automatically compute the number of rows based on number of child controls.
  74969. */
  74970. get columns(): BABYLON.int;
  74971. set columns(value: BABYLON.int);
  74972. /**
  74973. * Gets or sets a the number of rows requested.
  74974. * The panel will automatically compute the number of columns based on number of child controls.
  74975. */
  74976. get rows(): BABYLON.int;
  74977. set rows(value: BABYLON.int);
  74978. /**
  74979. * Creates new VolumeBasedPanel
  74980. */
  74981. constructor();
  74982. protected _arrangeChildren(): void;
  74983. /** Child classes must implement this function to provide correct control positioning */
  74984. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74985. /** Child classes can implement this function to provide additional processing */
  74986. protected _finalProcessing(): void;
  74987. }
  74988. }
  74989. declare module BABYLON.GUI {
  74990. /**
  74991. * Class used to create a container panel deployed on the surface of a cylinder
  74992. */
  74993. export class CylinderPanel extends VolumeBasedPanel {
  74994. private _radius;
  74995. /**
  74996. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74997. */
  74998. get radius(): BABYLON.float;
  74999. set radius(value: BABYLON.float);
  75000. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75001. private _cylindricalMapping;
  75002. }
  75003. }
  75004. declare module BABYLON.GUI {
  75005. /** @hidden */
  75006. export var fluentVertexShader: {
  75007. name: string;
  75008. shader: string;
  75009. };
  75010. }
  75011. declare module BABYLON.GUI {
  75012. /** @hidden */
  75013. export var fluentPixelShader: {
  75014. name: string;
  75015. shader: string;
  75016. };
  75017. }
  75018. declare module BABYLON.GUI {
  75019. /** @hidden */
  75020. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  75021. INNERGLOW: boolean;
  75022. BORDER: boolean;
  75023. HOVERLIGHT: boolean;
  75024. TEXTURE: boolean;
  75025. constructor();
  75026. }
  75027. /**
  75028. * Class used to render controls with fluent desgin
  75029. */
  75030. export class FluentMaterial extends BABYLON.PushMaterial {
  75031. /**
  75032. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  75033. */
  75034. innerGlowColorIntensity: number;
  75035. /**
  75036. * Gets or sets the inner glow color (white by default)
  75037. */
  75038. innerGlowColor: BABYLON.Color3;
  75039. /**
  75040. * Gets or sets alpha value (default is 1.0)
  75041. */
  75042. alpha: number;
  75043. /**
  75044. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  75045. */
  75046. albedoColor: BABYLON.Color3;
  75047. /**
  75048. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  75049. */
  75050. renderBorders: boolean;
  75051. /**
  75052. * Gets or sets border width (default is 0.5)
  75053. */
  75054. borderWidth: number;
  75055. /**
  75056. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  75057. */
  75058. edgeSmoothingValue: number;
  75059. /**
  75060. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  75061. */
  75062. borderMinValue: number;
  75063. /**
  75064. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  75065. */
  75066. renderHoverLight: boolean;
  75067. /**
  75068. * Gets or sets the radius used to render the hover light (default is 1.0)
  75069. */
  75070. hoverRadius: number;
  75071. /**
  75072. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  75073. */
  75074. hoverColor: BABYLON.Color4;
  75075. /**
  75076. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  75077. */
  75078. hoverPosition: BABYLON.Vector3;
  75079. private _albedoTexture;
  75080. /** Gets or sets the texture to use for albedo color */
  75081. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75082. /**
  75083. * Creates a new Fluent material
  75084. * @param name defines the name of the material
  75085. * @param scene defines the hosting scene
  75086. */
  75087. constructor(name: string, scene: BABYLON.Scene);
  75088. needAlphaBlending(): boolean;
  75089. needAlphaTesting(): boolean;
  75090. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75091. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75092. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75093. getActiveTextures(): BABYLON.BaseTexture[];
  75094. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75095. dispose(forceDisposeEffect?: boolean): void;
  75096. clone(name: string): FluentMaterial;
  75097. serialize(): any;
  75098. getClassName(): string;
  75099. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  75100. }
  75101. }
  75102. declare module BABYLON.GUI {
  75103. /**
  75104. * Class used to create a holographic button in 3D
  75105. */
  75106. export class HolographicButton extends Button3D {
  75107. private _backPlate;
  75108. private _textPlate;
  75109. private _frontPlate;
  75110. private _text;
  75111. private _imageUrl;
  75112. private _shareMaterials;
  75113. private _frontMaterial;
  75114. private _backMaterial;
  75115. private _plateMaterial;
  75116. private _pickedPointObserver;
  75117. private _tooltipFade;
  75118. private _tooltipTextBlock;
  75119. private _tooltipTexture;
  75120. private _tooltipMesh;
  75121. private _tooltipHoverObserver;
  75122. private _tooltipOutObserver;
  75123. private _disposeTooltip;
  75124. /**
  75125. * Rendering ground id of all the mesh in the button
  75126. */
  75127. set renderingGroupId(id: number);
  75128. get renderingGroupId(): number;
  75129. /**
  75130. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  75131. */
  75132. set tooltipText(text: BABYLON.Nullable<string>);
  75133. get tooltipText(): BABYLON.Nullable<string>;
  75134. /**
  75135. * Gets or sets text for the button
  75136. */
  75137. get text(): string;
  75138. set text(value: string);
  75139. /**
  75140. * Gets or sets the image url for the button
  75141. */
  75142. get imageUrl(): string;
  75143. set imageUrl(value: string);
  75144. /**
  75145. * Gets the back material used by this button
  75146. */
  75147. get backMaterial(): FluentMaterial;
  75148. /**
  75149. * Gets the front material used by this button
  75150. */
  75151. get frontMaterial(): FluentMaterial;
  75152. /**
  75153. * Gets the plate material used by this button
  75154. */
  75155. get plateMaterial(): BABYLON.StandardMaterial;
  75156. /**
  75157. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  75158. */
  75159. get shareMaterials(): boolean;
  75160. /**
  75161. * Creates a new button
  75162. * @param name defines the control name
  75163. */
  75164. constructor(name?: string, shareMaterials?: boolean);
  75165. protected _getTypeName(): string;
  75166. private _rebuildContent;
  75167. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75168. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75169. private _createBackMaterial;
  75170. private _createFrontMaterial;
  75171. private _createPlateMaterial;
  75172. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  75173. /**
  75174. * Releases all associated resources
  75175. */
  75176. dispose(): void;
  75177. }
  75178. }
  75179. declare module BABYLON.GUI {
  75180. /**
  75181. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  75182. */
  75183. export class MeshButton3D extends Button3D {
  75184. /** @hidden */
  75185. protected _currentMesh: BABYLON.Mesh;
  75186. /**
  75187. * Creates a new 3D button based on a mesh
  75188. * @param mesh mesh to become a 3D button
  75189. * @param name defines the control name
  75190. */
  75191. constructor(mesh: BABYLON.Mesh, name?: string);
  75192. protected _getTypeName(): string;
  75193. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75194. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75195. }
  75196. }
  75197. declare module BABYLON.GUI {
  75198. /**
  75199. * Class used to create a container panel deployed on the surface of a plane
  75200. */
  75201. export class PlanePanel extends VolumeBasedPanel {
  75202. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75203. }
  75204. }
  75205. declare module BABYLON.GUI {
  75206. /**
  75207. * Class used to create a container panel where items get randomized planar mapping
  75208. */
  75209. export class ScatterPanel extends VolumeBasedPanel {
  75210. private _iteration;
  75211. /**
  75212. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  75213. */
  75214. get iteration(): BABYLON.float;
  75215. set iteration(value: BABYLON.float);
  75216. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75217. private _scatterMapping;
  75218. protected _finalProcessing(): void;
  75219. }
  75220. }
  75221. declare module BABYLON.GUI {
  75222. /**
  75223. * Class used to create a container panel deployed on the surface of a sphere
  75224. */
  75225. export class SpherePanel extends VolumeBasedPanel {
  75226. private _radius;
  75227. /**
  75228. * Gets or sets the radius of the sphere where to project controls (5 by default)
  75229. */
  75230. get radius(): BABYLON.float;
  75231. set radius(value: BABYLON.float);
  75232. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75233. private _sphericalMapping;
  75234. }
  75235. }
  75236. declare module BABYLON.GUI {
  75237. /**
  75238. * Class used to create a stack panel in 3D on XY plane
  75239. */
  75240. export class StackPanel3D extends Container3D {
  75241. private _isVertical;
  75242. /**
  75243. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  75244. */
  75245. get isVertical(): boolean;
  75246. set isVertical(value: boolean);
  75247. /**
  75248. * Gets or sets the distance between elements
  75249. */
  75250. margin: number;
  75251. /**
  75252. * Creates new StackPanel
  75253. * @param isVertical
  75254. */
  75255. constructor(isVertical?: boolean);
  75256. protected _arrangeChildren(): void;
  75257. }
  75258. }
  75259. declare module BABYLON {
  75260. /**
  75261. * Configuration for glTF validation
  75262. */
  75263. export interface IGLTFValidationConfiguration {
  75264. /**
  75265. * The url of the glTF validator.
  75266. */
  75267. url: string;
  75268. }
  75269. /**
  75270. * glTF validation
  75271. */
  75272. export class GLTFValidation {
  75273. /**
  75274. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  75275. */
  75276. static Configuration: IGLTFValidationConfiguration;
  75277. private static _LoadScriptPromise;
  75278. /**
  75279. * Validate a glTF asset using the glTF-Validator.
  75280. * @param data The JSON of a glTF or the array buffer of a binary glTF
  75281. * @param rootUrl The root url for the glTF
  75282. * @param fileName The file name for the glTF
  75283. * @param getExternalResource The callback to get external resources for the glTF validator
  75284. * @returns A promise that resolves with the glTF validation results once complete
  75285. */
  75286. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  75287. }
  75288. }
  75289. declare module BABYLON {
  75290. /**
  75291. * Mode that determines the coordinate system to use.
  75292. */
  75293. export enum GLTFLoaderCoordinateSystemMode {
  75294. /**
  75295. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  75296. */
  75297. AUTO = 0,
  75298. /**
  75299. * Sets the useRightHandedSystem flag on the scene.
  75300. */
  75301. FORCE_RIGHT_HANDED = 1
  75302. }
  75303. /**
  75304. * Mode that determines what animations will start.
  75305. */
  75306. export enum GLTFLoaderAnimationStartMode {
  75307. /**
  75308. * No animation will start.
  75309. */
  75310. NONE = 0,
  75311. /**
  75312. * The first animation will start.
  75313. */
  75314. FIRST = 1,
  75315. /**
  75316. * All animations will start.
  75317. */
  75318. ALL = 2
  75319. }
  75320. /**
  75321. * Interface that contains the data for the glTF asset.
  75322. */
  75323. export interface IGLTFLoaderData {
  75324. /**
  75325. * The object that represents the glTF JSON.
  75326. */
  75327. json: Object;
  75328. /**
  75329. * The BIN chunk of a binary glTF.
  75330. */
  75331. bin: Nullable<IDataBuffer>;
  75332. }
  75333. /**
  75334. * Interface for extending the loader.
  75335. */
  75336. export interface IGLTFLoaderExtension {
  75337. /**
  75338. * The name of this extension.
  75339. */
  75340. readonly name: string;
  75341. /**
  75342. * Defines whether this extension is enabled.
  75343. */
  75344. enabled: boolean;
  75345. /**
  75346. * Defines the order of this extension.
  75347. * The loader sorts the extensions using these values when loading.
  75348. */
  75349. order?: number;
  75350. }
  75351. /**
  75352. * Loader state.
  75353. */
  75354. export enum GLTFLoaderState {
  75355. /**
  75356. * The asset is loading.
  75357. */
  75358. LOADING = 0,
  75359. /**
  75360. * The asset is ready for rendering.
  75361. */
  75362. READY = 1,
  75363. /**
  75364. * The asset is completely loaded.
  75365. */
  75366. COMPLETE = 2
  75367. }
  75368. /** @hidden */
  75369. export interface IImportMeshAsyncOutput {
  75370. meshes: AbstractMesh[];
  75371. particleSystems: IParticleSystem[];
  75372. skeletons: Skeleton[];
  75373. animationGroups: AnimationGroup[];
  75374. lights: Light[];
  75375. transformNodes: TransformNode[];
  75376. }
  75377. /** @hidden */
  75378. export interface IGLTFLoader extends IDisposable {
  75379. readonly state: Nullable<GLTFLoaderState>;
  75380. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75381. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75382. }
  75383. /**
  75384. * File loader for loading glTF files into a scene.
  75385. */
  75386. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75387. /** @hidden */
  75388. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75389. /** @hidden */
  75390. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75391. /**
  75392. * Raised when the asset has been parsed
  75393. */
  75394. onParsedObservable: Observable<IGLTFLoaderData>;
  75395. private _onParsedObserver;
  75396. /**
  75397. * Raised when the asset has been parsed
  75398. */
  75399. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75400. /**
  75401. * 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.
  75402. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75403. * Defaults to true.
  75404. * @hidden
  75405. */
  75406. static IncrementalLoading: boolean;
  75407. /**
  75408. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75409. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75410. * @hidden
  75411. */
  75412. static HomogeneousCoordinates: boolean;
  75413. /**
  75414. * The coordinate system mode. Defaults to AUTO.
  75415. */
  75416. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75417. /**
  75418. * The animation start mode. Defaults to FIRST.
  75419. */
  75420. animationStartMode: GLTFLoaderAnimationStartMode;
  75421. /**
  75422. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75423. */
  75424. compileMaterials: boolean;
  75425. /**
  75426. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75427. */
  75428. useClipPlane: boolean;
  75429. /**
  75430. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75431. */
  75432. compileShadowGenerators: boolean;
  75433. /**
  75434. * Defines if the Alpha blended materials are only applied as coverage.
  75435. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75436. * If true, no extra effects are applied to transparent pixels.
  75437. */
  75438. transparencyAsCoverage: boolean;
  75439. /**
  75440. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75441. * Enabling will disable offline support and glTF validator.
  75442. * Defaults to false.
  75443. */
  75444. useRangeRequests: boolean;
  75445. /**
  75446. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75447. */
  75448. createInstances: boolean;
  75449. /**
  75450. * Function called before loading a url referenced by the asset.
  75451. */
  75452. preprocessUrlAsync: (url: string) => Promise<string>;
  75453. /**
  75454. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75455. */
  75456. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75457. private _onMeshLoadedObserver;
  75458. /**
  75459. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75460. */
  75461. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75462. /**
  75463. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75464. */
  75465. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75466. private _onTextureLoadedObserver;
  75467. /**
  75468. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75469. */
  75470. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75471. /**
  75472. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75473. */
  75474. readonly onMaterialLoadedObservable: Observable<Material>;
  75475. private _onMaterialLoadedObserver;
  75476. /**
  75477. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75478. */
  75479. set onMaterialLoaded(callback: (material: Material) => void);
  75480. /**
  75481. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75482. */
  75483. readonly onCameraLoadedObservable: Observable<Camera>;
  75484. private _onCameraLoadedObserver;
  75485. /**
  75486. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75487. */
  75488. set onCameraLoaded(callback: (camera: Camera) => void);
  75489. /**
  75490. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75491. * For assets with LODs, raised when all of the LODs are complete.
  75492. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75493. */
  75494. readonly onCompleteObservable: Observable<void>;
  75495. private _onCompleteObserver;
  75496. /**
  75497. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75498. * For assets with LODs, raised when all of the LODs are complete.
  75499. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75500. */
  75501. set onComplete(callback: () => void);
  75502. /**
  75503. * Observable raised when an error occurs.
  75504. */
  75505. readonly onErrorObservable: Observable<any>;
  75506. private _onErrorObserver;
  75507. /**
  75508. * Callback raised when an error occurs.
  75509. */
  75510. set onError(callback: (reason: any) => void);
  75511. /**
  75512. * Observable raised after the loader is disposed.
  75513. */
  75514. readonly onDisposeObservable: Observable<void>;
  75515. private _onDisposeObserver;
  75516. /**
  75517. * Callback raised after the loader is disposed.
  75518. */
  75519. set onDispose(callback: () => void);
  75520. /**
  75521. * Observable raised after a loader extension is created.
  75522. * Set additional options for a loader extension in this event.
  75523. */
  75524. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75525. private _onExtensionLoadedObserver;
  75526. /**
  75527. * Callback raised after a loader extension is created.
  75528. */
  75529. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75530. /**
  75531. * Defines if the loader logging is enabled.
  75532. */
  75533. get loggingEnabled(): boolean;
  75534. set loggingEnabled(value: boolean);
  75535. /**
  75536. * Defines if the loader should capture performance counters.
  75537. */
  75538. get capturePerformanceCounters(): boolean;
  75539. set capturePerformanceCounters(value: boolean);
  75540. /**
  75541. * Defines if the loader should validate the asset.
  75542. */
  75543. validate: boolean;
  75544. /**
  75545. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75546. */
  75547. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75548. private _onValidatedObserver;
  75549. /**
  75550. * Callback raised after a loader extension is created.
  75551. */
  75552. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75553. private _loader;
  75554. /**
  75555. * Name of the loader ("gltf")
  75556. */
  75557. name: string;
  75558. /** @hidden */
  75559. extensions: ISceneLoaderPluginExtensions;
  75560. /**
  75561. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75562. */
  75563. dispose(): void;
  75564. /** @hidden */
  75565. _clear(): void;
  75566. /** @hidden */
  75567. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75568. /** @hidden */
  75569. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75570. /** @hidden */
  75571. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75572. meshes: AbstractMesh[];
  75573. particleSystems: IParticleSystem[];
  75574. skeletons: Skeleton[];
  75575. animationGroups: AnimationGroup[];
  75576. }>;
  75577. /** @hidden */
  75578. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75579. /** @hidden */
  75580. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75581. /** @hidden */
  75582. canDirectLoad(data: string): boolean;
  75583. /** @hidden */
  75584. directLoad(scene: Scene, data: string): any;
  75585. /**
  75586. * The callback that allows custom handling of the root url based on the response url.
  75587. * @param rootUrl the original root url
  75588. * @param responseURL the response url if available
  75589. * @returns the new root url
  75590. */
  75591. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75592. /** @hidden */
  75593. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75594. /**
  75595. * The loader state or null if the loader is not active.
  75596. */
  75597. get loaderState(): Nullable<GLTFLoaderState>;
  75598. /**
  75599. * Returns a promise that resolves when the asset is completely loaded.
  75600. * @returns a promise that resolves when the asset is completely loaded.
  75601. */
  75602. whenCompleteAsync(): Promise<void>;
  75603. private _validate;
  75604. private _getLoader;
  75605. private _parseJson;
  75606. private _unpackBinaryAsync;
  75607. private _unpackBinaryV1Async;
  75608. private _unpackBinaryV2Async;
  75609. private static _parseVersion;
  75610. private static _compareVersion;
  75611. private static readonly _logSpaces;
  75612. private _logIndentLevel;
  75613. private _loggingEnabled;
  75614. /** @hidden */
  75615. _log: (message: string) => void;
  75616. /** @hidden */
  75617. _logOpen(message: string): void;
  75618. /** @hidden */
  75619. _logClose(): void;
  75620. private _logEnabled;
  75621. private _logDisabled;
  75622. private _capturePerformanceCounters;
  75623. /** @hidden */
  75624. _startPerformanceCounter: (counterName: string) => void;
  75625. /** @hidden */
  75626. _endPerformanceCounter: (counterName: string) => void;
  75627. private _startPerformanceCounterEnabled;
  75628. private _startPerformanceCounterDisabled;
  75629. private _endPerformanceCounterEnabled;
  75630. private _endPerformanceCounterDisabled;
  75631. }
  75632. }
  75633. declare module BABYLON.GLTF1 {
  75634. /**
  75635. * Enums
  75636. * @hidden
  75637. */
  75638. export enum EComponentType {
  75639. BYTE = 5120,
  75640. UNSIGNED_BYTE = 5121,
  75641. SHORT = 5122,
  75642. UNSIGNED_SHORT = 5123,
  75643. FLOAT = 5126
  75644. }
  75645. /** @hidden */
  75646. export enum EShaderType {
  75647. FRAGMENT = 35632,
  75648. VERTEX = 35633
  75649. }
  75650. /** @hidden */
  75651. export enum EParameterType {
  75652. BYTE = 5120,
  75653. UNSIGNED_BYTE = 5121,
  75654. SHORT = 5122,
  75655. UNSIGNED_SHORT = 5123,
  75656. INT = 5124,
  75657. UNSIGNED_INT = 5125,
  75658. FLOAT = 5126,
  75659. FLOAT_VEC2 = 35664,
  75660. FLOAT_VEC3 = 35665,
  75661. FLOAT_VEC4 = 35666,
  75662. INT_VEC2 = 35667,
  75663. INT_VEC3 = 35668,
  75664. INT_VEC4 = 35669,
  75665. BOOL = 35670,
  75666. BOOL_VEC2 = 35671,
  75667. BOOL_VEC3 = 35672,
  75668. BOOL_VEC4 = 35673,
  75669. FLOAT_MAT2 = 35674,
  75670. FLOAT_MAT3 = 35675,
  75671. FLOAT_MAT4 = 35676,
  75672. SAMPLER_2D = 35678
  75673. }
  75674. /** @hidden */
  75675. export enum ETextureWrapMode {
  75676. CLAMP_TO_EDGE = 33071,
  75677. MIRRORED_REPEAT = 33648,
  75678. REPEAT = 10497
  75679. }
  75680. /** @hidden */
  75681. export enum ETextureFilterType {
  75682. NEAREST = 9728,
  75683. LINEAR = 9728,
  75684. NEAREST_MIPMAP_NEAREST = 9984,
  75685. LINEAR_MIPMAP_NEAREST = 9985,
  75686. NEAREST_MIPMAP_LINEAR = 9986,
  75687. LINEAR_MIPMAP_LINEAR = 9987
  75688. }
  75689. /** @hidden */
  75690. export enum ETextureFormat {
  75691. ALPHA = 6406,
  75692. RGB = 6407,
  75693. RGBA = 6408,
  75694. LUMINANCE = 6409,
  75695. LUMINANCE_ALPHA = 6410
  75696. }
  75697. /** @hidden */
  75698. export enum ECullingType {
  75699. FRONT = 1028,
  75700. BACK = 1029,
  75701. FRONT_AND_BACK = 1032
  75702. }
  75703. /** @hidden */
  75704. export enum EBlendingFunction {
  75705. ZERO = 0,
  75706. ONE = 1,
  75707. SRC_COLOR = 768,
  75708. ONE_MINUS_SRC_COLOR = 769,
  75709. DST_COLOR = 774,
  75710. ONE_MINUS_DST_COLOR = 775,
  75711. SRC_ALPHA = 770,
  75712. ONE_MINUS_SRC_ALPHA = 771,
  75713. DST_ALPHA = 772,
  75714. ONE_MINUS_DST_ALPHA = 773,
  75715. CONSTANT_COLOR = 32769,
  75716. ONE_MINUS_CONSTANT_COLOR = 32770,
  75717. CONSTANT_ALPHA = 32771,
  75718. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75719. SRC_ALPHA_SATURATE = 776
  75720. }
  75721. /** @hidden */
  75722. export interface IGLTFProperty {
  75723. extensions?: {
  75724. [key: string]: any;
  75725. };
  75726. extras?: Object;
  75727. }
  75728. /** @hidden */
  75729. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75730. name?: string;
  75731. }
  75732. /** @hidden */
  75733. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75734. bufferView: string;
  75735. byteOffset: number;
  75736. byteStride: number;
  75737. count: number;
  75738. type: string;
  75739. componentType: EComponentType;
  75740. max?: number[];
  75741. min?: number[];
  75742. name?: string;
  75743. }
  75744. /** @hidden */
  75745. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75746. buffer: string;
  75747. byteOffset: number;
  75748. byteLength: number;
  75749. byteStride: number;
  75750. target?: number;
  75751. }
  75752. /** @hidden */
  75753. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75754. uri: string;
  75755. byteLength?: number;
  75756. type?: string;
  75757. }
  75758. /** @hidden */
  75759. export interface IGLTFShader extends IGLTFChildRootProperty {
  75760. uri: string;
  75761. type: EShaderType;
  75762. }
  75763. /** @hidden */
  75764. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75765. attributes: string[];
  75766. fragmentShader: string;
  75767. vertexShader: string;
  75768. }
  75769. /** @hidden */
  75770. export interface IGLTFTechniqueParameter {
  75771. type: number;
  75772. count?: number;
  75773. semantic?: string;
  75774. node?: string;
  75775. value?: number | boolean | string | Array<any>;
  75776. source?: string;
  75777. babylonValue?: any;
  75778. }
  75779. /** @hidden */
  75780. export interface IGLTFTechniqueCommonProfile {
  75781. lightingModel: string;
  75782. texcoordBindings: Object;
  75783. parameters?: Array<any>;
  75784. }
  75785. /** @hidden */
  75786. export interface IGLTFTechniqueStatesFunctions {
  75787. blendColor?: number[];
  75788. blendEquationSeparate?: number[];
  75789. blendFuncSeparate?: number[];
  75790. colorMask: boolean[];
  75791. cullFace: number[];
  75792. }
  75793. /** @hidden */
  75794. export interface IGLTFTechniqueStates {
  75795. enable: number[];
  75796. functions: IGLTFTechniqueStatesFunctions;
  75797. }
  75798. /** @hidden */
  75799. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75800. parameters: {
  75801. [key: string]: IGLTFTechniqueParameter;
  75802. };
  75803. program: string;
  75804. attributes: {
  75805. [key: string]: string;
  75806. };
  75807. uniforms: {
  75808. [key: string]: string;
  75809. };
  75810. states: IGLTFTechniqueStates;
  75811. }
  75812. /** @hidden */
  75813. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75814. technique?: string;
  75815. values: string[];
  75816. }
  75817. /** @hidden */
  75818. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75819. attributes: {
  75820. [key: string]: string;
  75821. };
  75822. indices: string;
  75823. material: string;
  75824. mode?: number;
  75825. }
  75826. /** @hidden */
  75827. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75828. primitives: IGLTFMeshPrimitive[];
  75829. }
  75830. /** @hidden */
  75831. export interface IGLTFImage extends IGLTFChildRootProperty {
  75832. uri: string;
  75833. }
  75834. /** @hidden */
  75835. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75836. magFilter?: number;
  75837. minFilter?: number;
  75838. wrapS?: number;
  75839. wrapT?: number;
  75840. }
  75841. /** @hidden */
  75842. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75843. sampler: string;
  75844. source: string;
  75845. format?: ETextureFormat;
  75846. internalFormat?: ETextureFormat;
  75847. target?: number;
  75848. type?: number;
  75849. babylonTexture?: Texture;
  75850. }
  75851. /** @hidden */
  75852. export interface IGLTFAmbienLight {
  75853. color?: number[];
  75854. }
  75855. /** @hidden */
  75856. export interface IGLTFDirectionalLight {
  75857. color?: number[];
  75858. }
  75859. /** @hidden */
  75860. export interface IGLTFPointLight {
  75861. color?: number[];
  75862. constantAttenuation?: number;
  75863. linearAttenuation?: number;
  75864. quadraticAttenuation?: number;
  75865. }
  75866. /** @hidden */
  75867. export interface IGLTFSpotLight {
  75868. color?: number[];
  75869. constantAttenuation?: number;
  75870. fallOfAngle?: number;
  75871. fallOffExponent?: number;
  75872. linearAttenuation?: number;
  75873. quadraticAttenuation?: number;
  75874. }
  75875. /** @hidden */
  75876. export interface IGLTFLight extends IGLTFChildRootProperty {
  75877. type: string;
  75878. }
  75879. /** @hidden */
  75880. export interface IGLTFCameraOrthographic {
  75881. xmag: number;
  75882. ymag: number;
  75883. zfar: number;
  75884. znear: number;
  75885. }
  75886. /** @hidden */
  75887. export interface IGLTFCameraPerspective {
  75888. aspectRatio: number;
  75889. yfov: number;
  75890. zfar: number;
  75891. znear: number;
  75892. }
  75893. /** @hidden */
  75894. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75895. type: string;
  75896. }
  75897. /** @hidden */
  75898. export interface IGLTFAnimationChannelTarget {
  75899. id: string;
  75900. path: string;
  75901. }
  75902. /** @hidden */
  75903. export interface IGLTFAnimationChannel {
  75904. sampler: string;
  75905. target: IGLTFAnimationChannelTarget;
  75906. }
  75907. /** @hidden */
  75908. export interface IGLTFAnimationSampler {
  75909. input: string;
  75910. output: string;
  75911. interpolation?: string;
  75912. }
  75913. /** @hidden */
  75914. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75915. channels?: IGLTFAnimationChannel[];
  75916. parameters?: {
  75917. [key: string]: string;
  75918. };
  75919. samplers?: {
  75920. [key: string]: IGLTFAnimationSampler;
  75921. };
  75922. }
  75923. /** @hidden */
  75924. export interface IGLTFNodeInstanceSkin {
  75925. skeletons: string[];
  75926. skin: string;
  75927. meshes: string[];
  75928. }
  75929. /** @hidden */
  75930. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75931. bindShapeMatrix: number[];
  75932. inverseBindMatrices: string;
  75933. jointNames: string[];
  75934. babylonSkeleton?: Skeleton;
  75935. }
  75936. /** @hidden */
  75937. export interface IGLTFNode extends IGLTFChildRootProperty {
  75938. camera?: string;
  75939. children: string[];
  75940. skin?: string;
  75941. jointName?: string;
  75942. light?: string;
  75943. matrix: number[];
  75944. mesh?: string;
  75945. meshes?: string[];
  75946. rotation?: number[];
  75947. scale?: number[];
  75948. translation?: number[];
  75949. babylonNode?: Node;
  75950. }
  75951. /** @hidden */
  75952. export interface IGLTFScene extends IGLTFChildRootProperty {
  75953. nodes: string[];
  75954. }
  75955. /** @hidden */
  75956. export interface IGLTFRuntime {
  75957. extensions: {
  75958. [key: string]: any;
  75959. };
  75960. accessors: {
  75961. [key: string]: IGLTFAccessor;
  75962. };
  75963. buffers: {
  75964. [key: string]: IGLTFBuffer;
  75965. };
  75966. bufferViews: {
  75967. [key: string]: IGLTFBufferView;
  75968. };
  75969. meshes: {
  75970. [key: string]: IGLTFMesh;
  75971. };
  75972. lights: {
  75973. [key: string]: IGLTFLight;
  75974. };
  75975. cameras: {
  75976. [key: string]: IGLTFCamera;
  75977. };
  75978. nodes: {
  75979. [key: string]: IGLTFNode;
  75980. };
  75981. images: {
  75982. [key: string]: IGLTFImage;
  75983. };
  75984. textures: {
  75985. [key: string]: IGLTFTexture;
  75986. };
  75987. shaders: {
  75988. [key: string]: IGLTFShader;
  75989. };
  75990. programs: {
  75991. [key: string]: IGLTFProgram;
  75992. };
  75993. samplers: {
  75994. [key: string]: IGLTFSampler;
  75995. };
  75996. techniques: {
  75997. [key: string]: IGLTFTechnique;
  75998. };
  75999. materials: {
  76000. [key: string]: IGLTFMaterial;
  76001. };
  76002. animations: {
  76003. [key: string]: IGLTFAnimation;
  76004. };
  76005. skins: {
  76006. [key: string]: IGLTFSkins;
  76007. };
  76008. currentScene?: Object;
  76009. scenes: {
  76010. [key: string]: IGLTFScene;
  76011. };
  76012. extensionsUsed: string[];
  76013. extensionsRequired?: string[];
  76014. buffersCount: number;
  76015. shaderscount: number;
  76016. scene: Scene;
  76017. rootUrl: string;
  76018. loadedBufferCount: number;
  76019. loadedBufferViews: {
  76020. [name: string]: ArrayBufferView;
  76021. };
  76022. loadedShaderCount: number;
  76023. importOnlyMeshes: boolean;
  76024. importMeshesNames?: string[];
  76025. dummyNodes: Node[];
  76026. forAssetContainer: boolean;
  76027. }
  76028. /** @hidden */
  76029. export interface INodeToRoot {
  76030. bone: Bone;
  76031. node: IGLTFNode;
  76032. id: string;
  76033. }
  76034. /** @hidden */
  76035. export interface IJointNode {
  76036. node: IGLTFNode;
  76037. id: string;
  76038. }
  76039. }
  76040. declare module BABYLON.GLTF1 {
  76041. /**
  76042. * Utils functions for GLTF
  76043. * @hidden
  76044. */
  76045. export class GLTFUtils {
  76046. /**
  76047. * Sets the given "parameter" matrix
  76048. * @param scene: the Scene object
  76049. * @param source: the source node where to pick the matrix
  76050. * @param parameter: the GLTF technique parameter
  76051. * @param uniformName: the name of the shader's uniform
  76052. * @param shaderMaterial: the shader material
  76053. */
  76054. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  76055. /**
  76056. * Sets the given "parameter" matrix
  76057. * @param shaderMaterial: the shader material
  76058. * @param uniform: the name of the shader's uniform
  76059. * @param value: the value of the uniform
  76060. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  76061. */
  76062. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  76063. /**
  76064. * Returns the wrap mode of the texture
  76065. * @param mode: the mode value
  76066. */
  76067. static GetWrapMode(mode: number): number;
  76068. /**
  76069. * Returns the byte stride giving an accessor
  76070. * @param accessor: the GLTF accessor objet
  76071. */
  76072. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  76073. /**
  76074. * Returns the texture filter mode giving a mode value
  76075. * @param mode: the filter mode value
  76076. */
  76077. static GetTextureFilterMode(mode: number): ETextureFilterType;
  76078. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  76079. /**
  76080. * Returns a buffer from its accessor
  76081. * @param gltfRuntime: the GLTF runtime
  76082. * @param accessor: the GLTF accessor
  76083. */
  76084. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  76085. /**
  76086. * Decodes a buffer view into a string
  76087. * @param view: the buffer view
  76088. */
  76089. static DecodeBufferToText(view: ArrayBufferView): string;
  76090. /**
  76091. * Returns the default material of gltf. Related to
  76092. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  76093. * @param scene: the Babylon.js scene
  76094. */
  76095. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  76096. private static _DefaultMaterial;
  76097. }
  76098. }
  76099. declare module BABYLON.GLTF1 {
  76100. /**
  76101. * Implementation of the base glTF spec
  76102. * @hidden
  76103. */
  76104. export class GLTFLoaderBase {
  76105. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  76106. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76107. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  76108. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76109. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  76110. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76111. }
  76112. /**
  76113. * glTF V1 Loader
  76114. * @hidden
  76115. */
  76116. export class GLTFLoader implements IGLTFLoader {
  76117. static Extensions: {
  76118. [name: string]: GLTFLoaderExtension;
  76119. };
  76120. static RegisterExtension(extension: GLTFLoaderExtension): void;
  76121. state: Nullable<GLTFLoaderState>;
  76122. dispose(): void;
  76123. private _importMeshAsync;
  76124. /**
  76125. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  76126. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76127. * @param scene the scene the meshes should be added to
  76128. * @param forAssetContainer defines if the entities must be stored in the scene
  76129. * @param data gltf data containing information of the meshes in a loaded file
  76130. * @param rootUrl root url to load from
  76131. * @param onProgress event that fires when loading progress has occured
  76132. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76133. */
  76134. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  76135. private _loadAsync;
  76136. /**
  76137. * Imports all objects from a loaded gltf file and adds them to the scene
  76138. * @param scene the scene the objects should be added to
  76139. * @param data gltf data containing information of the meshes in a loaded file
  76140. * @param rootUrl root url to load from
  76141. * @param onProgress event that fires when loading progress has occured
  76142. * @returns a promise which completes when objects have been loaded to the scene
  76143. */
  76144. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  76145. private _loadShadersAsync;
  76146. private _loadBuffersAsync;
  76147. private _createNodes;
  76148. }
  76149. /** @hidden */
  76150. export abstract class GLTFLoaderExtension {
  76151. private _name;
  76152. constructor(name: string);
  76153. get name(): string;
  76154. /**
  76155. * Defines an override for loading the runtime
  76156. * Return true to stop further extensions from loading the runtime
  76157. */
  76158. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  76159. /**
  76160. * Defines an onverride for creating gltf runtime
  76161. * Return true to stop further extensions from creating the runtime
  76162. */
  76163. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  76164. /**
  76165. * Defines an override for loading buffers
  76166. * Return true to stop further extensions from loading this buffer
  76167. */
  76168. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  76169. /**
  76170. * Defines an override for loading texture buffers
  76171. * Return true to stop further extensions from loading this texture data
  76172. */
  76173. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76174. /**
  76175. * Defines an override for creating textures
  76176. * Return true to stop further extensions from loading this texture
  76177. */
  76178. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  76179. /**
  76180. * Defines an override for loading shader strings
  76181. * Return true to stop further extensions from loading this shader data
  76182. */
  76183. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76184. /**
  76185. * Defines an override for loading materials
  76186. * Return true to stop further extensions from loading this material
  76187. */
  76188. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76189. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  76190. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  76191. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76192. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76193. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  76194. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76195. private static LoadTextureBufferAsync;
  76196. private static CreateTextureAsync;
  76197. private static ApplyExtensions;
  76198. }
  76199. }
  76200. declare module BABYLON.GLTF1 {
  76201. /** @hidden */
  76202. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  76203. private _bin;
  76204. constructor();
  76205. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  76206. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76207. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76208. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76209. }
  76210. }
  76211. declare module BABYLON.GLTF1 {
  76212. /** @hidden */
  76213. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  76214. constructor();
  76215. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  76216. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76217. private _loadTexture;
  76218. }
  76219. }
  76220. declare module BABYLON.GLTF2.Loader {
  76221. /**
  76222. * Loader interface with an index field.
  76223. */
  76224. export interface IArrayItem {
  76225. /**
  76226. * The index of this item in the array.
  76227. */
  76228. index: number;
  76229. }
  76230. /**
  76231. * Loader interface with additional members.
  76232. */
  76233. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  76234. /** @hidden */
  76235. _data?: Promise<ArrayBufferView>;
  76236. /** @hidden */
  76237. _babylonVertexBuffer?: Promise<VertexBuffer>;
  76238. }
  76239. /**
  76240. * Loader interface with additional members.
  76241. */
  76242. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  76243. }
  76244. /** @hidden */
  76245. export interface _IAnimationSamplerData {
  76246. input: Float32Array;
  76247. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  76248. output: Float32Array;
  76249. }
  76250. /**
  76251. * Loader interface with additional members.
  76252. */
  76253. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  76254. /** @hidden */
  76255. _data?: Promise<_IAnimationSamplerData>;
  76256. }
  76257. /**
  76258. * Loader interface with additional members.
  76259. */
  76260. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  76261. channels: IAnimationChannel[];
  76262. samplers: IAnimationSampler[];
  76263. /** @hidden */
  76264. _babylonAnimationGroup?: AnimationGroup;
  76265. }
  76266. /**
  76267. * Loader interface with additional members.
  76268. */
  76269. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  76270. /** @hidden */
  76271. _data?: Promise<ArrayBufferView>;
  76272. }
  76273. /**
  76274. * Loader interface with additional members.
  76275. */
  76276. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  76277. /** @hidden */
  76278. _data?: Promise<ArrayBufferView>;
  76279. /** @hidden */
  76280. _babylonBuffer?: Promise<Buffer>;
  76281. }
  76282. /**
  76283. * Loader interface with additional members.
  76284. */
  76285. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  76286. }
  76287. /**
  76288. * Loader interface with additional members.
  76289. */
  76290. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  76291. /** @hidden */
  76292. _data?: Promise<ArrayBufferView>;
  76293. }
  76294. /**
  76295. * Loader interface with additional members.
  76296. */
  76297. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  76298. }
  76299. /**
  76300. * Loader interface with additional members.
  76301. */
  76302. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  76303. }
  76304. /**
  76305. * Loader interface with additional members.
  76306. */
  76307. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  76308. baseColorTexture?: ITextureInfo;
  76309. metallicRoughnessTexture?: ITextureInfo;
  76310. }
  76311. /**
  76312. * Loader interface with additional members.
  76313. */
  76314. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  76315. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76316. normalTexture?: IMaterialNormalTextureInfo;
  76317. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76318. emissiveTexture?: ITextureInfo;
  76319. /** @hidden */
  76320. _data?: {
  76321. [babylonDrawMode: number]: {
  76322. babylonMaterial: Material;
  76323. babylonMeshes: AbstractMesh[];
  76324. promise: Promise<void>;
  76325. };
  76326. };
  76327. }
  76328. /**
  76329. * Loader interface with additional members.
  76330. */
  76331. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  76332. primitives: IMeshPrimitive[];
  76333. }
  76334. /**
  76335. * Loader interface with additional members.
  76336. */
  76337. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  76338. /** @hidden */
  76339. _instanceData?: {
  76340. babylonSourceMesh: Mesh;
  76341. promise: Promise<any>;
  76342. };
  76343. }
  76344. /**
  76345. * Loader interface with additional members.
  76346. */
  76347. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76348. /**
  76349. * The parent glTF node.
  76350. */
  76351. parent?: INode;
  76352. /** @hidden */
  76353. _babylonTransformNode?: TransformNode;
  76354. /** @hidden */
  76355. _primitiveBabylonMeshes?: AbstractMesh[];
  76356. /** @hidden */
  76357. _babylonBones?: Bone[];
  76358. /** @hidden */
  76359. _numMorphTargets?: number;
  76360. }
  76361. /** @hidden */
  76362. export interface _ISamplerData {
  76363. noMipMaps: boolean;
  76364. samplingMode: number;
  76365. wrapU: number;
  76366. wrapV: number;
  76367. }
  76368. /**
  76369. * Loader interface with additional members.
  76370. */
  76371. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76372. /** @hidden */
  76373. _data?: _ISamplerData;
  76374. }
  76375. /**
  76376. * Loader interface with additional members.
  76377. */
  76378. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76379. }
  76380. /**
  76381. * Loader interface with additional members.
  76382. */
  76383. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76384. /** @hidden */
  76385. _data?: {
  76386. babylonSkeleton: Skeleton;
  76387. promise: Promise<void>;
  76388. };
  76389. }
  76390. /**
  76391. * Loader interface with additional members.
  76392. */
  76393. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76394. }
  76395. /**
  76396. * Loader interface with additional members.
  76397. */
  76398. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76399. }
  76400. /**
  76401. * Loader interface with additional members.
  76402. */
  76403. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76404. accessors?: IAccessor[];
  76405. animations?: IAnimation[];
  76406. buffers?: IBuffer[];
  76407. bufferViews?: IBufferView[];
  76408. cameras?: ICamera[];
  76409. images?: IImage[];
  76410. materials?: IMaterial[];
  76411. meshes?: IMesh[];
  76412. nodes?: INode[];
  76413. samplers?: ISampler[];
  76414. scenes?: IScene[];
  76415. skins?: ISkin[];
  76416. textures?: ITexture[];
  76417. }
  76418. }
  76419. declare module BABYLON.GLTF2 {
  76420. /**
  76421. * Interface for a glTF loader extension.
  76422. */
  76423. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76424. /**
  76425. * Called after the loader state changes to LOADING.
  76426. */
  76427. onLoading?(): void;
  76428. /**
  76429. * Called after the loader state changes to READY.
  76430. */
  76431. onReady?(): void;
  76432. /**
  76433. * Define this method to modify the default behavior when loading scenes.
  76434. * @param context The context when loading the asset
  76435. * @param scene The glTF scene property
  76436. * @returns A promise that resolves when the load is complete or null if not handled
  76437. */
  76438. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76439. /**
  76440. * Define this method to modify the default behavior when loading nodes.
  76441. * @param context The context when loading the asset
  76442. * @param node The glTF node property
  76443. * @param assign A function called synchronously after parsing the glTF properties
  76444. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76445. */
  76446. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76447. /**
  76448. * Define this method to modify the default behavior when loading cameras.
  76449. * @param context The context when loading the asset
  76450. * @param camera The glTF camera property
  76451. * @param assign A function called synchronously after parsing the glTF properties
  76452. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76453. */
  76454. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76455. /**
  76456. * @hidden
  76457. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76458. * @param context The context when loading the asset
  76459. * @param primitive The glTF mesh primitive property
  76460. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76461. */
  76462. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76463. /**
  76464. * @hidden
  76465. * Define this method to modify the default behavior when loading data for mesh primitives.
  76466. * @param context The context when loading the asset
  76467. * @param name The mesh name when loading the asset
  76468. * @param node The glTF node when loading the asset
  76469. * @param mesh The glTF mesh when loading the asset
  76470. * @param primitive The glTF mesh primitive property
  76471. * @param assign A function called synchronously after parsing the glTF properties
  76472. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76473. */
  76474. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76475. /**
  76476. * @hidden
  76477. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76478. * @param context The context when loading the asset
  76479. * @param material The glTF material property
  76480. * @param assign A function called synchronously after parsing the glTF properties
  76481. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76482. */
  76483. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76484. /**
  76485. * Define this method to modify the default behavior when creating materials.
  76486. * @param context The context when loading the asset
  76487. * @param material The glTF material property
  76488. * @param babylonDrawMode The draw mode for the Babylon material
  76489. * @returns The Babylon material or null if not handled
  76490. */
  76491. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76492. /**
  76493. * Define this method to modify the default behavior when loading material properties.
  76494. * @param context The context when loading the asset
  76495. * @param material The glTF material property
  76496. * @param babylonMaterial The Babylon material
  76497. * @returns A promise that resolves when the load is complete or null if not handled
  76498. */
  76499. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76500. /**
  76501. * Define this method to modify the default behavior when loading texture infos.
  76502. * @param context The context when loading the asset
  76503. * @param textureInfo The glTF texture info property
  76504. * @param assign A function called synchronously after parsing the glTF properties
  76505. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76506. */
  76507. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76508. /**
  76509. * @hidden
  76510. * Define this method to modify the default behavior when loading textures.
  76511. * @param context The context when loading the asset
  76512. * @param texture The glTF texture property
  76513. * @param assign A function called synchronously after parsing the glTF properties
  76514. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76515. */
  76516. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76517. /**
  76518. * Define this method to modify the default behavior when loading animations.
  76519. * @param context The context when loading the asset
  76520. * @param animation The glTF animation property
  76521. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76522. */
  76523. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76524. /**
  76525. * @hidden
  76526. * Define this method to modify the default behavior when loading skins.
  76527. * @param context The context when loading the asset
  76528. * @param node The glTF node property
  76529. * @param skin The glTF skin property
  76530. * @returns A promise that resolves when the load is complete or null if not handled
  76531. */
  76532. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76533. /**
  76534. * @hidden
  76535. * Define this method to modify the default behavior when loading uris.
  76536. * @param context The context when loading the asset
  76537. * @param property The glTF property associated with the uri
  76538. * @param uri The uri to load
  76539. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76540. */
  76541. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76542. /**
  76543. * Define this method to modify the default behavior when loading buffer views.
  76544. * @param context The context when loading the asset
  76545. * @param bufferView The glTF buffer view property
  76546. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76547. */
  76548. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76549. /**
  76550. * Define this method to modify the default behavior when loading buffers.
  76551. * @param context The context when loading the asset
  76552. * @param buffer The glTF buffer property
  76553. * @param byteOffset The byte offset to load
  76554. * @param byteLength The byte length to load
  76555. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76556. */
  76557. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76558. }
  76559. }
  76560. declare module BABYLON.GLTF2 {
  76561. /**
  76562. * Helper class for working with arrays when loading the glTF asset
  76563. */
  76564. export class ArrayItem {
  76565. /**
  76566. * Gets an item from the given array.
  76567. * @param context The context when loading the asset
  76568. * @param array The array to get the item from
  76569. * @param index The index to the array
  76570. * @returns The array item
  76571. */
  76572. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76573. /**
  76574. * Assign an `index` field to each item of the given array.
  76575. * @param array The array of items
  76576. */
  76577. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76578. }
  76579. /**
  76580. * The glTF 2.0 loader
  76581. */
  76582. export class GLTFLoader implements IGLTFLoader {
  76583. /** @hidden */
  76584. _completePromises: Promise<any>[];
  76585. /** @hidden */
  76586. _forAssetContainer: boolean;
  76587. /** Storage */
  76588. _babylonLights: Light[];
  76589. private _disposed;
  76590. private _parent;
  76591. private _state;
  76592. private _extensions;
  76593. private _rootUrl;
  76594. private _fileName;
  76595. private _uniqueRootUrl;
  76596. private _gltf;
  76597. private _bin;
  76598. private _babylonScene;
  76599. private _rootBabylonMesh;
  76600. private _defaultBabylonMaterialData;
  76601. private _progressCallback?;
  76602. private _requests;
  76603. private static _RegisteredExtensions;
  76604. /**
  76605. * The default glTF sampler.
  76606. */
  76607. static readonly DefaultSampler: ISampler;
  76608. /**
  76609. * Registers a loader extension.
  76610. * @param name The name of the loader extension.
  76611. * @param factory The factory function that creates the loader extension.
  76612. */
  76613. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76614. /**
  76615. * Unregisters a loader extension.
  76616. * @param name The name of the loader extension.
  76617. * @returns A boolean indicating whether the extension has been unregistered
  76618. */
  76619. static UnregisterExtension(name: string): boolean;
  76620. /**
  76621. * The loader state.
  76622. */
  76623. get state(): Nullable<GLTFLoaderState>;
  76624. /**
  76625. * The object that represents the glTF JSON.
  76626. */
  76627. get gltf(): IGLTF;
  76628. /**
  76629. * The BIN chunk of a binary glTF.
  76630. */
  76631. get bin(): Nullable<IDataBuffer>;
  76632. /**
  76633. * The parent file loader.
  76634. */
  76635. get parent(): GLTFFileLoader;
  76636. /**
  76637. * The Babylon scene when loading the asset.
  76638. */
  76639. get babylonScene(): Scene;
  76640. /**
  76641. * The root Babylon mesh when loading the asset.
  76642. */
  76643. get rootBabylonMesh(): Mesh;
  76644. /** @hidden */
  76645. constructor(parent: GLTFFileLoader);
  76646. /** @hidden */
  76647. dispose(): void;
  76648. /** @hidden */
  76649. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76650. /** @hidden */
  76651. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76652. private _loadAsync;
  76653. private _loadData;
  76654. private _setupData;
  76655. private _loadExtensions;
  76656. private _checkExtensions;
  76657. private _setState;
  76658. private _createRootNode;
  76659. /**
  76660. * Loads a glTF scene.
  76661. * @param context The context when loading the asset
  76662. * @param scene The glTF scene property
  76663. * @returns A promise that resolves when the load is complete
  76664. */
  76665. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76666. private _forEachPrimitive;
  76667. private _getMeshes;
  76668. private _getTransformNodes;
  76669. private _getSkeletons;
  76670. private _getAnimationGroups;
  76671. private _startAnimations;
  76672. /**
  76673. * Loads a glTF node.
  76674. * @param context The context when loading the asset
  76675. * @param node The glTF node property
  76676. * @param assign A function called synchronously after parsing the glTF properties
  76677. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76678. */
  76679. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76680. private _loadMeshAsync;
  76681. /**
  76682. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76683. * @param context The context when loading the asset
  76684. * @param name The mesh name when loading the asset
  76685. * @param node The glTF node when loading the asset
  76686. * @param mesh The glTF mesh when loading the asset
  76687. * @param primitive The glTF mesh primitive property
  76688. * @param assign A function called synchronously after parsing the glTF properties
  76689. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76690. */
  76691. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76692. private _loadVertexDataAsync;
  76693. private _createMorphTargets;
  76694. private _loadMorphTargetsAsync;
  76695. private _loadMorphTargetVertexDataAsync;
  76696. private static _LoadTransform;
  76697. private _loadSkinAsync;
  76698. private _loadBones;
  76699. private _loadBone;
  76700. private _loadSkinInverseBindMatricesDataAsync;
  76701. private _updateBoneMatrices;
  76702. private _getNodeMatrix;
  76703. /**
  76704. * Loads a glTF camera.
  76705. * @param context The context when loading the asset
  76706. * @param camera The glTF camera property
  76707. * @param assign A function called synchronously after parsing the glTF properties
  76708. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76709. */
  76710. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76711. private _loadAnimationsAsync;
  76712. /**
  76713. * Loads a glTF animation.
  76714. * @param context The context when loading the asset
  76715. * @param animation The glTF animation property
  76716. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76717. */
  76718. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76719. /**
  76720. * @hidden Loads a glTF animation channel.
  76721. * @param context The context when loading the asset
  76722. * @param animationContext The context of the animation when loading the asset
  76723. * @param animation The glTF animation property
  76724. * @param channel The glTF animation channel property
  76725. * @param babylonAnimationGroup The babylon animation group property
  76726. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76727. * @returns A void promise when the channel load is complete
  76728. */
  76729. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76730. private _loadAnimationSamplerAsync;
  76731. private _loadBufferAsync;
  76732. /**
  76733. * Loads a glTF buffer view.
  76734. * @param context The context when loading the asset
  76735. * @param bufferView The glTF buffer view property
  76736. * @returns A promise that resolves with the loaded data when the load is complete
  76737. */
  76738. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76739. private _loadAccessorAsync;
  76740. /** @hidden */
  76741. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76742. private _loadIndicesAccessorAsync;
  76743. private _loadVertexBufferViewAsync;
  76744. private _loadVertexAccessorAsync;
  76745. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76746. /** @hidden */
  76747. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76748. private _createDefaultMaterial;
  76749. /**
  76750. * Creates a Babylon material from a glTF material.
  76751. * @param context The context when loading the asset
  76752. * @param material The glTF material property
  76753. * @param babylonDrawMode The draw mode for the Babylon material
  76754. * @returns The Babylon material
  76755. */
  76756. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76757. /**
  76758. * Loads properties from a glTF material into a Babylon material.
  76759. * @param context The context when loading the asset
  76760. * @param material The glTF material property
  76761. * @param babylonMaterial The Babylon material
  76762. * @returns A promise that resolves when the load is complete
  76763. */
  76764. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76765. /**
  76766. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76767. * @param context The context when loading the asset
  76768. * @param material The glTF material property
  76769. * @param babylonMaterial The Babylon material
  76770. * @returns A promise that resolves when the load is complete
  76771. */
  76772. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76773. /**
  76774. * Loads the alpha properties from a glTF material into a Babylon material.
  76775. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76776. * @param context The context when loading the asset
  76777. * @param material The glTF material property
  76778. * @param babylonMaterial The Babylon material
  76779. */
  76780. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76781. /**
  76782. * Loads a glTF texture info.
  76783. * @param context The context when loading the asset
  76784. * @param textureInfo The glTF texture info property
  76785. * @param assign A function called synchronously after parsing the glTF properties
  76786. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76787. */
  76788. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76789. /** @hidden */
  76790. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76791. /** @hidden */
  76792. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76793. private _loadSampler;
  76794. /**
  76795. * Loads a glTF image.
  76796. * @param context The context when loading the asset
  76797. * @param image The glTF image property
  76798. * @returns A promise that resolves with the loaded data when the load is complete
  76799. */
  76800. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76801. /**
  76802. * Loads a glTF uri.
  76803. * @param context The context when loading the asset
  76804. * @param property The glTF property associated with the uri
  76805. * @param uri The base64 or relative uri
  76806. * @returns A promise that resolves with the loaded data when the load is complete
  76807. */
  76808. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76809. private _onProgress;
  76810. /**
  76811. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76812. * @param babylonObject the Babylon object with metadata
  76813. * @param pointer the JSON pointer
  76814. */
  76815. static AddPointerMetadata(babylonObject: {
  76816. metadata: any;
  76817. }, pointer: string): void;
  76818. private static _GetTextureWrapMode;
  76819. private static _GetTextureSamplingMode;
  76820. private static _GetTypedArrayConstructor;
  76821. private static _GetTypedArray;
  76822. private static _GetNumComponents;
  76823. private static _ValidateUri;
  76824. private static _GetDrawMode;
  76825. private _compileMaterialsAsync;
  76826. private _compileShadowGeneratorsAsync;
  76827. private _forEachExtensions;
  76828. private _applyExtensions;
  76829. private _extensionsOnLoading;
  76830. private _extensionsOnReady;
  76831. private _extensionsLoadSceneAsync;
  76832. private _extensionsLoadNodeAsync;
  76833. private _extensionsLoadCameraAsync;
  76834. private _extensionsLoadVertexDataAsync;
  76835. private _extensionsLoadMeshPrimitiveAsync;
  76836. private _extensionsLoadMaterialAsync;
  76837. private _extensionsCreateMaterial;
  76838. private _extensionsLoadMaterialPropertiesAsync;
  76839. private _extensionsLoadTextureInfoAsync;
  76840. private _extensionsLoadTextureAsync;
  76841. private _extensionsLoadAnimationAsync;
  76842. private _extensionsLoadSkinAsync;
  76843. private _extensionsLoadUriAsync;
  76844. private _extensionsLoadBufferViewAsync;
  76845. private _extensionsLoadBufferAsync;
  76846. /**
  76847. * Helper method called by a loader extension to load an glTF extension.
  76848. * @param context The context when loading the asset
  76849. * @param property The glTF property to load the extension from
  76850. * @param extensionName The name of the extension to load
  76851. * @param actionAsync The action to run
  76852. * @returns The promise returned by actionAsync or null if the extension does not exist
  76853. */
  76854. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76855. /**
  76856. * Helper method called by a loader extension to load a glTF extra.
  76857. * @param context The context when loading the asset
  76858. * @param property The glTF property to load the extra from
  76859. * @param extensionName The name of the extension to load
  76860. * @param actionAsync The action to run
  76861. * @returns The promise returned by actionAsync or null if the extra does not exist
  76862. */
  76863. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76864. /**
  76865. * Checks for presence of an extension.
  76866. * @param name The name of the extension to check
  76867. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76868. */
  76869. isExtensionUsed(name: string): boolean;
  76870. /**
  76871. * Increments the indentation level and logs a message.
  76872. * @param message The message to log
  76873. */
  76874. logOpen(message: string): void;
  76875. /**
  76876. * Decrements the indentation level.
  76877. */
  76878. logClose(): void;
  76879. /**
  76880. * Logs a message
  76881. * @param message The message to log
  76882. */
  76883. log(message: string): void;
  76884. /**
  76885. * Starts a performance counter.
  76886. * @param counterName The name of the performance counter
  76887. */
  76888. startPerformanceCounter(counterName: string): void;
  76889. /**
  76890. * Ends a performance counter.
  76891. * @param counterName The name of the performance counter
  76892. */
  76893. endPerformanceCounter(counterName: string): void;
  76894. }
  76895. }
  76896. declare module BABYLON.GLTF2.Loader.Extensions {
  76897. /**
  76898. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76899. */
  76900. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76901. /**
  76902. * The name of this extension.
  76903. */
  76904. readonly name: string;
  76905. /**
  76906. * Defines whether this extension is enabled.
  76907. */
  76908. enabled: boolean;
  76909. private _loader;
  76910. private _lights?;
  76911. /** @hidden */
  76912. constructor(loader: GLTFLoader);
  76913. /** @hidden */
  76914. dispose(): void;
  76915. /** @hidden */
  76916. onLoading(): void;
  76917. /** @hidden */
  76918. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76919. private _loadLightAsync;
  76920. }
  76921. }
  76922. declare module BABYLON.GLTF2.Loader.Extensions {
  76923. /**
  76924. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76925. */
  76926. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76927. /**
  76928. * The name of this extension.
  76929. */
  76930. readonly name: string;
  76931. /**
  76932. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76933. */
  76934. dracoCompression?: DracoCompression;
  76935. /**
  76936. * Defines whether this extension is enabled.
  76937. */
  76938. enabled: boolean;
  76939. private _loader;
  76940. /** @hidden */
  76941. constructor(loader: GLTFLoader);
  76942. /** @hidden */
  76943. dispose(): void;
  76944. /** @hidden */
  76945. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76946. }
  76947. }
  76948. declare module BABYLON.GLTF2.Loader.Extensions {
  76949. /**
  76950. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76951. */
  76952. export class KHR_lights implements IGLTFLoaderExtension {
  76953. /**
  76954. * The name of this extension.
  76955. */
  76956. readonly name: string;
  76957. /**
  76958. * Defines whether this extension is enabled.
  76959. */
  76960. enabled: boolean;
  76961. private _loader;
  76962. private _lights?;
  76963. /** @hidden */
  76964. constructor(loader: GLTFLoader);
  76965. /** @hidden */
  76966. dispose(): void;
  76967. /** @hidden */
  76968. onLoading(): void;
  76969. /** @hidden */
  76970. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76971. }
  76972. }
  76973. declare module BABYLON.GLTF2.Loader.Extensions {
  76974. /**
  76975. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76976. */
  76977. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76978. /**
  76979. * The name of this extension.
  76980. */
  76981. readonly name: string;
  76982. /**
  76983. * Defines whether this extension is enabled.
  76984. */
  76985. enabled: boolean;
  76986. /**
  76987. * Defines a number that determines the order the extensions are applied.
  76988. */
  76989. order: number;
  76990. private _loader;
  76991. /** @hidden */
  76992. constructor(loader: GLTFLoader);
  76993. /** @hidden */
  76994. dispose(): void;
  76995. /** @hidden */
  76996. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76997. private _loadSpecularGlossinessPropertiesAsync;
  76998. }
  76999. }
  77000. declare module BABYLON.GLTF2.Loader.Extensions {
  77001. /**
  77002. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  77003. */
  77004. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  77005. /**
  77006. * The name of this extension.
  77007. */
  77008. readonly name: string;
  77009. /**
  77010. * Defines whether this extension is enabled.
  77011. */
  77012. enabled: boolean;
  77013. /**
  77014. * Defines a number that determines the order the extensions are applied.
  77015. */
  77016. order: number;
  77017. private _loader;
  77018. /** @hidden */
  77019. constructor(loader: GLTFLoader);
  77020. /** @hidden */
  77021. dispose(): void;
  77022. /** @hidden */
  77023. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77024. private _loadUnlitPropertiesAsync;
  77025. }
  77026. }
  77027. declare module BABYLON.GLTF2.Loader.Extensions {
  77028. /**
  77029. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77030. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  77031. * !!! Experimental Extension Subject to Changes !!!
  77032. */
  77033. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  77034. /**
  77035. * The name of this extension.
  77036. */
  77037. readonly name: string;
  77038. /**
  77039. * Defines whether this extension is enabled.
  77040. */
  77041. enabled: boolean;
  77042. /**
  77043. * Defines a number that determines the order the extensions are applied.
  77044. */
  77045. order: number;
  77046. private _loader;
  77047. /** @hidden */
  77048. constructor(loader: GLTFLoader);
  77049. /** @hidden */
  77050. dispose(): void;
  77051. /** @hidden */
  77052. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77053. private _loadClearCoatPropertiesAsync;
  77054. }
  77055. }
  77056. declare module BABYLON.GLTF2.Loader.Extensions {
  77057. /**
  77058. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  77059. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77060. * !!! Experimental Extension Subject to Changes !!!
  77061. */
  77062. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  77063. /**
  77064. * The name of this extension.
  77065. */
  77066. readonly name: string;
  77067. /**
  77068. * Defines whether this extension is enabled.
  77069. */
  77070. enabled: boolean;
  77071. /**
  77072. * Defines a number that determines the order the extensions are applied.
  77073. */
  77074. order: number;
  77075. private _loader;
  77076. /** @hidden */
  77077. constructor(loader: GLTFLoader);
  77078. /** @hidden */
  77079. dispose(): void;
  77080. /** @hidden */
  77081. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77082. private _loadSheenPropertiesAsync;
  77083. }
  77084. }
  77085. declare module BABYLON.GLTF2.Loader.Extensions {
  77086. /**
  77087. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77088. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77089. * !!! Experimental Extension Subject to Changes !!!
  77090. */
  77091. export class KHR_materials_specular implements IGLTFLoaderExtension {
  77092. /**
  77093. * The name of this extension.
  77094. */
  77095. readonly name: string;
  77096. /**
  77097. * Defines whether this extension is enabled.
  77098. */
  77099. enabled: boolean;
  77100. /**
  77101. * Defines a number that determines the order the extensions are applied.
  77102. */
  77103. order: number;
  77104. private _loader;
  77105. /** @hidden */
  77106. constructor(loader: GLTFLoader);
  77107. /** @hidden */
  77108. dispose(): void;
  77109. /** @hidden */
  77110. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77111. private _loadSpecularPropertiesAsync;
  77112. }
  77113. }
  77114. declare module BABYLON.GLTF2.Loader.Extensions {
  77115. /**
  77116. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  77117. * [Playground Sample](//TODO)
  77118. * !!! Experimental Extension Subject to Changes !!!
  77119. */
  77120. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  77121. /**
  77122. * The name of this extension.
  77123. */
  77124. readonly name: string;
  77125. /**
  77126. * Defines whether this extension is enabled.
  77127. */
  77128. enabled: boolean;
  77129. private _loader;
  77130. /** @hidden */
  77131. constructor(loader: GLTFLoader);
  77132. /** @hidden */
  77133. dispose(): void;
  77134. /** @hidden */
  77135. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77136. }
  77137. }
  77138. declare module BABYLON.GLTF2.Loader.Extensions {
  77139. /**
  77140. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  77141. */
  77142. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  77143. /**
  77144. * The name of this extension.
  77145. */
  77146. readonly name: string;
  77147. /**
  77148. * Defines whether this extension is enabled.
  77149. */
  77150. enabled: boolean;
  77151. /** @hidden */
  77152. constructor(loader: GLTFLoader);
  77153. /** @hidden */
  77154. dispose(): void;
  77155. }
  77156. }
  77157. declare module BABYLON.GLTF2.Loader.Extensions {
  77158. /**
  77159. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  77160. * !!! Experimental Extension Subject to Changes !!!
  77161. */
  77162. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  77163. /** The name of this extension. */
  77164. readonly name: string;
  77165. /** Defines whether this extension is enabled. */
  77166. enabled: boolean;
  77167. private _loader;
  77168. /** @hidden */
  77169. constructor(loader: GLTFLoader);
  77170. /** @hidden */
  77171. dispose(): void;
  77172. /** @hidden */
  77173. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77174. }
  77175. }
  77176. declare module BABYLON.GLTF2.Loader.Extensions {
  77177. /**
  77178. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  77179. */
  77180. export class KHR_texture_transform implements IGLTFLoaderExtension {
  77181. /**
  77182. * The name of this extension.
  77183. */
  77184. readonly name: string;
  77185. /**
  77186. * Defines whether this extension is enabled.
  77187. */
  77188. enabled: boolean;
  77189. private _loader;
  77190. /** @hidden */
  77191. constructor(loader: GLTFLoader);
  77192. /** @hidden */
  77193. dispose(): void;
  77194. /** @hidden */
  77195. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77196. }
  77197. }
  77198. declare module BABYLON.GLTF2.Loader.Extensions {
  77199. /**
  77200. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  77201. */
  77202. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  77203. /**
  77204. * The name of this extension.
  77205. */
  77206. readonly name: string;
  77207. /**
  77208. * Defines whether this extension is enabled.
  77209. */
  77210. enabled: boolean;
  77211. private _loader;
  77212. private _clips;
  77213. private _emitters;
  77214. /** @hidden */
  77215. constructor(loader: GLTFLoader);
  77216. /** @hidden */
  77217. dispose(): void;
  77218. /** @hidden */
  77219. onLoading(): void;
  77220. /** @hidden */
  77221. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77222. /** @hidden */
  77223. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77224. /** @hidden */
  77225. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77226. private _loadClipAsync;
  77227. private _loadEmitterAsync;
  77228. private _getEventAction;
  77229. private _loadAnimationEventAsync;
  77230. }
  77231. }
  77232. declare module BABYLON.GLTF2.Loader.Extensions {
  77233. /**
  77234. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  77235. */
  77236. export class MSFT_lod implements IGLTFLoaderExtension {
  77237. /**
  77238. * The name of this extension.
  77239. */
  77240. readonly name: string;
  77241. /**
  77242. * Defines whether this extension is enabled.
  77243. */
  77244. enabled: boolean;
  77245. /**
  77246. * Defines a number that determines the order the extensions are applied.
  77247. */
  77248. order: number;
  77249. /**
  77250. * Maximum number of LODs to load, starting from the lowest LOD.
  77251. */
  77252. maxLODsToLoad: number;
  77253. /**
  77254. * Observable raised when all node LODs of one level are loaded.
  77255. * The event data is the index of the loaded LOD starting from zero.
  77256. * Dispose the loader to cancel the loading of the next level of LODs.
  77257. */
  77258. onNodeLODsLoadedObservable: Observable<number>;
  77259. /**
  77260. * Observable raised when all material LODs of one level are loaded.
  77261. * The event data is the index of the loaded LOD starting from zero.
  77262. * Dispose the loader to cancel the loading of the next level of LODs.
  77263. */
  77264. onMaterialLODsLoadedObservable: Observable<number>;
  77265. private _loader;
  77266. private _nodeIndexLOD;
  77267. private _nodeSignalLODs;
  77268. private _nodePromiseLODs;
  77269. private _materialIndexLOD;
  77270. private _materialSignalLODs;
  77271. private _materialPromiseLODs;
  77272. private _indexLOD;
  77273. private _bufferLODs;
  77274. /** @hidden */
  77275. constructor(loader: GLTFLoader);
  77276. /** @hidden */
  77277. dispose(): void;
  77278. /** @hidden */
  77279. onReady(): void;
  77280. /** @hidden */
  77281. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77282. /** @hidden */
  77283. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77284. /** @hidden */
  77285. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77286. /** @hidden */
  77287. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77288. /** @hidden */
  77289. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77290. private _loadBufferLOD;
  77291. /**
  77292. * Gets an array of LOD properties from lowest to highest.
  77293. */
  77294. private _getLODs;
  77295. private _disposeTransformNode;
  77296. private _disposeMaterials;
  77297. }
  77298. }
  77299. declare module BABYLON.GLTF2.Loader.Extensions {
  77300. /** @hidden */
  77301. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  77302. readonly name: string;
  77303. enabled: boolean;
  77304. private _loader;
  77305. constructor(loader: GLTFLoader);
  77306. dispose(): void;
  77307. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77308. }
  77309. }
  77310. declare module BABYLON.GLTF2.Loader.Extensions {
  77311. /** @hidden */
  77312. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  77313. readonly name: string;
  77314. enabled: boolean;
  77315. private _loader;
  77316. constructor(loader: GLTFLoader);
  77317. dispose(): void;
  77318. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77319. }
  77320. }
  77321. declare module BABYLON.GLTF2.Loader.Extensions {
  77322. /**
  77323. * Store glTF extras (if present) in BJS objects' metadata
  77324. */
  77325. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  77326. /**
  77327. * The name of this extension.
  77328. */
  77329. readonly name: string;
  77330. /**
  77331. * Defines whether this extension is enabled.
  77332. */
  77333. enabled: boolean;
  77334. private _loader;
  77335. private _assignExtras;
  77336. /** @hidden */
  77337. constructor(loader: GLTFLoader);
  77338. /** @hidden */
  77339. dispose(): void;
  77340. /** @hidden */
  77341. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77342. /** @hidden */
  77343. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77344. /** @hidden */
  77345. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77346. }
  77347. }
  77348. declare module BABYLON {
  77349. /**
  77350. * Class reading and parsing the MTL file bundled with the obj file.
  77351. */
  77352. export class MTLFileLoader {
  77353. /**
  77354. * Invert Y-Axis of referenced textures on load
  77355. */
  77356. static INVERT_TEXTURE_Y: boolean;
  77357. /**
  77358. * All material loaded from the mtl will be set here
  77359. */
  77360. materials: StandardMaterial[];
  77361. /**
  77362. * This function will read the mtl file and create each material described inside
  77363. * This function could be improve by adding :
  77364. * -some component missing (Ni, Tf...)
  77365. * -including the specific options available
  77366. *
  77367. * @param scene defines the scene the material will be created in
  77368. * @param data defines the mtl data to parse
  77369. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77370. * @param forAssetContainer defines if the material should be registered in the scene
  77371. */
  77372. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77373. /**
  77374. * Gets the texture for the material.
  77375. *
  77376. * If the material is imported from input file,
  77377. * We sanitize the url to ensure it takes the textre from aside the material.
  77378. *
  77379. * @param rootUrl The root url to load from
  77380. * @param value The value stored in the mtl
  77381. * @return The Texture
  77382. */
  77383. private static _getTexture;
  77384. }
  77385. }
  77386. declare module BABYLON {
  77387. /**
  77388. * Options for loading OBJ/MTL files
  77389. */
  77390. type MeshLoadOptions = {
  77391. /**
  77392. * Defines if UVs are optimized by default during load.
  77393. */
  77394. OptimizeWithUV: boolean;
  77395. /**
  77396. * Defines custom scaling of UV coordinates of loaded meshes.
  77397. */
  77398. UVScaling: Vector2;
  77399. /**
  77400. * Invert model on y-axis (does a model scaling inversion)
  77401. */
  77402. InvertY: boolean;
  77403. /**
  77404. * Invert Y-Axis of referenced textures on load
  77405. */
  77406. InvertTextureY: boolean;
  77407. /**
  77408. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77409. */
  77410. ImportVertexColors: boolean;
  77411. /**
  77412. * Compute the normals for the model, even if normals are present in the file.
  77413. */
  77414. ComputeNormals: boolean;
  77415. /**
  77416. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77417. */
  77418. SkipMaterials: boolean;
  77419. /**
  77420. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77421. */
  77422. MaterialLoadingFailsSilently: boolean;
  77423. };
  77424. /**
  77425. * OBJ file type loader.
  77426. * This is a babylon scene loader plugin.
  77427. */
  77428. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77429. /**
  77430. * Defines if UVs are optimized by default during load.
  77431. */
  77432. static OPTIMIZE_WITH_UV: boolean;
  77433. /**
  77434. * Invert model on y-axis (does a model scaling inversion)
  77435. */
  77436. static INVERT_Y: boolean;
  77437. /**
  77438. * Invert Y-Axis of referenced textures on load
  77439. */
  77440. static get INVERT_TEXTURE_Y(): boolean;
  77441. static set INVERT_TEXTURE_Y(value: boolean);
  77442. /**
  77443. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77444. */
  77445. static IMPORT_VERTEX_COLORS: boolean;
  77446. /**
  77447. * Compute the normals for the model, even if normals are present in the file.
  77448. */
  77449. static COMPUTE_NORMALS: boolean;
  77450. /**
  77451. * Defines custom scaling of UV coordinates of loaded meshes.
  77452. */
  77453. static UV_SCALING: Vector2;
  77454. /**
  77455. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77456. */
  77457. static SKIP_MATERIALS: boolean;
  77458. /**
  77459. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77460. *
  77461. * Defaults to true for backwards compatibility.
  77462. */
  77463. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77464. /**
  77465. * Defines the name of the plugin.
  77466. */
  77467. name: string;
  77468. /**
  77469. * Defines the extension the plugin is able to load.
  77470. */
  77471. extensions: string;
  77472. /** @hidden */
  77473. obj: RegExp;
  77474. /** @hidden */
  77475. group: RegExp;
  77476. /** @hidden */
  77477. mtllib: RegExp;
  77478. /** @hidden */
  77479. usemtl: RegExp;
  77480. /** @hidden */
  77481. smooth: RegExp;
  77482. /** @hidden */
  77483. vertexPattern: RegExp;
  77484. /** @hidden */
  77485. normalPattern: RegExp;
  77486. /** @hidden */
  77487. uvPattern: RegExp;
  77488. /** @hidden */
  77489. facePattern1: RegExp;
  77490. /** @hidden */
  77491. facePattern2: RegExp;
  77492. /** @hidden */
  77493. facePattern3: RegExp;
  77494. /** @hidden */
  77495. facePattern4: RegExp;
  77496. /** @hidden */
  77497. facePattern5: RegExp;
  77498. private _forAssetContainer;
  77499. private _meshLoadOptions;
  77500. /**
  77501. * Creates loader for .OBJ files
  77502. *
  77503. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77504. */
  77505. constructor(meshLoadOptions?: MeshLoadOptions);
  77506. private static get currentMeshLoadOptions();
  77507. /**
  77508. * Calls synchronously the MTL file attached to this obj.
  77509. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77510. * Without this function materials are not displayed in the first frame (but displayed after).
  77511. * In consequence it is impossible to get material information in your HTML file
  77512. *
  77513. * @param url The URL of the MTL file
  77514. * @param rootUrl
  77515. * @param onSuccess Callback function to be called when the MTL file is loaded
  77516. * @private
  77517. */
  77518. private _loadMTL;
  77519. /**
  77520. * Instantiates a OBJ file loader plugin.
  77521. * @returns the created plugin
  77522. */
  77523. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77524. /**
  77525. * If the data string can be loaded directly.
  77526. *
  77527. * @param data string containing the file data
  77528. * @returns if the data can be loaded directly
  77529. */
  77530. canDirectLoad(data: string): boolean;
  77531. /**
  77532. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77533. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77534. * @param scene the scene the meshes should be added to
  77535. * @param data the OBJ data to load
  77536. * @param rootUrl root url to load from
  77537. * @param onProgress event that fires when loading progress has occured
  77538. * @param fileName Defines the name of the file to load
  77539. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77540. */
  77541. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77542. meshes: AbstractMesh[];
  77543. particleSystems: IParticleSystem[];
  77544. skeletons: Skeleton[];
  77545. animationGroups: AnimationGroup[];
  77546. }>;
  77547. /**
  77548. * Imports all objects from the loaded OBJ data and adds them to the scene
  77549. * @param scene the scene the objects should be added to
  77550. * @param data the OBJ data to load
  77551. * @param rootUrl root url to load from
  77552. * @param onProgress event that fires when loading progress has occured
  77553. * @param fileName Defines the name of the file to load
  77554. * @returns a promise which completes when objects have been loaded to the scene
  77555. */
  77556. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77557. /**
  77558. * Load into an asset container.
  77559. * @param scene The scene to load into
  77560. * @param data The data to import
  77561. * @param rootUrl The root url for scene and resources
  77562. * @param onProgress The callback when the load progresses
  77563. * @param fileName Defines the name of the file to load
  77564. * @returns The loaded asset container
  77565. */
  77566. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77567. /**
  77568. * Read the OBJ file and create an Array of meshes.
  77569. * Each mesh contains all information given by the OBJ and the MTL file.
  77570. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77571. *
  77572. * @param meshesNames
  77573. * @param scene Scene The scene where are displayed the data
  77574. * @param data String The content of the obj file
  77575. * @param rootUrl String The path to the folder
  77576. * @returns Array<AbstractMesh>
  77577. * @private
  77578. */
  77579. private _parseSolid;
  77580. }
  77581. }
  77582. declare module BABYLON {
  77583. /**
  77584. * STL file type loader.
  77585. * This is a babylon scene loader plugin.
  77586. */
  77587. export class STLFileLoader implements ISceneLoaderPlugin {
  77588. /** @hidden */
  77589. solidPattern: RegExp;
  77590. /** @hidden */
  77591. facetsPattern: RegExp;
  77592. /** @hidden */
  77593. normalPattern: RegExp;
  77594. /** @hidden */
  77595. vertexPattern: RegExp;
  77596. /**
  77597. * Defines the name of the plugin.
  77598. */
  77599. name: string;
  77600. /**
  77601. * Defines the extensions the stl loader is able to load.
  77602. * force data to come in as an ArrayBuffer
  77603. * we'll convert to string if it looks like it's an ASCII .stl
  77604. */
  77605. extensions: ISceneLoaderPluginExtensions;
  77606. /**
  77607. * Import meshes into a scene.
  77608. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77609. * @param scene The scene to import into
  77610. * @param data The data to import
  77611. * @param rootUrl The root url for scene and resources
  77612. * @param meshes The meshes array to import into
  77613. * @param particleSystems The particle systems array to import into
  77614. * @param skeletons The skeletons array to import into
  77615. * @param onError The callback when import fails
  77616. * @returns True if successful or false otherwise
  77617. */
  77618. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77619. /**
  77620. * Load into a scene.
  77621. * @param scene The scene to load into
  77622. * @param data The data to import
  77623. * @param rootUrl The root url for scene and resources
  77624. * @param onError The callback when import fails
  77625. * @returns true if successful or false otherwise
  77626. */
  77627. load(scene: Scene, data: any, rootUrl: string): boolean;
  77628. /**
  77629. * Load into an asset container.
  77630. * @param scene The scene to load into
  77631. * @param data The data to import
  77632. * @param rootUrl The root url for scene and resources
  77633. * @param onError The callback when import fails
  77634. * @returns The loaded asset container
  77635. */
  77636. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77637. private _isBinary;
  77638. private _parseBinary;
  77639. private _parseASCII;
  77640. }
  77641. }
  77642. declare module BABYLON {
  77643. /**
  77644. * Class for generating OBJ data from a Babylon scene.
  77645. */
  77646. export class OBJExport {
  77647. /**
  77648. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77649. * @param mesh defines the list of meshes to serialize
  77650. * @param materials defines if materials should be exported
  77651. * @param matlibname defines the name of the associated mtl file
  77652. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77653. * @returns the OBJ content
  77654. */
  77655. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77656. /**
  77657. * Exports the material(s) of a mesh in .MTL file format (text)
  77658. * @param mesh defines the mesh to extract the material from
  77659. * @returns the mtl content
  77660. */
  77661. static MTL(mesh: Mesh): string;
  77662. }
  77663. }
  77664. declare module BABYLON {
  77665. /** @hidden */
  77666. export var __IGLTFExporterExtension: number;
  77667. /**
  77668. * Interface for extending the exporter
  77669. * @hidden
  77670. */
  77671. export interface IGLTFExporterExtension {
  77672. /**
  77673. * The name of this extension
  77674. */
  77675. readonly name: string;
  77676. /**
  77677. * Defines whether this extension is enabled
  77678. */
  77679. enabled: boolean;
  77680. /**
  77681. * Defines whether this extension is required
  77682. */
  77683. required: boolean;
  77684. }
  77685. }
  77686. declare module BABYLON.GLTF2.Exporter {
  77687. /** @hidden */
  77688. export var __IGLTFExporterExtensionV2: number;
  77689. /**
  77690. * Interface for a glTF exporter extension
  77691. * @hidden
  77692. */
  77693. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77694. /**
  77695. * Define this method to modify the default behavior before exporting a texture
  77696. * @param context The context when loading the asset
  77697. * @param babylonTexture The Babylon.js texture
  77698. * @param mimeType The mime-type of the generated image
  77699. * @returns A promise that resolves with the exported texture
  77700. */
  77701. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77702. /**
  77703. * Define this method to get notified when a texture info is created
  77704. * @param context The context when loading the asset
  77705. * @param textureInfo The glTF texture info
  77706. * @param babylonTexture The Babylon.js texture
  77707. */
  77708. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77709. /**
  77710. * Define this method to modify the default behavior when exporting texture info
  77711. * @param context The context when loading the asset
  77712. * @param meshPrimitive glTF mesh primitive
  77713. * @param babylonSubMesh Babylon submesh
  77714. * @param binaryWriter glTF serializer binary writer instance
  77715. * @returns nullable IMeshPrimitive promise
  77716. */
  77717. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77718. /**
  77719. * Define this method to modify the default behavior when exporting a node
  77720. * @param context The context when exporting the node
  77721. * @param node glTF node
  77722. * @param babylonNode BabylonJS node
  77723. * @returns nullable INode promise
  77724. */
  77725. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77726. [key: number]: number;
  77727. }): Promise<Nullable<INode>>;
  77728. /**
  77729. * Define this method to modify the default behavior when exporting a material
  77730. * @param material glTF material
  77731. * @param babylonMaterial BabylonJS material
  77732. * @returns nullable IMaterial promise
  77733. */
  77734. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77735. /**
  77736. * Define this method to return additional textures to export from a material
  77737. * @param material glTF material
  77738. * @param babylonMaterial BabylonJS material
  77739. * @returns List of textures
  77740. */
  77741. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77742. /** Gets a boolean indicating that this extension was used */
  77743. wasUsed: boolean;
  77744. /** Gets a boolean indicating that this extension is required for the file to work */
  77745. required: boolean;
  77746. /**
  77747. * Called after the exporter state changes to EXPORTING
  77748. */
  77749. onExporting?(): void;
  77750. }
  77751. }
  77752. declare module BABYLON.GLTF2.Exporter {
  77753. /**
  77754. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77755. * @hidden
  77756. */
  77757. export class _GLTFMaterialExporter {
  77758. /**
  77759. * Represents the dielectric specular values for R, G and B
  77760. */
  77761. private static readonly _DielectricSpecular;
  77762. /**
  77763. * Allows the maximum specular power to be defined for material calculations
  77764. */
  77765. private static readonly _MaxSpecularPower;
  77766. /**
  77767. * Mapping to store textures
  77768. */
  77769. private _textureMap;
  77770. /**
  77771. * Numeric tolerance value
  77772. */
  77773. private static readonly _Epsilon;
  77774. /**
  77775. * Reference to the glTF Exporter
  77776. */
  77777. private _exporter;
  77778. constructor(exporter: _Exporter);
  77779. /**
  77780. * Specifies if two colors are approximately equal in value
  77781. * @param color1 first color to compare to
  77782. * @param color2 second color to compare to
  77783. * @param epsilon threshold value
  77784. */
  77785. private static FuzzyEquals;
  77786. /**
  77787. * Gets the materials from a Babylon scene and converts them to glTF materials
  77788. * @param scene babylonjs scene
  77789. * @param mimeType texture mime type
  77790. * @param images array of images
  77791. * @param textures array of textures
  77792. * @param materials array of materials
  77793. * @param imageData mapping of texture names to base64 textures
  77794. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77795. */
  77796. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77797. /**
  77798. * Makes a copy of the glTF material without the texture parameters
  77799. * @param originalMaterial original glTF material
  77800. * @returns glTF material without texture parameters
  77801. */
  77802. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77803. /**
  77804. * Specifies if the material has any texture parameters present
  77805. * @param material glTF Material
  77806. * @returns boolean specifying if texture parameters are present
  77807. */
  77808. _hasTexturesPresent(material: IMaterial): boolean;
  77809. /**
  77810. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77811. * @param babylonStandardMaterial
  77812. * @returns glTF Metallic Roughness Material representation
  77813. */
  77814. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77815. /**
  77816. * Computes the metallic factor
  77817. * @param diffuse diffused value
  77818. * @param specular specular value
  77819. * @param oneMinusSpecularStrength one minus the specular strength
  77820. * @returns metallic value
  77821. */
  77822. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77823. /**
  77824. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77825. * @param glTFMaterial glTF material
  77826. * @param babylonMaterial Babylon material
  77827. */
  77828. private static _SetAlphaMode;
  77829. /**
  77830. * Converts a Babylon Standard Material to a glTF Material
  77831. * @param babylonStandardMaterial BJS Standard Material
  77832. * @param mimeType mime type to use for the textures
  77833. * @param images array of glTF image interfaces
  77834. * @param textures array of glTF texture interfaces
  77835. * @param materials array of glTF material interfaces
  77836. * @param imageData map of image file name to data
  77837. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77838. */
  77839. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77840. private _finishMaterial;
  77841. /**
  77842. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77843. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77844. * @param mimeType mime type to use for the textures
  77845. * @param images array of glTF image interfaces
  77846. * @param textures array of glTF texture interfaces
  77847. * @param materials array of glTF material interfaces
  77848. * @param imageData map of image file name to data
  77849. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77850. */
  77851. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77852. /**
  77853. * Converts an image typed array buffer to a base64 image
  77854. * @param buffer typed array buffer
  77855. * @param width width of the image
  77856. * @param height height of the image
  77857. * @param mimeType mimetype of the image
  77858. * @returns base64 image string
  77859. */
  77860. private _createBase64FromCanvasAsync;
  77861. /**
  77862. * Generates a white texture based on the specified width and height
  77863. * @param width width of the texture in pixels
  77864. * @param height height of the texture in pixels
  77865. * @param scene babylonjs scene
  77866. * @returns white texture
  77867. */
  77868. private _createWhiteTexture;
  77869. /**
  77870. * 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
  77871. * @param texture1 first texture to resize
  77872. * @param texture2 second texture to resize
  77873. * @param scene babylonjs scene
  77874. * @returns resized textures or null
  77875. */
  77876. private _resizeTexturesToSameDimensions;
  77877. /**
  77878. * Converts an array of pixels to a Float32Array
  77879. * Throws an error if the pixel format is not supported
  77880. * @param pixels - array buffer containing pixel values
  77881. * @returns Float32 of pixels
  77882. */
  77883. private _convertPixelArrayToFloat32;
  77884. /**
  77885. * Convert Specular Glossiness Textures to Metallic Roughness
  77886. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77887. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77888. * @param diffuseTexture texture used to store diffuse information
  77889. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77890. * @param factors specular glossiness material factors
  77891. * @param mimeType the mime type to use for the texture
  77892. * @returns pbr metallic roughness interface or null
  77893. */
  77894. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77895. /**
  77896. * Converts specular glossiness material properties to metallic roughness
  77897. * @param specularGlossiness interface with specular glossiness material properties
  77898. * @returns interface with metallic roughness material properties
  77899. */
  77900. private _convertSpecularGlossinessToMetallicRoughness;
  77901. /**
  77902. * Calculates the surface reflectance, independent of lighting conditions
  77903. * @param color Color source to calculate brightness from
  77904. * @returns number representing the perceived brightness, or zero if color is undefined
  77905. */
  77906. private _getPerceivedBrightness;
  77907. /**
  77908. * Returns the maximum color component value
  77909. * @param color
  77910. * @returns maximum color component value, or zero if color is null or undefined
  77911. */
  77912. private _getMaxComponent;
  77913. /**
  77914. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77915. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77916. * @param mimeType mime type to use for the textures
  77917. * @param images array of glTF image interfaces
  77918. * @param textures array of glTF texture interfaces
  77919. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77920. * @param imageData map of image file name to data
  77921. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77922. * @returns glTF PBR Metallic Roughness factors
  77923. */
  77924. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77925. private _getGLTFTextureSampler;
  77926. private _getGLTFTextureWrapMode;
  77927. private _getGLTFTextureWrapModesSampler;
  77928. /**
  77929. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77930. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77931. * @param mimeType mime type to use for the textures
  77932. * @param images array of glTF image interfaces
  77933. * @param textures array of glTF texture interfaces
  77934. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77935. * @param imageData map of image file name to data
  77936. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77937. * @returns glTF PBR Metallic Roughness factors
  77938. */
  77939. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77940. /**
  77941. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77942. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77943. * @param mimeType mime type to use for the textures
  77944. * @param images array of glTF image interfaces
  77945. * @param textures array of glTF texture interfaces
  77946. * @param materials array of glTF material interfaces
  77947. * @param imageData map of image file name to data
  77948. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77949. */
  77950. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77951. private setMetallicRoughnessPbrMaterial;
  77952. private getPixelsFromTexture;
  77953. /**
  77954. * Extracts a texture from a Babylon texture into file data and glTF data
  77955. * @param babylonTexture Babylon texture to extract
  77956. * @param mimeType Mime Type of the babylonTexture
  77957. * @return glTF texture info, or null if the texture format is not supported
  77958. */
  77959. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77960. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77961. /**
  77962. * Builds a texture from base64 string
  77963. * @param base64Texture base64 texture string
  77964. * @param baseTextureName Name to use for the texture
  77965. * @param mimeType image mime type for the texture
  77966. * @param images array of images
  77967. * @param textures array of textures
  77968. * @param imageData map of image data
  77969. * @returns glTF texture info, or null if the texture format is not supported
  77970. */
  77971. private _getTextureInfoFromBase64;
  77972. }
  77973. }
  77974. declare module BABYLON {
  77975. /**
  77976. * Class for holding and downloading glTF file data
  77977. */
  77978. export class GLTFData {
  77979. /**
  77980. * Object which contains the file name as the key and its data as the value
  77981. */
  77982. glTFFiles: {
  77983. [fileName: string]: string | Blob;
  77984. };
  77985. /**
  77986. * Initializes the glTF file object
  77987. */
  77988. constructor();
  77989. /**
  77990. * Downloads the glTF data as files based on their names and data
  77991. */
  77992. downloadFiles(): void;
  77993. }
  77994. }
  77995. declare module BABYLON {
  77996. /**
  77997. * Holds a collection of exporter options and parameters
  77998. */
  77999. export interface IExportOptions {
  78000. /**
  78001. * Function which indicates whether a babylon node should be exported or not
  78002. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  78003. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  78004. */
  78005. shouldExportNode?(node: Node): boolean;
  78006. /**
  78007. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  78008. * @param metadata source metadata to read from
  78009. * @returns the data to store to glTF node extras
  78010. */
  78011. metadataSelector?(metadata: any): any;
  78012. /**
  78013. * The sample rate to bake animation curves
  78014. */
  78015. animationSampleRate?: number;
  78016. /**
  78017. * Begin serialization without waiting for the scene to be ready
  78018. */
  78019. exportWithoutWaitingForScene?: boolean;
  78020. /**
  78021. * Indicates if coordinate system swapping root nodes should be included in export
  78022. */
  78023. includeCoordinateSystemConversionNodes?: boolean;
  78024. }
  78025. /**
  78026. * Class for generating glTF data from a Babylon scene.
  78027. */
  78028. export class GLTF2Export {
  78029. /**
  78030. * Exports the geometry of the scene to .gltf file format asynchronously
  78031. * @param scene Babylon scene with scene hierarchy information
  78032. * @param filePrefix File prefix to use when generating the glTF file
  78033. * @param options Exporter options
  78034. * @returns Returns an object with a .gltf file and associates texture names
  78035. * as keys and their data and paths as values
  78036. */
  78037. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78038. private static _PreExportAsync;
  78039. private static _PostExportAsync;
  78040. /**
  78041. * Exports the geometry of the scene to .glb file format asychronously
  78042. * @param scene Babylon scene with scene hierarchy information
  78043. * @param filePrefix File prefix to use when generating glb file
  78044. * @param options Exporter options
  78045. * @returns Returns an object with a .glb filename as key and data as value
  78046. */
  78047. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78048. }
  78049. }
  78050. declare module BABYLON.GLTF2.Exporter {
  78051. /**
  78052. * @hidden
  78053. */
  78054. export class _GLTFUtilities {
  78055. /**
  78056. * Creates a buffer view based on the supplied arguments
  78057. * @param bufferIndex index value of the specified buffer
  78058. * @param byteOffset byte offset value
  78059. * @param byteLength byte length of the bufferView
  78060. * @param byteStride byte distance between conequential elements
  78061. * @param name name of the buffer view
  78062. * @returns bufferView for glTF
  78063. */
  78064. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  78065. /**
  78066. * Creates an accessor based on the supplied arguments
  78067. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  78068. * @param name The name of the accessor
  78069. * @param type The type of the accessor
  78070. * @param componentType The datatype of components in the attribute
  78071. * @param count The number of attributes referenced by this accessor
  78072. * @param byteOffset The offset relative to the start of the bufferView in bytes
  78073. * @param min Minimum value of each component in this attribute
  78074. * @param max Maximum value of each component in this attribute
  78075. * @returns accessor for glTF
  78076. */
  78077. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  78078. /**
  78079. * Calculates the minimum and maximum values of an array of position floats
  78080. * @param positions Positions array of a mesh
  78081. * @param vertexStart Starting vertex offset to calculate min and max values
  78082. * @param vertexCount Number of vertices to check for min and max values
  78083. * @returns min number array and max number array
  78084. */
  78085. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  78086. min: number[];
  78087. max: number[];
  78088. };
  78089. /**
  78090. * Converts a new right-handed Vector3
  78091. * @param vector vector3 array
  78092. * @returns right-handed Vector3
  78093. */
  78094. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  78095. /**
  78096. * Converts a Vector3 to right-handed
  78097. * @param vector Vector3 to convert to right-handed
  78098. */
  78099. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  78100. /**
  78101. * Converts a three element number array to right-handed
  78102. * @param vector number array to convert to right-handed
  78103. */
  78104. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  78105. /**
  78106. * Converts a new right-handed Vector3
  78107. * @param vector vector3 array
  78108. * @returns right-handed Vector3
  78109. */
  78110. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  78111. /**
  78112. * Converts a Vector3 to right-handed
  78113. * @param vector Vector3 to convert to right-handed
  78114. */
  78115. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  78116. /**
  78117. * Converts a three element number array to right-handed
  78118. * @param vector number array to convert to right-handed
  78119. */
  78120. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  78121. /**
  78122. * Converts a Vector4 to right-handed
  78123. * @param vector Vector4 to convert to right-handed
  78124. */
  78125. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  78126. /**
  78127. * Converts a Vector4 to right-handed
  78128. * @param vector Vector4 to convert to right-handed
  78129. */
  78130. static _GetRightHandedArray4FromRef(vector: number[]): void;
  78131. /**
  78132. * Converts a Quaternion to right-handed
  78133. * @param quaternion Source quaternion to convert to right-handed
  78134. */
  78135. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  78136. /**
  78137. * Converts a Quaternion to right-handed
  78138. * @param quaternion Source quaternion to convert to right-handed
  78139. */
  78140. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  78141. static _NormalizeTangentFromRef(tangent: Vector4): void;
  78142. }
  78143. }
  78144. declare module BABYLON.GLTF2.Exporter {
  78145. /**
  78146. * Converts Babylon Scene into glTF 2.0.
  78147. * @hidden
  78148. */
  78149. export class _Exporter {
  78150. /**
  78151. * Stores the glTF to export
  78152. */
  78153. _glTF: IGLTF;
  78154. /**
  78155. * Stores all generated buffer views, which represents views into the main glTF buffer data
  78156. */
  78157. _bufferViews: IBufferView[];
  78158. /**
  78159. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  78160. */
  78161. _accessors: IAccessor[];
  78162. /**
  78163. * Stores all the generated nodes, which contains transform and/or mesh information per node
  78164. */
  78165. _nodes: INode[];
  78166. /**
  78167. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  78168. */
  78169. private _scenes;
  78170. /**
  78171. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  78172. */
  78173. private _meshes;
  78174. /**
  78175. * Stores all the generated material information, which represents the appearance of each primitive
  78176. */
  78177. _materials: IMaterial[];
  78178. _materialMap: {
  78179. [materialID: number]: number;
  78180. };
  78181. /**
  78182. * Stores all the generated texture information, which is referenced by glTF materials
  78183. */
  78184. _textures: ITexture[];
  78185. /**
  78186. * Stores all the generated image information, which is referenced by glTF textures
  78187. */
  78188. _images: IImage[];
  78189. /**
  78190. * Stores all the texture samplers
  78191. */
  78192. _samplers: ISampler[];
  78193. /**
  78194. * Stores all the generated animation samplers, which is referenced by glTF animations
  78195. */
  78196. /**
  78197. * Stores the animations for glTF models
  78198. */
  78199. private _animations;
  78200. /**
  78201. * Stores the total amount of bytes stored in the glTF buffer
  78202. */
  78203. private _totalByteLength;
  78204. /**
  78205. * Stores a reference to the Babylon scene containing the source geometry and material information
  78206. */
  78207. _babylonScene: Scene;
  78208. /**
  78209. * Stores a map of the image data, where the key is the file name and the value
  78210. * is the image data
  78211. */
  78212. _imageData: {
  78213. [fileName: string]: {
  78214. data: Uint8Array;
  78215. mimeType: ImageMimeType;
  78216. };
  78217. };
  78218. /**
  78219. * Stores a map of the unique id of a node to its index in the node array
  78220. */
  78221. _nodeMap: {
  78222. [key: number]: number;
  78223. };
  78224. /**
  78225. * Specifies if the source Babylon scene was left handed, and needed conversion.
  78226. */
  78227. _convertToRightHandedSystem: boolean;
  78228. /**
  78229. * Specifies if a Babylon node should be converted to right-handed on export
  78230. */
  78231. _convertToRightHandedSystemMap: {
  78232. [nodeId: number]: boolean;
  78233. };
  78234. _includeCoordinateSystemConversionNodes: boolean;
  78235. /**
  78236. * Baked animation sample rate
  78237. */
  78238. private _animationSampleRate;
  78239. private _options;
  78240. private _localEngine;
  78241. _glTFMaterialExporter: _GLTFMaterialExporter;
  78242. private _extensions;
  78243. private static _ExtensionNames;
  78244. private static _ExtensionFactories;
  78245. private _applyExtension;
  78246. private _applyExtensions;
  78247. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  78248. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  78249. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78250. [key: number]: number;
  78251. }): Promise<Nullable<INode>>;
  78252. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  78253. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  78254. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78255. private _forEachExtensions;
  78256. private _extensionsOnExporting;
  78257. /**
  78258. * Load glTF serializer extensions
  78259. */
  78260. private _loadExtensions;
  78261. /**
  78262. * Creates a glTF Exporter instance, which can accept optional exporter options
  78263. * @param babylonScene Babylon scene object
  78264. * @param options Options to modify the behavior of the exporter
  78265. */
  78266. constructor(babylonScene: Scene, options?: IExportOptions);
  78267. dispose(): void;
  78268. /**
  78269. * Registers a glTF exporter extension
  78270. * @param name Name of the extension to export
  78271. * @param factory The factory function that creates the exporter extension
  78272. */
  78273. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  78274. /**
  78275. * Un-registers an exporter extension
  78276. * @param name The name fo the exporter extension
  78277. * @returns A boolean indicating whether the extension has been un-registered
  78278. */
  78279. static UnregisterExtension(name: string): boolean;
  78280. /**
  78281. * Lazy load a local engine
  78282. */
  78283. _getLocalEngine(): Engine;
  78284. private reorderIndicesBasedOnPrimitiveMode;
  78285. /**
  78286. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  78287. * clock-wise during export to glTF
  78288. * @param submesh BabylonJS submesh
  78289. * @param primitiveMode Primitive mode of the mesh
  78290. * @param sideOrientation the winding order of the submesh
  78291. * @param vertexBufferKind The type of vertex attribute
  78292. * @param meshAttributeArray The vertex attribute data
  78293. * @param byteOffset The offset to the binary data
  78294. * @param binaryWriter The binary data for the glTF file
  78295. * @param convertToRightHandedSystem Converts the values to right-handed
  78296. */
  78297. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  78298. /**
  78299. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  78300. * clock-wise during export to glTF
  78301. * @param submesh BabylonJS submesh
  78302. * @param primitiveMode Primitive mode of the mesh
  78303. * @param sideOrientation the winding order of the submesh
  78304. * @param vertexBufferKind The type of vertex attribute
  78305. * @param meshAttributeArray The vertex attribute data
  78306. * @param byteOffset The offset to the binary data
  78307. * @param binaryWriter The binary data for the glTF file
  78308. * @param convertToRightHandedSystem Converts the values to right-handed
  78309. */
  78310. private reorderTriangleFillMode;
  78311. /**
  78312. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  78313. * clock-wise during export to glTF
  78314. * @param submesh BabylonJS submesh
  78315. * @param primitiveMode Primitive mode of the mesh
  78316. * @param sideOrientation the winding order of the submesh
  78317. * @param vertexBufferKind The type of vertex attribute
  78318. * @param meshAttributeArray The vertex attribute data
  78319. * @param byteOffset The offset to the binary data
  78320. * @param binaryWriter The binary data for the glTF file
  78321. * @param convertToRightHandedSystem Converts the values to right-handed
  78322. */
  78323. private reorderTriangleStripDrawMode;
  78324. /**
  78325. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  78326. * clock-wise during export to glTF
  78327. * @param submesh BabylonJS submesh
  78328. * @param primitiveMode Primitive mode of the mesh
  78329. * @param sideOrientation the winding order of the submesh
  78330. * @param vertexBufferKind The type of vertex attribute
  78331. * @param meshAttributeArray The vertex attribute data
  78332. * @param byteOffset The offset to the binary data
  78333. * @param binaryWriter The binary data for the glTF file
  78334. * @param convertToRightHandedSystem Converts the values to right-handed
  78335. */
  78336. private reorderTriangleFanMode;
  78337. /**
  78338. * Writes the vertex attribute data to binary
  78339. * @param vertices The vertices to write to the binary writer
  78340. * @param byteOffset The offset into the binary writer to overwrite binary data
  78341. * @param vertexAttributeKind The vertex attribute type
  78342. * @param meshAttributeArray The vertex attribute data
  78343. * @param binaryWriter The writer containing the binary data
  78344. * @param convertToRightHandedSystem Converts the values to right-handed
  78345. */
  78346. private writeVertexAttributeData;
  78347. /**
  78348. * Writes mesh attribute data to a data buffer
  78349. * Returns the bytelength of the data
  78350. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78351. * @param meshAttributeArray Array containing the attribute data
  78352. * @param binaryWriter The buffer to write the binary data to
  78353. * @param indices Used to specify the order of the vertex data
  78354. * @param convertToRightHandedSystem Converts the values to right-handed
  78355. */
  78356. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78357. /**
  78358. * Generates glTF json data
  78359. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78360. * @param glTFPrefix Text to use when prefixing a glTF file
  78361. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78362. * @returns json data as string
  78363. */
  78364. private generateJSON;
  78365. /**
  78366. * Generates data for .gltf and .bin files based on the glTF prefix string
  78367. * @param glTFPrefix Text to use when prefixing a glTF file
  78368. * @param dispose Dispose the exporter
  78369. * @returns GLTFData with glTF file data
  78370. */
  78371. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78372. /**
  78373. * Creates a binary buffer for glTF
  78374. * @returns array buffer for binary data
  78375. */
  78376. private _generateBinaryAsync;
  78377. /**
  78378. * Pads the number to a multiple of 4
  78379. * @param num number to pad
  78380. * @returns padded number
  78381. */
  78382. private _getPadding;
  78383. /**
  78384. * @hidden
  78385. */
  78386. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78387. /**
  78388. * Sets the TRS for each node
  78389. * @param node glTF Node for storing the transformation data
  78390. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78391. * @param convertToRightHandedSystem Converts the values to right-handed
  78392. */
  78393. private setNodeTransformation;
  78394. private getVertexBufferFromMesh;
  78395. /**
  78396. * Creates a bufferview based on the vertices type for the Babylon mesh
  78397. * @param kind Indicates the type of vertices data
  78398. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78399. * @param binaryWriter The buffer to write the bufferview data to
  78400. * @param convertToRightHandedSystem Converts the values to right-handed
  78401. */
  78402. private createBufferViewKind;
  78403. /**
  78404. * The primitive mode of the Babylon mesh
  78405. * @param babylonMesh The BabylonJS mesh
  78406. */
  78407. private getMeshPrimitiveMode;
  78408. /**
  78409. * Sets the primitive mode of the glTF mesh primitive
  78410. * @param meshPrimitive glTF mesh primitive
  78411. * @param primitiveMode The primitive mode
  78412. */
  78413. private setPrimitiveMode;
  78414. /**
  78415. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78416. * @param meshPrimitive glTF mesh primitive
  78417. * @param attributeKind vertex attribute
  78418. * @returns boolean specifying if uv coordinates are present
  78419. */
  78420. private setAttributeKind;
  78421. /**
  78422. * Sets data for the primitive attributes of each submesh
  78423. * @param mesh glTF Mesh object to store the primitive attribute information
  78424. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78425. * @param binaryWriter Buffer to write the attribute data to
  78426. * @param convertToRightHandedSystem Converts the values to right-handed
  78427. */
  78428. private setPrimitiveAttributesAsync;
  78429. /**
  78430. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78431. * @param node The node to check
  78432. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78433. */
  78434. private isBabylonCoordinateSystemConvertingNode;
  78435. /**
  78436. * Creates a glTF scene based on the array of meshes
  78437. * Returns the the total byte offset
  78438. * @param babylonScene Babylon scene to get the mesh data from
  78439. * @param binaryWriter Buffer to write binary data to
  78440. */
  78441. private createSceneAsync;
  78442. /**
  78443. * Creates a mapping of Node unique id to node index and handles animations
  78444. * @param babylonScene Babylon Scene
  78445. * @param nodes Babylon transform nodes
  78446. * @param binaryWriter Buffer to write binary data to
  78447. * @returns Node mapping of unique id to index
  78448. */
  78449. private createNodeMapAndAnimationsAsync;
  78450. /**
  78451. * Creates a glTF node from a Babylon mesh
  78452. * @param babylonMesh Source Babylon mesh
  78453. * @param binaryWriter Buffer for storing geometry data
  78454. * @param convertToRightHandedSystem Converts the values to right-handed
  78455. * @param nodeMap Node mapping of unique id to glTF node index
  78456. * @returns glTF node
  78457. */
  78458. private createNodeAsync;
  78459. }
  78460. /**
  78461. * @hidden
  78462. *
  78463. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78464. */
  78465. export class _BinaryWriter {
  78466. /**
  78467. * Array buffer which stores all binary data
  78468. */
  78469. private _arrayBuffer;
  78470. /**
  78471. * View of the array buffer
  78472. */
  78473. private _dataView;
  78474. /**
  78475. * byte offset of data in array buffer
  78476. */
  78477. private _byteOffset;
  78478. /**
  78479. * Initialize binary writer with an initial byte length
  78480. * @param byteLength Initial byte length of the array buffer
  78481. */
  78482. constructor(byteLength: number);
  78483. /**
  78484. * Resize the array buffer to the specified byte length
  78485. * @param byteLength
  78486. */
  78487. private resizeBuffer;
  78488. /**
  78489. * Get an array buffer with the length of the byte offset
  78490. * @returns ArrayBuffer resized to the byte offset
  78491. */
  78492. getArrayBuffer(): ArrayBuffer;
  78493. /**
  78494. * Get the byte offset of the array buffer
  78495. * @returns byte offset
  78496. */
  78497. getByteOffset(): number;
  78498. /**
  78499. * Stores an UInt8 in the array buffer
  78500. * @param entry
  78501. * @param byteOffset If defined, specifies where to set the value as an offset.
  78502. */
  78503. setUInt8(entry: number, byteOffset?: number): void;
  78504. /**
  78505. * Gets an UInt32 in the array buffer
  78506. * @param entry
  78507. * @param byteOffset If defined, specifies where to set the value as an offset.
  78508. */
  78509. getUInt32(byteOffset: number): number;
  78510. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78511. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78512. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78513. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78514. /**
  78515. * Stores a Float32 in the array buffer
  78516. * @param entry
  78517. */
  78518. setFloat32(entry: number, byteOffset?: number): void;
  78519. /**
  78520. * Stores an UInt32 in the array buffer
  78521. * @param entry
  78522. * @param byteOffset If defined, specifies where to set the value as an offset.
  78523. */
  78524. setUInt32(entry: number, byteOffset?: number): void;
  78525. }
  78526. }
  78527. declare module BABYLON.GLTF2.Exporter {
  78528. /**
  78529. * @hidden
  78530. * Interface to store animation data.
  78531. */
  78532. export interface _IAnimationData {
  78533. /**
  78534. * Keyframe data.
  78535. */
  78536. inputs: number[];
  78537. /**
  78538. * Value data.
  78539. */
  78540. outputs: number[][];
  78541. /**
  78542. * Animation interpolation data.
  78543. */
  78544. samplerInterpolation: AnimationSamplerInterpolation;
  78545. /**
  78546. * Minimum keyframe value.
  78547. */
  78548. inputsMin: number;
  78549. /**
  78550. * Maximum keyframe value.
  78551. */
  78552. inputsMax: number;
  78553. }
  78554. /**
  78555. * @hidden
  78556. */
  78557. export interface _IAnimationInfo {
  78558. /**
  78559. * The target channel for the animation
  78560. */
  78561. animationChannelTargetPath: AnimationChannelTargetPath;
  78562. /**
  78563. * The glTF accessor type for the data.
  78564. */
  78565. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78566. /**
  78567. * Specifies if quaternions should be used.
  78568. */
  78569. useQuaternion: boolean;
  78570. }
  78571. /**
  78572. * @hidden
  78573. * Utility class for generating glTF animation data from BabylonJS.
  78574. */
  78575. export class _GLTFAnimation {
  78576. /**
  78577. * @ignore
  78578. *
  78579. * Creates glTF channel animation from BabylonJS animation.
  78580. * @param babylonTransformNode - BabylonJS mesh.
  78581. * @param animation - animation.
  78582. * @param animationChannelTargetPath - The target animation channel.
  78583. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78584. * @param useQuaternion - Specifies if quaternions are used.
  78585. * @returns nullable IAnimationData
  78586. */
  78587. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78588. private static _DeduceAnimationInfo;
  78589. /**
  78590. * @ignore
  78591. * Create node animations from the transform node animations
  78592. * @param babylonNode
  78593. * @param runtimeGLTFAnimation
  78594. * @param idleGLTFAnimations
  78595. * @param nodeMap
  78596. * @param nodes
  78597. * @param binaryWriter
  78598. * @param bufferViews
  78599. * @param accessors
  78600. * @param convertToRightHandedSystem
  78601. * @param animationSampleRate
  78602. */
  78603. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78604. [key: number]: number;
  78605. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78606. /**
  78607. * @ignore
  78608. * Create node animations from the animation groups
  78609. * @param babylonScene
  78610. * @param glTFAnimations
  78611. * @param nodeMap
  78612. * @param nodes
  78613. * @param binaryWriter
  78614. * @param bufferViews
  78615. * @param accessors
  78616. * @param convertToRightHandedSystemMap
  78617. * @param animationSampleRate
  78618. */
  78619. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78620. [key: number]: number;
  78621. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78622. [nodeId: number]: boolean;
  78623. }, animationSampleRate: number): void;
  78624. private static AddAnimation;
  78625. /**
  78626. * Create a baked animation
  78627. * @param babylonTransformNode BabylonJS mesh
  78628. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78629. * @param animationChannelTargetPath animation target channel
  78630. * @param minFrame minimum animation frame
  78631. * @param maxFrame maximum animation frame
  78632. * @param fps frames per second of the animation
  78633. * @param inputs input key frames of the animation
  78634. * @param outputs output key frame data of the animation
  78635. * @param convertToRightHandedSystem converts the values to right-handed
  78636. * @param useQuaternion specifies if quaternions should be used
  78637. */
  78638. private static _CreateBakedAnimation;
  78639. private static _ConvertFactorToVector3OrQuaternion;
  78640. private static _SetInterpolatedValue;
  78641. /**
  78642. * Creates linear animation from the animation key frames
  78643. * @param babylonTransformNode BabylonJS mesh
  78644. * @param animation BabylonJS animation
  78645. * @param animationChannelTargetPath The target animation channel
  78646. * @param frameDelta The difference between the last and first frame of the animation
  78647. * @param inputs Array to store the key frame times
  78648. * @param outputs Array to store the key frame data
  78649. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78650. * @param useQuaternion Specifies if quaternions are used in the animation
  78651. */
  78652. private static _CreateLinearOrStepAnimation;
  78653. /**
  78654. * Creates cubic spline animation from the animation key frames
  78655. * @param babylonTransformNode BabylonJS mesh
  78656. * @param animation BabylonJS animation
  78657. * @param animationChannelTargetPath The target animation channel
  78658. * @param frameDelta The difference between the last and first frame of the animation
  78659. * @param inputs Array to store the key frame times
  78660. * @param outputs Array to store the key frame data
  78661. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78662. * @param useQuaternion Specifies if quaternions are used in the animation
  78663. */
  78664. private static _CreateCubicSplineAnimation;
  78665. private static _GetBasePositionRotationOrScale;
  78666. /**
  78667. * Adds a key frame value
  78668. * @param keyFrame
  78669. * @param animation
  78670. * @param outputs
  78671. * @param animationChannelTargetPath
  78672. * @param basePositionRotationOrScale
  78673. * @param convertToRightHandedSystem
  78674. * @param useQuaternion
  78675. */
  78676. private static _AddKeyframeValue;
  78677. /**
  78678. * Determine the interpolation based on the key frames
  78679. * @param keyFrames
  78680. * @param animationChannelTargetPath
  78681. * @param useQuaternion
  78682. */
  78683. private static _DeduceInterpolation;
  78684. /**
  78685. * Adds an input tangent or output tangent to the output data
  78686. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78687. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78688. * @param outputs The animation data by keyframe
  78689. * @param animationChannelTargetPath The target animation channel
  78690. * @param interpolation The interpolation type
  78691. * @param keyFrame The key frame with the animation data
  78692. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78693. * @param useQuaternion Specifies if quaternions are used
  78694. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78695. */
  78696. private static AddSplineTangent;
  78697. /**
  78698. * Get the minimum and maximum key frames' frame values
  78699. * @param keyFrames animation key frames
  78700. * @returns the minimum and maximum key frame value
  78701. */
  78702. private static calculateMinMaxKeyFrames;
  78703. }
  78704. }
  78705. declare module BABYLON.GLTF2.Exporter {
  78706. /** @hidden */
  78707. export var textureTransformPixelShader: {
  78708. name: string;
  78709. shader: string;
  78710. };
  78711. }
  78712. declare module BABYLON.GLTF2.Exporter.Extensions {
  78713. /**
  78714. * @hidden
  78715. */
  78716. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78717. private _recordedTextures;
  78718. /** Name of this extension */
  78719. readonly name: string;
  78720. /** Defines whether this extension is enabled */
  78721. enabled: boolean;
  78722. /** Defines whether this extension is required */
  78723. required: boolean;
  78724. /** Reference to the glTF exporter */
  78725. private _wasUsed;
  78726. constructor(exporter: _Exporter);
  78727. dispose(): void;
  78728. /** @hidden */
  78729. get wasUsed(): boolean;
  78730. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78731. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78732. /**
  78733. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78734. * @param babylonTexture
  78735. * @param offset
  78736. * @param rotation
  78737. * @param scale
  78738. * @param scene
  78739. */
  78740. private _textureTransformTextureAsync;
  78741. }
  78742. }
  78743. declare module BABYLON.GLTF2.Exporter.Extensions {
  78744. /**
  78745. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78746. */
  78747. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78748. /** The name of this extension. */
  78749. readonly name: string;
  78750. /** Defines whether this extension is enabled. */
  78751. enabled: boolean;
  78752. /** Defines whether this extension is required */
  78753. required: boolean;
  78754. /** Reference to the glTF exporter */
  78755. private _exporter;
  78756. private _lights;
  78757. /** @hidden */
  78758. constructor(exporter: _Exporter);
  78759. /** @hidden */
  78760. dispose(): void;
  78761. /** @hidden */
  78762. get wasUsed(): boolean;
  78763. /** @hidden */
  78764. onExporting(): void;
  78765. /**
  78766. * Define this method to modify the default behavior when exporting a node
  78767. * @param context The context when exporting the node
  78768. * @param node glTF node
  78769. * @param babylonNode BabylonJS node
  78770. * @param nodeMap Node mapping of unique id to glTF node index
  78771. * @returns nullable INode promise
  78772. */
  78773. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78774. [key: number]: number;
  78775. }): Promise<Nullable<INode>>;
  78776. }
  78777. }
  78778. declare module BABYLON.GLTF2.Exporter.Extensions {
  78779. /**
  78780. * @hidden
  78781. */
  78782. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78783. /** Name of this extension */
  78784. readonly name: string;
  78785. /** Defines whether this extension is enabled */
  78786. enabled: boolean;
  78787. /** Defines whether this extension is required */
  78788. required: boolean;
  78789. /** Reference to the glTF exporter */
  78790. private _textureInfos;
  78791. private _exportedTextures;
  78792. private _wasUsed;
  78793. constructor(exporter: _Exporter);
  78794. dispose(): void;
  78795. /** @hidden */
  78796. get wasUsed(): boolean;
  78797. private _getTextureIndex;
  78798. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78799. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78800. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78801. }
  78802. }
  78803. declare module BABYLON {
  78804. /**
  78805. * Class for generating STL data from a Babylon scene.
  78806. */
  78807. export class STLExport {
  78808. /**
  78809. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78810. * @param meshes list defines the mesh to serialize
  78811. * @param download triggers the automatic download of the file.
  78812. * @param fileName changes the downloads fileName.
  78813. * @param binary changes the STL to a binary type.
  78814. * @param isLittleEndian toggle for binary type exporter.
  78815. * @returns the STL as UTF8 string
  78816. */
  78817. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78818. }
  78819. }
  78820. declare module "babylonjs-gltf2interface" {
  78821. export = BABYLON.GLTF2;
  78822. }
  78823. /**
  78824. * Module for glTF 2.0 Interface
  78825. */
  78826. declare module BABYLON.GLTF2 {
  78827. /**
  78828. * The datatype of the components in the attribute
  78829. */
  78830. const enum AccessorComponentType {
  78831. /**
  78832. * Byte
  78833. */
  78834. BYTE = 5120,
  78835. /**
  78836. * Unsigned Byte
  78837. */
  78838. UNSIGNED_BYTE = 5121,
  78839. /**
  78840. * Short
  78841. */
  78842. SHORT = 5122,
  78843. /**
  78844. * Unsigned Short
  78845. */
  78846. UNSIGNED_SHORT = 5123,
  78847. /**
  78848. * Unsigned Int
  78849. */
  78850. UNSIGNED_INT = 5125,
  78851. /**
  78852. * Float
  78853. */
  78854. FLOAT = 5126,
  78855. }
  78856. /**
  78857. * Specifies if the attirbute is a scalar, vector, or matrix
  78858. */
  78859. const enum AccessorType {
  78860. /**
  78861. * Scalar
  78862. */
  78863. SCALAR = "SCALAR",
  78864. /**
  78865. * Vector2
  78866. */
  78867. VEC2 = "VEC2",
  78868. /**
  78869. * Vector3
  78870. */
  78871. VEC3 = "VEC3",
  78872. /**
  78873. * Vector4
  78874. */
  78875. VEC4 = "VEC4",
  78876. /**
  78877. * Matrix2x2
  78878. */
  78879. MAT2 = "MAT2",
  78880. /**
  78881. * Matrix3x3
  78882. */
  78883. MAT3 = "MAT3",
  78884. /**
  78885. * Matrix4x4
  78886. */
  78887. MAT4 = "MAT4",
  78888. }
  78889. /**
  78890. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78891. */
  78892. const enum AnimationChannelTargetPath {
  78893. /**
  78894. * Translation
  78895. */
  78896. TRANSLATION = "translation",
  78897. /**
  78898. * Rotation
  78899. */
  78900. ROTATION = "rotation",
  78901. /**
  78902. * Scale
  78903. */
  78904. SCALE = "scale",
  78905. /**
  78906. * Weights
  78907. */
  78908. WEIGHTS = "weights",
  78909. }
  78910. /**
  78911. * Interpolation algorithm
  78912. */
  78913. const enum AnimationSamplerInterpolation {
  78914. /**
  78915. * The animated values are linearly interpolated between keyframes
  78916. */
  78917. LINEAR = "LINEAR",
  78918. /**
  78919. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78920. */
  78921. STEP = "STEP",
  78922. /**
  78923. * The animation's interpolation is computed using a cubic spline with specified tangents
  78924. */
  78925. CUBICSPLINE = "CUBICSPLINE",
  78926. }
  78927. /**
  78928. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78929. */
  78930. const enum CameraType {
  78931. /**
  78932. * A perspective camera containing properties to create a perspective projection matrix
  78933. */
  78934. PERSPECTIVE = "perspective",
  78935. /**
  78936. * An orthographic camera containing properties to create an orthographic projection matrix
  78937. */
  78938. ORTHOGRAPHIC = "orthographic",
  78939. }
  78940. /**
  78941. * The mime-type of the image
  78942. */
  78943. const enum ImageMimeType {
  78944. /**
  78945. * JPEG Mime-type
  78946. */
  78947. JPEG = "image/jpeg",
  78948. /**
  78949. * PNG Mime-type
  78950. */
  78951. PNG = "image/png",
  78952. }
  78953. /**
  78954. * The alpha rendering mode of the material
  78955. */
  78956. const enum MaterialAlphaMode {
  78957. /**
  78958. * The alpha value is ignored and the rendered output is fully opaque
  78959. */
  78960. OPAQUE = "OPAQUE",
  78961. /**
  78962. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78963. */
  78964. MASK = "MASK",
  78965. /**
  78966. * 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)
  78967. */
  78968. BLEND = "BLEND",
  78969. }
  78970. /**
  78971. * The type of the primitives to render
  78972. */
  78973. const enum MeshPrimitiveMode {
  78974. /**
  78975. * Points
  78976. */
  78977. POINTS = 0,
  78978. /**
  78979. * Lines
  78980. */
  78981. LINES = 1,
  78982. /**
  78983. * Line Loop
  78984. */
  78985. LINE_LOOP = 2,
  78986. /**
  78987. * Line Strip
  78988. */
  78989. LINE_STRIP = 3,
  78990. /**
  78991. * Triangles
  78992. */
  78993. TRIANGLES = 4,
  78994. /**
  78995. * Triangle Strip
  78996. */
  78997. TRIANGLE_STRIP = 5,
  78998. /**
  78999. * Triangle Fan
  79000. */
  79001. TRIANGLE_FAN = 6,
  79002. }
  79003. /**
  79004. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79005. */
  79006. const enum TextureMagFilter {
  79007. /**
  79008. * Nearest
  79009. */
  79010. NEAREST = 9728,
  79011. /**
  79012. * Linear
  79013. */
  79014. LINEAR = 9729,
  79015. }
  79016. /**
  79017. * Minification filter. All valid values correspond to WebGL enums
  79018. */
  79019. const enum TextureMinFilter {
  79020. /**
  79021. * Nearest
  79022. */
  79023. NEAREST = 9728,
  79024. /**
  79025. * Linear
  79026. */
  79027. LINEAR = 9729,
  79028. /**
  79029. * Nearest Mip-Map Nearest
  79030. */
  79031. NEAREST_MIPMAP_NEAREST = 9984,
  79032. /**
  79033. * Linear Mipmap Nearest
  79034. */
  79035. LINEAR_MIPMAP_NEAREST = 9985,
  79036. /**
  79037. * Nearest Mipmap Linear
  79038. */
  79039. NEAREST_MIPMAP_LINEAR = 9986,
  79040. /**
  79041. * Linear Mipmap Linear
  79042. */
  79043. LINEAR_MIPMAP_LINEAR = 9987,
  79044. }
  79045. /**
  79046. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79047. */
  79048. const enum TextureWrapMode {
  79049. /**
  79050. * Clamp to Edge
  79051. */
  79052. CLAMP_TO_EDGE = 33071,
  79053. /**
  79054. * Mirrored Repeat
  79055. */
  79056. MIRRORED_REPEAT = 33648,
  79057. /**
  79058. * Repeat
  79059. */
  79060. REPEAT = 10497,
  79061. }
  79062. /**
  79063. * glTF Property
  79064. */
  79065. interface IProperty {
  79066. /**
  79067. * Dictionary object with extension-specific objects
  79068. */
  79069. extensions?: {
  79070. [key: string]: any;
  79071. };
  79072. /**
  79073. * Application-Specific data
  79074. */
  79075. extras?: any;
  79076. }
  79077. /**
  79078. * glTF Child of Root Property
  79079. */
  79080. interface IChildRootProperty extends IProperty {
  79081. /**
  79082. * The user-defined name of this object
  79083. */
  79084. name?: string;
  79085. }
  79086. /**
  79087. * Indices of those attributes that deviate from their initialization value
  79088. */
  79089. interface IAccessorSparseIndices extends IProperty {
  79090. /**
  79091. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79092. */
  79093. bufferView: number;
  79094. /**
  79095. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79096. */
  79097. byteOffset?: number;
  79098. /**
  79099. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  79100. */
  79101. componentType: AccessorComponentType;
  79102. }
  79103. /**
  79104. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  79105. */
  79106. interface IAccessorSparseValues extends IProperty {
  79107. /**
  79108. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79109. */
  79110. bufferView: number;
  79111. /**
  79112. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79113. */
  79114. byteOffset?: number;
  79115. }
  79116. /**
  79117. * Sparse storage of attributes that deviate from their initialization value
  79118. */
  79119. interface IAccessorSparse extends IProperty {
  79120. /**
  79121. * The number of attributes encoded in this sparse accessor
  79122. */
  79123. count: number;
  79124. /**
  79125. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  79126. */
  79127. indices: IAccessorSparseIndices;
  79128. /**
  79129. * 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
  79130. */
  79131. values: IAccessorSparseValues;
  79132. }
  79133. /**
  79134. * 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
  79135. */
  79136. interface IAccessor extends IChildRootProperty {
  79137. /**
  79138. * The index of the bufferview
  79139. */
  79140. bufferView?: number;
  79141. /**
  79142. * The offset relative to the start of the bufferView in bytes
  79143. */
  79144. byteOffset?: number;
  79145. /**
  79146. * The datatype of components in the attribute
  79147. */
  79148. componentType: AccessorComponentType;
  79149. /**
  79150. * Specifies whether integer data values should be normalized
  79151. */
  79152. normalized?: boolean;
  79153. /**
  79154. * The number of attributes referenced by this accessor
  79155. */
  79156. count: number;
  79157. /**
  79158. * Specifies if the attribute is a scalar, vector, or matrix
  79159. */
  79160. type: AccessorType;
  79161. /**
  79162. * Maximum value of each component in this attribute
  79163. */
  79164. max?: number[];
  79165. /**
  79166. * Minimum value of each component in this attribute
  79167. */
  79168. min?: number[];
  79169. /**
  79170. * Sparse storage of attributes that deviate from their initialization value
  79171. */
  79172. sparse?: IAccessorSparse;
  79173. }
  79174. /**
  79175. * Targets an animation's sampler at a node's property
  79176. */
  79177. interface IAnimationChannel extends IProperty {
  79178. /**
  79179. * The index of a sampler in this animation used to compute the value for the target
  79180. */
  79181. sampler: number;
  79182. /**
  79183. * The index of the node and TRS property to target
  79184. */
  79185. target: IAnimationChannelTarget;
  79186. }
  79187. /**
  79188. * The index of the node and TRS property that an animation channel targets
  79189. */
  79190. interface IAnimationChannelTarget extends IProperty {
  79191. /**
  79192. * The index of the node to target
  79193. */
  79194. node: number;
  79195. /**
  79196. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  79197. */
  79198. path: AnimationChannelTargetPath;
  79199. }
  79200. /**
  79201. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79202. */
  79203. interface IAnimationSampler extends IProperty {
  79204. /**
  79205. * The index of an accessor containing keyframe input values, e.g., time
  79206. */
  79207. input: number;
  79208. /**
  79209. * Interpolation algorithm
  79210. */
  79211. interpolation?: AnimationSamplerInterpolation;
  79212. /**
  79213. * The index of an accessor, containing keyframe output values
  79214. */
  79215. output: number;
  79216. }
  79217. /**
  79218. * A keyframe animation
  79219. */
  79220. interface IAnimation extends IChildRootProperty {
  79221. /**
  79222. * An array of channels, each of which targets an animation's sampler at a node's property
  79223. */
  79224. channels: IAnimationChannel[];
  79225. /**
  79226. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79227. */
  79228. samplers: IAnimationSampler[];
  79229. }
  79230. /**
  79231. * Metadata about the glTF asset
  79232. */
  79233. interface IAsset extends IChildRootProperty {
  79234. /**
  79235. * A copyright message suitable for display to credit the content creator
  79236. */
  79237. copyright?: string;
  79238. /**
  79239. * Tool that generated this glTF model. Useful for debugging
  79240. */
  79241. generator?: string;
  79242. /**
  79243. * The glTF version that this asset targets
  79244. */
  79245. version: string;
  79246. /**
  79247. * The minimum glTF version that this asset targets
  79248. */
  79249. minVersion?: string;
  79250. }
  79251. /**
  79252. * A buffer points to binary geometry, animation, or skins
  79253. */
  79254. interface IBuffer extends IChildRootProperty {
  79255. /**
  79256. * 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
  79257. */
  79258. uri?: string;
  79259. /**
  79260. * The length of the buffer in bytes
  79261. */
  79262. byteLength: number;
  79263. }
  79264. /**
  79265. * A view into a buffer generally representing a subset of the buffer
  79266. */
  79267. interface IBufferView extends IChildRootProperty {
  79268. /**
  79269. * The index of the buffer
  79270. */
  79271. buffer: number;
  79272. /**
  79273. * The offset into the buffer in bytes
  79274. */
  79275. byteOffset?: number;
  79276. /**
  79277. * The lenth of the bufferView in bytes
  79278. */
  79279. byteLength: number;
  79280. /**
  79281. * The stride, in bytes
  79282. */
  79283. byteStride?: number;
  79284. }
  79285. /**
  79286. * An orthographic camera containing properties to create an orthographic projection matrix
  79287. */
  79288. interface ICameraOrthographic extends IProperty {
  79289. /**
  79290. * The floating-point horizontal magnification of the view. Must not be zero
  79291. */
  79292. xmag: number;
  79293. /**
  79294. * The floating-point vertical magnification of the view. Must not be zero
  79295. */
  79296. ymag: number;
  79297. /**
  79298. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  79299. */
  79300. zfar: number;
  79301. /**
  79302. * The floating-point distance to the near clipping plane
  79303. */
  79304. znear: number;
  79305. }
  79306. /**
  79307. * A perspective camera containing properties to create a perspective projection matrix
  79308. */
  79309. interface ICameraPerspective extends IProperty {
  79310. /**
  79311. * The floating-point aspect ratio of the field of view
  79312. */
  79313. aspectRatio?: number;
  79314. /**
  79315. * The floating-point vertical field of view in radians
  79316. */
  79317. yfov: number;
  79318. /**
  79319. * The floating-point distance to the far clipping plane
  79320. */
  79321. zfar?: number;
  79322. /**
  79323. * The floating-point distance to the near clipping plane
  79324. */
  79325. znear: number;
  79326. }
  79327. /**
  79328. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79329. */
  79330. interface ICamera extends IChildRootProperty {
  79331. /**
  79332. * An orthographic camera containing properties to create an orthographic projection matrix
  79333. */
  79334. orthographic?: ICameraOrthographic;
  79335. /**
  79336. * A perspective camera containing properties to create a perspective projection matrix
  79337. */
  79338. perspective?: ICameraPerspective;
  79339. /**
  79340. * Specifies if the camera uses a perspective or orthographic projection
  79341. */
  79342. type: CameraType;
  79343. }
  79344. /**
  79345. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79346. */
  79347. interface IImage extends IChildRootProperty {
  79348. /**
  79349. * 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
  79350. */
  79351. uri?: string;
  79352. /**
  79353. * The image's MIME type
  79354. */
  79355. mimeType?: ImageMimeType;
  79356. /**
  79357. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79358. */
  79359. bufferView?: number;
  79360. }
  79361. /**
  79362. * Material Normal Texture Info
  79363. */
  79364. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79365. /**
  79366. * The scalar multiplier applied to each normal vector of the normal texture
  79367. */
  79368. scale?: number;
  79369. }
  79370. /**
  79371. * Material Occlusion Texture Info
  79372. */
  79373. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79374. /**
  79375. * A scalar multiplier controlling the amount of occlusion applied
  79376. */
  79377. strength?: number;
  79378. }
  79379. /**
  79380. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79381. */
  79382. interface IMaterialPbrMetallicRoughness {
  79383. /**
  79384. * The material's base color factor
  79385. */
  79386. baseColorFactor?: number[];
  79387. /**
  79388. * The base color texture
  79389. */
  79390. baseColorTexture?: ITextureInfo;
  79391. /**
  79392. * The metalness of the material
  79393. */
  79394. metallicFactor?: number;
  79395. /**
  79396. * The roughness of the material
  79397. */
  79398. roughnessFactor?: number;
  79399. /**
  79400. * The metallic-roughness texture
  79401. */
  79402. metallicRoughnessTexture?: ITextureInfo;
  79403. }
  79404. /**
  79405. * The material appearance of a primitive
  79406. */
  79407. interface IMaterial extends IChildRootProperty {
  79408. /**
  79409. * 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
  79410. */
  79411. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79412. /**
  79413. * The normal map texture
  79414. */
  79415. normalTexture?: IMaterialNormalTextureInfo;
  79416. /**
  79417. * The occlusion map texture
  79418. */
  79419. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79420. /**
  79421. * The emissive map texture
  79422. */
  79423. emissiveTexture?: ITextureInfo;
  79424. /**
  79425. * 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
  79426. */
  79427. emissiveFactor?: number[];
  79428. /**
  79429. * The alpha rendering mode of the material
  79430. */
  79431. alphaMode?: MaterialAlphaMode;
  79432. /**
  79433. * The alpha cutoff value of the material
  79434. */
  79435. alphaCutoff?: number;
  79436. /**
  79437. * Specifies whether the material is double sided
  79438. */
  79439. doubleSided?: boolean;
  79440. }
  79441. /**
  79442. * Geometry to be rendered with the given material
  79443. */
  79444. interface IMeshPrimitive extends IProperty {
  79445. /**
  79446. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79447. */
  79448. attributes: {
  79449. [name: string]: number;
  79450. };
  79451. /**
  79452. * The index of the accessor that contains the indices
  79453. */
  79454. indices?: number;
  79455. /**
  79456. * The index of the material to apply to this primitive when rendering
  79457. */
  79458. material?: number;
  79459. /**
  79460. * The type of primitives to render. All valid values correspond to WebGL enums
  79461. */
  79462. mode?: MeshPrimitiveMode;
  79463. /**
  79464. * 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
  79465. */
  79466. targets?: {
  79467. [name: string]: number;
  79468. }[];
  79469. }
  79470. /**
  79471. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79472. */
  79473. interface IMesh extends IChildRootProperty {
  79474. /**
  79475. * An array of primitives, each defining geometry to be rendered with a material
  79476. */
  79477. primitives: IMeshPrimitive[];
  79478. /**
  79479. * Array of weights to be applied to the Morph Targets
  79480. */
  79481. weights?: number[];
  79482. }
  79483. /**
  79484. * A node in the node hierarchy
  79485. */
  79486. interface INode extends IChildRootProperty {
  79487. /**
  79488. * The index of the camera referenced by this node
  79489. */
  79490. camera?: number;
  79491. /**
  79492. * The indices of this node's children
  79493. */
  79494. children?: number[];
  79495. /**
  79496. * The index of the skin referenced by this node
  79497. */
  79498. skin?: number;
  79499. /**
  79500. * A floating-point 4x4 transformation matrix stored in column-major order
  79501. */
  79502. matrix?: number[];
  79503. /**
  79504. * The index of the mesh in this node
  79505. */
  79506. mesh?: number;
  79507. /**
  79508. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79509. */
  79510. rotation?: number[];
  79511. /**
  79512. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79513. */
  79514. scale?: number[];
  79515. /**
  79516. * The node's translation along the x, y, and z axes
  79517. */
  79518. translation?: number[];
  79519. /**
  79520. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79521. */
  79522. weights?: number[];
  79523. }
  79524. /**
  79525. * Texture sampler properties for filtering and wrapping modes
  79526. */
  79527. interface ISampler extends IChildRootProperty {
  79528. /**
  79529. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79530. */
  79531. magFilter?: TextureMagFilter;
  79532. /**
  79533. * Minification filter. All valid values correspond to WebGL enums
  79534. */
  79535. minFilter?: TextureMinFilter;
  79536. /**
  79537. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79538. */
  79539. wrapS?: TextureWrapMode;
  79540. /**
  79541. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79542. */
  79543. wrapT?: TextureWrapMode;
  79544. }
  79545. /**
  79546. * The root nodes of a scene
  79547. */
  79548. interface IScene extends IChildRootProperty {
  79549. /**
  79550. * The indices of each root node
  79551. */
  79552. nodes: number[];
  79553. }
  79554. /**
  79555. * Joints and matrices defining a skin
  79556. */
  79557. interface ISkin extends IChildRootProperty {
  79558. /**
  79559. * 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
  79560. */
  79561. inverseBindMatrices?: number;
  79562. /**
  79563. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79564. */
  79565. skeleton?: number;
  79566. /**
  79567. * 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)
  79568. */
  79569. joints: number[];
  79570. }
  79571. /**
  79572. * A texture and its sampler
  79573. */
  79574. interface ITexture extends IChildRootProperty {
  79575. /**
  79576. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79577. */
  79578. sampler?: number;
  79579. /**
  79580. * The index of the image used by this texture
  79581. */
  79582. source: number;
  79583. }
  79584. /**
  79585. * Reference to a texture
  79586. */
  79587. interface ITextureInfo extends IProperty {
  79588. /**
  79589. * The index of the texture
  79590. */
  79591. index: number;
  79592. /**
  79593. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79594. */
  79595. texCoord?: number;
  79596. }
  79597. /**
  79598. * The root object for a glTF asset
  79599. */
  79600. interface IGLTF extends IProperty {
  79601. /**
  79602. * An array of accessors. An accessor is a typed view into a bufferView
  79603. */
  79604. accessors?: IAccessor[];
  79605. /**
  79606. * An array of keyframe animations
  79607. */
  79608. animations?: IAnimation[];
  79609. /**
  79610. * Metadata about the glTF asset
  79611. */
  79612. asset: IAsset;
  79613. /**
  79614. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79615. */
  79616. buffers?: IBuffer[];
  79617. /**
  79618. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79619. */
  79620. bufferViews?: IBufferView[];
  79621. /**
  79622. * An array of cameras
  79623. */
  79624. cameras?: ICamera[];
  79625. /**
  79626. * Names of glTF extensions used somewhere in this asset
  79627. */
  79628. extensionsUsed?: string[];
  79629. /**
  79630. * Names of glTF extensions required to properly load this asset
  79631. */
  79632. extensionsRequired?: string[];
  79633. /**
  79634. * An array of images. An image defines data used to create a texture
  79635. */
  79636. images?: IImage[];
  79637. /**
  79638. * An array of materials. A material defines the appearance of a primitive
  79639. */
  79640. materials?: IMaterial[];
  79641. /**
  79642. * An array of meshes. A mesh is a set of primitives to be rendered
  79643. */
  79644. meshes?: IMesh[];
  79645. /**
  79646. * An array of nodes
  79647. */
  79648. nodes?: INode[];
  79649. /**
  79650. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79651. */
  79652. samplers?: ISampler[];
  79653. /**
  79654. * The index of the default scene
  79655. */
  79656. scene?: number;
  79657. /**
  79658. * An array of scenes
  79659. */
  79660. scenes?: IScene[];
  79661. /**
  79662. * An array of skins. A skin is defined by joints and matrices
  79663. */
  79664. skins?: ISkin[];
  79665. /**
  79666. * An array of textures
  79667. */
  79668. textures?: ITexture[];
  79669. }
  79670. /**
  79671. * The glTF validation results
  79672. * @ignore
  79673. */
  79674. interface IGLTFValidationResults {
  79675. info: {
  79676. generator: string;
  79677. hasAnimations: boolean;
  79678. hasDefaultScene: boolean;
  79679. hasMaterials: boolean;
  79680. hasMorphTargets: boolean;
  79681. hasSkins: boolean;
  79682. hasTextures: boolean;
  79683. maxAttributesUsed: number;
  79684. primitivesCount: number
  79685. };
  79686. issues: {
  79687. messages: Array<string>;
  79688. numErrors: number;
  79689. numHints: number;
  79690. numInfos: number;
  79691. numWarnings: number;
  79692. truncated: boolean
  79693. };
  79694. mimeType: string;
  79695. uri: string;
  79696. validatedAt: string;
  79697. validatorVersion: string;
  79698. }
  79699. /**
  79700. * The glTF validation options
  79701. */
  79702. interface IGLTFValidationOptions {
  79703. /** Uri to use */
  79704. uri?: string;
  79705. /** Function used to load external resources */
  79706. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79707. /** Boolean indicating that we need to validate accessor data */
  79708. validateAccessorData?: boolean;
  79709. /** max number of issues allowed */
  79710. maxIssues?: number;
  79711. /** Ignored issues */
  79712. ignoredIssues?: Array<string>;
  79713. /** Value to override severy settings */
  79714. severityOverrides?: Object;
  79715. }
  79716. /**
  79717. * The glTF validator object
  79718. * @ignore
  79719. */
  79720. interface IGLTFValidator {
  79721. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79722. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79723. }
  79724. }
  79725. declare module BABYLON {
  79726. /** @hidden */
  79727. export var cellPixelShader: {
  79728. name: string;
  79729. shader: string;
  79730. };
  79731. }
  79732. declare module BABYLON {
  79733. /** @hidden */
  79734. export var cellVertexShader: {
  79735. name: string;
  79736. shader: string;
  79737. };
  79738. }
  79739. declare module BABYLON {
  79740. export class CellMaterial extends BABYLON.PushMaterial {
  79741. private _diffuseTexture;
  79742. diffuseTexture: BABYLON.BaseTexture;
  79743. diffuseColor: BABYLON.Color3;
  79744. _computeHighLevel: boolean;
  79745. computeHighLevel: boolean;
  79746. private _disableLighting;
  79747. disableLighting: boolean;
  79748. private _maxSimultaneousLights;
  79749. maxSimultaneousLights: number;
  79750. constructor(name: string, scene: BABYLON.Scene);
  79751. needAlphaBlending(): boolean;
  79752. needAlphaTesting(): boolean;
  79753. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79754. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79755. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79756. getAnimatables(): BABYLON.IAnimatable[];
  79757. getActiveTextures(): BABYLON.BaseTexture[];
  79758. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79759. dispose(forceDisposeEffect?: boolean): void;
  79760. getClassName(): string;
  79761. clone(name: string): CellMaterial;
  79762. serialize(): any;
  79763. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79764. }
  79765. }
  79766. declare module BABYLON {
  79767. export class CustomShaderStructure {
  79768. FragmentStore: string;
  79769. VertexStore: string;
  79770. constructor();
  79771. }
  79772. export class ShaderSpecialParts {
  79773. constructor();
  79774. Fragment_Begin: string;
  79775. Fragment_Definitions: string;
  79776. Fragment_MainBegin: string;
  79777. Fragment_Custom_Diffuse: string;
  79778. Fragment_Before_Lights: string;
  79779. Fragment_Before_Fog: string;
  79780. Fragment_Custom_Alpha: string;
  79781. Fragment_Before_FragColor: string;
  79782. Vertex_Begin: string;
  79783. Vertex_Definitions: string;
  79784. Vertex_MainBegin: string;
  79785. Vertex_Before_PositionUpdated: string;
  79786. Vertex_Before_NormalUpdated: string;
  79787. Vertex_After_WorldPosComputed: string;
  79788. Vertex_MainEnd: string;
  79789. }
  79790. export class CustomMaterial extends BABYLON.StandardMaterial {
  79791. static ShaderIndexer: number;
  79792. CustomParts: ShaderSpecialParts;
  79793. _isCreatedShader: boolean;
  79794. _createdShaderName: string;
  79795. _customUniform: string[];
  79796. _newUniforms: string[];
  79797. _newUniformInstances: any[];
  79798. _newSamplerInstances: BABYLON.Texture[];
  79799. _customAttributes: string[];
  79800. FragmentShader: string;
  79801. VertexShader: string;
  79802. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79803. ReviewUniform(name: string, arr: string[]): string[];
  79804. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79805. constructor(name: string, scene: BABYLON.Scene);
  79806. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79807. AddAttribute(name: string): CustomMaterial;
  79808. Fragment_Begin(shaderPart: string): CustomMaterial;
  79809. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79810. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79811. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79812. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79813. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79814. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79815. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79816. Vertex_Begin(shaderPart: string): CustomMaterial;
  79817. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79818. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79819. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79820. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79821. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  79822. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79823. }
  79824. }
  79825. declare module BABYLON {
  79826. export class ShaderAlebdoParts {
  79827. constructor();
  79828. Fragment_Begin: string;
  79829. Fragment_Definitions: string;
  79830. Fragment_MainBegin: string;
  79831. Fragment_Custom_Albedo: string;
  79832. Fragment_Before_Lights: string;
  79833. Fragment_Custom_MetallicRoughness: string;
  79834. Fragment_Custom_MicroSurface: string;
  79835. Fragment_Before_Fog: string;
  79836. Fragment_Custom_Alpha: string;
  79837. Fragment_Before_FragColor: string;
  79838. Vertex_Begin: string;
  79839. Vertex_Definitions: string;
  79840. Vertex_MainBegin: string;
  79841. Vertex_Before_PositionUpdated: string;
  79842. Vertex_Before_NormalUpdated: string;
  79843. Vertex_After_WorldPosComputed: string;
  79844. Vertex_MainEnd: string;
  79845. }
  79846. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79847. static ShaderIndexer: number;
  79848. CustomParts: ShaderAlebdoParts;
  79849. _isCreatedShader: boolean;
  79850. _createdShaderName: string;
  79851. _customUniform: string[];
  79852. _newUniforms: string[];
  79853. _newUniformInstances: any[];
  79854. _newSamplerInstances: BABYLON.Texture[];
  79855. _customAttributes: string[];
  79856. FragmentShader: string;
  79857. VertexShader: string;
  79858. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79859. ReviewUniform(name: string, arr: string[]): string[];
  79860. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79861. constructor(name: string, scene: BABYLON.Scene);
  79862. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79863. AddAttribute(name: string): PBRCustomMaterial;
  79864. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79865. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79866. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79867. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79868. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79869. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79870. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79871. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79872. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79873. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79874. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79875. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79876. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79877. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79878. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79879. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  79880. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79881. }
  79882. }
  79883. declare module BABYLON {
  79884. /** @hidden */
  79885. export var firePixelShader: {
  79886. name: string;
  79887. shader: string;
  79888. };
  79889. }
  79890. declare module BABYLON {
  79891. /** @hidden */
  79892. export var fireVertexShader: {
  79893. name: string;
  79894. shader: string;
  79895. };
  79896. }
  79897. declare module BABYLON {
  79898. export class FireMaterial extends BABYLON.PushMaterial {
  79899. private _diffuseTexture;
  79900. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79901. private _distortionTexture;
  79902. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79903. private _opacityTexture;
  79904. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79905. diffuseColor: BABYLON.Color3;
  79906. speed: number;
  79907. private _scaledDiffuse;
  79908. private _lastTime;
  79909. constructor(name: string, scene: BABYLON.Scene);
  79910. needAlphaBlending(): boolean;
  79911. needAlphaTesting(): boolean;
  79912. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79913. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79914. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79915. getAnimatables(): BABYLON.IAnimatable[];
  79916. getActiveTextures(): BABYLON.BaseTexture[];
  79917. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79918. getClassName(): string;
  79919. dispose(forceDisposeEffect?: boolean): void;
  79920. clone(name: string): FireMaterial;
  79921. serialize(): any;
  79922. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79923. }
  79924. }
  79925. declare module BABYLON {
  79926. /** @hidden */
  79927. export var furPixelShader: {
  79928. name: string;
  79929. shader: string;
  79930. };
  79931. }
  79932. declare module BABYLON {
  79933. /** @hidden */
  79934. export var furVertexShader: {
  79935. name: string;
  79936. shader: string;
  79937. };
  79938. }
  79939. declare module BABYLON {
  79940. export class FurMaterial extends BABYLON.PushMaterial {
  79941. private _diffuseTexture;
  79942. diffuseTexture: BABYLON.BaseTexture;
  79943. private _heightTexture;
  79944. heightTexture: BABYLON.BaseTexture;
  79945. diffuseColor: BABYLON.Color3;
  79946. furLength: number;
  79947. furAngle: number;
  79948. furColor: BABYLON.Color3;
  79949. furOffset: number;
  79950. furSpacing: number;
  79951. furGravity: BABYLON.Vector3;
  79952. furSpeed: number;
  79953. furDensity: number;
  79954. furOcclusion: number;
  79955. furTexture: BABYLON.DynamicTexture;
  79956. private _disableLighting;
  79957. disableLighting: boolean;
  79958. private _maxSimultaneousLights;
  79959. maxSimultaneousLights: number;
  79960. highLevelFur: boolean;
  79961. _meshes: BABYLON.AbstractMesh[];
  79962. private _furTime;
  79963. constructor(name: string, scene: BABYLON.Scene);
  79964. get furTime(): number;
  79965. set furTime(furTime: number);
  79966. needAlphaBlending(): boolean;
  79967. needAlphaTesting(): boolean;
  79968. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79969. updateFur(): void;
  79970. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79971. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79972. getAnimatables(): BABYLON.IAnimatable[];
  79973. getActiveTextures(): BABYLON.BaseTexture[];
  79974. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79975. dispose(forceDisposeEffect?: boolean): void;
  79976. clone(name: string): FurMaterial;
  79977. serialize(): any;
  79978. getClassName(): string;
  79979. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79980. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79981. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79982. }
  79983. }
  79984. declare module BABYLON {
  79985. /** @hidden */
  79986. export var gradientPixelShader: {
  79987. name: string;
  79988. shader: string;
  79989. };
  79990. }
  79991. declare module BABYLON {
  79992. /** @hidden */
  79993. export var gradientVertexShader: {
  79994. name: string;
  79995. shader: string;
  79996. };
  79997. }
  79998. declare module BABYLON {
  79999. export class GradientMaterial extends BABYLON.PushMaterial {
  80000. private _maxSimultaneousLights;
  80001. maxSimultaneousLights: number;
  80002. topColor: BABYLON.Color3;
  80003. topColorAlpha: number;
  80004. bottomColor: BABYLON.Color3;
  80005. bottomColorAlpha: number;
  80006. offset: number;
  80007. scale: number;
  80008. smoothness: number;
  80009. private _disableLighting;
  80010. disableLighting: boolean;
  80011. constructor(name: string, scene: BABYLON.Scene);
  80012. needAlphaBlending(): boolean;
  80013. needAlphaTesting(): boolean;
  80014. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80015. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80016. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80017. getAnimatables(): BABYLON.IAnimatable[];
  80018. dispose(forceDisposeEffect?: boolean): void;
  80019. clone(name: string): GradientMaterial;
  80020. serialize(): any;
  80021. getClassName(): string;
  80022. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  80023. }
  80024. }
  80025. declare module BABYLON {
  80026. /** @hidden */
  80027. export var gridPixelShader: {
  80028. name: string;
  80029. shader: string;
  80030. };
  80031. }
  80032. declare module BABYLON {
  80033. /** @hidden */
  80034. export var gridVertexShader: {
  80035. name: string;
  80036. shader: string;
  80037. };
  80038. }
  80039. declare module BABYLON {
  80040. /**
  80041. * The grid materials allows you to wrap any shape with a grid.
  80042. * Colors are customizable.
  80043. */
  80044. export class GridMaterial extends BABYLON.PushMaterial {
  80045. /**
  80046. * Main color of the grid (e.g. between lines)
  80047. */
  80048. mainColor: BABYLON.Color3;
  80049. /**
  80050. * Color of the grid lines.
  80051. */
  80052. lineColor: BABYLON.Color3;
  80053. /**
  80054. * The scale of the grid compared to unit.
  80055. */
  80056. gridRatio: number;
  80057. /**
  80058. * Allows setting an offset for the grid lines.
  80059. */
  80060. gridOffset: BABYLON.Vector3;
  80061. /**
  80062. * The frequency of thicker lines.
  80063. */
  80064. majorUnitFrequency: number;
  80065. /**
  80066. * The visibility of minor units in the grid.
  80067. */
  80068. minorUnitVisibility: number;
  80069. /**
  80070. * The grid opacity outside of the lines.
  80071. */
  80072. opacity: number;
  80073. /**
  80074. * Determine RBG output is premultiplied by alpha value.
  80075. */
  80076. preMultiplyAlpha: boolean;
  80077. private _opacityTexture;
  80078. opacityTexture: BABYLON.BaseTexture;
  80079. private _gridControl;
  80080. /**
  80081. * constructor
  80082. * @param name The name given to the material in order to identify it afterwards.
  80083. * @param scene The scene the material is used in.
  80084. */
  80085. constructor(name: string, scene: BABYLON.Scene);
  80086. /**
  80087. * Returns wehter or not the grid requires alpha blending.
  80088. */
  80089. needAlphaBlending(): boolean;
  80090. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80091. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80092. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80093. /**
  80094. * Dispose the material and its associated resources.
  80095. * @param forceDisposeEffect will also dispose the used effect when true
  80096. */
  80097. dispose(forceDisposeEffect?: boolean): void;
  80098. clone(name: string): GridMaterial;
  80099. serialize(): any;
  80100. getClassName(): string;
  80101. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  80102. }
  80103. }
  80104. declare module BABYLON {
  80105. /** @hidden */
  80106. export var lavaPixelShader: {
  80107. name: string;
  80108. shader: string;
  80109. };
  80110. }
  80111. declare module BABYLON {
  80112. /** @hidden */
  80113. export var lavaVertexShader: {
  80114. name: string;
  80115. shader: string;
  80116. };
  80117. }
  80118. declare module BABYLON {
  80119. export class LavaMaterial extends BABYLON.PushMaterial {
  80120. private _diffuseTexture;
  80121. diffuseTexture: BABYLON.BaseTexture;
  80122. noiseTexture: BABYLON.BaseTexture;
  80123. fogColor: BABYLON.Color3;
  80124. speed: number;
  80125. movingSpeed: number;
  80126. lowFrequencySpeed: number;
  80127. fogDensity: number;
  80128. private _lastTime;
  80129. diffuseColor: BABYLON.Color3;
  80130. private _disableLighting;
  80131. disableLighting: boolean;
  80132. private _unlit;
  80133. unlit: boolean;
  80134. private _maxSimultaneousLights;
  80135. maxSimultaneousLights: number;
  80136. private _scaledDiffuse;
  80137. constructor(name: string, scene: BABYLON.Scene);
  80138. needAlphaBlending(): boolean;
  80139. needAlphaTesting(): boolean;
  80140. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80141. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80142. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80143. getAnimatables(): BABYLON.IAnimatable[];
  80144. getActiveTextures(): BABYLON.BaseTexture[];
  80145. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80146. dispose(forceDisposeEffect?: boolean): void;
  80147. clone(name: string): LavaMaterial;
  80148. serialize(): any;
  80149. getClassName(): string;
  80150. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  80151. }
  80152. }
  80153. declare module BABYLON {
  80154. /** @hidden */
  80155. export var mixPixelShader: {
  80156. name: string;
  80157. shader: string;
  80158. };
  80159. }
  80160. declare module BABYLON {
  80161. /** @hidden */
  80162. export var mixVertexShader: {
  80163. name: string;
  80164. shader: string;
  80165. };
  80166. }
  80167. declare module BABYLON {
  80168. export class MixMaterial extends BABYLON.PushMaterial {
  80169. /**
  80170. * Mix textures
  80171. */
  80172. private _mixTexture1;
  80173. mixTexture1: BABYLON.BaseTexture;
  80174. private _mixTexture2;
  80175. mixTexture2: BABYLON.BaseTexture;
  80176. /**
  80177. * Diffuse textures
  80178. */
  80179. private _diffuseTexture1;
  80180. diffuseTexture1: BABYLON.Texture;
  80181. private _diffuseTexture2;
  80182. diffuseTexture2: BABYLON.Texture;
  80183. private _diffuseTexture3;
  80184. diffuseTexture3: BABYLON.Texture;
  80185. private _diffuseTexture4;
  80186. diffuseTexture4: BABYLON.Texture;
  80187. private _diffuseTexture5;
  80188. diffuseTexture5: BABYLON.Texture;
  80189. private _diffuseTexture6;
  80190. diffuseTexture6: BABYLON.Texture;
  80191. private _diffuseTexture7;
  80192. diffuseTexture7: BABYLON.Texture;
  80193. private _diffuseTexture8;
  80194. diffuseTexture8: BABYLON.Texture;
  80195. /**
  80196. * Uniforms
  80197. */
  80198. diffuseColor: BABYLON.Color3;
  80199. specularColor: BABYLON.Color3;
  80200. specularPower: number;
  80201. private _disableLighting;
  80202. disableLighting: boolean;
  80203. private _maxSimultaneousLights;
  80204. maxSimultaneousLights: number;
  80205. constructor(name: string, scene: BABYLON.Scene);
  80206. needAlphaBlending(): boolean;
  80207. needAlphaTesting(): boolean;
  80208. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80209. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80210. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80211. getAnimatables(): BABYLON.IAnimatable[];
  80212. getActiveTextures(): BABYLON.BaseTexture[];
  80213. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80214. dispose(forceDisposeEffect?: boolean): void;
  80215. clone(name: string): MixMaterial;
  80216. serialize(): any;
  80217. getClassName(): string;
  80218. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  80219. }
  80220. }
  80221. declare module BABYLON {
  80222. /** @hidden */
  80223. export var normalPixelShader: {
  80224. name: string;
  80225. shader: string;
  80226. };
  80227. }
  80228. declare module BABYLON {
  80229. /** @hidden */
  80230. export var normalVertexShader: {
  80231. name: string;
  80232. shader: string;
  80233. };
  80234. }
  80235. declare module BABYLON {
  80236. export class NormalMaterial extends BABYLON.PushMaterial {
  80237. private _diffuseTexture;
  80238. diffuseTexture: BABYLON.BaseTexture;
  80239. diffuseColor: BABYLON.Color3;
  80240. private _disableLighting;
  80241. disableLighting: boolean;
  80242. private _maxSimultaneousLights;
  80243. maxSimultaneousLights: number;
  80244. constructor(name: string, scene: BABYLON.Scene);
  80245. needAlphaBlending(): boolean;
  80246. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80247. needAlphaTesting(): boolean;
  80248. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80249. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80250. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80251. getAnimatables(): BABYLON.IAnimatable[];
  80252. getActiveTextures(): BABYLON.BaseTexture[];
  80253. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80254. dispose(forceDisposeEffect?: boolean): void;
  80255. clone(name: string): NormalMaterial;
  80256. serialize(): any;
  80257. getClassName(): string;
  80258. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  80259. }
  80260. }
  80261. declare module BABYLON {
  80262. /** @hidden */
  80263. export var shadowOnlyPixelShader: {
  80264. name: string;
  80265. shader: string;
  80266. };
  80267. }
  80268. declare module BABYLON {
  80269. /** @hidden */
  80270. export var shadowOnlyVertexShader: {
  80271. name: string;
  80272. shader: string;
  80273. };
  80274. }
  80275. declare module BABYLON {
  80276. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  80277. private _activeLight;
  80278. constructor(name: string, scene: BABYLON.Scene);
  80279. shadowColor: BABYLON.Color3;
  80280. needAlphaBlending(): boolean;
  80281. needAlphaTesting(): boolean;
  80282. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80283. get activeLight(): BABYLON.IShadowLight;
  80284. set activeLight(light: BABYLON.IShadowLight);
  80285. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80286. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80287. clone(name: string): ShadowOnlyMaterial;
  80288. serialize(): any;
  80289. getClassName(): string;
  80290. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  80291. }
  80292. }
  80293. declare module BABYLON {
  80294. /** @hidden */
  80295. export var simplePixelShader: {
  80296. name: string;
  80297. shader: string;
  80298. };
  80299. }
  80300. declare module BABYLON {
  80301. /** @hidden */
  80302. export var simpleVertexShader: {
  80303. name: string;
  80304. shader: string;
  80305. };
  80306. }
  80307. declare module BABYLON {
  80308. export class SimpleMaterial extends BABYLON.PushMaterial {
  80309. private _diffuseTexture;
  80310. diffuseTexture: BABYLON.BaseTexture;
  80311. diffuseColor: BABYLON.Color3;
  80312. private _disableLighting;
  80313. disableLighting: boolean;
  80314. private _maxSimultaneousLights;
  80315. maxSimultaneousLights: number;
  80316. constructor(name: string, scene: BABYLON.Scene);
  80317. needAlphaBlending(): boolean;
  80318. needAlphaTesting(): boolean;
  80319. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80320. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80321. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80322. getAnimatables(): BABYLON.IAnimatable[];
  80323. getActiveTextures(): BABYLON.BaseTexture[];
  80324. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80325. dispose(forceDisposeEffect?: boolean): void;
  80326. clone(name: string): SimpleMaterial;
  80327. serialize(): any;
  80328. getClassName(): string;
  80329. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  80330. }
  80331. }
  80332. declare module BABYLON {
  80333. /** @hidden */
  80334. export var skyPixelShader: {
  80335. name: string;
  80336. shader: string;
  80337. };
  80338. }
  80339. declare module BABYLON {
  80340. /** @hidden */
  80341. export var skyVertexShader: {
  80342. name: string;
  80343. shader: string;
  80344. };
  80345. }
  80346. declare module BABYLON {
  80347. /**
  80348. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80349. * @see https://doc.babylonjs.com/extensions/sky
  80350. */
  80351. export class SkyMaterial extends BABYLON.PushMaterial {
  80352. /**
  80353. * Defines the overall luminance of sky in interval ]0, 1[.
  80354. */
  80355. luminance: number;
  80356. /**
  80357. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80358. */
  80359. turbidity: number;
  80360. /**
  80361. * Defines the sky appearance (light intensity).
  80362. */
  80363. rayleigh: number;
  80364. /**
  80365. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80366. */
  80367. mieCoefficient: number;
  80368. /**
  80369. * Defines the amount of haze particles following the Mie scattering theory.
  80370. */
  80371. mieDirectionalG: number;
  80372. /**
  80373. * Defines the distance of the sun according to the active scene camera.
  80374. */
  80375. distance: number;
  80376. /**
  80377. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80378. * "inclined".
  80379. */
  80380. inclination: number;
  80381. /**
  80382. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80383. * an object direction and a reference direction.
  80384. */
  80385. azimuth: number;
  80386. /**
  80387. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80388. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80389. */
  80390. sunPosition: BABYLON.Vector3;
  80391. /**
  80392. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80393. * .sunPosition property.
  80394. */
  80395. useSunPosition: boolean;
  80396. /**
  80397. * Defines an offset vector used to get a horizon offset.
  80398. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80399. */
  80400. cameraOffset: BABYLON.Vector3;
  80401. private _cameraPosition;
  80402. /**
  80403. * Instantiates a new sky material.
  80404. * This material allows to create dynamic and texture free
  80405. * effects for skyboxes by taking care of the atmosphere state.
  80406. * @see https://doc.babylonjs.com/extensions/sky
  80407. * @param name Define the name of the material in the scene
  80408. * @param scene Define the scene the material belong to
  80409. */
  80410. constructor(name: string, scene: BABYLON.Scene);
  80411. /**
  80412. * Specifies if the material will require alpha blending
  80413. * @returns a boolean specifying if alpha blending is needed
  80414. */
  80415. needAlphaBlending(): boolean;
  80416. /**
  80417. * Specifies if this material should be rendered in alpha test mode
  80418. * @returns false as the sky material doesn't need alpha testing.
  80419. */
  80420. needAlphaTesting(): boolean;
  80421. /**
  80422. * Get the texture used for alpha test purpose.
  80423. * @returns null as the sky material has no texture.
  80424. */
  80425. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80426. /**
  80427. * Get if the submesh is ready to be used and all its information available.
  80428. * Child classes can use it to update shaders
  80429. * @param mesh defines the mesh to check
  80430. * @param subMesh defines which submesh to check
  80431. * @param useInstances specifies that instances should be used
  80432. * @returns a boolean indicating that the submesh is ready or not
  80433. */
  80434. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80435. /**
  80436. * Binds the submesh to this material by preparing the effect and shader to draw
  80437. * @param world defines the world transformation matrix
  80438. * @param mesh defines the mesh containing the submesh
  80439. * @param subMesh defines the submesh to bind the material to
  80440. */
  80441. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80442. /**
  80443. * Get the list of animatables in the material.
  80444. * @returns the list of animatables object used in the material
  80445. */
  80446. getAnimatables(): BABYLON.IAnimatable[];
  80447. /**
  80448. * Disposes the material
  80449. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80450. */
  80451. dispose(forceDisposeEffect?: boolean): void;
  80452. /**
  80453. * Makes a duplicate of the material, and gives it a new name
  80454. * @param name defines the new name for the duplicated material
  80455. * @returns the cloned material
  80456. */
  80457. clone(name: string): SkyMaterial;
  80458. /**
  80459. * Serializes this material in a JSON representation
  80460. * @returns the serialized material object
  80461. */
  80462. serialize(): any;
  80463. /**
  80464. * Gets the current class name of the material e.g. "SkyMaterial"
  80465. * Mainly use in serialization.
  80466. * @returns the class name
  80467. */
  80468. getClassName(): string;
  80469. /**
  80470. * Creates a sky material from parsed material data
  80471. * @param source defines the JSON representation of the material
  80472. * @param scene defines the hosting scene
  80473. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80474. * @returns a new sky material
  80475. */
  80476. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80477. }
  80478. }
  80479. declare module BABYLON {
  80480. /** @hidden */
  80481. export var terrainPixelShader: {
  80482. name: string;
  80483. shader: string;
  80484. };
  80485. }
  80486. declare module BABYLON {
  80487. /** @hidden */
  80488. export var terrainVertexShader: {
  80489. name: string;
  80490. shader: string;
  80491. };
  80492. }
  80493. declare module BABYLON {
  80494. export class TerrainMaterial extends BABYLON.PushMaterial {
  80495. private _mixTexture;
  80496. mixTexture: BABYLON.BaseTexture;
  80497. private _diffuseTexture1;
  80498. diffuseTexture1: BABYLON.Texture;
  80499. private _diffuseTexture2;
  80500. diffuseTexture2: BABYLON.Texture;
  80501. private _diffuseTexture3;
  80502. diffuseTexture3: BABYLON.Texture;
  80503. private _bumpTexture1;
  80504. bumpTexture1: BABYLON.Texture;
  80505. private _bumpTexture2;
  80506. bumpTexture2: BABYLON.Texture;
  80507. private _bumpTexture3;
  80508. bumpTexture3: BABYLON.Texture;
  80509. diffuseColor: BABYLON.Color3;
  80510. specularColor: BABYLON.Color3;
  80511. specularPower: number;
  80512. private _disableLighting;
  80513. disableLighting: boolean;
  80514. private _maxSimultaneousLights;
  80515. maxSimultaneousLights: number;
  80516. constructor(name: string, scene: BABYLON.Scene);
  80517. needAlphaBlending(): boolean;
  80518. needAlphaTesting(): boolean;
  80519. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80520. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80521. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80522. getAnimatables(): BABYLON.IAnimatable[];
  80523. getActiveTextures(): BABYLON.BaseTexture[];
  80524. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80525. dispose(forceDisposeEffect?: boolean): void;
  80526. clone(name: string): TerrainMaterial;
  80527. serialize(): any;
  80528. getClassName(): string;
  80529. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80530. }
  80531. }
  80532. declare module BABYLON {
  80533. /** @hidden */
  80534. export var triplanarPixelShader: {
  80535. name: string;
  80536. shader: string;
  80537. };
  80538. }
  80539. declare module BABYLON {
  80540. /** @hidden */
  80541. export var triplanarVertexShader: {
  80542. name: string;
  80543. shader: string;
  80544. };
  80545. }
  80546. declare module BABYLON {
  80547. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80548. mixTexture: BABYLON.BaseTexture;
  80549. private _diffuseTextureX;
  80550. diffuseTextureX: BABYLON.BaseTexture;
  80551. private _diffuseTextureY;
  80552. diffuseTextureY: BABYLON.BaseTexture;
  80553. private _diffuseTextureZ;
  80554. diffuseTextureZ: BABYLON.BaseTexture;
  80555. private _normalTextureX;
  80556. normalTextureX: BABYLON.BaseTexture;
  80557. private _normalTextureY;
  80558. normalTextureY: BABYLON.BaseTexture;
  80559. private _normalTextureZ;
  80560. normalTextureZ: BABYLON.BaseTexture;
  80561. tileSize: number;
  80562. diffuseColor: BABYLON.Color3;
  80563. specularColor: BABYLON.Color3;
  80564. specularPower: number;
  80565. private _disableLighting;
  80566. disableLighting: boolean;
  80567. private _maxSimultaneousLights;
  80568. maxSimultaneousLights: number;
  80569. constructor(name: string, scene: BABYLON.Scene);
  80570. needAlphaBlending(): boolean;
  80571. needAlphaTesting(): boolean;
  80572. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80573. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80574. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80575. getAnimatables(): BABYLON.IAnimatable[];
  80576. getActiveTextures(): BABYLON.BaseTexture[];
  80577. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80578. dispose(forceDisposeEffect?: boolean): void;
  80579. clone(name: string): TriPlanarMaterial;
  80580. serialize(): any;
  80581. getClassName(): string;
  80582. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80583. }
  80584. }
  80585. declare module BABYLON {
  80586. /** @hidden */
  80587. export var waterPixelShader: {
  80588. name: string;
  80589. shader: string;
  80590. };
  80591. }
  80592. declare module BABYLON {
  80593. /** @hidden */
  80594. export var waterVertexShader: {
  80595. name: string;
  80596. shader: string;
  80597. };
  80598. }
  80599. declare module BABYLON {
  80600. export class WaterMaterial extends BABYLON.PushMaterial {
  80601. renderTargetSize: BABYLON.Vector2;
  80602. private _bumpTexture;
  80603. bumpTexture: BABYLON.BaseTexture;
  80604. diffuseColor: BABYLON.Color3;
  80605. specularColor: BABYLON.Color3;
  80606. specularPower: number;
  80607. private _disableLighting;
  80608. disableLighting: boolean;
  80609. private _maxSimultaneousLights;
  80610. maxSimultaneousLights: number;
  80611. /**
  80612. * @param {number}: Represents the wind force
  80613. */
  80614. windForce: number;
  80615. /**
  80616. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80617. */
  80618. windDirection: BABYLON.Vector2;
  80619. /**
  80620. * @param {number}: Wave height, represents the height of the waves
  80621. */
  80622. waveHeight: number;
  80623. /**
  80624. * @param {number}: Bump height, represents the bump height related to the bump map
  80625. */
  80626. bumpHeight: number;
  80627. /**
  80628. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80629. */
  80630. private _bumpSuperimpose;
  80631. bumpSuperimpose: boolean;
  80632. /**
  80633. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80634. */
  80635. private _fresnelSeparate;
  80636. fresnelSeparate: boolean;
  80637. /**
  80638. * @param {boolean}: bump Waves modify the reflection.
  80639. */
  80640. private _bumpAffectsReflection;
  80641. bumpAffectsReflection: boolean;
  80642. /**
  80643. * @param {number}: The water color blended with the refraction (near)
  80644. */
  80645. waterColor: BABYLON.Color3;
  80646. /**
  80647. * @param {number}: The blend factor related to the water color
  80648. */
  80649. colorBlendFactor: number;
  80650. /**
  80651. * @param {number}: The water color blended with the reflection (far)
  80652. */
  80653. waterColor2: BABYLON.Color3;
  80654. /**
  80655. * @param {number}: The blend factor related to the water color (reflection, far)
  80656. */
  80657. colorBlendFactor2: number;
  80658. /**
  80659. * @param {number}: Represents the maximum length of a wave
  80660. */
  80661. waveLength: number;
  80662. /**
  80663. * @param {number}: Defines the waves speed
  80664. */
  80665. waveSpeed: number;
  80666. /**
  80667. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80668. * will avoid calculating useless pixels in the pixel shader of the water material.
  80669. */
  80670. disableClipPlane: boolean;
  80671. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80672. private _mesh;
  80673. private _refractionRTT;
  80674. private _reflectionRTT;
  80675. private _reflectionTransform;
  80676. private _lastTime;
  80677. private _lastDeltaTime;
  80678. private _useLogarithmicDepth;
  80679. private _waitingRenderList;
  80680. private _imageProcessingConfiguration;
  80681. private _imageProcessingObserver;
  80682. /**
  80683. * Gets a boolean indicating that current material needs to register RTT
  80684. */
  80685. get hasRenderTargetTextures(): boolean;
  80686. /**
  80687. * Constructor
  80688. */
  80689. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80690. get useLogarithmicDepth(): boolean;
  80691. set useLogarithmicDepth(value: boolean);
  80692. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80693. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80694. addToRenderList(node: any): void;
  80695. enableRenderTargets(enable: boolean): void;
  80696. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80697. get renderTargetsEnabled(): boolean;
  80698. needAlphaBlending(): boolean;
  80699. needAlphaTesting(): boolean;
  80700. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80701. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80702. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80703. private _createRenderTargets;
  80704. getAnimatables(): BABYLON.IAnimatable[];
  80705. getActiveTextures(): BABYLON.BaseTexture[];
  80706. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80707. dispose(forceDisposeEffect?: boolean): void;
  80708. clone(name: string): WaterMaterial;
  80709. serialize(): any;
  80710. getClassName(): string;
  80711. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80712. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80713. }
  80714. }
  80715. declare module BABYLON {
  80716. /** @hidden */
  80717. export var asciiartPixelShader: {
  80718. name: string;
  80719. shader: string;
  80720. };
  80721. }
  80722. declare module BABYLON {
  80723. /**
  80724. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80725. *
  80726. * It basically takes care rendering the font front the given font size to a texture.
  80727. * This is used later on in the postprocess.
  80728. */
  80729. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80730. private _font;
  80731. private _text;
  80732. private _charSize;
  80733. /**
  80734. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80735. */
  80736. get charSize(): number;
  80737. /**
  80738. * Create a new instance of the Ascii Art FontTexture class
  80739. * @param name the name of the texture
  80740. * @param font the font to use, use the W3C CSS notation
  80741. * @param text the caracter set to use in the rendering.
  80742. * @param scene the scene that owns the texture
  80743. */
  80744. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80745. /**
  80746. * Gets the max char width of a font.
  80747. * @param font the font to use, use the W3C CSS notation
  80748. * @return the max char width
  80749. */
  80750. private getFontWidth;
  80751. /**
  80752. * Gets the max char height of a font.
  80753. * @param font the font to use, use the W3C CSS notation
  80754. * @return the max char height
  80755. */
  80756. private getFontHeight;
  80757. /**
  80758. * Clones the current AsciiArtTexture.
  80759. * @return the clone of the texture.
  80760. */
  80761. clone(): AsciiArtFontTexture;
  80762. /**
  80763. * Parses a json object representing the texture and returns an instance of it.
  80764. * @param source the source JSON representation
  80765. * @param scene the scene to create the texture for
  80766. * @return the parsed texture
  80767. */
  80768. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80769. }
  80770. /**
  80771. * Option available in the Ascii Art Post Process.
  80772. */
  80773. export interface IAsciiArtPostProcessOptions {
  80774. /**
  80775. * The font to use following the w3c font definition.
  80776. */
  80777. font?: string;
  80778. /**
  80779. * The character set to use in the postprocess.
  80780. */
  80781. characterSet?: string;
  80782. /**
  80783. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80784. * This number is defined between 0 and 1;
  80785. */
  80786. mixToTile?: number;
  80787. /**
  80788. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80789. * This number is defined between 0 and 1;
  80790. */
  80791. mixToNormal?: number;
  80792. }
  80793. /**
  80794. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80795. *
  80796. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80797. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80798. */
  80799. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80800. /**
  80801. * The font texture used to render the char in the post process.
  80802. */
  80803. private _asciiArtFontTexture;
  80804. /**
  80805. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80806. * This number is defined between 0 and 1;
  80807. */
  80808. mixToTile: number;
  80809. /**
  80810. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80811. * This number is defined between 0 and 1;
  80812. */
  80813. mixToNormal: number;
  80814. /**
  80815. * Instantiates a new Ascii Art Post Process.
  80816. * @param name the name to give to the postprocess
  80817. * @camera the camera to apply the post process to.
  80818. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80819. */
  80820. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80821. }
  80822. }
  80823. declare module BABYLON {
  80824. /** @hidden */
  80825. export var digitalrainPixelShader: {
  80826. name: string;
  80827. shader: string;
  80828. };
  80829. }
  80830. declare module BABYLON {
  80831. /**
  80832. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80833. *
  80834. * It basically takes care rendering the font front the given font size to a texture.
  80835. * This is used later on in the postprocess.
  80836. */
  80837. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80838. private _font;
  80839. private _text;
  80840. private _charSize;
  80841. /**
  80842. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80843. */
  80844. get charSize(): number;
  80845. /**
  80846. * Create a new instance of the Digital Rain FontTexture class
  80847. * @param name the name of the texture
  80848. * @param font the font to use, use the W3C CSS notation
  80849. * @param text the caracter set to use in the rendering.
  80850. * @param scene the scene that owns the texture
  80851. */
  80852. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80853. /**
  80854. * Gets the max char width of a font.
  80855. * @param font the font to use, use the W3C CSS notation
  80856. * @return the max char width
  80857. */
  80858. private getFontWidth;
  80859. /**
  80860. * Gets the max char height of a font.
  80861. * @param font the font to use, use the W3C CSS notation
  80862. * @return the max char height
  80863. */
  80864. private getFontHeight;
  80865. /**
  80866. * Clones the current DigitalRainFontTexture.
  80867. * @return the clone of the texture.
  80868. */
  80869. clone(): DigitalRainFontTexture;
  80870. /**
  80871. * Parses a json object representing the texture and returns an instance of it.
  80872. * @param source the source JSON representation
  80873. * @param scene the scene to create the texture for
  80874. * @return the parsed texture
  80875. */
  80876. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80877. }
  80878. /**
  80879. * Option available in the Digital Rain Post Process.
  80880. */
  80881. export interface IDigitalRainPostProcessOptions {
  80882. /**
  80883. * The font to use following the w3c font definition.
  80884. */
  80885. font?: string;
  80886. /**
  80887. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80888. * This number is defined between 0 and 1;
  80889. */
  80890. mixToTile?: number;
  80891. /**
  80892. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80893. * This number is defined between 0 and 1;
  80894. */
  80895. mixToNormal?: number;
  80896. }
  80897. /**
  80898. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80899. *
  80900. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80901. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80902. */
  80903. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80904. /**
  80905. * The font texture used to render the char in the post process.
  80906. */
  80907. private _digitalRainFontTexture;
  80908. /**
  80909. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80910. * This number is defined between 0 and 1;
  80911. */
  80912. mixToTile: number;
  80913. /**
  80914. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80915. * This number is defined between 0 and 1;
  80916. */
  80917. mixToNormal: number;
  80918. /**
  80919. * Instantiates a new Digital Rain Post Process.
  80920. * @param name the name to give to the postprocess
  80921. * @camera the camera to apply the post process to.
  80922. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80923. */
  80924. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80925. }
  80926. }
  80927. declare module BABYLON {
  80928. /** @hidden */
  80929. export var brickProceduralTexturePixelShader: {
  80930. name: string;
  80931. shader: string;
  80932. };
  80933. }
  80934. declare module BABYLON {
  80935. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  80936. private _numberOfBricksHeight;
  80937. private _numberOfBricksWidth;
  80938. private _jointColor;
  80939. private _brickColor;
  80940. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80941. updateShaderUniforms(): void;
  80942. get numberOfBricksHeight(): number;
  80943. set numberOfBricksHeight(value: number);
  80944. get numberOfBricksWidth(): number;
  80945. set numberOfBricksWidth(value: number);
  80946. get jointColor(): BABYLON.Color3;
  80947. set jointColor(value: BABYLON.Color3);
  80948. get brickColor(): BABYLON.Color3;
  80949. set brickColor(value: BABYLON.Color3);
  80950. /**
  80951. * Serializes this brick procedural texture
  80952. * @returns a serialized brick procedural texture object
  80953. */
  80954. serialize(): any;
  80955. /**
  80956. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  80957. * @param parsedTexture defines parsed texture data
  80958. * @param scene defines the current scene
  80959. * @param rootUrl defines the root URL containing brick procedural texture information
  80960. * @returns a parsed Brick Procedural BABYLON.Texture
  80961. */
  80962. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  80963. }
  80964. }
  80965. declare module BABYLON {
  80966. /** @hidden */
  80967. export var cloudProceduralTexturePixelShader: {
  80968. name: string;
  80969. shader: string;
  80970. };
  80971. }
  80972. declare module BABYLON {
  80973. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  80974. private _skyColor;
  80975. private _cloudColor;
  80976. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80977. updateShaderUniforms(): void;
  80978. get skyColor(): BABYLON.Color4;
  80979. set skyColor(value: BABYLON.Color4);
  80980. get cloudColor(): BABYLON.Color4;
  80981. set cloudColor(value: BABYLON.Color4);
  80982. /**
  80983. * Serializes this cloud procedural texture
  80984. * @returns a serialized cloud procedural texture object
  80985. */
  80986. serialize(): any;
  80987. /**
  80988. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  80989. * @param parsedTexture defines parsed texture data
  80990. * @param scene defines the current scene
  80991. * @param rootUrl defines the root URL containing cloud procedural texture information
  80992. * @returns a parsed Cloud Procedural BABYLON.Texture
  80993. */
  80994. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  80995. }
  80996. }
  80997. declare module BABYLON {
  80998. /** @hidden */
  80999. export var fireProceduralTexturePixelShader: {
  81000. name: string;
  81001. shader: string;
  81002. };
  81003. }
  81004. declare module BABYLON {
  81005. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  81006. private _time;
  81007. private _speed;
  81008. private _autoGenerateTime;
  81009. private _fireColors;
  81010. private _alphaThreshold;
  81011. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81012. updateShaderUniforms(): void;
  81013. render(useCameraPostProcess?: boolean): void;
  81014. static get PurpleFireColors(): BABYLON.Color3[];
  81015. static get GreenFireColors(): BABYLON.Color3[];
  81016. static get RedFireColors(): BABYLON.Color3[];
  81017. static get BlueFireColors(): BABYLON.Color3[];
  81018. get autoGenerateTime(): boolean;
  81019. set autoGenerateTime(value: boolean);
  81020. get fireColors(): BABYLON.Color3[];
  81021. set fireColors(value: BABYLON.Color3[]);
  81022. get time(): number;
  81023. set time(value: number);
  81024. get speed(): BABYLON.Vector2;
  81025. set speed(value: BABYLON.Vector2);
  81026. get alphaThreshold(): number;
  81027. set alphaThreshold(value: number);
  81028. /**
  81029. * Serializes this fire procedural texture
  81030. * @returns a serialized fire procedural texture object
  81031. */
  81032. serialize(): any;
  81033. /**
  81034. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  81035. * @param parsedTexture defines parsed texture data
  81036. * @param scene defines the current scene
  81037. * @param rootUrl defines the root URL containing fire procedural texture information
  81038. * @returns a parsed Fire Procedural BABYLON.Texture
  81039. */
  81040. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  81041. }
  81042. }
  81043. declare module BABYLON {
  81044. /** @hidden */
  81045. export var grassProceduralTexturePixelShader: {
  81046. name: string;
  81047. shader: string;
  81048. };
  81049. }
  81050. declare module BABYLON {
  81051. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  81052. private _grassColors;
  81053. private _groundColor;
  81054. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81055. updateShaderUniforms(): void;
  81056. get grassColors(): BABYLON.Color3[];
  81057. set grassColors(value: BABYLON.Color3[]);
  81058. get groundColor(): BABYLON.Color3;
  81059. set groundColor(value: BABYLON.Color3);
  81060. /**
  81061. * Serializes this grass procedural texture
  81062. * @returns a serialized grass procedural texture object
  81063. */
  81064. serialize(): any;
  81065. /**
  81066. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  81067. * @param parsedTexture defines parsed texture data
  81068. * @param scene defines the current scene
  81069. * @param rootUrl defines the root URL containing grass procedural texture information
  81070. * @returns a parsed Grass Procedural BABYLON.Texture
  81071. */
  81072. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  81073. }
  81074. }
  81075. declare module BABYLON {
  81076. /** @hidden */
  81077. export var marbleProceduralTexturePixelShader: {
  81078. name: string;
  81079. shader: string;
  81080. };
  81081. }
  81082. declare module BABYLON {
  81083. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  81084. private _numberOfTilesHeight;
  81085. private _numberOfTilesWidth;
  81086. private _amplitude;
  81087. private _jointColor;
  81088. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81089. updateShaderUniforms(): void;
  81090. get numberOfTilesHeight(): number;
  81091. set numberOfTilesHeight(value: number);
  81092. get amplitude(): number;
  81093. set amplitude(value: number);
  81094. get numberOfTilesWidth(): number;
  81095. set numberOfTilesWidth(value: number);
  81096. get jointColor(): BABYLON.Color3;
  81097. set jointColor(value: BABYLON.Color3);
  81098. /**
  81099. * Serializes this marble procedural texture
  81100. * @returns a serialized marble procedural texture object
  81101. */
  81102. serialize(): any;
  81103. /**
  81104. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  81105. * @param parsedTexture defines parsed texture data
  81106. * @param scene defines the current scene
  81107. * @param rootUrl defines the root URL containing marble procedural texture information
  81108. * @returns a parsed Marble Procedural BABYLON.Texture
  81109. */
  81110. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  81111. }
  81112. }
  81113. declare module BABYLON {
  81114. /** @hidden */
  81115. export var normalMapProceduralTexturePixelShader: {
  81116. name: string;
  81117. shader: string;
  81118. };
  81119. }
  81120. declare module BABYLON {
  81121. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  81122. private _baseTexture;
  81123. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81124. updateShaderUniforms(): void;
  81125. render(useCameraPostProcess?: boolean): void;
  81126. resize(size: any, generateMipMaps: any): void;
  81127. get baseTexture(): BABYLON.Texture;
  81128. set baseTexture(texture: BABYLON.Texture);
  81129. /**
  81130. * Serializes this normal map procedural texture
  81131. * @returns a serialized normal map procedural texture object
  81132. */
  81133. serialize(): any;
  81134. /**
  81135. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  81136. * @param parsedTexture defines parsed texture data
  81137. * @param scene defines the current scene
  81138. * @param rootUrl defines the root URL containing normal map procedural texture information
  81139. * @returns a parsed Normal Map Procedural BABYLON.Texture
  81140. */
  81141. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  81142. }
  81143. }
  81144. declare module BABYLON {
  81145. /** @hidden */
  81146. export var perlinNoiseProceduralTexturePixelShader: {
  81147. name: string;
  81148. shader: string;
  81149. };
  81150. }
  81151. declare module BABYLON {
  81152. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  81153. time: number;
  81154. timeScale: number;
  81155. translationSpeed: number;
  81156. private _currentTranslation;
  81157. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81158. updateShaderUniforms(): void;
  81159. render(useCameraPostProcess?: boolean): void;
  81160. resize(size: any, generateMipMaps: any): void;
  81161. /**
  81162. * Serializes this perlin noise procedural texture
  81163. * @returns a serialized perlin noise procedural texture object
  81164. */
  81165. serialize(): any;
  81166. /**
  81167. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  81168. * @param parsedTexture defines parsed texture data
  81169. * @param scene defines the current scene
  81170. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  81171. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  81172. */
  81173. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  81174. }
  81175. }
  81176. declare module BABYLON {
  81177. /** @hidden */
  81178. export var roadProceduralTexturePixelShader: {
  81179. name: string;
  81180. shader: string;
  81181. };
  81182. }
  81183. declare module BABYLON {
  81184. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  81185. private _roadColor;
  81186. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81187. updateShaderUniforms(): void;
  81188. get roadColor(): BABYLON.Color3;
  81189. set roadColor(value: BABYLON.Color3);
  81190. /**
  81191. * Serializes this road procedural texture
  81192. * @returns a serialized road procedural texture object
  81193. */
  81194. serialize(): any;
  81195. /**
  81196. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  81197. * @param parsedTexture defines parsed texture data
  81198. * @param scene defines the current scene
  81199. * @param rootUrl defines the root URL containing road procedural texture information
  81200. * @returns a parsed Road Procedural BABYLON.Texture
  81201. */
  81202. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  81203. }
  81204. }
  81205. declare module BABYLON {
  81206. /** @hidden */
  81207. export var starfieldProceduralTexturePixelShader: {
  81208. name: string;
  81209. shader: string;
  81210. };
  81211. }
  81212. declare module BABYLON {
  81213. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  81214. private _time;
  81215. private _alpha;
  81216. private _beta;
  81217. private _zoom;
  81218. private _formuparam;
  81219. private _stepsize;
  81220. private _tile;
  81221. private _brightness;
  81222. private _darkmatter;
  81223. private _distfading;
  81224. private _saturation;
  81225. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81226. updateShaderUniforms(): void;
  81227. get time(): number;
  81228. set time(value: number);
  81229. get alpha(): number;
  81230. set alpha(value: number);
  81231. get beta(): number;
  81232. set beta(value: number);
  81233. get formuparam(): number;
  81234. set formuparam(value: number);
  81235. get stepsize(): number;
  81236. set stepsize(value: number);
  81237. get zoom(): number;
  81238. set zoom(value: number);
  81239. get tile(): number;
  81240. set tile(value: number);
  81241. get brightness(): number;
  81242. set brightness(value: number);
  81243. get darkmatter(): number;
  81244. set darkmatter(value: number);
  81245. get distfading(): number;
  81246. set distfading(value: number);
  81247. get saturation(): number;
  81248. set saturation(value: number);
  81249. /**
  81250. * Serializes this starfield procedural texture
  81251. * @returns a serialized starfield procedural texture object
  81252. */
  81253. serialize(): any;
  81254. /**
  81255. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  81256. * @param parsedTexture defines parsed texture data
  81257. * @param scene defines the current scene
  81258. * @param rootUrl defines the root URL containing startfield procedural texture information
  81259. * @returns a parsed Starfield Procedural BABYLON.Texture
  81260. */
  81261. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  81262. }
  81263. }
  81264. declare module BABYLON {
  81265. /** @hidden */
  81266. export var woodProceduralTexturePixelShader: {
  81267. name: string;
  81268. shader: string;
  81269. };
  81270. }
  81271. declare module BABYLON {
  81272. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  81273. private _ampScale;
  81274. private _woodColor;
  81275. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81276. updateShaderUniforms(): void;
  81277. get ampScale(): number;
  81278. set ampScale(value: number);
  81279. get woodColor(): BABYLON.Color3;
  81280. set woodColor(value: BABYLON.Color3);
  81281. /**
  81282. * Serializes this wood procedural texture
  81283. * @returns a serialized wood procedural texture object
  81284. */
  81285. serialize(): any;
  81286. /**
  81287. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  81288. * @param parsedTexture defines parsed texture data
  81289. * @param scene defines the current scene
  81290. * @param rootUrl defines the root URL containing wood procedural texture information
  81291. * @returns a parsed Wood Procedural BABYLON.Texture
  81292. */
  81293. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  81294. }
  81295. }