documentation.d.ts 3.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static get Now(): number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  483. /**
  484. * Returns client's state
  485. */
  486. get readyState(): number;
  487. /**
  488. * Returns client's status
  489. */
  490. get status(): number;
  491. /**
  492. * Returns client's status as a text
  493. */
  494. get statusText(): string;
  495. /**
  496. * Returns client's response
  497. */
  498. get response(): any;
  499. /**
  500. * Returns client's response url
  501. */
  502. get responseURL(): string;
  503. /**
  504. * Returns client's response as text
  505. */
  506. get responseText(): string;
  507. /**
  508. * Gets or sets the expected response type
  509. */
  510. get responseType(): XMLHttpRequestResponseType;
  511. set responseType(value: XMLHttpRequestResponseType);
  512. /** @hidden */
  513. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  514. /** @hidden */
  515. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  516. /**
  517. * Cancels any network activity
  518. */
  519. abort(): void;
  520. /**
  521. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  522. * @param body defines an optional request body
  523. */
  524. send(body?: Document | BodyInit | null): void;
  525. /**
  526. * Sets the request method, request URL
  527. * @param method defines the method to use (GET, POST, etc..)
  528. * @param url defines the url to connect with
  529. */
  530. open(method: string, url: string): void;
  531. /**
  532. * Sets the value of a request header.
  533. * @param name The name of the header whose value is to be set
  534. * @param value The value to set as the body of the header
  535. */
  536. setRequestHeader(name: string, value: string): void;
  537. /**
  538. * Get the string containing the text of a particular header's value.
  539. * @param name The name of the header
  540. * @returns The string containing the text of the given header name
  541. */
  542. getResponseHeader(name: string): Nullable<string>;
  543. }
  544. }
  545. declare module BABYLON {
  546. /**
  547. * File request interface
  548. */
  549. export interface IFileRequest {
  550. /**
  551. * Raised when the request is complete (success or error).
  552. */
  553. onCompleteObservable: Observable<IFileRequest>;
  554. /**
  555. * Aborts the request for a file.
  556. */
  557. abort: () => void;
  558. }
  559. }
  560. declare module BABYLON {
  561. /**
  562. * Define options used to create a render target texture
  563. */
  564. export class RenderTargetCreationOptions {
  565. /**
  566. * Specifies is mipmaps must be generated
  567. */
  568. generateMipMaps?: boolean;
  569. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  570. generateDepthBuffer?: boolean;
  571. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  572. generateStencilBuffer?: boolean;
  573. /** Defines texture type (int by default) */
  574. type?: number;
  575. /** Defines sampling mode (trilinear by default) */
  576. samplingMode?: number;
  577. /** Defines format (RGBA by default) */
  578. format?: number;
  579. }
  580. }
  581. declare module BABYLON {
  582. /**
  583. * @hidden
  584. **/
  585. export class _TimeToken {
  586. _startTimeQuery: Nullable<WebGLQuery>;
  587. _endTimeQuery: Nullable<WebGLQuery>;
  588. _timeElapsedQuery: Nullable<WebGLQuery>;
  589. _timeElapsedQueryEnded: boolean;
  590. }
  591. }
  592. declare module BABYLON {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** 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 */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** 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 */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** 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 */
  688. static readonly GEQUAL: number;
  689. /** 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 */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and no mip */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** mag = nearest and min = nearest and mip = none */
  774. static readonly TEXTURE_NEAREST_NEAREST: number;
  775. /** Bilinear is mag = linear and min = linear and no mip */
  776. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  777. /** mag = linear and min = linear and mip = none */
  778. static readonly TEXTURE_LINEAR_LINEAR: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** nearest is mag = nearest and min = nearest and mip = linear */
  792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  798. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * 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.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * 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.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module BABYLON {
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module BABYLON {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module BABYLON {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. get underlyingResource(): any;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export interface ProcessingOptions {
  1150. defines: string[];
  1151. indexParameters: any;
  1152. isFragment: boolean;
  1153. shouldUseHighPrecisionShader: boolean;
  1154. supportsUniformBuffers: boolean;
  1155. shadersRepository: string;
  1156. includesShadersStore: {
  1157. [key: string]: string;
  1158. };
  1159. processor?: IShaderProcessor;
  1160. version: string;
  1161. platformName: string;
  1162. lookForClosingBracketForUniformBuffer?: boolean;
  1163. }
  1164. }
  1165. declare module BABYLON {
  1166. /** @hidden */
  1167. export class ShaderCodeNode {
  1168. line: string;
  1169. children: ShaderCodeNode[];
  1170. additionalDefineKey?: string;
  1171. additionalDefineValue?: string;
  1172. isValid(preprocessors: {
  1173. [key: string]: string;
  1174. }): boolean;
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderCodeCursor {
  1183. private _lines;
  1184. lineIndex: number;
  1185. get currentLine(): string;
  1186. get canRead(): boolean;
  1187. set lines(value: string[]);
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1193. process(preprocessors: {
  1194. [key: string]: string;
  1195. }, options: ProcessingOptions): string;
  1196. }
  1197. }
  1198. declare module BABYLON {
  1199. /** @hidden */
  1200. export class ShaderDefineExpression {
  1201. isTrue(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderCodeTestNode extends ShaderCodeNode {
  1209. testExpression: ShaderDefineExpression;
  1210. isValid(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1218. define: string;
  1219. not: boolean;
  1220. constructor(define: string, not?: boolean);
  1221. isTrue(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /** @hidden */
  1228. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1229. leftOperand: ShaderDefineExpression;
  1230. rightOperand: ShaderDefineExpression;
  1231. isTrue(preprocessors: {
  1232. [key: string]: string;
  1233. }): boolean;
  1234. }
  1235. }
  1236. declare module BABYLON {
  1237. /** @hidden */
  1238. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1239. leftOperand: ShaderDefineExpression;
  1240. rightOperand: ShaderDefineExpression;
  1241. isTrue(preprocessors: {
  1242. [key: string]: string;
  1243. }): boolean;
  1244. }
  1245. }
  1246. declare module BABYLON {
  1247. /** @hidden */
  1248. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1249. define: string;
  1250. operand: string;
  1251. testValue: string;
  1252. constructor(define: string, operand: string, testValue: string);
  1253. isTrue(preprocessors: {
  1254. [key: string]: string;
  1255. }): boolean;
  1256. }
  1257. }
  1258. declare module BABYLON {
  1259. /**
  1260. * Class used to enable access to offline support
  1261. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1262. */
  1263. export interface IOfflineProvider {
  1264. /**
  1265. * Gets a boolean indicating if scene must be saved in the database
  1266. */
  1267. enableSceneOffline: boolean;
  1268. /**
  1269. * Gets a boolean indicating if textures must be saved in the database
  1270. */
  1271. enableTexturesOffline: boolean;
  1272. /**
  1273. * Open the offline support and make it available
  1274. * @param successCallback defines the callback to call on success
  1275. * @param errorCallback defines the callback to call on error
  1276. */
  1277. open(successCallback: () => void, errorCallback: () => void): void;
  1278. /**
  1279. * Loads an image from the offline support
  1280. * @param url defines the url to load from
  1281. * @param image defines the target DOM image
  1282. */
  1283. loadImage(url: string, image: HTMLImageElement): void;
  1284. /**
  1285. * Loads a file from offline support
  1286. * @param url defines the URL to load from
  1287. * @param sceneLoaded defines a callback to call on success
  1288. * @param progressCallBack defines a callback to call when progress changed
  1289. * @param errorCallback defines a callback to call on error
  1290. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1291. */
  1292. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1293. }
  1294. }
  1295. declare module BABYLON {
  1296. /**
  1297. * Class used to help managing file picking and drag'n'drop
  1298. * File Storage
  1299. */
  1300. export class FilesInputStore {
  1301. /**
  1302. * List of files ready to be loaded
  1303. */
  1304. static FilesToLoad: {
  1305. [key: string]: File;
  1306. };
  1307. }
  1308. }
  1309. declare module BABYLON {
  1310. /**
  1311. * Class used to define a retry strategy when error happens while loading assets
  1312. */
  1313. export class RetryStrategy {
  1314. /**
  1315. * Function used to defines an exponential back off strategy
  1316. * @param maxRetries defines the maximum number of retries (3 by default)
  1317. * @param baseInterval defines the interval between retries
  1318. * @returns the strategy function to use
  1319. */
  1320. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /**
  1325. * @ignore
  1326. * Application error to support additional information when loading a file
  1327. */
  1328. export abstract class BaseError extends Error {
  1329. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1330. }
  1331. }
  1332. declare module BABYLON {
  1333. /** @ignore */
  1334. export class LoadFileError extends BaseError {
  1335. request?: WebRequest;
  1336. file?: File;
  1337. /**
  1338. * Creates a new LoadFileError
  1339. * @param message defines the message of the error
  1340. * @param request defines the optional web request
  1341. * @param file defines the optional file
  1342. */
  1343. constructor(message: string, object?: WebRequest | File);
  1344. }
  1345. /** @ignore */
  1346. export class RequestFileError extends BaseError {
  1347. request: WebRequest;
  1348. /**
  1349. * Creates a new LoadFileError
  1350. * @param message defines the message of the error
  1351. * @param request defines the optional web request
  1352. */
  1353. constructor(message: string, request: WebRequest);
  1354. }
  1355. /** @ignore */
  1356. export class ReadFileError extends BaseError {
  1357. file: File;
  1358. /**
  1359. * Creates a new ReadFileError
  1360. * @param message defines the message of the error
  1361. * @param file defines the optional file
  1362. */
  1363. constructor(message: string, file: File);
  1364. }
  1365. /**
  1366. * @hidden
  1367. */
  1368. export class FileTools {
  1369. /**
  1370. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1371. */
  1372. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1373. /**
  1374. * Gets or sets the base URL to use to load assets
  1375. */
  1376. static BaseUrl: string;
  1377. /**
  1378. * Default behaviour for cors in the application.
  1379. * It can be a string if the expected behavior is identical in the entire app.
  1380. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1381. */
  1382. static CorsBehavior: string | ((url: string | string[]) => string);
  1383. /**
  1384. * Gets or sets a function used to pre-process url before using them to load assets
  1385. */
  1386. static PreprocessUrl: (url: string) => string;
  1387. /**
  1388. * Removes unwanted characters from an url
  1389. * @param url defines the url to clean
  1390. * @returns the cleaned url
  1391. */
  1392. private static _CleanUrl;
  1393. /**
  1394. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1395. * @param url define the url we are trying
  1396. * @param element define the dom element where to configure the cors policy
  1397. */
  1398. static SetCorsBehavior(url: string | string[], element: {
  1399. crossOrigin: string | null;
  1400. }): void;
  1401. /**
  1402. * Loads an image as an HTMLImageElement.
  1403. * @param input url string, ArrayBuffer, or Blob to load
  1404. * @param onLoad callback called when the image successfully loads
  1405. * @param onError callback called when the image fails to load
  1406. * @param offlineProvider offline provider for caching
  1407. * @param mimeType optional mime type
  1408. * @returns the HTMLImageElement of the loaded image
  1409. */
  1410. 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>;
  1411. /**
  1412. * Reads a file from a File object
  1413. * @param file defines the file to load
  1414. * @param onSuccess defines the callback to call when data is loaded
  1415. * @param onProgress defines the callback to call during loading process
  1416. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1417. * @param onError defines the callback to call when an error occurs
  1418. * @returns a file request object
  1419. */
  1420. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1421. /**
  1422. * Loads a file from a url
  1423. * @param url url to load
  1424. * @param onSuccess callback called when the file successfully loads
  1425. * @param onProgress callback called while file is loading (if the server supports this mode)
  1426. * @param offlineProvider defines the offline provider for caching
  1427. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1428. * @param onError callback called when the file fails to load
  1429. * @returns a file request object
  1430. */
  1431. 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;
  1432. /**
  1433. * Loads a file
  1434. * @param url url to load
  1435. * @param onSuccess callback called when the file successfully loads
  1436. * @param onProgress callback called while file is loading (if the server supports this mode)
  1437. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1438. * @param onError callback called when the file fails to load
  1439. * @param onOpened callback called when the web request is opened
  1440. * @returns a file request object
  1441. */
  1442. 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;
  1443. /**
  1444. * Checks if the loaded document was accessed via `file:`-Protocol.
  1445. * @returns boolean
  1446. */
  1447. static IsFileURL(): boolean;
  1448. }
  1449. }
  1450. declare module BABYLON {
  1451. /** @hidden */
  1452. export class ShaderProcessor {
  1453. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1454. private static _ProcessPrecision;
  1455. private static _ExtractOperation;
  1456. private static _BuildSubExpression;
  1457. private static _BuildExpression;
  1458. private static _MoveCursorWithinIf;
  1459. private static _MoveCursor;
  1460. private static _EvaluatePreProcessors;
  1461. private static _PreparePreProcessors;
  1462. private static _ProcessShaderConversion;
  1463. private static _ProcessIncludes;
  1464. /**
  1465. * Loads a file from a url
  1466. * @param url url to load
  1467. * @param onSuccess callback called when the file successfully loads
  1468. * @param onProgress callback called while file is loading (if the server supports this mode)
  1469. * @param offlineProvider defines the offline provider for caching
  1470. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1471. * @param onError callback called when the file fails to load
  1472. * @returns a file request object
  1473. * @hidden
  1474. */
  1475. 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;
  1476. }
  1477. }
  1478. declare module BABYLON {
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor4Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. a: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IColor3Like {
  1492. r: float;
  1493. g: float;
  1494. b: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector4Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. w: float;
  1504. }
  1505. /**
  1506. * @hidden
  1507. */
  1508. export interface IVector3Like {
  1509. x: float;
  1510. y: float;
  1511. z: float;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IVector2Like {
  1517. x: float;
  1518. y: float;
  1519. }
  1520. /**
  1521. * @hidden
  1522. */
  1523. export interface IMatrixLike {
  1524. toArray(): DeepImmutable<Float32Array>;
  1525. updateFlag: int;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IViewportLike {
  1531. x: float;
  1532. y: float;
  1533. width: float;
  1534. height: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IPlaneLike {
  1540. normal: IVector3Like;
  1541. d: float;
  1542. normalize(): void;
  1543. }
  1544. }
  1545. declare module BABYLON {
  1546. /**
  1547. * Interface used to define common properties for effect fallbacks
  1548. */
  1549. export interface IEffectFallbacks {
  1550. /**
  1551. * Removes the defines that should be removed when falling back.
  1552. * @param currentDefines defines the current define statements for the shader.
  1553. * @param effect defines the current effect we try to compile
  1554. * @returns The resulting defines with defines of the current rank removed.
  1555. */
  1556. reduce(currentDefines: string, effect: Effect): string;
  1557. /**
  1558. * Removes the fallback from the bound mesh.
  1559. */
  1560. unBindMesh(): void;
  1561. /**
  1562. * Checks to see if more fallbacks are still availible.
  1563. */
  1564. hasMoreFallbacks: boolean;
  1565. }
  1566. }
  1567. declare module BABYLON {
  1568. /**
  1569. * Class used to evalaute queries containing `and` and `or` operators
  1570. */
  1571. export class AndOrNotEvaluator {
  1572. /**
  1573. * Evaluate a query
  1574. * @param query defines the query to evaluate
  1575. * @param evaluateCallback defines the callback used to filter result
  1576. * @returns true if the query matches
  1577. */
  1578. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1579. private static _HandleParenthesisContent;
  1580. private static _SimplifyNegation;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to store custom tags
  1586. */
  1587. export class Tags {
  1588. /**
  1589. * Adds support for tags on the given object
  1590. * @param obj defines the object to use
  1591. */
  1592. static EnableFor(obj: any): void;
  1593. /**
  1594. * Removes tags support
  1595. * @param obj defines the object to use
  1596. */
  1597. static DisableFor(obj: any): void;
  1598. /**
  1599. * Gets a boolean indicating if the given object has tags
  1600. * @param obj defines the object to use
  1601. * @returns a boolean
  1602. */
  1603. static HasTags(obj: any): boolean;
  1604. /**
  1605. * Gets the tags available on a given object
  1606. * @param obj defines the object to use
  1607. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1608. * @returns the tags
  1609. */
  1610. static GetTags(obj: any, asString?: boolean): any;
  1611. /**
  1612. * Adds tags to an object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1615. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1616. */
  1617. static AddTagsTo(obj: any, tagsString: string): void;
  1618. /**
  1619. * @hidden
  1620. */
  1621. static _AddTagTo(obj: any, tag: string): void;
  1622. /**
  1623. * Removes specific tags from a specific object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tags to remove
  1626. */
  1627. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1628. /**
  1629. * @hidden
  1630. */
  1631. static _RemoveTagFrom(obj: any, tag: string): void;
  1632. /**
  1633. * Defines if tags hosted on an object match a given query
  1634. * @param obj defines the object to use
  1635. * @param tagsQuery defines the tag query
  1636. * @returns a boolean
  1637. */
  1638. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1639. }
  1640. }
  1641. declare module BABYLON {
  1642. /**
  1643. * Scalar computation library
  1644. */
  1645. export class Scalar {
  1646. /**
  1647. * Two pi constants convenient for computation.
  1648. */
  1649. static TwoPi: number;
  1650. /**
  1651. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1652. * @param a number
  1653. * @param b number
  1654. * @param epsilon (default = 1.401298E-45)
  1655. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. */
  1657. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1658. /**
  1659. * Returns a string : the upper case translation of the number i to hexadecimal.
  1660. * @param i number
  1661. * @returns the upper case translation of the number i to hexadecimal.
  1662. */
  1663. static ToHex(i: number): string;
  1664. /**
  1665. * Returns -1 if value is negative and +1 is value is positive.
  1666. * @param value the value
  1667. * @returns the value itself if it's equal to zero.
  1668. */
  1669. static Sign(value: number): number;
  1670. /**
  1671. * Returns the value itself if it's between min and max.
  1672. * Returns min if the value is lower than min.
  1673. * Returns max if the value is greater than max.
  1674. * @param value the value to clmap
  1675. * @param min the min value to clamp to (default: 0)
  1676. * @param max the max value to clamp to (default: 1)
  1677. * @returns the clamped value
  1678. */
  1679. static Clamp(value: number, min?: number, max?: number): number;
  1680. /**
  1681. * the log2 of value.
  1682. * @param value the value to compute log2 of
  1683. * @returns the log2 of value.
  1684. */
  1685. static Log2(value: number): number;
  1686. /**
  1687. * Loops the value, so that it is never larger than length and never smaller than 0.
  1688. *
  1689. * This is similar to the modulo operator but it works with floating point numbers.
  1690. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1691. * With t = 5 and length = 2.5, the result would be 0.0.
  1692. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1693. * @param value the value
  1694. * @param length the length
  1695. * @returns the looped value
  1696. */
  1697. static Repeat(value: number, length: number): number;
  1698. /**
  1699. * Normalize the value between 0.0 and 1.0 using min and max values
  1700. * @param value value to normalize
  1701. * @param min max to normalize between
  1702. * @param max min to normalize between
  1703. * @returns the normalized value
  1704. */
  1705. static Normalize(value: number, min: number, max: number): number;
  1706. /**
  1707. * Denormalize the value from 0.0 and 1.0 using min and max values
  1708. * @param normalized value to denormalize
  1709. * @param min max to denormalize between
  1710. * @param max min to denormalize between
  1711. * @returns the denormalized value
  1712. */
  1713. static Denormalize(normalized: number, min: number, max: number): number;
  1714. /**
  1715. * Calculates the shortest difference between two given angles given in degrees.
  1716. * @param current current angle in degrees
  1717. * @param target target angle in degrees
  1718. * @returns the delta
  1719. */
  1720. static DeltaAngle(current: number, target: number): number;
  1721. /**
  1722. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1723. * @param tx value
  1724. * @param length length
  1725. * @returns The returned value will move back and forth between 0 and length
  1726. */
  1727. static PingPong(tx: number, length: number): number;
  1728. /**
  1729. * Interpolates between min and max with smoothing at the limits.
  1730. *
  1731. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1732. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1733. * @param from from
  1734. * @param to to
  1735. * @param tx value
  1736. * @returns the smooth stepped value
  1737. */
  1738. static SmoothStep(from: number, to: number, tx: number): number;
  1739. /**
  1740. * Moves a value current towards target.
  1741. *
  1742. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1743. * Negative values of maxDelta pushes the value away from target.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting value
  1748. */
  1749. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. *
  1753. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1754. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting angle
  1759. */
  1760. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  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 Lerp(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1771. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1772. * @param start start value
  1773. * @param end target value
  1774. * @param amount amount to lerp between
  1775. * @returns the lerped value
  1776. */
  1777. static LerpAngle(start: number, end: number, amount: number): number;
  1778. /**
  1779. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1780. * @param a start value
  1781. * @param b target value
  1782. * @param value value between a and b
  1783. * @returns the inverseLerp value
  1784. */
  1785. static InverseLerp(a: number, b: number, value: number): number;
  1786. /**
  1787. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1788. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1789. * @param value1 spline value
  1790. * @param tangent1 spline value
  1791. * @param value2 spline value
  1792. * @param tangent2 spline value
  1793. * @param amount input value
  1794. * @returns hermite result
  1795. */
  1796. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1797. /**
  1798. * Returns a random float number between and min and max values
  1799. * @param min min value of random
  1800. * @param max max value of random
  1801. * @returns random value
  1802. */
  1803. static RandomRange(min: number, max: number): number;
  1804. /**
  1805. * This function returns percentage of a number in a given range.
  1806. *
  1807. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1808. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1809. * @param number to convert to percentage
  1810. * @param min min range
  1811. * @param max max range
  1812. * @returns the percentage
  1813. */
  1814. static RangeToPercent(number: number, min: number, max: number): number;
  1815. /**
  1816. * This function returns number that corresponds to the percentage in a given range.
  1817. *
  1818. * PercentToRange(0.34,0,100) will return 34.
  1819. * @param percent to convert to number
  1820. * @param min min range
  1821. * @param max max range
  1822. * @returns the number
  1823. */
  1824. static PercentToRange(percent: number, min: number, max: number): number;
  1825. /**
  1826. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1827. * @param angle The angle to normalize in radian.
  1828. * @return The converted angle.
  1829. */
  1830. static NormalizeRadians(angle: number): number;
  1831. }
  1832. }
  1833. declare module BABYLON {
  1834. /**
  1835. * Constant used to convert a value to gamma space
  1836. * @ignorenaming
  1837. */
  1838. export const ToGammaSpace: number;
  1839. /**
  1840. * Constant used to convert a value to linear space
  1841. * @ignorenaming
  1842. */
  1843. export const ToLinearSpace = 2.2;
  1844. /**
  1845. * Constant used to define the minimal number value in Babylon.js
  1846. * @ignorenaming
  1847. */
  1848. let Epsilon: number;
  1849. }
  1850. declare module BABYLON {
  1851. /**
  1852. * Class used to represent a viewport on screen
  1853. */
  1854. export class Viewport {
  1855. /** viewport left coordinate */
  1856. x: number;
  1857. /** viewport top coordinate */
  1858. y: number;
  1859. /**viewport width */
  1860. width: number;
  1861. /** viewport height */
  1862. height: number;
  1863. /**
  1864. * Creates a Viewport object located at (x, y) and sized (width, height)
  1865. * @param x defines viewport left coordinate
  1866. * @param y defines viewport top coordinate
  1867. * @param width defines the viewport width
  1868. * @param height defines the viewport height
  1869. */
  1870. constructor(
  1871. /** viewport left coordinate */
  1872. x: number,
  1873. /** viewport top coordinate */
  1874. y: number,
  1875. /**viewport width */
  1876. width: number,
  1877. /** viewport height */
  1878. height: number);
  1879. /**
  1880. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1881. * @param renderWidth defines the rendering width
  1882. * @param renderHeight defines the rendering height
  1883. * @returns a new Viewport
  1884. */
  1885. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1886. /**
  1887. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1888. * @param renderWidth defines the rendering width
  1889. * @param renderHeight defines the rendering height
  1890. * @param ref defines the target viewport
  1891. * @returns the current viewport
  1892. */
  1893. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1894. /**
  1895. * Returns a new Viewport copied from the current one
  1896. * @returns a new Viewport
  1897. */
  1898. clone(): Viewport;
  1899. }
  1900. }
  1901. declare module BABYLON {
  1902. /**
  1903. * Class containing a set of static utilities functions for arrays.
  1904. */
  1905. export class ArrayTools {
  1906. /**
  1907. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1908. * @param size the number of element to construct and put in the array
  1909. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1910. * @returns a new array filled with new objects
  1911. */
  1912. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1913. }
  1914. }
  1915. declare module BABYLON {
  1916. /**
  1917. * Class representing a vector containing 2 coordinates
  1918. */
  1919. export class Vector2 {
  1920. /** defines the first coordinate */
  1921. x: number;
  1922. /** defines the second coordinate */
  1923. y: number;
  1924. /**
  1925. * Creates a new Vector2 from the given x and y coordinates
  1926. * @param x defines the first coordinate
  1927. * @param y defines the second coordinate
  1928. */
  1929. constructor(
  1930. /** defines the first coordinate */
  1931. x?: number,
  1932. /** defines the second coordinate */
  1933. y?: number);
  1934. /**
  1935. * Gets a string with the Vector2 coordinates
  1936. * @returns a string with the Vector2 coordinates
  1937. */
  1938. toString(): string;
  1939. /**
  1940. * Gets class name
  1941. * @returns the string "Vector2"
  1942. */
  1943. getClassName(): string;
  1944. /**
  1945. * Gets current vector hash code
  1946. * @returns the Vector2 hash code as a number
  1947. */
  1948. getHashCode(): number;
  1949. /**
  1950. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1951. * @param array defines the source array
  1952. * @param index defines the offset in source array
  1953. * @returns the current Vector2
  1954. */
  1955. toArray(array: FloatArray, index?: number): Vector2;
  1956. /**
  1957. * Copy the current vector to an array
  1958. * @returns a new array with 2 elements: the Vector2 coordinates.
  1959. */
  1960. asArray(): number[];
  1961. /**
  1962. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1963. * @param source defines the source Vector2
  1964. * @returns the current updated Vector2
  1965. */
  1966. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1967. /**
  1968. * Sets the Vector2 coordinates with the given floats
  1969. * @param x defines the first coordinate
  1970. * @param y defines the second coordinate
  1971. * @returns the current updated Vector2
  1972. */
  1973. copyFromFloats(x: number, y: number): Vector2;
  1974. /**
  1975. * Sets the Vector2 coordinates with the given floats
  1976. * @param x defines the first coordinate
  1977. * @param y defines the second coordinate
  1978. * @returns the current updated Vector2
  1979. */
  1980. set(x: number, y: number): Vector2;
  1981. /**
  1982. * Add another vector with the current one
  1983. * @param otherVector defines the other vector
  1984. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1985. */
  1986. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1987. /**
  1988. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1989. * @param otherVector defines the other vector
  1990. * @param result defines the target vector
  1991. * @returns the unmodified current Vector2
  1992. */
  1993. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1994. /**
  1995. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1996. * @param otherVector defines the other vector
  1997. * @returns the current updated Vector2
  1998. */
  1999. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2000. /**
  2001. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2002. * @param otherVector defines the other vector
  2003. * @returns a new Vector2
  2004. */
  2005. addVector3(otherVector: Vector3): Vector2;
  2006. /**
  2007. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2008. * @param otherVector defines the other vector
  2009. * @returns a new Vector2
  2010. */
  2011. subtract(otherVector: Vector2): Vector2;
  2012. /**
  2013. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2014. * @param otherVector defines the other vector
  2015. * @param result defines the target vector
  2016. * @returns the unmodified current Vector2
  2017. */
  2018. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2019. /**
  2020. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @returns the current updated Vector2
  2023. */
  2024. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2025. /**
  2026. * Multiplies in place the current Vector2 coordinates by the given ones
  2027. * @param otherVector defines the other vector
  2028. * @returns the current updated Vector2
  2029. */
  2030. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2031. /**
  2032. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2033. * @param otherVector defines the other vector
  2034. * @returns a new Vector2
  2035. */
  2036. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2037. /**
  2038. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @param result defines the target vector
  2041. * @returns the unmodified current Vector2
  2042. */
  2043. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2044. /**
  2045. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2046. * @param x defines the first coordinate
  2047. * @param y defines the second coordinate
  2048. * @returns a new Vector2
  2049. */
  2050. multiplyByFloats(x: number, y: number): Vector2;
  2051. /**
  2052. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2053. * @param otherVector defines the other vector
  2054. * @returns a new Vector2
  2055. */
  2056. divide(otherVector: Vector2): Vector2;
  2057. /**
  2058. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2059. * @param otherVector defines the other vector
  2060. * @param result defines the target vector
  2061. * @returns the unmodified current Vector2
  2062. */
  2063. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2064. /**
  2065. * Divides the current Vector2 coordinates by the given ones
  2066. * @param otherVector defines the other vector
  2067. * @returns the current updated Vector2
  2068. */
  2069. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2070. /**
  2071. * Gets a new Vector2 with current Vector2 negated coordinates
  2072. * @returns a new Vector2
  2073. */
  2074. negate(): Vector2;
  2075. /**
  2076. * Negate this vector in place
  2077. * @returns this
  2078. */
  2079. negateInPlace(): Vector2;
  2080. /**
  2081. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2082. * @param result defines the Vector3 object where to store the result
  2083. * @returns the current Vector2
  2084. */
  2085. negateToRef(result: Vector2): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * 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".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Class used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Negate this vector in place
  2439. * @returns this
  2440. */
  2441. negateInPlace(): Vector3;
  2442. /**
  2443. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2444. * @param result defines the Vector3 object where to store the result
  2445. * @returns the current Vector3
  2446. */
  2447. negateToRef(result: Vector3): Vector3;
  2448. /**
  2449. * Multiplies the Vector3 coordinates by the float "scale"
  2450. * @param scale defines the multiplier factor
  2451. * @returns the current updated Vector3
  2452. */
  2453. scaleInPlace(scale: number): Vector3;
  2454. /**
  2455. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2456. * @param scale defines the multiplier factor
  2457. * @returns a new Vector3
  2458. */
  2459. scale(scale: number): Vector3;
  2460. /**
  2461. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2462. * @param scale defines the multiplier factor
  2463. * @param result defines the Vector3 object where to store the result
  2464. * @returns the current Vector3
  2465. */
  2466. scaleToRef(scale: number, result: Vector3): Vector3;
  2467. /**
  2468. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2469. * @param scale defines the scale factor
  2470. * @param result defines the Vector3 object where to store the result
  2471. * @returns the unmodified current Vector3
  2472. */
  2473. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2474. /**
  2475. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2476. * @param otherVector defines the second operand
  2477. * @returns true if both vectors are equals
  2478. */
  2479. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2480. /**
  2481. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2482. * @param otherVector defines the second operand
  2483. * @param epsilon defines the minimal distance to define values as equals
  2484. * @returns true if both vectors are distant less than epsilon
  2485. */
  2486. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2487. /**
  2488. * Returns true if the current Vector3 coordinates equals the given floats
  2489. * @param x defines the x coordinate of the operand
  2490. * @param y defines the y coordinate of the operand
  2491. * @param z defines the z coordinate of the operand
  2492. * @returns true if both vectors are equals
  2493. */
  2494. equalsToFloats(x: number, y: number, z: number): boolean;
  2495. /**
  2496. * Multiplies the current Vector3 coordinates by the given ones
  2497. * @param otherVector defines the second operand
  2498. * @returns the current updated Vector3
  2499. */
  2500. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2501. /**
  2502. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2503. * @param otherVector defines the second operand
  2504. * @returns the new Vector3
  2505. */
  2506. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2507. /**
  2508. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2509. * @param otherVector defines the second operand
  2510. * @param result defines the Vector3 object where to store the result
  2511. * @returns the current Vector3
  2512. */
  2513. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2514. /**
  2515. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2516. * @param x defines the x coordinate of the operand
  2517. * @param y defines the y coordinate of the operand
  2518. * @param z defines the z coordinate of the operand
  2519. * @returns the new Vector3
  2520. */
  2521. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2522. /**
  2523. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2524. * @param otherVector defines the second operand
  2525. * @returns the new Vector3
  2526. */
  2527. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2528. /**
  2529. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2530. * @param otherVector defines the second operand
  2531. * @param result defines the Vector3 object where to store the result
  2532. * @returns the current Vector3
  2533. */
  2534. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2535. /**
  2536. * Divides the current Vector3 coordinates by the given ones.
  2537. * @param otherVector defines the second operand
  2538. * @returns the current updated Vector3
  2539. */
  2540. divideInPlace(otherVector: Vector3): Vector3;
  2541. /**
  2542. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2543. * @param other defines the second operand
  2544. * @returns the current updated Vector3
  2545. */
  2546. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2547. /**
  2548. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2549. * @param other defines the second operand
  2550. * @returns the current updated Vector3
  2551. */
  2552. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2553. /**
  2554. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2555. * @param x defines the x coordinate of the operand
  2556. * @param y defines the y coordinate of the operand
  2557. * @param z defines the z coordinate of the operand
  2558. * @returns the current updated Vector3
  2559. */
  2560. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2561. /**
  2562. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the current updated Vector3
  2567. */
  2568. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2571. * Check if is non uniform within a certain amount of decimal places to account for this
  2572. * @param epsilon the amount the values can differ
  2573. * @returns if the the vector is non uniform to a certain number of decimal places
  2574. */
  2575. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2576. /**
  2577. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2578. */
  2579. get isNonUniform(): boolean;
  2580. /**
  2581. * Gets a new Vector3 from current Vector3 floored values
  2582. * @returns a new Vector3
  2583. */
  2584. floor(): Vector3;
  2585. /**
  2586. * Gets a new Vector3 from current Vector3 floored values
  2587. * @returns a new Vector3
  2588. */
  2589. fract(): Vector3;
  2590. /**
  2591. * Gets the length of the Vector3
  2592. * @returns the length of the Vector3
  2593. */
  2594. length(): number;
  2595. /**
  2596. * Gets the squared length of the Vector3
  2597. * @returns squared length of the Vector3
  2598. */
  2599. lengthSquared(): number;
  2600. /**
  2601. * Normalize the current Vector3.
  2602. * Please note that this is an in place operation.
  2603. * @returns the current updated Vector3
  2604. */
  2605. normalize(): Vector3;
  2606. /**
  2607. * Reorders the x y z properties of the vector in place
  2608. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2609. * @returns the current updated vector
  2610. */
  2611. reorderInPlace(order: string): this;
  2612. /**
  2613. * Rotates the vector around 0,0,0 by a quaternion
  2614. * @param quaternion the rotation quaternion
  2615. * @param result vector to store the result
  2616. * @returns the resulting vector
  2617. */
  2618. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2619. /**
  2620. * Rotates a vector around a given point
  2621. * @param quaternion the rotation quaternion
  2622. * @param point the point to rotate around
  2623. * @param result vector to store the result
  2624. * @returns the resulting vector
  2625. */
  2626. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2627. /**
  2628. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2629. * The cross product is then orthogonal to both current and "other"
  2630. * @param other defines the right operand
  2631. * @returns the cross product
  2632. */
  2633. cross(other: Vector3): Vector3;
  2634. /**
  2635. * Normalize the current Vector3 with the given input length.
  2636. * Please note that this is an in place operation.
  2637. * @param len the length of the vector
  2638. * @returns the current updated Vector3
  2639. */
  2640. normalizeFromLength(len: number): Vector3;
  2641. /**
  2642. * Normalize the current Vector3 to a new vector
  2643. * @returns the new Vector3
  2644. */
  2645. normalizeToNew(): Vector3;
  2646. /**
  2647. * Normalize the current Vector3 to the reference
  2648. * @param reference define the Vector3 to update
  2649. * @returns the updated Vector3
  2650. */
  2651. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Creates a new Vector3 copied from the current Vector3
  2654. * @returns the new Vector3
  2655. */
  2656. clone(): Vector3;
  2657. /**
  2658. * Copies the given vector coordinates to the current Vector3 ones
  2659. * @param source defines the source Vector3
  2660. * @returns the current updated Vector3
  2661. */
  2662. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2663. /**
  2664. * Copies the given floats to the current Vector3 coordinates
  2665. * @param x defines the x coordinate of the operand
  2666. * @param y defines the y coordinate of the operand
  2667. * @param z defines the z coordinate of the operand
  2668. * @returns the current updated Vector3
  2669. */
  2670. copyFromFloats(x: number, y: number, z: number): Vector3;
  2671. /**
  2672. * Copies the given floats to the current Vector3 coordinates
  2673. * @param x defines the x coordinate of the operand
  2674. * @param y defines the y coordinate of the operand
  2675. * @param z defines the z coordinate of the operand
  2676. * @returns the current updated Vector3
  2677. */
  2678. set(x: number, y: number, z: number): Vector3;
  2679. /**
  2680. * Copies the given float to the current Vector3 coordinates
  2681. * @param v defines the x, y and z coordinates of the operand
  2682. * @returns the current updated Vector3
  2683. */
  2684. setAll(v: number): Vector3;
  2685. /**
  2686. * Get the clip factor between two vectors
  2687. * @param vector0 defines the first operand
  2688. * @param vector1 defines the second operand
  2689. * @param axis defines the axis to use
  2690. * @param size defines the size along the axis
  2691. * @returns the clip factor
  2692. */
  2693. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2694. /**
  2695. * Get angle between two vectors
  2696. * @param vector0 angle between vector0 and vector1
  2697. * @param vector1 angle between vector0 and vector1
  2698. * @param normal direction of the normal
  2699. * @return the angle between vector0 and vector1
  2700. */
  2701. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2702. /**
  2703. * Returns a new Vector3 set from the index "offset" of the given array
  2704. * @param array defines the source array
  2705. * @param offset defines the offset in the source array
  2706. * @returns the new Vector3
  2707. */
  2708. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2709. /**
  2710. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2711. * @param array defines the source array
  2712. * @param offset defines the offset in the source array
  2713. * @returns the new Vector3
  2714. * @deprecated Please use FromArray instead.
  2715. */
  2716. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2717. /**
  2718. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2719. * @param array defines the source array
  2720. * @param offset defines the offset in the source array
  2721. * @param result defines the Vector3 where to store the result
  2722. */
  2723. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2724. /**
  2725. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2726. * @param array defines the source array
  2727. * @param offset defines the offset in the source array
  2728. * @param result defines the Vector3 where to store the result
  2729. * @deprecated Please use FromArrayToRef instead.
  2730. */
  2731. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2732. /**
  2733. * Sets the given vector "result" with the given floats.
  2734. * @param x defines the x coordinate of the source
  2735. * @param y defines the y coordinate of the source
  2736. * @param z defines the z coordinate of the source
  2737. * @param result defines the Vector3 where to store the result
  2738. */
  2739. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2740. /**
  2741. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2742. * @returns a new empty Vector3
  2743. */
  2744. static Zero(): Vector3;
  2745. /**
  2746. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2747. * @returns a new unit Vector3
  2748. */
  2749. static One(): Vector3;
  2750. /**
  2751. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2752. * @returns a new up Vector3
  2753. */
  2754. static Up(): Vector3;
  2755. /**
  2756. * Gets a up Vector3 that must not be updated
  2757. */
  2758. static get UpReadOnly(): DeepImmutable<Vector3>;
  2759. /**
  2760. * Gets a zero Vector3 that must not be updated
  2761. */
  2762. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2763. /**
  2764. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2765. * @returns a new down Vector3
  2766. */
  2767. static Down(): Vector3;
  2768. /**
  2769. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2770. * @returns a new forward Vector3
  2771. */
  2772. static Forward(): Vector3;
  2773. /**
  2774. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2775. * @returns a new forward Vector3
  2776. */
  2777. static Backward(): Vector3;
  2778. /**
  2779. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2780. * @returns a new right Vector3
  2781. */
  2782. static Right(): Vector3;
  2783. /**
  2784. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2785. * @returns a new left Vector3
  2786. */
  2787. static Left(): Vector3;
  2788. /**
  2789. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2790. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2791. * @param vector defines the Vector3 to transform
  2792. * @param transformation defines the transformation matrix
  2793. * @returns the transformed Vector3
  2794. */
  2795. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2796. /**
  2797. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2798. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2799. * @param vector defines the Vector3 to transform
  2800. * @param transformation defines the transformation matrix
  2801. * @param result defines the Vector3 where to store the result
  2802. */
  2803. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2804. /**
  2805. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2806. * This method computes tranformed coordinates only, not transformed direction vectors
  2807. * @param x define the x coordinate of the source vector
  2808. * @param y define the y coordinate of the source vector
  2809. * @param z define the z coordinate of the source vector
  2810. * @param transformation defines the transformation matrix
  2811. * @param result defines the Vector3 where to store the result
  2812. */
  2813. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2814. /**
  2815. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2816. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2817. * @param vector defines the Vector3 to transform
  2818. * @param transformation defines the transformation matrix
  2819. * @returns the new Vector3
  2820. */
  2821. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2822. /**
  2823. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2824. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2825. * @param vector defines the Vector3 to transform
  2826. * @param transformation defines the transformation matrix
  2827. * @param result defines the Vector3 where to store the result
  2828. */
  2829. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2830. /**
  2831. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2832. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2833. * @param x define the x coordinate of the source vector
  2834. * @param y define the y coordinate of the source vector
  2835. * @param z define the z coordinate of the source vector
  2836. * @param transformation defines the transformation matrix
  2837. * @param result defines the Vector3 where to store the result
  2838. */
  2839. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2840. /**
  2841. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2842. * @param value1 defines the first control point
  2843. * @param value2 defines the second control point
  2844. * @param value3 defines the third control point
  2845. * @param value4 defines the fourth control point
  2846. * @param amount defines the amount on the spline to use
  2847. * @returns the new Vector3
  2848. */
  2849. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2850. /**
  2851. * 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"
  2852. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2853. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2854. * @param value defines the current value
  2855. * @param min defines the lower range value
  2856. * @param max defines the upper range value
  2857. * @returns the new Vector3
  2858. */
  2859. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2860. /**
  2861. * 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"
  2862. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2863. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2864. * @param value defines the current value
  2865. * @param min defines the lower range value
  2866. * @param max defines the upper range value
  2867. * @param result defines the Vector3 where to store the result
  2868. */
  2869. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2870. /**
  2871. * Checks if a given vector is inside a specific range
  2872. * @param v defines the vector to test
  2873. * @param min defines the minimum range
  2874. * @param max defines the maximum range
  2875. */
  2876. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2877. /**
  2878. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2879. * @param value1 defines the first control point
  2880. * @param tangent1 defines the first tangent vector
  2881. * @param value2 defines the second control point
  2882. * @param tangent2 defines the second tangent vector
  2883. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2884. * @returns the new Vector3
  2885. */
  2886. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2887. /**
  2888. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2889. * @param start defines the start value
  2890. * @param end defines the end value
  2891. * @param amount max defines amount between both (between 0 and 1)
  2892. * @returns the new Vector3
  2893. */
  2894. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2895. /**
  2896. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2897. * @param start defines the start value
  2898. * @param end defines the end value
  2899. * @param amount max defines amount between both (between 0 and 1)
  2900. * @param result defines the Vector3 where to store the result
  2901. */
  2902. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2903. /**
  2904. * Returns the dot product (float) between the vectors "left" and "right"
  2905. * @param left defines the left operand
  2906. * @param right defines the right operand
  2907. * @returns the dot product
  2908. */
  2909. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2910. /**
  2911. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2912. * The cross product is then orthogonal to both "left" and "right"
  2913. * @param left defines the left operand
  2914. * @param right defines the right operand
  2915. * @returns the cross product
  2916. */
  2917. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2918. /**
  2919. * Sets the given vector "result" with the cross product of "left" and "right"
  2920. * The cross product is then orthogonal to both "left" and "right"
  2921. * @param left defines the left operand
  2922. * @param right defines the right operand
  2923. * @param result defines the Vector3 where to store the result
  2924. */
  2925. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2926. /**
  2927. * Returns a new Vector3 as the normalization of the given vector
  2928. * @param vector defines the Vector3 to normalize
  2929. * @returns the new Vector3
  2930. */
  2931. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2932. /**
  2933. * Sets the given vector "result" with the normalization of the given first vector
  2934. * @param vector defines the Vector3 to normalize
  2935. * @param result defines the Vector3 where to store the result
  2936. */
  2937. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2938. /**
  2939. * Project a Vector3 onto screen space
  2940. * @param vector defines the Vector3 to project
  2941. * @param world defines the world matrix to use
  2942. * @param transform defines the transform (view x projection) matrix to use
  2943. * @param viewport defines the screen viewport to use
  2944. * @returns the new Vector3
  2945. */
  2946. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2947. /** @hidden */
  2948. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2949. /**
  2950. * Unproject from screen space to object space
  2951. * @param source defines the screen space Vector3 to use
  2952. * @param viewportWidth defines the current width of the viewport
  2953. * @param viewportHeight defines the current height of the viewport
  2954. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2955. * @param transform defines the transform (view x projection) matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @returns the new Vector3
  2968. */
  2969. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param source defines the screen space Vector3 to use
  2973. * @param viewportWidth defines the current width of the viewport
  2974. * @param viewportHeight defines the current height of the viewport
  2975. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2976. * @param view defines the view matrix to use
  2977. * @param projection defines the projection matrix to use
  2978. * @param result defines the Vector3 where to store the result
  2979. */
  2980. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2981. /**
  2982. * Unproject from screen space to object space
  2983. * @param sourceX defines the screen space x coordinate to use
  2984. * @param sourceY defines the screen space y coordinate to use
  2985. * @param sourceZ defines the screen space z coordinate to use
  2986. * @param viewportWidth defines the current width of the viewport
  2987. * @param viewportHeight defines the current height of the viewport
  2988. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2989. * @param view defines the view matrix to use
  2990. * @param projection defines the projection matrix to use
  2991. * @param result defines the Vector3 where to store the result
  2992. */
  2993. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2994. /**
  2995. * Gets the minimal coordinate values between two Vector3
  2996. * @param left defines the first operand
  2997. * @param right defines the second operand
  2998. * @returns the new Vector3
  2999. */
  3000. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3001. /**
  3002. * Gets the maximal coordinate values between two Vector3
  3003. * @param left defines the first operand
  3004. * @param right defines the second operand
  3005. * @returns the new Vector3
  3006. */
  3007. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3008. /**
  3009. * Returns the distance between the vectors "value1" and "value2"
  3010. * @param value1 defines the first operand
  3011. * @param value2 defines the second operand
  3012. * @returns the distance
  3013. */
  3014. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3015. /**
  3016. * Returns the squared distance between the vectors "value1" and "value2"
  3017. * @param value1 defines the first operand
  3018. * @param value2 defines the second operand
  3019. * @returns the squared distance
  3020. */
  3021. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3022. /**
  3023. * Returns a new Vector3 located at the center between "value1" and "value2"
  3024. * @param value1 defines the first operand
  3025. * @param value2 defines the second operand
  3026. * @returns the new Vector3
  3027. */
  3028. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3031. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3032. * to something in order to rotate it from its local system to the given target system
  3033. * Note: axis1, axis2 and axis3 are normalized during this operation
  3034. * @param axis1 defines the first axis
  3035. * @param axis2 defines the second axis
  3036. * @param axis3 defines the third axis
  3037. * @returns a new Vector3
  3038. */
  3039. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3040. /**
  3041. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3042. * @param axis1 defines the first axis
  3043. * @param axis2 defines the second axis
  3044. * @param axis3 defines the third axis
  3045. * @param ref defines the Vector3 where to store the result
  3046. */
  3047. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3048. }
  3049. /**
  3050. * Vector4 class created for EulerAngle class conversion to Quaternion
  3051. */
  3052. export class Vector4 {
  3053. /** x value of the vector */
  3054. x: number;
  3055. /** y value of the vector */
  3056. y: number;
  3057. /** z value of the vector */
  3058. z: number;
  3059. /** w value of the vector */
  3060. w: number;
  3061. /**
  3062. * Creates a Vector4 object from the given floats.
  3063. * @param x x value of the vector
  3064. * @param y y value of the vector
  3065. * @param z z value of the vector
  3066. * @param w w value of the vector
  3067. */
  3068. constructor(
  3069. /** x value of the vector */
  3070. x: number,
  3071. /** y value of the vector */
  3072. y: number,
  3073. /** z value of the vector */
  3074. z: number,
  3075. /** w value of the vector */
  3076. w: number);
  3077. /**
  3078. * Returns the string with the Vector4 coordinates.
  3079. * @returns a string containing all the vector values
  3080. */
  3081. toString(): string;
  3082. /**
  3083. * Returns the string "Vector4".
  3084. * @returns "Vector4"
  3085. */
  3086. getClassName(): string;
  3087. /**
  3088. * Returns the Vector4 hash code.
  3089. * @returns a unique hash code
  3090. */
  3091. getHashCode(): number;
  3092. /**
  3093. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3094. * @returns the resulting array
  3095. */
  3096. asArray(): number[];
  3097. /**
  3098. * Populates the given array from the given index with the Vector4 coordinates.
  3099. * @param array array to populate
  3100. * @param index index of the array to start at (default: 0)
  3101. * @returns the Vector4.
  3102. */
  3103. toArray(array: FloatArray, index?: number): Vector4;
  3104. /**
  3105. * Adds the given vector to the current Vector4.
  3106. * @param otherVector the vector to add
  3107. * @returns the updated Vector4.
  3108. */
  3109. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3110. /**
  3111. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3112. * @param otherVector the vector to add
  3113. * @returns the resulting vector
  3114. */
  3115. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3116. /**
  3117. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3118. * @param otherVector the vector to add
  3119. * @param result the vector to store the result
  3120. * @returns the current Vector4.
  3121. */
  3122. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3123. /**
  3124. * Subtract in place the given vector from the current Vector4.
  3125. * @param otherVector the vector to subtract
  3126. * @returns the updated Vector4.
  3127. */
  3128. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3129. /**
  3130. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3131. * @param otherVector the vector to add
  3132. * @returns the new vector with the result
  3133. */
  3134. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3135. /**
  3136. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3137. * @param otherVector the vector to subtract
  3138. * @param result the vector to store the result
  3139. * @returns the current Vector4.
  3140. */
  3141. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3142. /**
  3143. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3144. */
  3145. /**
  3146. * Returns a new Vector4 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. * @returns new vector containing the result
  3152. */
  3153. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3154. /**
  3155. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3156. * @param x value to subtract
  3157. * @param y value to subtract
  3158. * @param z value to subtract
  3159. * @param w value to subtract
  3160. * @param result the vector to store the result in
  3161. * @returns the current Vector4.
  3162. */
  3163. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3166. * @returns a new vector with the negated values
  3167. */
  3168. negate(): Vector4;
  3169. /**
  3170. * Negate this vector in place
  3171. * @returns this
  3172. */
  3173. negateInPlace(): Vector4;
  3174. /**
  3175. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3176. * @param result defines the Vector3 object where to store the result
  3177. * @returns the current Vector4
  3178. */
  3179. negateToRef(result: Vector4): Vector4;
  3180. /**
  3181. * Multiplies the current Vector4 coordinates by scale (float).
  3182. * @param scale the number to scale with
  3183. * @returns the updated Vector4.
  3184. */
  3185. scaleInPlace(scale: number): Vector4;
  3186. /**
  3187. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3188. * @param scale the number to scale with
  3189. * @returns a new vector with the result
  3190. */
  3191. scale(scale: number): Vector4;
  3192. /**
  3193. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3194. * @param scale the number to scale with
  3195. * @param result a vector to store the result in
  3196. * @returns the current Vector4.
  3197. */
  3198. scaleToRef(scale: number, result: Vector4): Vector4;
  3199. /**
  3200. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3201. * @param scale defines the scale factor
  3202. * @param result defines the Vector4 object where to store the result
  3203. * @returns the unmodified current Vector4
  3204. */
  3205. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3206. /**
  3207. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3208. * @param otherVector the vector to compare against
  3209. * @returns true if they are equal
  3210. */
  3211. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3212. /**
  3213. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3214. * @param otherVector vector to compare against
  3215. * @param epsilon (Default: very small number)
  3216. * @returns true if they are equal
  3217. */
  3218. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3219. /**
  3220. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3221. * @param x x value to compare against
  3222. * @param y y value to compare against
  3223. * @param z z value to compare against
  3224. * @param w w value to compare against
  3225. * @returns true if equal
  3226. */
  3227. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3228. /**
  3229. * Multiplies in place the current Vector4 by the given one.
  3230. * @param otherVector vector to multiple with
  3231. * @returns the updated Vector4.
  3232. */
  3233. multiplyInPlace(otherVector: Vector4): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3236. * @param otherVector vector to multiple with
  3237. * @returns resulting new vector
  3238. */
  3239. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3242. * @param otherVector vector to multiple with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3249. * @param x x value multiply with
  3250. * @param y y value multiply with
  3251. * @param z z value multiply with
  3252. * @param w w value multiply with
  3253. * @returns resulting new vector
  3254. */
  3255. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3256. /**
  3257. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3258. * @param otherVector vector to devide with
  3259. * @returns resulting new vector
  3260. */
  3261. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3262. /**
  3263. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3264. * @param otherVector vector to devide with
  3265. * @param result vector to store the result
  3266. * @returns the current Vector4.
  3267. */
  3268. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3269. /**
  3270. * Divides the current Vector3 coordinates by the given ones.
  3271. * @param otherVector vector to devide with
  3272. * @returns the updated Vector3.
  3273. */
  3274. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3275. /**
  3276. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3277. * @param other defines the second operand
  3278. * @returns the current updated Vector4
  3279. */
  3280. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3281. /**
  3282. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3283. * @param other defines the second operand
  3284. * @returns the current updated Vector4
  3285. */
  3286. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3287. /**
  3288. * Gets a new Vector4 from current Vector4 floored values
  3289. * @returns a new Vector4
  3290. */
  3291. floor(): Vector4;
  3292. /**
  3293. * Gets a new Vector4 from current Vector3 floored values
  3294. * @returns a new Vector4
  3295. */
  3296. fract(): Vector4;
  3297. /**
  3298. * Returns the Vector4 length (float).
  3299. * @returns the length
  3300. */
  3301. length(): number;
  3302. /**
  3303. * Returns the Vector4 squared length (float).
  3304. * @returns the length squared
  3305. */
  3306. lengthSquared(): number;
  3307. /**
  3308. * Normalizes in place the Vector4.
  3309. * @returns the updated Vector4.
  3310. */
  3311. normalize(): Vector4;
  3312. /**
  3313. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3314. * @returns this converted to a new vector3
  3315. */
  3316. toVector3(): Vector3;
  3317. /**
  3318. * Returns a new Vector4 copied from the current one.
  3319. * @returns the new cloned vector
  3320. */
  3321. clone(): Vector4;
  3322. /**
  3323. * Updates the current Vector4 with the given one coordinates.
  3324. * @param source the source vector to copy from
  3325. * @returns the updated Vector4.
  3326. */
  3327. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3328. /**
  3329. * Updates the current Vector4 coordinates with the given floats.
  3330. * @param x float to copy from
  3331. * @param y float to copy from
  3332. * @param z float to copy from
  3333. * @param w float to copy from
  3334. * @returns the updated Vector4.
  3335. */
  3336. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3337. /**
  3338. * Updates the current Vector4 coordinates with the given floats.
  3339. * @param x float to set from
  3340. * @param y float to set from
  3341. * @param z float to set from
  3342. * @param w float to set from
  3343. * @returns the updated Vector4.
  3344. */
  3345. set(x: number, y: number, z: number, w: number): Vector4;
  3346. /**
  3347. * Copies the given float to the current Vector3 coordinates
  3348. * @param v defines the x, y, z and w coordinates of the operand
  3349. * @returns the current updated Vector3
  3350. */
  3351. setAll(v: number): Vector4;
  3352. /**
  3353. * Returns a new Vector4 set from the starting index of the given array.
  3354. * @param array the array to pull values from
  3355. * @param offset the offset into the array to start at
  3356. * @returns the new vector
  3357. */
  3358. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3359. /**
  3360. * Updates the given vector "result" from the starting index of the given array.
  3361. * @param array the array to pull values from
  3362. * @param offset the offset into the array to start at
  3363. * @param result the vector to store the result in
  3364. */
  3365. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3366. /**
  3367. * Updates the given vector "result" from the starting index of the given Float32Array.
  3368. * @param array the array to pull values from
  3369. * @param offset the offset into the array to start at
  3370. * @param result the vector to store the result in
  3371. */
  3372. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3373. /**
  3374. * Updates the given vector "result" coordinates from the given floats.
  3375. * @param x float to set from
  3376. * @param y float to set from
  3377. * @param z float to set from
  3378. * @param w float to set from
  3379. * @param result the vector to the floats in
  3380. */
  3381. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3382. /**
  3383. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3384. * @returns the new vector
  3385. */
  3386. static Zero(): Vector4;
  3387. /**
  3388. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3389. * @returns the new vector
  3390. */
  3391. static One(): Vector4;
  3392. /**
  3393. * Returns a new normalized Vector4 from the given one.
  3394. * @param vector the vector to normalize
  3395. * @returns the vector
  3396. */
  3397. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3398. /**
  3399. * Updates the given vector "result" from the normalization of the given one.
  3400. * @param vector the vector to normalize
  3401. * @param result the vector to store the result in
  3402. */
  3403. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3404. /**
  3405. * Returns a vector with the minimum values from the left and right vectors
  3406. * @param left left vector to minimize
  3407. * @param right right vector to minimize
  3408. * @returns a new vector with the minimum of the left and right vector values
  3409. */
  3410. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3411. /**
  3412. * Returns a vector with the maximum values from the left and right vectors
  3413. * @param left left vector to maximize
  3414. * @param right right vector to maximize
  3415. * @returns a new vector with the maximum of the left and right vector values
  3416. */
  3417. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3418. /**
  3419. * Returns the distance (float) between the vectors "value1" and "value2".
  3420. * @param value1 value to calulate the distance between
  3421. * @param value2 value to calulate the distance between
  3422. * @return the distance between the two vectors
  3423. */
  3424. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3425. /**
  3426. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3427. * @param value1 value to calulate the distance between
  3428. * @param value2 value to calulate the distance between
  3429. * @return the distance between the two vectors squared
  3430. */
  3431. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3432. /**
  3433. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3434. * @param value1 value to calulate the center between
  3435. * @param value2 value to calulate the center between
  3436. * @return the center between the two vectors
  3437. */
  3438. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3441. * This methods computes transformed normalized direction vectors only.
  3442. * @param vector the vector to transform
  3443. * @param transformation the transformation matrix to apply
  3444. * @returns the new vector
  3445. */
  3446. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3447. /**
  3448. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3449. * This methods computes transformed normalized direction vectors only.
  3450. * @param vector the vector to transform
  3451. * @param transformation the transformation matrix to apply
  3452. * @param result the vector to store the result in
  3453. */
  3454. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3455. /**
  3456. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3457. * This methods computes transformed normalized direction vectors only.
  3458. * @param x value to transform
  3459. * @param y value to transform
  3460. * @param z value to transform
  3461. * @param w value to transform
  3462. * @param transformation the transformation matrix to apply
  3463. * @param result the vector to store the results in
  3464. */
  3465. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3466. /**
  3467. * Creates a new Vector4 from a Vector3
  3468. * @param source defines the source data
  3469. * @param w defines the 4th component (default is 0)
  3470. * @returns a new Vector4
  3471. */
  3472. static FromVector3(source: Vector3, w?: number): Vector4;
  3473. }
  3474. /**
  3475. * Class used to store quaternion data
  3476. * @see https://en.wikipedia.org/wiki/Quaternion
  3477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3478. */
  3479. export class Quaternion {
  3480. /** defines the first component (0 by default) */
  3481. x: number;
  3482. /** defines the second component (0 by default) */
  3483. y: number;
  3484. /** defines the third component (0 by default) */
  3485. z: number;
  3486. /** defines the fourth component (1.0 by default) */
  3487. w: number;
  3488. /**
  3489. * Creates a new Quaternion from the given floats
  3490. * @param x defines the first component (0 by default)
  3491. * @param y defines the second component (0 by default)
  3492. * @param z defines the third component (0 by default)
  3493. * @param w defines the fourth component (1.0 by default)
  3494. */
  3495. constructor(
  3496. /** defines the first component (0 by default) */
  3497. x?: number,
  3498. /** defines the second component (0 by default) */
  3499. y?: number,
  3500. /** defines the third component (0 by default) */
  3501. z?: number,
  3502. /** defines the fourth component (1.0 by default) */
  3503. w?: number);
  3504. /**
  3505. * Gets a string representation for the current quaternion
  3506. * @returns a string with the Quaternion coordinates
  3507. */
  3508. toString(): string;
  3509. /**
  3510. * Gets the class name of the quaternion
  3511. * @returns the string "Quaternion"
  3512. */
  3513. getClassName(): string;
  3514. /**
  3515. * Gets a hash code for this quaternion
  3516. * @returns the quaternion hash code
  3517. */
  3518. getHashCode(): number;
  3519. /**
  3520. * Copy the quaternion to an array
  3521. * @returns a new array populated with 4 elements from the quaternion coordinates
  3522. */
  3523. asArray(): number[];
  3524. /**
  3525. * Check if two quaternions are equals
  3526. * @param otherQuaternion defines the second operand
  3527. * @return true if the current quaternion and the given one coordinates are strictly equals
  3528. */
  3529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3530. /**
  3531. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3532. * @param otherQuaternion defines the other quaternion
  3533. * @param epsilon defines the minimal distance to consider equality
  3534. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3535. */
  3536. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3537. /**
  3538. * Clone the current quaternion
  3539. * @returns a new quaternion copied from the current one
  3540. */
  3541. clone(): Quaternion;
  3542. /**
  3543. * Copy a quaternion to the current one
  3544. * @param other defines the other quaternion
  3545. * @returns the updated current quaternion
  3546. */
  3547. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3548. /**
  3549. * Updates the current quaternion with 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. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3557. /**
  3558. * Updates the current quaternion from the given float coordinates
  3559. * @param x defines the x coordinate
  3560. * @param y defines the y coordinate
  3561. * @param z defines the z coordinate
  3562. * @param w defines the w coordinate
  3563. * @returns the updated current quaternion
  3564. */
  3565. set(x: number, y: number, z: number, w: number): Quaternion;
  3566. /**
  3567. * Adds two quaternions
  3568. * @param other defines the second operand
  3569. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3570. */
  3571. add(other: DeepImmutable<Quaternion>): Quaternion;
  3572. /**
  3573. * Add a quaternion to the current one
  3574. * @param other defines the quaternion to add
  3575. * @returns the current quaternion
  3576. */
  3577. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3578. /**
  3579. * Subtract two quaternions
  3580. * @param other defines the second operand
  3581. * @returns a new quaternion as the subtraction result of the given one from the current one
  3582. */
  3583. subtract(other: Quaternion): Quaternion;
  3584. /**
  3585. * Multiplies the current quaternion by a scale factor
  3586. * @param value defines the scale factor
  3587. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3588. */
  3589. scale(value: number): Quaternion;
  3590. /**
  3591. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3592. * @param scale defines the scale factor
  3593. * @param result defines the Quaternion object where to store the result
  3594. * @returns the unmodified current quaternion
  3595. */
  3596. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3597. /**
  3598. * Multiplies in place the current quaternion by a scale factor
  3599. * @param value defines the scale factor
  3600. * @returns the current modified quaternion
  3601. */
  3602. scaleInPlace(value: number): Quaternion;
  3603. /**
  3604. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3605. * @param scale defines the scale factor
  3606. * @param result defines the Quaternion object where to store the result
  3607. * @returns the unmodified current quaternion
  3608. */
  3609. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3610. /**
  3611. * Multiplies two quaternions
  3612. * @param q1 defines the second operand
  3613. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3614. */
  3615. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3616. /**
  3617. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3618. * @param q1 defines the second operand
  3619. * @param result defines the target quaternion
  3620. * @returns the current quaternion
  3621. */
  3622. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3623. /**
  3624. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3625. * @param q1 defines the second operand
  3626. * @returns the currentupdated quaternion
  3627. */
  3628. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3629. /**
  3630. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3631. * @param ref defines the target quaternion
  3632. * @returns the current quaternion
  3633. */
  3634. conjugateToRef(ref: Quaternion): Quaternion;
  3635. /**
  3636. * Conjugates in place (1-q) the current quaternion
  3637. * @returns the current updated quaternion
  3638. */
  3639. conjugateInPlace(): Quaternion;
  3640. /**
  3641. * Conjugates in place (1-q) the current quaternion
  3642. * @returns a new quaternion
  3643. */
  3644. conjugate(): Quaternion;
  3645. /**
  3646. * Gets length of current quaternion
  3647. * @returns the quaternion length (float)
  3648. */
  3649. length(): number;
  3650. /**
  3651. * Normalize in place the current quaternion
  3652. * @returns the current updated quaternion
  3653. */
  3654. normalize(): Quaternion;
  3655. /**
  3656. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3657. * @param order is a reserved parameter and is ignore for now
  3658. * @returns a new Vector3 containing the Euler angles
  3659. */
  3660. toEulerAngles(order?: string): Vector3;
  3661. /**
  3662. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3663. * @param result defines the vector which will be filled with the Euler angles
  3664. * @param order is a reserved parameter and is ignore for now
  3665. * @returns the current unchanged quaternion
  3666. */
  3667. toEulerAnglesToRef(result: Vector3): Quaternion;
  3668. /**
  3669. * Updates the given rotation matrix with the current quaternion values
  3670. * @param result defines the target matrix
  3671. * @returns the current unchanged quaternion
  3672. */
  3673. toRotationMatrix(result: Matrix): Quaternion;
  3674. /**
  3675. * Updates the current quaternion from the given rotation matrix values
  3676. * @param matrix defines the source matrix
  3677. * @returns the current updated quaternion
  3678. */
  3679. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3680. /**
  3681. * Creates a new quaternion from a rotation matrix
  3682. * @param matrix defines the source matrix
  3683. * @returns a new quaternion created from the given rotation matrix values
  3684. */
  3685. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3686. /**
  3687. * Updates the given quaternion with the given rotation matrix values
  3688. * @param matrix defines the source matrix
  3689. * @param result defines the target quaternion
  3690. */
  3691. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3692. /**
  3693. * Returns the dot product (float) between the quaternions "left" and "right"
  3694. * @param left defines the left operand
  3695. * @param right defines the right operand
  3696. * @returns the dot product
  3697. */
  3698. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3699. /**
  3700. * Checks if the two quaternions are close to each other
  3701. * @param quat0 defines the first quaternion to check
  3702. * @param quat1 defines the second quaternion to check
  3703. * @returns true if the two quaternions are close to each other
  3704. */
  3705. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates an empty quaternion
  3708. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3709. */
  3710. static Zero(): Quaternion;
  3711. /**
  3712. * Inverse a given quaternion
  3713. * @param q defines the source quaternion
  3714. * @returns a new quaternion as the inverted current quaternion
  3715. */
  3716. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3717. /**
  3718. * Inverse a given quaternion
  3719. * @param q defines the source quaternion
  3720. * @param result the quaternion the result will be stored in
  3721. * @returns the result quaternion
  3722. */
  3723. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3724. /**
  3725. * Creates an identity quaternion
  3726. * @returns the identity quaternion
  3727. */
  3728. static Identity(): Quaternion;
  3729. /**
  3730. * Gets a boolean indicating if the given quaternion is identity
  3731. * @param quaternion defines the quaternion to check
  3732. * @returns true if the quaternion is identity
  3733. */
  3734. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3735. /**
  3736. * Creates a quaternion from a rotation around an axis
  3737. * @param axis defines the axis to use
  3738. * @param angle defines the angle to use
  3739. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3740. */
  3741. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3742. /**
  3743. * Creates a rotation around an axis and stores it into the given quaternion
  3744. * @param axis defines the axis to use
  3745. * @param angle defines the angle to use
  3746. * @param result defines the target quaternion
  3747. * @returns the target quaternion
  3748. */
  3749. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3750. /**
  3751. * Creates a new quaternion from data stored into an array
  3752. * @param array defines the data source
  3753. * @param offset defines the offset in the source array where the data starts
  3754. * @returns a new quaternion
  3755. */
  3756. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3757. /**
  3758. * Create a quaternion from Euler rotation angles
  3759. * @param x Pitch
  3760. * @param y Yaw
  3761. * @param z Roll
  3762. * @returns the new Quaternion
  3763. */
  3764. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3765. /**
  3766. * Updates a quaternion from Euler rotation angles
  3767. * @param x Pitch
  3768. * @param y Yaw
  3769. * @param z Roll
  3770. * @param result the quaternion to store the result
  3771. * @returns the updated quaternion
  3772. */
  3773. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3774. /**
  3775. * Create a quaternion from Euler rotation vector
  3776. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3777. * @returns the new Quaternion
  3778. */
  3779. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3780. /**
  3781. * Updates a quaternion from Euler rotation vector
  3782. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3783. * @param result the quaternion to store the result
  3784. * @returns the updated quaternion
  3785. */
  3786. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3787. /**
  3788. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3789. * @param yaw defines the rotation around Y axis
  3790. * @param pitch defines the rotation around X axis
  3791. * @param roll defines the rotation around Z axis
  3792. * @returns the new quaternion
  3793. */
  3794. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3795. /**
  3796. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3797. * @param yaw defines the rotation around Y axis
  3798. * @param pitch defines the rotation around X axis
  3799. * @param roll defines the rotation around Z axis
  3800. * @param result defines the target quaternion
  3801. */
  3802. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3803. /**
  3804. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3805. * @param alpha defines the rotation around first axis
  3806. * @param beta defines the rotation around second axis
  3807. * @param gamma defines the rotation around third axis
  3808. * @returns the new quaternion
  3809. */
  3810. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3811. /**
  3812. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3813. * @param alpha defines the rotation around first axis
  3814. * @param beta defines the rotation around second axis
  3815. * @param gamma defines the rotation around third axis
  3816. * @param result defines the target quaternion
  3817. */
  3818. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3819. /**
  3820. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3821. * @param axis1 defines the first axis
  3822. * @param axis2 defines the second axis
  3823. * @param axis3 defines the third axis
  3824. * @returns the new quaternion
  3825. */
  3826. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3827. /**
  3828. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3829. * @param axis1 defines the first axis
  3830. * @param axis2 defines the second axis
  3831. * @param axis3 defines the third axis
  3832. * @param ref defines the target quaternion
  3833. */
  3834. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3835. /**
  3836. * Interpolates between two quaternions
  3837. * @param left defines first quaternion
  3838. * @param right defines second quaternion
  3839. * @param amount defines the gradient to use
  3840. * @returns the new interpolated quaternion
  3841. */
  3842. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3843. /**
  3844. * Interpolates between two quaternions and stores it into a target quaternion
  3845. * @param left defines first quaternion
  3846. * @param right defines second quaternion
  3847. * @param amount defines the gradient to use
  3848. * @param result defines the target quaternion
  3849. */
  3850. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3851. /**
  3852. * Interpolate between two quaternions using Hermite interpolation
  3853. * @param value1 defines first quaternion
  3854. * @param tangent1 defines the incoming tangent
  3855. * @param value2 defines second quaternion
  3856. * @param tangent2 defines the outgoing tangent
  3857. * @param amount defines the target quaternion
  3858. * @returns the new interpolated quaternion
  3859. */
  3860. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3861. }
  3862. /**
  3863. * Class used to store matrix data (4x4)
  3864. */
  3865. export class Matrix {
  3866. private static _updateFlagSeed;
  3867. private static _identityReadOnly;
  3868. private _isIdentity;
  3869. private _isIdentityDirty;
  3870. private _isIdentity3x2;
  3871. private _isIdentity3x2Dirty;
  3872. /**
  3873. * Gets the update flag of the matrix which is an unique number for the matrix.
  3874. * It will be incremented every time the matrix data change.
  3875. * You can use it to speed the comparison between two versions of the same matrix.
  3876. */
  3877. updateFlag: number;
  3878. private readonly _m;
  3879. /**
  3880. * Gets the internal data of the matrix
  3881. */
  3882. get m(): DeepImmutable<Float32Array>;
  3883. /** @hidden */
  3884. _markAsUpdated(): void;
  3885. /** @hidden */
  3886. private _updateIdentityStatus;
  3887. /**
  3888. * Creates an empty matrix (filled with zeros)
  3889. */
  3890. constructor();
  3891. /**
  3892. * Check if the current matrix is identity
  3893. * @returns true is the matrix is the identity matrix
  3894. */
  3895. isIdentity(): boolean;
  3896. /**
  3897. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3898. * @returns true is the matrix is the identity matrix
  3899. */
  3900. isIdentityAs3x2(): boolean;
  3901. /**
  3902. * Gets the determinant of the matrix
  3903. * @returns the matrix determinant
  3904. */
  3905. determinant(): number;
  3906. /**
  3907. * Returns the matrix as a Float32Array
  3908. * @returns the matrix underlying array
  3909. */
  3910. toArray(): DeepImmutable<Float32Array>;
  3911. /**
  3912. * Returns the matrix as a Float32Array
  3913. * @returns the matrix underlying array.
  3914. */
  3915. asArray(): DeepImmutable<Float32Array>;
  3916. /**
  3917. * Inverts the current matrix in place
  3918. * @returns the current inverted matrix
  3919. */
  3920. invert(): Matrix;
  3921. /**
  3922. * Sets all the matrix elements to zero
  3923. * @returns the current matrix
  3924. */
  3925. reset(): Matrix;
  3926. /**
  3927. * Adds the current matrix with a second one
  3928. * @param other defines the matrix to add
  3929. * @returns a new matrix as the addition of the current matrix and the given one
  3930. */
  3931. add(other: DeepImmutable<Matrix>): Matrix;
  3932. /**
  3933. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3934. * @param other defines the matrix to add
  3935. * @param result defines the target matrix
  3936. * @returns the current matrix
  3937. */
  3938. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3939. /**
  3940. * Adds in place the given matrix to the current matrix
  3941. * @param other defines the second operand
  3942. * @returns the current updated matrix
  3943. */
  3944. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3945. /**
  3946. * Sets the given matrix to the current inverted Matrix
  3947. * @param other defines the target matrix
  3948. * @returns the unmodified current matrix
  3949. */
  3950. invertToRef(other: Matrix): Matrix;
  3951. /**
  3952. * add a value at the specified position in the current Matrix
  3953. * @param index the index of the value within the matrix. between 0 and 15.
  3954. * @param value the value to be added
  3955. * @returns the current updated matrix
  3956. */
  3957. addAtIndex(index: number, value: number): Matrix;
  3958. /**
  3959. * mutiply the specified position in the current Matrix by a value
  3960. * @param index the index of the value within the matrix. between 0 and 15.
  3961. * @param value the value to be added
  3962. * @returns the current updated matrix
  3963. */
  3964. multiplyAtIndex(index: number, value: number): Matrix;
  3965. /**
  3966. * Inserts the translation vector (using 3 floats) in the current matrix
  3967. * @param x defines the 1st component of the translation
  3968. * @param y defines the 2nd component of the translation
  3969. * @param z defines the 3rd component of the translation
  3970. * @returns the current updated matrix
  3971. */
  3972. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3973. /**
  3974. * Adds the translation vector (using 3 floats) in the current matrix
  3975. * @param x defines the 1st component of the translation
  3976. * @param y defines the 2nd component of the translation
  3977. * @param z defines the 3rd component of the translation
  3978. * @returns the current updated matrix
  3979. */
  3980. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3981. /**
  3982. * Inserts the translation vector in the current matrix
  3983. * @param vector3 defines the translation to insert
  3984. * @returns the current updated matrix
  3985. */
  3986. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3987. /**
  3988. * Gets the translation value of the current matrix
  3989. * @returns a new Vector3 as the extracted translation from the matrix
  3990. */
  3991. getTranslation(): Vector3;
  3992. /**
  3993. * Fill a Vector3 with the extracted translation from the matrix
  3994. * @param result defines the Vector3 where to store the translation
  3995. * @returns the current matrix
  3996. */
  3997. getTranslationToRef(result: Vector3): Matrix;
  3998. /**
  3999. * Remove rotation and scaling part from the matrix
  4000. * @returns the updated matrix
  4001. */
  4002. removeRotationAndScaling(): Matrix;
  4003. /**
  4004. * Multiply two matrices
  4005. * @param other defines the second operand
  4006. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4007. */
  4008. multiply(other: DeepImmutable<Matrix>): Matrix;
  4009. /**
  4010. * Copy the current matrix from the given one
  4011. * @param other defines the source matrix
  4012. * @returns the current updated matrix
  4013. */
  4014. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4015. /**
  4016. * Populates the given array from the starting index with the current matrix values
  4017. * @param array defines the target array
  4018. * @param offset defines the offset in the target array where to start storing values
  4019. * @returns the current matrix
  4020. */
  4021. copyToArray(array: Float32Array, offset?: number): Matrix;
  4022. /**
  4023. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4024. * @param other defines the second operand
  4025. * @param result defines the matrix where to store the multiplication
  4026. * @returns the current matrix
  4027. */
  4028. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4029. /**
  4030. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4031. * @param other defines the second operand
  4032. * @param result defines the array where to store the multiplication
  4033. * @param offset defines the offset in the target array where to start storing values
  4034. * @returns the current matrix
  4035. */
  4036. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4037. /**
  4038. * Check equality between this matrix and a second one
  4039. * @param value defines the second matrix to compare
  4040. * @returns true is the current matrix and the given one values are strictly equal
  4041. */
  4042. equals(value: DeepImmutable<Matrix>): boolean;
  4043. /**
  4044. * Clone the current matrix
  4045. * @returns a new matrix from the current matrix
  4046. */
  4047. clone(): Matrix;
  4048. /**
  4049. * Returns the name of the current matrix class
  4050. * @returns the string "Matrix"
  4051. */
  4052. getClassName(): string;
  4053. /**
  4054. * Gets the hash code of the current matrix
  4055. * @returns the hash code
  4056. */
  4057. getHashCode(): number;
  4058. /**
  4059. * Decomposes the current Matrix into a translation, rotation and scaling components
  4060. * @param scale defines the scale vector3 given as a reference to update
  4061. * @param rotation defines the rotation quaternion given as a reference to update
  4062. * @param translation defines the translation vector3 given as a reference to update
  4063. * @returns true if operation was successful
  4064. */
  4065. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4066. /**
  4067. * Gets specific row of the matrix
  4068. * @param index defines the number of the row to get
  4069. * @returns the index-th row of the current matrix as a new Vector4
  4070. */
  4071. getRow(index: number): Nullable<Vector4>;
  4072. /**
  4073. * Sets the index-th row of the current matrix to the vector4 values
  4074. * @param index defines the number of the row to set
  4075. * @param row defines the target vector4
  4076. * @returns the updated current matrix
  4077. */
  4078. setRow(index: number, row: Vector4): Matrix;
  4079. /**
  4080. * Compute the transpose of the matrix
  4081. * @returns the new transposed matrix
  4082. */
  4083. transpose(): Matrix;
  4084. /**
  4085. * Compute the transpose of the matrix and store it in a given matrix
  4086. * @param result defines the target matrix
  4087. * @returns the current matrix
  4088. */
  4089. transposeToRef(result: Matrix): Matrix;
  4090. /**
  4091. * Sets the index-th row of the current matrix with the given 4 x float values
  4092. * @param index defines the row index
  4093. * @param x defines the x component to set
  4094. * @param y defines the y component to set
  4095. * @param z defines the z component to set
  4096. * @param w defines the w component to set
  4097. * @returns the updated current matrix
  4098. */
  4099. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4100. /**
  4101. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4102. * @param scale defines the scale factor
  4103. * @returns a new matrix
  4104. */
  4105. scale(scale: number): Matrix;
  4106. /**
  4107. * Scale the current matrix values by a factor to a given result matrix
  4108. * @param scale defines the scale factor
  4109. * @param result defines the matrix to store the result
  4110. * @returns the current matrix
  4111. */
  4112. scaleToRef(scale: number, result: Matrix): Matrix;
  4113. /**
  4114. * Scale the current matrix values by a factor and add the result to a given matrix
  4115. * @param scale defines the scale factor
  4116. * @param result defines the Matrix to store the result
  4117. * @returns the current matrix
  4118. */
  4119. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4120. /**
  4121. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4122. * @param ref matrix to store the result
  4123. */
  4124. toNormalMatrix(ref: Matrix): void;
  4125. /**
  4126. * Gets only rotation part of the current matrix
  4127. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4128. */
  4129. getRotationMatrix(): Matrix;
  4130. /**
  4131. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4132. * @param result defines the target matrix to store data to
  4133. * @returns the current matrix
  4134. */
  4135. getRotationMatrixToRef(result: Matrix): Matrix;
  4136. /**
  4137. * Toggles model matrix from being right handed to left handed in place and vice versa
  4138. */
  4139. toggleModelMatrixHandInPlace(): void;
  4140. /**
  4141. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4142. */
  4143. toggleProjectionMatrixHandInPlace(): void;
  4144. /**
  4145. * Creates a matrix from an array
  4146. * @param array defines the source array
  4147. * @param offset defines an offset in the source array
  4148. * @returns a new Matrix set from the starting index of the given array
  4149. */
  4150. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4151. /**
  4152. * Copy the content of an array into a given matrix
  4153. * @param array defines the source array
  4154. * @param offset defines an offset in the source array
  4155. * @param result defines the target matrix
  4156. */
  4157. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4158. /**
  4159. * Stores an array into a matrix after having multiplied each component by a given factor
  4160. * @param array defines the source array
  4161. * @param offset defines the offset in the source array
  4162. * @param scale defines the scaling factor
  4163. * @param result defines the target matrix
  4164. */
  4165. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4166. /**
  4167. * Gets an identity matrix that must not be updated
  4168. */
  4169. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4170. /**
  4171. * Stores a list of values (16) inside a given matrix
  4172. * @param initialM11 defines 1st value of 1st row
  4173. * @param initialM12 defines 2nd value of 1st row
  4174. * @param initialM13 defines 3rd value of 1st row
  4175. * @param initialM14 defines 4th value of 1st row
  4176. * @param initialM21 defines 1st value of 2nd row
  4177. * @param initialM22 defines 2nd value of 2nd row
  4178. * @param initialM23 defines 3rd value of 2nd row
  4179. * @param initialM24 defines 4th value of 2nd row
  4180. * @param initialM31 defines 1st value of 3rd row
  4181. * @param initialM32 defines 2nd value of 3rd row
  4182. * @param initialM33 defines 3rd value of 3rd row
  4183. * @param initialM34 defines 4th value of 3rd row
  4184. * @param initialM41 defines 1st value of 4th row
  4185. * @param initialM42 defines 2nd value of 4th row
  4186. * @param initialM43 defines 3rd value of 4th row
  4187. * @param initialM44 defines 4th value of 4th row
  4188. * @param result defines the target matrix
  4189. */
  4190. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4191. /**
  4192. * Creates new matrix from a list of values (16)
  4193. * @param initialM11 defines 1st value of 1st row
  4194. * @param initialM12 defines 2nd value of 1st row
  4195. * @param initialM13 defines 3rd value of 1st row
  4196. * @param initialM14 defines 4th value of 1st row
  4197. * @param initialM21 defines 1st value of 2nd row
  4198. * @param initialM22 defines 2nd value of 2nd row
  4199. * @param initialM23 defines 3rd value of 2nd row
  4200. * @param initialM24 defines 4th value of 2nd row
  4201. * @param initialM31 defines 1st value of 3rd row
  4202. * @param initialM32 defines 2nd value of 3rd row
  4203. * @param initialM33 defines 3rd value of 3rd row
  4204. * @param initialM34 defines 4th value of 3rd row
  4205. * @param initialM41 defines 1st value of 4th row
  4206. * @param initialM42 defines 2nd value of 4th row
  4207. * @param initialM43 defines 3rd value of 4th row
  4208. * @param initialM44 defines 4th value of 4th row
  4209. * @returns the new matrix
  4210. */
  4211. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4212. /**
  4213. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4214. * @param scale defines the scale vector3
  4215. * @param rotation defines the rotation quaternion
  4216. * @param translation defines the translation vector3
  4217. * @returns a new matrix
  4218. */
  4219. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4220. /**
  4221. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4222. * @param scale defines the scale vector3
  4223. * @param rotation defines the rotation quaternion
  4224. * @param translation defines the translation vector3
  4225. * @param result defines the target matrix
  4226. */
  4227. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4228. /**
  4229. * Creates a new identity matrix
  4230. * @returns a new identity matrix
  4231. */
  4232. static Identity(): Matrix;
  4233. /**
  4234. * Creates a new identity matrix and stores the result in a given matrix
  4235. * @param result defines the target matrix
  4236. */
  4237. static IdentityToRef(result: Matrix): void;
  4238. /**
  4239. * Creates a new zero matrix
  4240. * @returns a new zero matrix
  4241. */
  4242. static Zero(): Matrix;
  4243. /**
  4244. * Creates a new rotation matrix for "angle" radians around the X axis
  4245. * @param angle defines the angle (in radians) to use
  4246. * @return the new matrix
  4247. */
  4248. static RotationX(angle: number): Matrix;
  4249. /**
  4250. * Creates a new matrix as the invert of a given matrix
  4251. * @param source defines the source matrix
  4252. * @returns the new matrix
  4253. */
  4254. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4255. /**
  4256. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4257. * @param angle defines the angle (in radians) to use
  4258. * @param result defines the target matrix
  4259. */
  4260. static RotationXToRef(angle: number, result: Matrix): void;
  4261. /**
  4262. * Creates a new rotation matrix for "angle" radians around the Y axis
  4263. * @param angle defines the angle (in radians) to use
  4264. * @return the new matrix
  4265. */
  4266. static RotationY(angle: number): Matrix;
  4267. /**
  4268. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4269. * @param angle defines the angle (in radians) to use
  4270. * @param result defines the target matrix
  4271. */
  4272. static RotationYToRef(angle: number, result: Matrix): void;
  4273. /**
  4274. * Creates a new rotation matrix for "angle" radians around the Z axis
  4275. * @param angle defines the angle (in radians) to use
  4276. * @return the new matrix
  4277. */
  4278. static RotationZ(angle: number): Matrix;
  4279. /**
  4280. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4281. * @param angle defines the angle (in radians) to use
  4282. * @param result defines the target matrix
  4283. */
  4284. static RotationZToRef(angle: number, result: Matrix): void;
  4285. /**
  4286. * Creates a new rotation matrix for "angle" radians around the given axis
  4287. * @param axis defines the axis to use
  4288. * @param angle defines the angle (in radians) to use
  4289. * @return the new matrix
  4290. */
  4291. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4292. /**
  4293. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4294. * @param axis defines the axis to use
  4295. * @param angle defines the angle (in radians) to use
  4296. * @param result defines the target matrix
  4297. */
  4298. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4299. /**
  4300. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4301. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4302. * @param from defines the vector to align
  4303. * @param to defines the vector to align to
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4307. /**
  4308. * Creates a rotation matrix
  4309. * @param yaw defines the yaw angle in radians (Y axis)
  4310. * @param pitch defines the pitch angle in radians (X axis)
  4311. * @param roll defines the roll angle in radians (X axis)
  4312. * @returns the new rotation matrix
  4313. */
  4314. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4315. /**
  4316. * Creates a rotation matrix and stores it in a given matrix
  4317. * @param yaw defines the yaw angle in radians (Y axis)
  4318. * @param pitch defines the pitch angle in radians (X axis)
  4319. * @param roll defines the roll angle in radians (X axis)
  4320. * @param result defines the target matrix
  4321. */
  4322. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4323. /**
  4324. * Creates a scaling matrix
  4325. * @param x defines the scale factor on X axis
  4326. * @param y defines the scale factor on Y axis
  4327. * @param z defines the scale factor on Z axis
  4328. * @returns the new matrix
  4329. */
  4330. static Scaling(x: number, y: number, z: number): Matrix;
  4331. /**
  4332. * Creates a scaling matrix and stores it in a given matrix
  4333. * @param x defines the scale factor on X axis
  4334. * @param y defines the scale factor on Y axis
  4335. * @param z defines the scale factor on Z axis
  4336. * @param result defines the target matrix
  4337. */
  4338. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4339. /**
  4340. * Creates a translation matrix
  4341. * @param x defines the translation on X axis
  4342. * @param y defines the translation on Y axis
  4343. * @param z defines the translationon Z axis
  4344. * @returns the new matrix
  4345. */
  4346. static Translation(x: number, y: number, z: number): Matrix;
  4347. /**
  4348. * Creates a translation matrix and stores it in a given matrix
  4349. * @param x defines the translation on X axis
  4350. * @param y defines the translation on Y axis
  4351. * @param z defines the translationon Z axis
  4352. * @param result defines the target matrix
  4353. */
  4354. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4355. /**
  4356. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4357. * @param startValue defines the start value
  4358. * @param endValue defines the end value
  4359. * @param gradient defines the gradient factor
  4360. * @returns the new matrix
  4361. */
  4362. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4363. /**
  4364. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4365. * @param startValue defines the start value
  4366. * @param endValue defines the end value
  4367. * @param gradient defines the gradient factor
  4368. * @param result defines the Matrix object where to store data
  4369. */
  4370. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4371. /**
  4372. * Builds a new matrix whose values are computed by:
  4373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4376. * @param startValue defines the first matrix
  4377. * @param endValue defines the second matrix
  4378. * @param gradient defines the gradient between the two matrices
  4379. * @returns the new matrix
  4380. */
  4381. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4382. /**
  4383. * Update a matrix to values which are computed by:
  4384. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4385. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4386. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4387. * @param startValue defines the first matrix
  4388. * @param endValue defines the second matrix
  4389. * @param gradient defines the gradient between the two matrices
  4390. * @param result defines the target matrix
  4391. */
  4392. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4393. /**
  4394. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4395. * This function works in left handed mode
  4396. * @param eye defines the final position of the entity
  4397. * @param target defines where the entity should look at
  4398. * @param up defines the up vector for the entity
  4399. * @returns the new matrix
  4400. */
  4401. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4402. /**
  4403. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4404. * This function works in left handed mode
  4405. * @param eye defines the final position of the entity
  4406. * @param target defines where the entity should look at
  4407. * @param up defines the up vector for the entity
  4408. * @param result defines the target matrix
  4409. */
  4410. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4411. /**
  4412. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4413. * This function works in right handed mode
  4414. * @param eye defines the final position of the entity
  4415. * @param target defines where the entity should look at
  4416. * @param up defines the up vector for the entity
  4417. * @returns the new matrix
  4418. */
  4419. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4420. /**
  4421. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4422. * This function works in right handed mode
  4423. * @param eye defines the final position of the entity
  4424. * @param target defines where the entity should look at
  4425. * @param up defines the up vector for the entity
  4426. * @param result defines the target matrix
  4427. */
  4428. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4429. /**
  4430. * Create a left-handed orthographic projection matrix
  4431. * @param width defines the viewport width
  4432. * @param height defines the viewport height
  4433. * @param znear defines the near clip plane
  4434. * @param zfar defines the far clip plane
  4435. * @returns a new matrix as a left-handed orthographic projection matrix
  4436. */
  4437. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4438. /**
  4439. * Store a left-handed orthographic projection to a given matrix
  4440. * @param width defines the viewport width
  4441. * @param height defines the viewport height
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @param result defines the target matrix
  4445. */
  4446. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4447. /**
  4448. * Create a left-handed orthographic projection matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @returns a new matrix as a left-handed orthographic projection matrix
  4456. */
  4457. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4458. /**
  4459. * Stores a left-handed orthographic projection into a given matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @param result defines the target matrix
  4467. */
  4468. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Creates a right-handed orthographic projection matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a right-handed orthographic projection matrix
  4478. */
  4479. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a right-handed orthographic projection into a given matrix
  4482. * @param left defines the viewport left coordinate
  4483. * @param right defines the viewport right coordinate
  4484. * @param bottom defines the viewport bottom coordinate
  4485. * @param top defines the viewport top coordinate
  4486. * @param znear defines the near clip plane
  4487. * @param zfar defines the far clip plane
  4488. * @param result defines the target matrix
  4489. */
  4490. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4491. /**
  4492. * Creates a left-handed perspective projection matrix
  4493. * @param width defines the viewport width
  4494. * @param height defines the viewport height
  4495. * @param znear defines the near clip plane
  4496. * @param zfar defines the far clip plane
  4497. * @returns a new matrix as a left-handed perspective projection matrix
  4498. */
  4499. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4500. /**
  4501. * Creates a left-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a left-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a left-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Creates a right-handed perspective projection matrix
  4531. * @param fov defines the horizontal field of view
  4532. * @param aspect defines the aspect ratio
  4533. * @param znear defines the near clip plane
  4534. * @param zfar defines the far clip plane
  4535. * @returns a new matrix as a right-handed perspective projection matrix
  4536. */
  4537. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4538. /**
  4539. * Stores a right-handed perspective projection into a given matrix
  4540. * @param fov defines the horizontal field of view
  4541. * @param aspect defines the aspect ratio
  4542. * @param znear defines the near clip plane
  4543. * @param zfar defines the far clip plane
  4544. * @param result defines the target matrix
  4545. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4546. */
  4547. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4548. /**
  4549. * Stores a right-handed perspective projection into a given matrix
  4550. * @param fov defines the horizontal field of view
  4551. * @param aspect defines the aspect ratio
  4552. * @param znear defines the near clip plane
  4553. * @param zfar not used as infinity is used as far clip
  4554. * @param result defines the target matrix
  4555. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4556. */
  4557. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4558. /**
  4559. * Stores a perspective projection for WebVR info a given matrix
  4560. * @param fov defines the field of view
  4561. * @param znear defines the near clip plane
  4562. * @param zfar defines the far clip plane
  4563. * @param result defines the target matrix
  4564. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4565. */
  4566. static PerspectiveFovWebVRToRef(fov: {
  4567. upDegrees: number;
  4568. downDegrees: number;
  4569. leftDegrees: number;
  4570. rightDegrees: number;
  4571. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4572. /**
  4573. * Computes a complete transformation matrix
  4574. * @param viewport defines the viewport to use
  4575. * @param world defines the world matrix
  4576. * @param view defines the view matrix
  4577. * @param projection defines the projection matrix
  4578. * @param zmin defines the near clip plane
  4579. * @param zmax defines the far clip plane
  4580. * @returns the transformation matrix
  4581. */
  4582. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4583. /**
  4584. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4585. * @param matrix defines the matrix to use
  4586. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4587. */
  4588. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4589. /**
  4590. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4591. * @param matrix defines the matrix to use
  4592. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4593. */
  4594. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4595. /**
  4596. * Compute the transpose of a given matrix
  4597. * @param matrix defines the matrix to transpose
  4598. * @returns the new matrix
  4599. */
  4600. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4601. /**
  4602. * Compute the transpose of a matrix and store it in a target matrix
  4603. * @param matrix defines the matrix to transpose
  4604. * @param result defines the target matrix
  4605. */
  4606. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4607. /**
  4608. * Computes a reflection matrix from a plane
  4609. * @param plane defines the reflection plane
  4610. * @returns a new matrix
  4611. */
  4612. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4613. /**
  4614. * Computes a reflection matrix from a plane
  4615. * @param plane defines the reflection plane
  4616. * @param result defines the target matrix
  4617. */
  4618. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4619. /**
  4620. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4621. * @param xaxis defines the value of the 1st axis
  4622. * @param yaxis defines the value of the 2nd axis
  4623. * @param zaxis defines the value of the 3rd axis
  4624. * @param result defines the target matrix
  4625. */
  4626. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4627. /**
  4628. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4629. * @param quat defines the quaternion to use
  4630. * @param result defines the target matrix
  4631. */
  4632. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4633. }
  4634. /**
  4635. * @hidden
  4636. */
  4637. export class TmpVectors {
  4638. static Vector2: Vector2[];
  4639. static Vector3: Vector3[];
  4640. static Vector4: Vector4[];
  4641. static Quaternion: Quaternion[];
  4642. static Matrix: Matrix[];
  4643. }
  4644. }
  4645. declare module BABYLON {
  4646. /**
  4647. * Defines potential orientation for back face culling
  4648. */
  4649. export enum Orientation {
  4650. /**
  4651. * Clockwise
  4652. */
  4653. CW = 0,
  4654. /** Counter clockwise */
  4655. CCW = 1
  4656. }
  4657. /** Class used to represent a Bezier curve */
  4658. export class BezierCurve {
  4659. /**
  4660. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4661. * @param t defines the time
  4662. * @param x1 defines the left coordinate on X axis
  4663. * @param y1 defines the left coordinate on Y axis
  4664. * @param x2 defines the right coordinate on X axis
  4665. * @param y2 defines the right coordinate on Y axis
  4666. * @returns the interpolated value
  4667. */
  4668. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4669. }
  4670. /**
  4671. * Defines angle representation
  4672. */
  4673. export class Angle {
  4674. private _radians;
  4675. /**
  4676. * Creates an Angle object of "radians" radians (float).
  4677. * @param radians the angle in radians
  4678. */
  4679. constructor(radians: number);
  4680. /**
  4681. * Get value in degrees
  4682. * @returns the Angle value in degrees (float)
  4683. */
  4684. degrees(): number;
  4685. /**
  4686. * Get value in radians
  4687. * @returns the Angle value in radians (float)
  4688. */
  4689. radians(): number;
  4690. /**
  4691. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4692. * @param a defines first vector
  4693. * @param b defines second vector
  4694. * @returns a new Angle
  4695. */
  4696. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4697. /**
  4698. * Gets a new Angle object from the given float in radians
  4699. * @param radians defines the angle value in radians
  4700. * @returns a new Angle
  4701. */
  4702. static FromRadians(radians: number): Angle;
  4703. /**
  4704. * Gets a new Angle object from the given float in degrees
  4705. * @param degrees defines the angle value in degrees
  4706. * @returns a new Angle
  4707. */
  4708. static FromDegrees(degrees: number): Angle;
  4709. }
  4710. /**
  4711. * This represents an arc in a 2d space.
  4712. */
  4713. export class Arc2 {
  4714. /** Defines the start point of the arc */
  4715. startPoint: Vector2;
  4716. /** Defines the mid point of the arc */
  4717. midPoint: Vector2;
  4718. /** Defines the end point of the arc */
  4719. endPoint: Vector2;
  4720. /**
  4721. * Defines the center point of the arc.
  4722. */
  4723. centerPoint: Vector2;
  4724. /**
  4725. * Defines the radius of the arc.
  4726. */
  4727. radius: number;
  4728. /**
  4729. * Defines the angle of the arc (from mid point to end point).
  4730. */
  4731. angle: Angle;
  4732. /**
  4733. * Defines the start angle of the arc (from start point to middle point).
  4734. */
  4735. startAngle: Angle;
  4736. /**
  4737. * Defines the orientation of the arc (clock wise/counter clock wise).
  4738. */
  4739. orientation: Orientation;
  4740. /**
  4741. * Creates an Arc object from the three given points : start, middle and end.
  4742. * @param startPoint Defines the start point of the arc
  4743. * @param midPoint Defines the midlle point of the arc
  4744. * @param endPoint Defines the end point of the arc
  4745. */
  4746. constructor(
  4747. /** Defines the start point of the arc */
  4748. startPoint: Vector2,
  4749. /** Defines the mid point of the arc */
  4750. midPoint: Vector2,
  4751. /** Defines the end point of the arc */
  4752. endPoint: Vector2);
  4753. }
  4754. /**
  4755. * Represents a 2D path made up of multiple 2D points
  4756. */
  4757. export class Path2 {
  4758. private _points;
  4759. private _length;
  4760. /**
  4761. * If the path start and end point are the same
  4762. */
  4763. closed: boolean;
  4764. /**
  4765. * Creates a Path2 object from the starting 2D coordinates x and y.
  4766. * @param x the starting points x value
  4767. * @param y the starting points y value
  4768. */
  4769. constructor(x: number, y: number);
  4770. /**
  4771. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4772. * @param x the added points x value
  4773. * @param y the added points y value
  4774. * @returns the updated Path2.
  4775. */
  4776. addLineTo(x: number, y: number): Path2;
  4777. /**
  4778. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4779. * @param midX middle point x value
  4780. * @param midY middle point y value
  4781. * @param endX end point x value
  4782. * @param endY end point y value
  4783. * @param numberOfSegments (default: 36)
  4784. * @returns the updated Path2.
  4785. */
  4786. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4787. /**
  4788. * Closes the Path2.
  4789. * @returns the Path2.
  4790. */
  4791. close(): Path2;
  4792. /**
  4793. * Gets the sum of the distance between each sequential point in the path
  4794. * @returns the Path2 total length (float).
  4795. */
  4796. length(): number;
  4797. /**
  4798. * Gets the points which construct the path
  4799. * @returns the Path2 internal array of points.
  4800. */
  4801. getPoints(): Vector2[];
  4802. /**
  4803. * Retreives the point at the distance aways from the starting point
  4804. * @param normalizedLengthPosition the length along the path to retreive the point from
  4805. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4806. */
  4807. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4808. /**
  4809. * Creates a new path starting from an x and y position
  4810. * @param x starting x value
  4811. * @param y starting y value
  4812. * @returns a new Path2 starting at the coordinates (x, y).
  4813. */
  4814. static StartingAt(x: number, y: number): Path2;
  4815. }
  4816. /**
  4817. * Represents a 3D path made up of multiple 3D points
  4818. */
  4819. export class Path3D {
  4820. /**
  4821. * an array of Vector3, the curve axis of the Path3D
  4822. */
  4823. path: Vector3[];
  4824. private _curve;
  4825. private _distances;
  4826. private _tangents;
  4827. private _normals;
  4828. private _binormals;
  4829. private _raw;
  4830. private _alignTangentsWithPath;
  4831. private readonly _pointAtData;
  4832. /**
  4833. * new Path3D(path, normal, raw)
  4834. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4835. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4836. * @param path an array of Vector3, the curve axis of the Path3D
  4837. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4838. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4839. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4840. */
  4841. constructor(
  4842. /**
  4843. * an array of Vector3, the curve axis of the Path3D
  4844. */
  4845. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4846. /**
  4847. * Returns the Path3D array of successive Vector3 designing its curve.
  4848. * @returns the Path3D array of successive Vector3 designing its curve.
  4849. */
  4850. getCurve(): Vector3[];
  4851. /**
  4852. * Returns the Path3D array of successive Vector3 designing its curve.
  4853. * @returns the Path3D array of successive Vector3 designing its curve.
  4854. */
  4855. getPoints(): Vector3[];
  4856. /**
  4857. * @returns the computed length (float) of the path.
  4858. */
  4859. length(): number;
  4860. /**
  4861. * Returns an array populated with tangent vectors on each Path3D curve point.
  4862. * @returns an array populated with tangent vectors on each Path3D curve point.
  4863. */
  4864. getTangents(): Vector3[];
  4865. /**
  4866. * Returns an array populated with normal vectors on each Path3D curve point.
  4867. * @returns an array populated with normal vectors on each Path3D curve point.
  4868. */
  4869. getNormals(): Vector3[];
  4870. /**
  4871. * Returns an array populated with binormal vectors on each Path3D curve point.
  4872. * @returns an array populated with binormal vectors on each Path3D curve point.
  4873. */
  4874. getBinormals(): Vector3[];
  4875. /**
  4876. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4877. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4878. */
  4879. getDistances(): number[];
  4880. /**
  4881. * Returns an interpolated point along this path
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @returns a new Vector3 as the point
  4884. */
  4885. getPointAt(position: number): Vector3;
  4886. /**
  4887. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4888. * @param position the position of the point along this path, from 0.0 to 1.0
  4889. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4890. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4891. */
  4892. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4893. /**
  4894. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4895. * @param position the position of the point along this path, from 0.0 to 1.0
  4896. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4897. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4898. */
  4899. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4900. /**
  4901. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4902. * @param position the position of the point along this path, from 0.0 to 1.0
  4903. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4904. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4905. */
  4906. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4907. /**
  4908. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4909. * @param position the position of the point along this path, from 0.0 to 1.0
  4910. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4911. */
  4912. getDistanceAt(position: number): number;
  4913. /**
  4914. * Returns the array index of the previous point of an interpolated point along this path
  4915. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4916. * @returns the array index
  4917. */
  4918. getPreviousPointIndexAt(position: number): number;
  4919. /**
  4920. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4921. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4922. * @returns the sub position
  4923. */
  4924. getSubPositionAt(position: number): number;
  4925. /**
  4926. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4927. * @param target the vector of which to get the closest position to
  4928. * @returns the position of the closest virtual point on this path to the target vector
  4929. */
  4930. getClosestPositionTo(target: Vector3): number;
  4931. /**
  4932. * Returns a sub path (slice) of this path
  4933. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4934. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4935. * @returns a sub path (slice) of this path
  4936. */
  4937. slice(start?: number, end?: number): Path3D;
  4938. /**
  4939. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4940. * @param path path which all values are copied into the curves points
  4941. * @param firstNormal which should be projected onto the curve
  4942. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4943. * @returns the same object updated.
  4944. */
  4945. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4946. private _compute;
  4947. private _getFirstNonNullVector;
  4948. private _getLastNonNullVector;
  4949. private _normalVector;
  4950. /**
  4951. * Updates the point at data for an interpolated point along this curve
  4952. * @param position the position of the point along this curve, from 0.0 to 1.0
  4953. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4954. * @returns the (updated) point at data
  4955. */
  4956. private _updatePointAtData;
  4957. /**
  4958. * Updates the point at data from the specified parameters
  4959. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4960. * @param point the interpolated point
  4961. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4962. */
  4963. private _setPointAtData;
  4964. /**
  4965. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4966. */
  4967. private _updateInterpolationMatrix;
  4968. }
  4969. /**
  4970. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4971. * A Curve3 is designed from a series of successive Vector3.
  4972. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4973. */
  4974. export class Curve3 {
  4975. private _points;
  4976. private _length;
  4977. /**
  4978. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4979. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4980. * @param v1 (Vector3) the control point
  4981. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4982. * @param nbPoints (integer) the wanted number of points in the curve
  4983. * @returns the created Curve3
  4984. */
  4985. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4986. /**
  4987. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4988. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4989. * @param v1 (Vector3) the first control point
  4990. * @param v2 (Vector3) the second control point
  4991. * @param v3 (Vector3) the end point of the Cubic Bezier
  4992. * @param nbPoints (integer) the wanted number of points in the curve
  4993. * @returns the created Curve3
  4994. */
  4995. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4996. /**
  4997. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4998. * @param p1 (Vector3) the origin point of the Hermite Spline
  4999. * @param t1 (Vector3) the tangent vector at the origin point
  5000. * @param p2 (Vector3) the end point of the Hermite Spline
  5001. * @param t2 (Vector3) the tangent vector at the end point
  5002. * @param nbPoints (integer) the wanted number of points in the curve
  5003. * @returns the created Curve3
  5004. */
  5005. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5006. /**
  5007. * Returns a Curve3 object along a CatmullRom Spline curve :
  5008. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5009. * @param nbPoints (integer) the wanted number of points between each curve control points
  5010. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5011. * @returns the created Curve3
  5012. */
  5013. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5014. /**
  5015. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5016. * A Curve3 is designed from a series of successive Vector3.
  5017. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5018. * @param points points which make up the curve
  5019. */
  5020. constructor(points: Vector3[]);
  5021. /**
  5022. * @returns the Curve3 stored array of successive Vector3
  5023. */
  5024. getPoints(): Vector3[];
  5025. /**
  5026. * @returns the computed length (float) of the curve.
  5027. */
  5028. length(): number;
  5029. /**
  5030. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5031. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5032. * curveA and curveB keep unchanged.
  5033. * @param curve the curve to continue from this curve
  5034. * @returns the newly constructed curve
  5035. */
  5036. continue(curve: DeepImmutable<Curve3>): Curve3;
  5037. private _computeLength;
  5038. }
  5039. }
  5040. declare module BABYLON {
  5041. /**
  5042. * This represents the main contract an easing function should follow.
  5043. * Easing functions are used throughout the animation system.
  5044. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5045. */
  5046. export interface IEasingFunction {
  5047. /**
  5048. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5049. * of the easing function.
  5050. * The link below provides some of the most common examples of easing functions.
  5051. * @see https://easings.net/
  5052. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5053. * @returns the corresponding value on the curve defined by the easing function
  5054. */
  5055. ease(gradient: number): number;
  5056. }
  5057. /**
  5058. * Base class used for every default easing function.
  5059. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5060. */
  5061. export class EasingFunction implements IEasingFunction {
  5062. /**
  5063. * Interpolation follows the mathematical formula associated with the easing function.
  5064. */
  5065. static readonly EASINGMODE_EASEIN: number;
  5066. /**
  5067. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5068. */
  5069. static readonly EASINGMODE_EASEOUT: number;
  5070. /**
  5071. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5072. */
  5073. static readonly EASINGMODE_EASEINOUT: number;
  5074. private _easingMode;
  5075. /**
  5076. * Sets the easing mode of the current function.
  5077. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5078. */
  5079. setEasingMode(easingMode: number): void;
  5080. /**
  5081. * Gets the current easing mode.
  5082. * @returns the easing mode
  5083. */
  5084. getEasingMode(): number;
  5085. /**
  5086. * @hidden
  5087. */
  5088. easeInCore(gradient: number): number;
  5089. /**
  5090. * Given an input gradient between 0 and 1, this returns the corresponding value
  5091. * of the easing function.
  5092. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5093. * @returns the corresponding value on the curve defined by the easing function
  5094. */
  5095. ease(gradient: number): number;
  5096. }
  5097. /**
  5098. * Easing function with a circle shape (see link below).
  5099. * @see https://easings.net/#easeInCirc
  5100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5101. */
  5102. export class CircleEase extends EasingFunction implements IEasingFunction {
  5103. /** @hidden */
  5104. easeInCore(gradient: number): number;
  5105. }
  5106. /**
  5107. * Easing function with a ease back shape (see link below).
  5108. * @see https://easings.net/#easeInBack
  5109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5110. */
  5111. export class BackEase extends EasingFunction implements IEasingFunction {
  5112. /** Defines the amplitude of the function */
  5113. amplitude: number;
  5114. /**
  5115. * Instantiates a back ease easing
  5116. * @see https://easings.net/#easeInBack
  5117. * @param amplitude Defines the amplitude of the function
  5118. */
  5119. constructor(
  5120. /** Defines the amplitude of the function */
  5121. amplitude?: number);
  5122. /** @hidden */
  5123. easeInCore(gradient: number): number;
  5124. }
  5125. /**
  5126. * Easing function with a bouncing shape (see link below).
  5127. * @see https://easings.net/#easeInBounce
  5128. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5129. */
  5130. export class BounceEase extends EasingFunction implements IEasingFunction {
  5131. /** Defines the number of bounces */
  5132. bounces: number;
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness: number;
  5135. /**
  5136. * Instantiates a bounce easing
  5137. * @see https://easings.net/#easeInBounce
  5138. * @param bounces Defines the number of bounces
  5139. * @param bounciness Defines the amplitude of the bounce
  5140. */
  5141. constructor(
  5142. /** Defines the number of bounces */
  5143. bounces?: number,
  5144. /** Defines the amplitude of the bounce */
  5145. bounciness?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a power of 3 shape (see link below).
  5151. * @see https://easings.net/#easeInCubic
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class CubicEase extends EasingFunction implements IEasingFunction {
  5155. /** @hidden */
  5156. easeInCore(gradient: number): number;
  5157. }
  5158. /**
  5159. * Easing function with an elastic shape (see link below).
  5160. * @see https://easings.net/#easeInElastic
  5161. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5162. */
  5163. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5164. /** Defines the number of oscillations*/
  5165. oscillations: number;
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness: number;
  5168. /**
  5169. * Instantiates an elastic easing function
  5170. * @see https://easings.net/#easeInElastic
  5171. * @param oscillations Defines the number of oscillations
  5172. * @param springiness Defines the amplitude of the oscillations
  5173. */
  5174. constructor(
  5175. /** Defines the number of oscillations*/
  5176. oscillations?: number,
  5177. /** Defines the amplitude of the oscillations*/
  5178. springiness?: number);
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with an exponential shape (see link below).
  5184. * @see https://easings.net/#easeInExpo
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5188. /** Defines the exponent of the function */
  5189. exponent: number;
  5190. /**
  5191. * Instantiates an exponential easing function
  5192. * @see https://easings.net/#easeInExpo
  5193. * @param exponent Defines the exponent of the function
  5194. */
  5195. constructor(
  5196. /** Defines the exponent of the function */
  5197. exponent?: number);
  5198. /** @hidden */
  5199. easeInCore(gradient: number): number;
  5200. }
  5201. /**
  5202. * Easing function with a power shape (see link below).
  5203. * @see https://easings.net/#easeInQuad
  5204. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5205. */
  5206. export class PowerEase extends EasingFunction implements IEasingFunction {
  5207. /** Defines the power of the function */
  5208. power: number;
  5209. /**
  5210. * Instantiates an power base easing function
  5211. * @see https://easings.net/#easeInQuad
  5212. * @param power Defines the power of the function
  5213. */
  5214. constructor(
  5215. /** Defines the power of the function */
  5216. power?: number);
  5217. /** @hidden */
  5218. easeInCore(gradient: number): number;
  5219. }
  5220. /**
  5221. * Easing function with a power of 2 shape (see link below).
  5222. * @see https://easings.net/#easeInQuad
  5223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5224. */
  5225. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5226. /** @hidden */
  5227. easeInCore(gradient: number): number;
  5228. }
  5229. /**
  5230. * Easing function with a power of 4 shape (see link below).
  5231. * @see https://easings.net/#easeInQuart
  5232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5233. */
  5234. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5235. /** @hidden */
  5236. easeInCore(gradient: number): number;
  5237. }
  5238. /**
  5239. * Easing function with a power of 5 shape (see link below).
  5240. * @see https://easings.net/#easeInQuint
  5241. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5242. */
  5243. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5244. /** @hidden */
  5245. easeInCore(gradient: number): number;
  5246. }
  5247. /**
  5248. * Easing function with a sin shape (see link below).
  5249. * @see https://easings.net/#easeInSine
  5250. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5251. */
  5252. export class SineEase extends EasingFunction implements IEasingFunction {
  5253. /** @hidden */
  5254. easeInCore(gradient: number): number;
  5255. }
  5256. /**
  5257. * Easing function with a bezier shape (see link below).
  5258. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5260. */
  5261. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5262. /** Defines the x component of the start tangent in the bezier curve */
  5263. x1: number;
  5264. /** Defines the y component of the start tangent in the bezier curve */
  5265. y1: number;
  5266. /** Defines the x component of the end tangent in the bezier curve */
  5267. x2: number;
  5268. /** Defines the y component of the end tangent in the bezier curve */
  5269. y2: number;
  5270. /**
  5271. * Instantiates a bezier function
  5272. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5273. * @param x1 Defines the x component of the start tangent in the bezier curve
  5274. * @param y1 Defines the y component of the start tangent in the bezier curve
  5275. * @param x2 Defines the x component of the end tangent in the bezier curve
  5276. * @param y2 Defines the y component of the end tangent in the bezier curve
  5277. */
  5278. constructor(
  5279. /** Defines the x component of the start tangent in the bezier curve */
  5280. x1?: number,
  5281. /** Defines the y component of the start tangent in the bezier curve */
  5282. y1?: number,
  5283. /** Defines the x component of the end tangent in the bezier curve */
  5284. x2?: number,
  5285. /** Defines the y component of the end tangent in the bezier curve */
  5286. y2?: number);
  5287. /** @hidden */
  5288. easeInCore(gradient: number): number;
  5289. }
  5290. }
  5291. declare module BABYLON {
  5292. /**
  5293. * Class used to hold a RBG color
  5294. */
  5295. export class Color3 {
  5296. /**
  5297. * Defines the red component (between 0 and 1, default is 0)
  5298. */
  5299. r: number;
  5300. /**
  5301. * Defines the green component (between 0 and 1, default is 0)
  5302. */
  5303. g: number;
  5304. /**
  5305. * Defines the blue component (between 0 and 1, default is 0)
  5306. */
  5307. b: number;
  5308. /**
  5309. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5310. * @param r defines the red component (between 0 and 1, default is 0)
  5311. * @param g defines the green component (between 0 and 1, default is 0)
  5312. * @param b defines the blue component (between 0 and 1, default is 0)
  5313. */
  5314. constructor(
  5315. /**
  5316. * Defines the red component (between 0 and 1, default is 0)
  5317. */
  5318. r?: number,
  5319. /**
  5320. * Defines the green component (between 0 and 1, default is 0)
  5321. */
  5322. g?: number,
  5323. /**
  5324. * Defines the blue component (between 0 and 1, default is 0)
  5325. */
  5326. b?: number);
  5327. /**
  5328. * Creates a string with the Color3 current values
  5329. * @returns the string representation of the Color3 object
  5330. */
  5331. toString(): string;
  5332. /**
  5333. * Returns the string "Color3"
  5334. * @returns "Color3"
  5335. */
  5336. getClassName(): string;
  5337. /**
  5338. * Compute the Color3 hash code
  5339. * @returns an unique number that can be used to hash Color3 objects
  5340. */
  5341. getHashCode(): number;
  5342. /**
  5343. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5344. * @param array defines the array where to store the r,g,b components
  5345. * @param index defines an optional index in the target array to define where to start storing values
  5346. * @returns the current Color3 object
  5347. */
  5348. toArray(array: FloatArray, index?: number): Color3;
  5349. /**
  5350. * Returns a new Color4 object from the current Color3 and the given alpha
  5351. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5352. * @returns a new Color4 object
  5353. */
  5354. toColor4(alpha?: number): Color4;
  5355. /**
  5356. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5357. * @returns the new array
  5358. */
  5359. asArray(): number[];
  5360. /**
  5361. * Returns the luminance value
  5362. * @returns a float value
  5363. */
  5364. toLuminance(): number;
  5365. /**
  5366. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5367. * @param otherColor defines the second operand
  5368. * @returns the new Color3 object
  5369. */
  5370. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5371. /**
  5372. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5373. * @param otherColor defines the second operand
  5374. * @param result defines the Color3 object where to store the result
  5375. * @returns the current Color3
  5376. */
  5377. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5378. /**
  5379. * Determines equality between Color3 objects
  5380. * @param otherColor defines the second operand
  5381. * @returns true if the rgb values are equal to the given ones
  5382. */
  5383. equals(otherColor: DeepImmutable<Color3>): boolean;
  5384. /**
  5385. * Determines equality between the current Color3 object and a set of r,b,g values
  5386. * @param r defines the red component to check
  5387. * @param g defines the green component to check
  5388. * @param b defines the blue component to check
  5389. * @returns true if the rgb values are equal to the given ones
  5390. */
  5391. equalsFloats(r: number, g: number, b: number): boolean;
  5392. /**
  5393. * Multiplies in place each rgb value by scale
  5394. * @param scale defines the scaling factor
  5395. * @returns the updated Color3
  5396. */
  5397. scale(scale: number): Color3;
  5398. /**
  5399. * Multiplies the rgb values by scale and stores the result into "result"
  5400. * @param scale defines the scaling factor
  5401. * @param result defines the Color3 object where to store the result
  5402. * @returns the unmodified current Color3
  5403. */
  5404. scaleToRef(scale: number, result: Color3): Color3;
  5405. /**
  5406. * Scale the current Color3 values by a factor and add the result to a given Color3
  5407. * @param scale defines the scale factor
  5408. * @param result defines color to store the result into
  5409. * @returns the unmodified current Color3
  5410. */
  5411. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5412. /**
  5413. * Clamps the rgb values by the min and max values and stores the result into "result"
  5414. * @param min defines minimum clamping value (default is 0)
  5415. * @param max defines maximum clamping value (default is 1)
  5416. * @param result defines color to store the result into
  5417. * @returns the original Color3
  5418. */
  5419. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5420. /**
  5421. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5422. * @param otherColor defines the second operand
  5423. * @returns the new Color3
  5424. */
  5425. add(otherColor: DeepImmutable<Color3>): Color3;
  5426. /**
  5427. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5428. * @param otherColor defines the second operand
  5429. * @param result defines Color3 object to store the result into
  5430. * @returns the unmodified current Color3
  5431. */
  5432. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5433. /**
  5434. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5435. * @param otherColor defines the second operand
  5436. * @returns the new Color3
  5437. */
  5438. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5439. /**
  5440. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5441. * @param otherColor defines the second operand
  5442. * @param result defines Color3 object to store the result into
  5443. * @returns the unmodified current Color3
  5444. */
  5445. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5446. /**
  5447. * Copy the current object
  5448. * @returns a new Color3 copied the current one
  5449. */
  5450. clone(): Color3;
  5451. /**
  5452. * Copies the rgb values from the source in the current Color3
  5453. * @param source defines the source Color3 object
  5454. * @returns the updated Color3 object
  5455. */
  5456. copyFrom(source: DeepImmutable<Color3>): Color3;
  5457. /**
  5458. * Updates the Color3 rgb values from the given floats
  5459. * @param r defines the red component to read from
  5460. * @param g defines the green component to read from
  5461. * @param b defines the blue component to read from
  5462. * @returns the current Color3 object
  5463. */
  5464. copyFromFloats(r: number, g: number, b: number): Color3;
  5465. /**
  5466. * Updates the Color3 rgb values from the given floats
  5467. * @param r defines the red component to read from
  5468. * @param g defines the green component to read from
  5469. * @param b defines the blue component to read from
  5470. * @returns the current Color3 object
  5471. */
  5472. set(r: number, g: number, b: number): Color3;
  5473. /**
  5474. * Compute the Color3 hexadecimal code as a string
  5475. * @returns a string containing the hexadecimal representation of the Color3 object
  5476. */
  5477. toHexString(): string;
  5478. /**
  5479. * Computes a new Color3 converted from the current one to linear space
  5480. * @returns a new Color3 object
  5481. */
  5482. toLinearSpace(): Color3;
  5483. /**
  5484. * Converts current color in rgb space to HSV values
  5485. * @returns a new color3 representing the HSV values
  5486. */
  5487. toHSV(): Color3;
  5488. /**
  5489. * Converts current color in rgb space to HSV values
  5490. * @param result defines the Color3 where to store the HSV values
  5491. */
  5492. toHSVToRef(result: Color3): void;
  5493. /**
  5494. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the linear space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5499. /**
  5500. * Computes a new Color3 converted from the current one to gamma space
  5501. * @returns a new Color3 object
  5502. */
  5503. toGammaSpace(): Color3;
  5504. /**
  5505. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5506. * @param convertedColor defines the Color3 object where to store the gamma space version
  5507. * @returns the unmodified Color3
  5508. */
  5509. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5510. private static _BlackReadOnly;
  5511. /**
  5512. * Convert Hue, saturation and value to a Color3 (RGB)
  5513. * @param hue defines the hue
  5514. * @param saturation defines the saturation
  5515. * @param value defines the value
  5516. * @param result defines the Color3 where to store the RGB values
  5517. */
  5518. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5519. /**
  5520. * Creates a new Color3 from the string containing valid hexadecimal values
  5521. * @param hex defines a string containing valid hexadecimal values
  5522. * @returns a new Color3 object
  5523. */
  5524. static FromHexString(hex: string): Color3;
  5525. /**
  5526. * Creates a new Color3 from the starting index of the given array
  5527. * @param array defines the source array
  5528. * @param offset defines an offset in the source array
  5529. * @returns a new Color3 object
  5530. */
  5531. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5532. /**
  5533. * Creates a new Color3 from integer values (< 256)
  5534. * @param r defines the red component to read from (value between 0 and 255)
  5535. * @param g defines the green component to read from (value between 0 and 255)
  5536. * @param b defines the blue component to read from (value between 0 and 255)
  5537. * @returns a new Color3 object
  5538. */
  5539. static FromInts(r: number, g: number, b: number): Color3;
  5540. /**
  5541. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5542. * @param start defines the start Color3 value
  5543. * @param end defines the end Color3 value
  5544. * @param amount defines the gradient value between start and end
  5545. * @returns a new Color3 object
  5546. */
  5547. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5548. /**
  5549. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5550. * @param left defines the start value
  5551. * @param right defines the end value
  5552. * @param amount defines the gradient factor
  5553. * @param result defines the Color3 object where to store the result
  5554. */
  5555. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5556. /**
  5557. * Returns a Color3 value containing a red color
  5558. * @returns a new Color3 object
  5559. */
  5560. static Red(): Color3;
  5561. /**
  5562. * Returns a Color3 value containing a green color
  5563. * @returns a new Color3 object
  5564. */
  5565. static Green(): Color3;
  5566. /**
  5567. * Returns a Color3 value containing a blue color
  5568. * @returns a new Color3 object
  5569. */
  5570. static Blue(): Color3;
  5571. /**
  5572. * Returns a Color3 value containing a black color
  5573. * @returns a new Color3 object
  5574. */
  5575. static Black(): Color3;
  5576. /**
  5577. * Gets a Color3 value containing a black color that must not be updated
  5578. */
  5579. static get BlackReadOnly(): DeepImmutable<Color3>;
  5580. /**
  5581. * Returns a Color3 value containing a white color
  5582. * @returns a new Color3 object
  5583. */
  5584. static White(): Color3;
  5585. /**
  5586. * Returns a Color3 value containing a purple color
  5587. * @returns a new Color3 object
  5588. */
  5589. static Purple(): Color3;
  5590. /**
  5591. * Returns a Color3 value containing a magenta color
  5592. * @returns a new Color3 object
  5593. */
  5594. static Magenta(): Color3;
  5595. /**
  5596. * Returns a Color3 value containing a yellow color
  5597. * @returns a new Color3 object
  5598. */
  5599. static Yellow(): Color3;
  5600. /**
  5601. * Returns a Color3 value containing a gray color
  5602. * @returns a new Color3 object
  5603. */
  5604. static Gray(): Color3;
  5605. /**
  5606. * Returns a Color3 value containing a teal color
  5607. * @returns a new Color3 object
  5608. */
  5609. static Teal(): Color3;
  5610. /**
  5611. * Returns a Color3 value containing a random color
  5612. * @returns a new Color3 object
  5613. */
  5614. static Random(): Color3;
  5615. }
  5616. /**
  5617. * Class used to hold a RBGA color
  5618. */
  5619. export class Color4 {
  5620. /**
  5621. * Defines the red component (between 0 and 1, default is 0)
  5622. */
  5623. r: number;
  5624. /**
  5625. * Defines the green component (between 0 and 1, default is 0)
  5626. */
  5627. g: number;
  5628. /**
  5629. * Defines the blue component (between 0 and 1, default is 0)
  5630. */
  5631. b: number;
  5632. /**
  5633. * Defines the alpha component (between 0 and 1, default is 1)
  5634. */
  5635. a: number;
  5636. /**
  5637. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5638. * @param r defines the red component (between 0 and 1, default is 0)
  5639. * @param g defines the green component (between 0 and 1, default is 0)
  5640. * @param b defines the blue component (between 0 and 1, default is 0)
  5641. * @param a defines the alpha component (between 0 and 1, default is 1)
  5642. */
  5643. constructor(
  5644. /**
  5645. * Defines the red component (between 0 and 1, default is 0)
  5646. */
  5647. r?: number,
  5648. /**
  5649. * Defines the green component (between 0 and 1, default is 0)
  5650. */
  5651. g?: number,
  5652. /**
  5653. * Defines the blue component (between 0 and 1, default is 0)
  5654. */
  5655. b?: number,
  5656. /**
  5657. * Defines the alpha component (between 0 and 1, default is 1)
  5658. */
  5659. a?: number);
  5660. /**
  5661. * Adds in place the given Color4 values to the current Color4 object
  5662. * @param right defines the second operand
  5663. * @returns the current updated Color4 object
  5664. */
  5665. addInPlace(right: DeepImmutable<Color4>): Color4;
  5666. /**
  5667. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5668. * @returns the new array
  5669. */
  5670. asArray(): number[];
  5671. /**
  5672. * Stores from the starting index in the given array the Color4 successive values
  5673. * @param array defines the array where to store the r,g,b components
  5674. * @param index defines an optional index in the target array to define where to start storing values
  5675. * @returns the current Color4 object
  5676. */
  5677. toArray(array: number[], index?: number): Color4;
  5678. /**
  5679. * Determines equality between Color4 objects
  5680. * @param otherColor defines the second operand
  5681. * @returns true if the rgba values are equal to the given ones
  5682. */
  5683. equals(otherColor: DeepImmutable<Color4>): boolean;
  5684. /**
  5685. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5686. * @param right defines the second operand
  5687. * @returns a new Color4 object
  5688. */
  5689. add(right: DeepImmutable<Color4>): Color4;
  5690. /**
  5691. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5692. * @param right defines the second operand
  5693. * @returns a new Color4 object
  5694. */
  5695. subtract(right: DeepImmutable<Color4>): Color4;
  5696. /**
  5697. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5698. * @param right defines the second operand
  5699. * @param result defines the Color4 object where to store the result
  5700. * @returns the current Color4 object
  5701. */
  5702. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5703. /**
  5704. * Creates a new Color4 with the current Color4 values multiplied by scale
  5705. * @param scale defines the scaling factor to apply
  5706. * @returns a new Color4 object
  5707. */
  5708. scale(scale: number): Color4;
  5709. /**
  5710. * Multiplies the current Color4 values by scale and stores the result in "result"
  5711. * @param scale defines the scaling factor to apply
  5712. * @param result defines the Color4 object where to store the result
  5713. * @returns the current unmodified Color4
  5714. */
  5715. scaleToRef(scale: number, result: Color4): Color4;
  5716. /**
  5717. * Scale the current Color4 values by a factor and add the result to a given Color4
  5718. * @param scale defines the scale factor
  5719. * @param result defines the Color4 object where to store the result
  5720. * @returns the unmodified current Color4
  5721. */
  5722. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5723. /**
  5724. * Clamps the rgb values by the min and max values and stores the result into "result"
  5725. * @param min defines minimum clamping value (default is 0)
  5726. * @param max defines maximum clamping value (default is 1)
  5727. * @param result defines color to store the result into.
  5728. * @returns the cuurent Color4
  5729. */
  5730. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5731. /**
  5732. * Multipy an Color4 value by another and return a new Color4 object
  5733. * @param color defines the Color4 value to multiply by
  5734. * @returns a new Color4 object
  5735. */
  5736. multiply(color: Color4): Color4;
  5737. /**
  5738. * Multipy a Color4 value by another and push the result in a reference value
  5739. * @param color defines the Color4 value to multiply by
  5740. * @param result defines the Color4 to fill the result in
  5741. * @returns the result Color4
  5742. */
  5743. multiplyToRef(color: Color4, result: Color4): Color4;
  5744. /**
  5745. * Creates a string with the Color4 current values
  5746. * @returns the string representation of the Color4 object
  5747. */
  5748. toString(): string;
  5749. /**
  5750. * Returns the string "Color4"
  5751. * @returns "Color4"
  5752. */
  5753. getClassName(): string;
  5754. /**
  5755. * Compute the Color4 hash code
  5756. * @returns an unique number that can be used to hash Color4 objects
  5757. */
  5758. getHashCode(): number;
  5759. /**
  5760. * Creates a new Color4 copied from the current one
  5761. * @returns a new Color4 object
  5762. */
  5763. clone(): Color4;
  5764. /**
  5765. * Copies the given Color4 values into the current one
  5766. * @param source defines the source Color4 object
  5767. * @returns the current updated Color4 object
  5768. */
  5769. copyFrom(source: Color4): Color4;
  5770. /**
  5771. * Copies the given float values into the current one
  5772. * @param r defines the red component to read from
  5773. * @param g defines the green component to read from
  5774. * @param b defines the blue component to read from
  5775. * @param a defines the alpha component to read from
  5776. * @returns the current updated Color4 object
  5777. */
  5778. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5779. /**
  5780. * Copies the given float values into the current one
  5781. * @param r defines the red component to read from
  5782. * @param g defines the green component to read from
  5783. * @param b defines the blue component to read from
  5784. * @param a defines the alpha component to read from
  5785. * @returns the current updated Color4 object
  5786. */
  5787. set(r: number, g: number, b: number, a: number): Color4;
  5788. /**
  5789. * Compute the Color4 hexadecimal code as a string
  5790. * @returns a string containing the hexadecimal representation of the Color4 object
  5791. */
  5792. toHexString(): string;
  5793. /**
  5794. * Computes a new Color4 converted from the current one to linear space
  5795. * @returns a new Color4 object
  5796. */
  5797. toLinearSpace(): Color4;
  5798. /**
  5799. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5800. * @param convertedColor defines the Color4 object where to store the linear space version
  5801. * @returns the unmodified Color4
  5802. */
  5803. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5804. /**
  5805. * Computes a new Color4 converted from the current one to gamma space
  5806. * @returns a new Color4 object
  5807. */
  5808. toGammaSpace(): Color4;
  5809. /**
  5810. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5811. * @param convertedColor defines the Color4 object where to store the gamma space version
  5812. * @returns the unmodified Color4
  5813. */
  5814. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5815. /**
  5816. * Creates a new Color4 from the string containing valid hexadecimal values
  5817. * @param hex defines a string containing valid hexadecimal values
  5818. * @returns a new Color4 object
  5819. */
  5820. static FromHexString(hex: string): Color4;
  5821. /**
  5822. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5823. * @param left defines the start value
  5824. * @param right defines the end value
  5825. * @param amount defines the gradient factor
  5826. * @returns a new Color4 object
  5827. */
  5828. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5829. /**
  5830. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5831. * @param left defines the start value
  5832. * @param right defines the end value
  5833. * @param amount defines the gradient factor
  5834. * @param result defines the Color4 object where to store data
  5835. */
  5836. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5837. /**
  5838. * Creates a new Color4 from a Color3 and an alpha value
  5839. * @param color3 defines the source Color3 to read from
  5840. * @param alpha defines the alpha component (1.0 by default)
  5841. * @returns a new Color4 object
  5842. */
  5843. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5844. /**
  5845. * Creates a new Color4 from the starting index element of the given array
  5846. * @param array defines the source array to read from
  5847. * @param offset defines the offset in the source array
  5848. * @returns a new Color4 object
  5849. */
  5850. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5851. /**
  5852. * Creates a new Color3 from integer values (< 256)
  5853. * @param r defines the red component to read from (value between 0 and 255)
  5854. * @param g defines the green component to read from (value between 0 and 255)
  5855. * @param b defines the blue component to read from (value between 0 and 255)
  5856. * @param a defines the alpha component to read from (value between 0 and 255)
  5857. * @returns a new Color3 object
  5858. */
  5859. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5860. /**
  5861. * Check the content of a given array and convert it to an array containing RGBA data
  5862. * If the original array was already containing count * 4 values then it is returned directly
  5863. * @param colors defines the array to check
  5864. * @param count defines the number of RGBA data to expect
  5865. * @returns an array containing count * 4 values (RGBA)
  5866. */
  5867. static CheckColors4(colors: number[], count: number): number[];
  5868. }
  5869. /**
  5870. * @hidden
  5871. */
  5872. export class TmpColors {
  5873. static Color3: Color3[];
  5874. static Color4: Color4[];
  5875. }
  5876. }
  5877. declare module BABYLON {
  5878. /**
  5879. * Defines an interface which represents an animation key frame
  5880. */
  5881. export interface IAnimationKey {
  5882. /**
  5883. * Frame of the key frame
  5884. */
  5885. frame: number;
  5886. /**
  5887. * Value at the specifies key frame
  5888. */
  5889. value: any;
  5890. /**
  5891. * The input tangent for the cubic hermite spline
  5892. */
  5893. inTangent?: any;
  5894. /**
  5895. * The output tangent for the cubic hermite spline
  5896. */
  5897. outTangent?: any;
  5898. /**
  5899. * The animation interpolation type
  5900. */
  5901. interpolation?: AnimationKeyInterpolation;
  5902. }
  5903. /**
  5904. * Enum for the animation key frame interpolation type
  5905. */
  5906. export enum AnimationKeyInterpolation {
  5907. /**
  5908. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5909. */
  5910. STEP = 1
  5911. }
  5912. }
  5913. declare module BABYLON {
  5914. /**
  5915. * Represents the range of an animation
  5916. */
  5917. export class AnimationRange {
  5918. /**The name of the animation range**/
  5919. name: string;
  5920. /**The starting frame of the animation */
  5921. from: number;
  5922. /**The ending frame of the animation*/
  5923. to: number;
  5924. /**
  5925. * Initializes the range of an animation
  5926. * @param name The name of the animation range
  5927. * @param from The starting frame of the animation
  5928. * @param to The ending frame of the animation
  5929. */
  5930. constructor(
  5931. /**The name of the animation range**/
  5932. name: string,
  5933. /**The starting frame of the animation */
  5934. from: number,
  5935. /**The ending frame of the animation*/
  5936. to: number);
  5937. /**
  5938. * Makes a copy of the animation range
  5939. * @returns A copy of the animation range
  5940. */
  5941. clone(): AnimationRange;
  5942. }
  5943. }
  5944. declare module BABYLON {
  5945. /**
  5946. * Composed of a frame, and an action function
  5947. */
  5948. export class AnimationEvent {
  5949. /** The frame for which the event is triggered **/
  5950. frame: number;
  5951. /** The event to perform when triggered **/
  5952. action: (currentFrame: number) => void;
  5953. /** Specifies if the event should be triggered only once**/
  5954. onlyOnce?: boolean | undefined;
  5955. /**
  5956. * Specifies if the animation event is done
  5957. */
  5958. isDone: boolean;
  5959. /**
  5960. * Initializes the animation event
  5961. * @param frame The frame for which the event is triggered
  5962. * @param action The event to perform when triggered
  5963. * @param onlyOnce Specifies if the event should be triggered only once
  5964. */
  5965. constructor(
  5966. /** The frame for which the event is triggered **/
  5967. frame: number,
  5968. /** The event to perform when triggered **/
  5969. action: (currentFrame: number) => void,
  5970. /** Specifies if the event should be triggered only once**/
  5971. onlyOnce?: boolean | undefined);
  5972. /** @hidden */
  5973. _clone(): AnimationEvent;
  5974. }
  5975. }
  5976. declare module BABYLON {
  5977. /**
  5978. * Interface used to define a behavior
  5979. */
  5980. export interface Behavior<T> {
  5981. /** gets or sets behavior's name */
  5982. name: string;
  5983. /**
  5984. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5985. */
  5986. init(): void;
  5987. /**
  5988. * Called when the behavior is attached to a target
  5989. * @param target defines the target where the behavior is attached to
  5990. */
  5991. attach(target: T): void;
  5992. /**
  5993. * Called when the behavior is detached from its target
  5994. */
  5995. detach(): void;
  5996. }
  5997. /**
  5998. * Interface implemented by classes supporting behaviors
  5999. */
  6000. export interface IBehaviorAware<T> {
  6001. /**
  6002. * Attach a behavior
  6003. * @param behavior defines the behavior to attach
  6004. * @returns the current host
  6005. */
  6006. addBehavior(behavior: Behavior<T>): T;
  6007. /**
  6008. * Remove a behavior from the current object
  6009. * @param behavior defines the behavior to detach
  6010. * @returns the current host
  6011. */
  6012. removeBehavior(behavior: Behavior<T>): T;
  6013. /**
  6014. * Gets a behavior using its name to search
  6015. * @param name defines the name to search
  6016. * @returns the behavior or null if not found
  6017. */
  6018. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6019. }
  6020. }
  6021. declare module BABYLON {
  6022. /**
  6023. * Defines an array and its length.
  6024. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6025. */
  6026. export interface ISmartArrayLike<T> {
  6027. /**
  6028. * The data of the array.
  6029. */
  6030. data: Array<T>;
  6031. /**
  6032. * The active length of the array.
  6033. */
  6034. length: number;
  6035. }
  6036. /**
  6037. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6038. */
  6039. export class SmartArray<T> implements ISmartArrayLike<T> {
  6040. /**
  6041. * The full set of data from the array.
  6042. */
  6043. data: Array<T>;
  6044. /**
  6045. * The active length of the array.
  6046. */
  6047. length: number;
  6048. protected _id: number;
  6049. /**
  6050. * Instantiates a Smart Array.
  6051. * @param capacity defines the default capacity of the array.
  6052. */
  6053. constructor(capacity: number);
  6054. /**
  6055. * Pushes a value at the end of the active data.
  6056. * @param value defines the object to push in the array.
  6057. */
  6058. push(value: T): void;
  6059. /**
  6060. * Iterates over the active data and apply the lambda to them.
  6061. * @param func defines the action to apply on each value.
  6062. */
  6063. forEach(func: (content: T) => void): void;
  6064. /**
  6065. * Sorts the full sets of data.
  6066. * @param compareFn defines the comparison function to apply.
  6067. */
  6068. sort(compareFn: (a: T, b: T) => number): void;
  6069. /**
  6070. * Resets the active data to an empty array.
  6071. */
  6072. reset(): void;
  6073. /**
  6074. * Releases all the data from the array as well as the array.
  6075. */
  6076. dispose(): void;
  6077. /**
  6078. * Concats the active data with a given array.
  6079. * @param array defines the data to concatenate with.
  6080. */
  6081. concat(array: any): void;
  6082. /**
  6083. * Returns the position of a value in the active data.
  6084. * @param value defines the value to find the index for
  6085. * @returns the index if found in the active data otherwise -1
  6086. */
  6087. indexOf(value: T): number;
  6088. /**
  6089. * Returns whether an element is part of the active data.
  6090. * @param value defines the value to look for
  6091. * @returns true if found in the active data otherwise false
  6092. */
  6093. contains(value: T): boolean;
  6094. private static _GlobalId;
  6095. }
  6096. /**
  6097. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6098. * The data in this array can only be present once
  6099. */
  6100. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6101. private _duplicateId;
  6102. /**
  6103. * Pushes a value at the end of the active data.
  6104. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6105. * @param value defines the object to push in the array.
  6106. */
  6107. push(value: T): void;
  6108. /**
  6109. * Pushes a value at the end of the active data.
  6110. * If the data is already present, it won t be added again
  6111. * @param value defines the object to push in the array.
  6112. * @returns true if added false if it was already present
  6113. */
  6114. pushNoDuplicate(value: T): boolean;
  6115. /**
  6116. * Resets the active data to an empty array.
  6117. */
  6118. reset(): void;
  6119. /**
  6120. * Concats the active data with a given array.
  6121. * This ensures no dupplicate will be present in the result.
  6122. * @param array defines the data to concatenate with.
  6123. */
  6124. concatWithNoDuplicate(array: any): void;
  6125. }
  6126. }
  6127. declare module BABYLON {
  6128. /**
  6129. * @ignore
  6130. * This is a list of all the different input types that are available in the application.
  6131. * Fo instance: ArcRotateCameraGamepadInput...
  6132. */
  6133. export var CameraInputTypes: {};
  6134. /**
  6135. * This is the contract to implement in order to create a new input class.
  6136. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6137. */
  6138. export interface ICameraInput<TCamera extends Camera> {
  6139. /**
  6140. * Defines the camera the input is attached to.
  6141. */
  6142. camera: Nullable<TCamera>;
  6143. /**
  6144. * Gets the class name of the current intput.
  6145. * @returns the class name
  6146. */
  6147. getClassName(): string;
  6148. /**
  6149. * Get the friendly name associated with the input class.
  6150. * @returns the input friendly name
  6151. */
  6152. getSimpleName(): string;
  6153. /**
  6154. * Attach the input controls to a specific dom element to get the input from.
  6155. * @param element Defines the element the controls should be listened from
  6156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6157. */
  6158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6159. /**
  6160. * Detach the current controls from the specified dom element.
  6161. * @param element Defines the element to stop listening the inputs from
  6162. */
  6163. detachControl(element: Nullable<HTMLElement>): void;
  6164. /**
  6165. * Update the current camera state depending on the inputs that have been used this frame.
  6166. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6167. */
  6168. checkInputs?: () => void;
  6169. }
  6170. /**
  6171. * Represents a map of input types to input instance or input index to input instance.
  6172. */
  6173. export interface CameraInputsMap<TCamera extends Camera> {
  6174. /**
  6175. * Accessor to the input by input type.
  6176. */
  6177. [name: string]: ICameraInput<TCamera>;
  6178. /**
  6179. * Accessor to the input by input index.
  6180. */
  6181. [idx: number]: ICameraInput<TCamera>;
  6182. }
  6183. /**
  6184. * This represents the input manager used within a camera.
  6185. * It helps dealing with all the different kind of input attached to a camera.
  6186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6187. */
  6188. export class CameraInputsManager<TCamera extends Camera> {
  6189. /**
  6190. * Defines the list of inputs attahed to the camera.
  6191. */
  6192. attached: CameraInputsMap<TCamera>;
  6193. /**
  6194. * Defines the dom element the camera is collecting inputs from.
  6195. * This is null if the controls have not been attached.
  6196. */
  6197. attachedElement: Nullable<HTMLElement>;
  6198. /**
  6199. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6200. */
  6201. noPreventDefault: boolean;
  6202. /**
  6203. * Defined the camera the input manager belongs to.
  6204. */
  6205. camera: TCamera;
  6206. /**
  6207. * Update the current camera state depending on the inputs that have been used this frame.
  6208. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6209. */
  6210. checkInputs: () => void;
  6211. /**
  6212. * Instantiate a new Camera Input Manager.
  6213. * @param camera Defines the camera the input manager blongs to
  6214. */
  6215. constructor(camera: TCamera);
  6216. /**
  6217. * Add an input method to a camera
  6218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6219. * @param input camera input method
  6220. */
  6221. add(input: ICameraInput<TCamera>): void;
  6222. /**
  6223. * Remove a specific input method from a camera
  6224. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6225. * @param inputToRemove camera input method
  6226. */
  6227. remove(inputToRemove: ICameraInput<TCamera>): void;
  6228. /**
  6229. * Remove a specific input type from a camera
  6230. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6231. * @param inputType the type of the input to remove
  6232. */
  6233. removeByType(inputType: string): void;
  6234. private _addCheckInputs;
  6235. /**
  6236. * Attach the input controls to the currently attached dom element to listen the events from.
  6237. * @param input Defines the input to attach
  6238. */
  6239. attachInput(input: ICameraInput<TCamera>): void;
  6240. /**
  6241. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6242. * @param element Defines the dom element to collect the events from
  6243. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6244. */
  6245. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6246. /**
  6247. * Detach the current manager inputs controls from a specific dom element.
  6248. * @param element Defines the dom element to collect the events from
  6249. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6250. */
  6251. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6252. /**
  6253. * Rebuild the dynamic inputCheck function from the current list of
  6254. * defined inputs in the manager.
  6255. */
  6256. rebuildInputCheck(): void;
  6257. /**
  6258. * Remove all attached input methods from a camera
  6259. */
  6260. clear(): void;
  6261. /**
  6262. * Serialize the current input manager attached to a camera.
  6263. * This ensures than once parsed,
  6264. * the input associated to the camera will be identical to the current ones
  6265. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6266. */
  6267. serialize(serializedCamera: any): void;
  6268. /**
  6269. * Parses an input manager serialized JSON to restore the previous list of inputs
  6270. * and states associated to a camera.
  6271. * @param parsedCamera Defines the JSON to parse
  6272. */
  6273. parse(parsedCamera: any): void;
  6274. }
  6275. }
  6276. declare module BABYLON {
  6277. /**
  6278. * Class used to store data that will be store in GPU memory
  6279. */
  6280. export class Buffer {
  6281. private _engine;
  6282. private _buffer;
  6283. /** @hidden */
  6284. _data: Nullable<DataArray>;
  6285. private _updatable;
  6286. private _instanced;
  6287. private _divisor;
  6288. /**
  6289. * Gets the byte stride.
  6290. */
  6291. readonly byteStride: number;
  6292. /**
  6293. * Constructor
  6294. * @param engine the engine
  6295. * @param data the data to use for this buffer
  6296. * @param updatable whether the data is updatable
  6297. * @param stride the stride (optional)
  6298. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6299. * @param instanced whether the buffer is instanced (optional)
  6300. * @param useBytes set to true if the stride in in bytes (optional)
  6301. * @param divisor sets an optional divisor for instances (1 by default)
  6302. */
  6303. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6304. /**
  6305. * Create a new VertexBuffer based on the current buffer
  6306. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6307. * @param offset defines offset in the buffer (0 by default)
  6308. * @param size defines the size in floats of attributes (position is 3 for instance)
  6309. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6310. * @param instanced defines if the vertex buffer contains indexed data
  6311. * @param useBytes defines if the offset and stride are in bytes *
  6312. * @param divisor sets an optional divisor for instances (1 by default)
  6313. * @returns the new vertex buffer
  6314. */
  6315. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6316. /**
  6317. * Gets a boolean indicating if the Buffer is updatable?
  6318. * @returns true if the buffer is updatable
  6319. */
  6320. isUpdatable(): boolean;
  6321. /**
  6322. * Gets current buffer's data
  6323. * @returns a DataArray or null
  6324. */
  6325. getData(): Nullable<DataArray>;
  6326. /**
  6327. * Gets underlying native buffer
  6328. * @returns underlying native buffer
  6329. */
  6330. getBuffer(): Nullable<DataBuffer>;
  6331. /**
  6332. * Gets the stride in float32 units (i.e. byte stride / 4).
  6333. * May not be an integer if the byte stride is not divisible by 4.
  6334. * @returns the stride in float32 units
  6335. * @deprecated Please use byteStride instead.
  6336. */
  6337. getStrideSize(): number;
  6338. /**
  6339. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6340. * @param data defines the data to store
  6341. */
  6342. create(data?: Nullable<DataArray>): void;
  6343. /** @hidden */
  6344. _rebuild(): void;
  6345. /**
  6346. * Update current buffer data
  6347. * @param data defines the data to store
  6348. */
  6349. update(data: DataArray): void;
  6350. /**
  6351. * Updates the data directly.
  6352. * @param data the new data
  6353. * @param offset the new offset
  6354. * @param vertexCount the vertex count (optional)
  6355. * @param useBytes set to true if the offset is in bytes
  6356. */
  6357. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6358. /**
  6359. * Release all resources
  6360. */
  6361. dispose(): void;
  6362. }
  6363. /**
  6364. * Specialized buffer used to store vertex data
  6365. */
  6366. export class VertexBuffer {
  6367. /** @hidden */
  6368. _buffer: Buffer;
  6369. private _kind;
  6370. private _size;
  6371. private _ownsBuffer;
  6372. private _instanced;
  6373. private _instanceDivisor;
  6374. /**
  6375. * The byte type.
  6376. */
  6377. static readonly BYTE: number;
  6378. /**
  6379. * The unsigned byte type.
  6380. */
  6381. static readonly UNSIGNED_BYTE: number;
  6382. /**
  6383. * The short type.
  6384. */
  6385. static readonly SHORT: number;
  6386. /**
  6387. * The unsigned short type.
  6388. */
  6389. static readonly UNSIGNED_SHORT: number;
  6390. /**
  6391. * The integer type.
  6392. */
  6393. static readonly INT: number;
  6394. /**
  6395. * The unsigned integer type.
  6396. */
  6397. static readonly UNSIGNED_INT: number;
  6398. /**
  6399. * The float type.
  6400. */
  6401. static readonly FLOAT: number;
  6402. /**
  6403. * Gets or sets the instance divisor when in instanced mode
  6404. */
  6405. get instanceDivisor(): number;
  6406. set instanceDivisor(value: number);
  6407. /**
  6408. * Gets the byte stride.
  6409. */
  6410. readonly byteStride: number;
  6411. /**
  6412. * Gets the byte offset.
  6413. */
  6414. readonly byteOffset: number;
  6415. /**
  6416. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6417. */
  6418. readonly normalized: boolean;
  6419. /**
  6420. * Gets the data type of each component in the array.
  6421. */
  6422. readonly type: number;
  6423. /**
  6424. * Constructor
  6425. * @param engine the engine
  6426. * @param data the data to use for this vertex buffer
  6427. * @param kind the vertex buffer kind
  6428. * @param updatable whether the data is updatable
  6429. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6430. * @param stride the stride (optional)
  6431. * @param instanced whether the buffer is instanced (optional)
  6432. * @param offset the offset of the data (optional)
  6433. * @param size the number of components (optional)
  6434. * @param type the type of the component (optional)
  6435. * @param normalized whether the data contains normalized data (optional)
  6436. * @param useBytes set to true if stride and offset are in bytes (optional)
  6437. * @param divisor defines the instance divisor to use (1 by default)
  6438. */
  6439. 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);
  6440. /** @hidden */
  6441. _rebuild(): void;
  6442. /**
  6443. * Returns the kind of the VertexBuffer (string)
  6444. * @returns a string
  6445. */
  6446. getKind(): string;
  6447. /**
  6448. * Gets a boolean indicating if the VertexBuffer is updatable?
  6449. * @returns true if the buffer is updatable
  6450. */
  6451. isUpdatable(): boolean;
  6452. /**
  6453. * Gets current buffer's data
  6454. * @returns a DataArray or null
  6455. */
  6456. getData(): Nullable<DataArray>;
  6457. /**
  6458. * Gets underlying native buffer
  6459. * @returns underlying native buffer
  6460. */
  6461. getBuffer(): Nullable<DataBuffer>;
  6462. /**
  6463. * Gets the stride in float32 units (i.e. byte stride / 4).
  6464. * May not be an integer if the byte stride is not divisible by 4.
  6465. * @returns the stride in float32 units
  6466. * @deprecated Please use byteStride instead.
  6467. */
  6468. getStrideSize(): number;
  6469. /**
  6470. * Returns the offset as a multiple of the type byte length.
  6471. * @returns the offset in bytes
  6472. * @deprecated Please use byteOffset instead.
  6473. */
  6474. getOffset(): number;
  6475. /**
  6476. * Returns the number of components per vertex attribute (integer)
  6477. * @returns the size in float
  6478. */
  6479. getSize(): number;
  6480. /**
  6481. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6482. * @returns true if this buffer is instanced
  6483. */
  6484. getIsInstanced(): boolean;
  6485. /**
  6486. * Returns the instancing divisor, zero for non-instanced (integer).
  6487. * @returns a number
  6488. */
  6489. getInstanceDivisor(): number;
  6490. /**
  6491. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6492. * @param data defines the data to store
  6493. */
  6494. create(data?: DataArray): void;
  6495. /**
  6496. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6497. * This function will create a new buffer if the current one is not updatable
  6498. * @param data defines the data to store
  6499. */
  6500. update(data: DataArray): void;
  6501. /**
  6502. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6503. * Returns the directly updated WebGLBuffer.
  6504. * @param data the new data
  6505. * @param offset the new offset
  6506. * @param useBytes set to true if the offset is in bytes
  6507. */
  6508. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6509. /**
  6510. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6511. */
  6512. dispose(): void;
  6513. /**
  6514. * Enumerates each value of this vertex buffer as numbers.
  6515. * @param count the number of values to enumerate
  6516. * @param callback the callback function called for each value
  6517. */
  6518. forEach(count: number, callback: (value: number, index: number) => void): void;
  6519. /**
  6520. * Positions
  6521. */
  6522. static readonly PositionKind: string;
  6523. /**
  6524. * Normals
  6525. */
  6526. static readonly NormalKind: string;
  6527. /**
  6528. * Tangents
  6529. */
  6530. static readonly TangentKind: string;
  6531. /**
  6532. * Texture coordinates
  6533. */
  6534. static readonly UVKind: string;
  6535. /**
  6536. * Texture coordinates 2
  6537. */
  6538. static readonly UV2Kind: string;
  6539. /**
  6540. * Texture coordinates 3
  6541. */
  6542. static readonly UV3Kind: string;
  6543. /**
  6544. * Texture coordinates 4
  6545. */
  6546. static readonly UV4Kind: string;
  6547. /**
  6548. * Texture coordinates 5
  6549. */
  6550. static readonly UV5Kind: string;
  6551. /**
  6552. * Texture coordinates 6
  6553. */
  6554. static readonly UV6Kind: string;
  6555. /**
  6556. * Colors
  6557. */
  6558. static readonly ColorKind: string;
  6559. /**
  6560. * Matrix indices (for bones)
  6561. */
  6562. static readonly MatricesIndicesKind: string;
  6563. /**
  6564. * Matrix weights (for bones)
  6565. */
  6566. static readonly MatricesWeightsKind: string;
  6567. /**
  6568. * Additional matrix indices (for bones)
  6569. */
  6570. static readonly MatricesIndicesExtraKind: string;
  6571. /**
  6572. * Additional matrix weights (for bones)
  6573. */
  6574. static readonly MatricesWeightsExtraKind: string;
  6575. /**
  6576. * Deduces the stride given a kind.
  6577. * @param kind The kind string to deduce
  6578. * @returns The deduced stride
  6579. */
  6580. static DeduceStride(kind: string): number;
  6581. /**
  6582. * Gets the byte length of the given type.
  6583. * @param type the type
  6584. * @returns the number of bytes
  6585. */
  6586. static GetTypeByteLength(type: number): number;
  6587. /**
  6588. * Enumerates each value of the given parameters as numbers.
  6589. * @param data the data to enumerate
  6590. * @param byteOffset the byte offset of the data
  6591. * @param byteStride the byte stride of the data
  6592. * @param componentCount the number of components per element
  6593. * @param componentType the type of the component
  6594. * @param count the number of values to enumerate
  6595. * @param normalized whether the data is normalized
  6596. * @param callback the callback function called for each value
  6597. */
  6598. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6599. private static _GetFloatValue;
  6600. }
  6601. }
  6602. declare module BABYLON {
  6603. /**
  6604. * @hidden
  6605. */
  6606. export class IntersectionInfo {
  6607. bu: Nullable<number>;
  6608. bv: Nullable<number>;
  6609. distance: number;
  6610. faceId: number;
  6611. subMeshId: number;
  6612. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6613. }
  6614. }
  6615. declare module BABYLON {
  6616. /**
  6617. * Represens a plane by the equation ax + by + cz + d = 0
  6618. */
  6619. export class Plane {
  6620. private static _TmpMatrix;
  6621. /**
  6622. * Normal of the plane (a,b,c)
  6623. */
  6624. normal: Vector3;
  6625. /**
  6626. * d component of the plane
  6627. */
  6628. d: number;
  6629. /**
  6630. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6631. * @param a a component of the plane
  6632. * @param b b component of the plane
  6633. * @param c c component of the plane
  6634. * @param d d component of the plane
  6635. */
  6636. constructor(a: number, b: number, c: number, d: number);
  6637. /**
  6638. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6639. */
  6640. asArray(): number[];
  6641. /**
  6642. * @returns a new plane copied from the current Plane.
  6643. */
  6644. clone(): Plane;
  6645. /**
  6646. * @returns the string "Plane".
  6647. */
  6648. getClassName(): string;
  6649. /**
  6650. * @returns the Plane hash code.
  6651. */
  6652. getHashCode(): number;
  6653. /**
  6654. * Normalize the current Plane in place.
  6655. * @returns the updated Plane.
  6656. */
  6657. normalize(): Plane;
  6658. /**
  6659. * Applies a transformation the plane and returns the result
  6660. * @param transformation the transformation matrix to be applied to the plane
  6661. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6662. */
  6663. transform(transformation: DeepImmutable<Matrix>): Plane;
  6664. /**
  6665. * Calcualtte the dot product between the point and the plane normal
  6666. * @param point point to calculate the dot product with
  6667. * @returns the dot product (float) of the point coordinates and the plane normal.
  6668. */
  6669. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6670. /**
  6671. * Updates the current Plane from the plane defined by the three given points.
  6672. * @param point1 one of the points used to contruct the plane
  6673. * @param point2 one of the points used to contruct the plane
  6674. * @param point3 one of the points used to contruct the plane
  6675. * @returns the updated Plane.
  6676. */
  6677. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6678. /**
  6679. * Checks if the plane is facing a given direction
  6680. * @param direction the direction to check if the plane is facing
  6681. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6682. * @returns True is the vector "direction" is the same side than the plane normal.
  6683. */
  6684. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6685. /**
  6686. * Calculates the distance to a point
  6687. * @param point point to calculate distance to
  6688. * @returns the signed distance (float) from the given point to the Plane.
  6689. */
  6690. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6691. /**
  6692. * Creates a plane from an array
  6693. * @param array the array to create a plane from
  6694. * @returns a new Plane from the given array.
  6695. */
  6696. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6697. /**
  6698. * Creates a plane from three points
  6699. * @param point1 point used to create the plane
  6700. * @param point2 point used to create the plane
  6701. * @param point3 point used to create the plane
  6702. * @returns a new Plane defined by the three given points.
  6703. */
  6704. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6705. /**
  6706. * Creates a plane from an origin point and a normal
  6707. * @param origin origin of the plane to be constructed
  6708. * @param normal normal of the plane to be constructed
  6709. * @returns a new Plane the normal vector to this plane at the given origin point.
  6710. * Note : the vector "normal" is updated because normalized.
  6711. */
  6712. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6713. /**
  6714. * Calculates the distance from a plane and a point
  6715. * @param origin origin of the plane to be constructed
  6716. * @param normal normal of the plane to be constructed
  6717. * @param point point to calculate distance to
  6718. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6719. */
  6720. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6721. }
  6722. }
  6723. declare module BABYLON {
  6724. /**
  6725. * Class used to store bounding sphere information
  6726. */
  6727. export class BoundingSphere {
  6728. /**
  6729. * Gets the center of the bounding sphere in local space
  6730. */
  6731. readonly center: Vector3;
  6732. /**
  6733. * Radius of the bounding sphere in local space
  6734. */
  6735. radius: number;
  6736. /**
  6737. * Gets the center of the bounding sphere in world space
  6738. */
  6739. readonly centerWorld: Vector3;
  6740. /**
  6741. * Radius of the bounding sphere in world space
  6742. */
  6743. radiusWorld: number;
  6744. /**
  6745. * Gets the minimum vector in local space
  6746. */
  6747. readonly minimum: Vector3;
  6748. /**
  6749. * Gets the maximum vector in local space
  6750. */
  6751. readonly maximum: Vector3;
  6752. private _worldMatrix;
  6753. private static readonly TmpVector3;
  6754. /**
  6755. * Creates a new bounding sphere
  6756. * @param min defines the minimum vector (in local space)
  6757. * @param max defines the maximum vector (in local space)
  6758. * @param worldMatrix defines the new world matrix
  6759. */
  6760. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6761. /**
  6762. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6763. * @param min defines the new minimum vector (in local space)
  6764. * @param max defines the new maximum vector (in local space)
  6765. * @param worldMatrix defines the new world matrix
  6766. */
  6767. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6768. /**
  6769. * Scale the current bounding sphere by applying a scale factor
  6770. * @param factor defines the scale factor to apply
  6771. * @returns the current bounding box
  6772. */
  6773. scale(factor: number): BoundingSphere;
  6774. /**
  6775. * Gets the world matrix of the bounding box
  6776. * @returns a matrix
  6777. */
  6778. getWorldMatrix(): DeepImmutable<Matrix>;
  6779. /** @hidden */
  6780. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6781. /**
  6782. * Tests if the bounding sphere is intersecting the frustum planes
  6783. * @param frustumPlanes defines the frustum planes to test
  6784. * @returns true if there is an intersection
  6785. */
  6786. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6787. /**
  6788. * Tests if the bounding sphere center is in between the frustum planes.
  6789. * Used for optimistic fast inclusion.
  6790. * @param frustumPlanes defines the frustum planes to test
  6791. * @returns true if the sphere center is in between the frustum planes
  6792. */
  6793. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6794. /**
  6795. * Tests if a point is inside the bounding sphere
  6796. * @param point defines the point to test
  6797. * @returns true if the point is inside the bounding sphere
  6798. */
  6799. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6800. /**
  6801. * Checks if two sphere intersct
  6802. * @param sphere0 sphere 0
  6803. * @param sphere1 sphere 1
  6804. * @returns true if the speres intersect
  6805. */
  6806. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6807. }
  6808. }
  6809. declare module BABYLON {
  6810. /**
  6811. * Class used to store bounding box information
  6812. */
  6813. export class BoundingBox implements ICullable {
  6814. /**
  6815. * Gets the 8 vectors representing the bounding box in local space
  6816. */
  6817. readonly vectors: Vector3[];
  6818. /**
  6819. * Gets the center of the bounding box in local space
  6820. */
  6821. readonly center: Vector3;
  6822. /**
  6823. * Gets the center of the bounding box in world space
  6824. */
  6825. readonly centerWorld: Vector3;
  6826. /**
  6827. * Gets the extend size in local space
  6828. */
  6829. readonly extendSize: Vector3;
  6830. /**
  6831. * Gets the extend size in world space
  6832. */
  6833. readonly extendSizeWorld: Vector3;
  6834. /**
  6835. * Gets the OBB (object bounding box) directions
  6836. */
  6837. readonly directions: Vector3[];
  6838. /**
  6839. * Gets the 8 vectors representing the bounding box in world space
  6840. */
  6841. readonly vectorsWorld: Vector3[];
  6842. /**
  6843. * Gets the minimum vector in world space
  6844. */
  6845. readonly minimumWorld: Vector3;
  6846. /**
  6847. * Gets the maximum vector in world space
  6848. */
  6849. readonly maximumWorld: Vector3;
  6850. /**
  6851. * Gets the minimum vector in local space
  6852. */
  6853. readonly minimum: Vector3;
  6854. /**
  6855. * Gets the maximum vector in local space
  6856. */
  6857. readonly maximum: Vector3;
  6858. private _worldMatrix;
  6859. private static readonly TmpVector3;
  6860. /**
  6861. * @hidden
  6862. */
  6863. _tag: number;
  6864. /**
  6865. * Creates a new bounding box
  6866. * @param min defines the minimum vector (in local space)
  6867. * @param max defines the maximum vector (in local space)
  6868. * @param worldMatrix defines the new world matrix
  6869. */
  6870. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6871. /**
  6872. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6873. * @param min defines the new minimum vector (in local space)
  6874. * @param max defines the new maximum vector (in local space)
  6875. * @param worldMatrix defines the new world matrix
  6876. */
  6877. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6878. /**
  6879. * Scale the current bounding box by applying a scale factor
  6880. * @param factor defines the scale factor to apply
  6881. * @returns the current bounding box
  6882. */
  6883. scale(factor: number): BoundingBox;
  6884. /**
  6885. * Gets the world matrix of the bounding box
  6886. * @returns a matrix
  6887. */
  6888. getWorldMatrix(): DeepImmutable<Matrix>;
  6889. /** @hidden */
  6890. _update(world: DeepImmutable<Matrix>): void;
  6891. /**
  6892. * Tests if the bounding box is intersecting the frustum planes
  6893. * @param frustumPlanes defines the frustum planes to test
  6894. * @returns true if there is an intersection
  6895. */
  6896. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6897. /**
  6898. * Tests if the bounding box is entirely inside the frustum planes
  6899. * @param frustumPlanes defines the frustum planes to test
  6900. * @returns true if there is an inclusion
  6901. */
  6902. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6903. /**
  6904. * Tests if a point is inside the bounding box
  6905. * @param point defines the point to test
  6906. * @returns true if the point is inside the bounding box
  6907. */
  6908. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6909. /**
  6910. * Tests if the bounding box intersects with a bounding sphere
  6911. * @param sphere defines the sphere to test
  6912. * @returns true if there is an intersection
  6913. */
  6914. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6915. /**
  6916. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6917. * @param min defines the min vector to use
  6918. * @param max defines the max vector to use
  6919. * @returns true if there is an intersection
  6920. */
  6921. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6922. /**
  6923. * Tests if two bounding boxes are intersections
  6924. * @param box0 defines the first box to test
  6925. * @param box1 defines the second box to test
  6926. * @returns true if there is an intersection
  6927. */
  6928. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6929. /**
  6930. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6931. * @param minPoint defines the minimum vector of the bounding box
  6932. * @param maxPoint defines the maximum vector of the bounding box
  6933. * @param sphereCenter defines the sphere center
  6934. * @param sphereRadius defines the sphere radius
  6935. * @returns true if there is an intersection
  6936. */
  6937. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6938. /**
  6939. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6940. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6941. * @param frustumPlanes defines the frustum planes to test
  6942. * @return true if there is an inclusion
  6943. */
  6944. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6945. /**
  6946. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6947. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6948. * @param frustumPlanes defines the frustum planes to test
  6949. * @return true if there is an intersection
  6950. */
  6951. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6952. }
  6953. }
  6954. declare module BABYLON {
  6955. /** @hidden */
  6956. export class Collider {
  6957. /** Define if a collision was found */
  6958. collisionFound: boolean;
  6959. /**
  6960. * Define last intersection point in local space
  6961. */
  6962. intersectionPoint: Vector3;
  6963. /**
  6964. * Define last collided mesh
  6965. */
  6966. collidedMesh: Nullable<AbstractMesh>;
  6967. private _collisionPoint;
  6968. private _planeIntersectionPoint;
  6969. private _tempVector;
  6970. private _tempVector2;
  6971. private _tempVector3;
  6972. private _tempVector4;
  6973. private _edge;
  6974. private _baseToVertex;
  6975. private _destinationPoint;
  6976. private _slidePlaneNormal;
  6977. private _displacementVector;
  6978. /** @hidden */
  6979. _radius: Vector3;
  6980. /** @hidden */
  6981. _retry: number;
  6982. private _velocity;
  6983. private _basePoint;
  6984. private _epsilon;
  6985. /** @hidden */
  6986. _velocityWorldLength: number;
  6987. /** @hidden */
  6988. _basePointWorld: Vector3;
  6989. private _velocityWorld;
  6990. private _normalizedVelocity;
  6991. /** @hidden */
  6992. _initialVelocity: Vector3;
  6993. /** @hidden */
  6994. _initialPosition: Vector3;
  6995. private _nearestDistance;
  6996. private _collisionMask;
  6997. get collisionMask(): number;
  6998. set collisionMask(mask: number);
  6999. /**
  7000. * Gets the plane normal used to compute the sliding response (in local space)
  7001. */
  7002. get slidePlaneNormal(): Vector3;
  7003. /** @hidden */
  7004. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7005. /** @hidden */
  7006. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7007. /** @hidden */
  7008. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7009. /** @hidden */
  7010. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7011. /** @hidden */
  7012. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7013. /** @hidden */
  7014. _getResponse(pos: Vector3, vel: Vector3): void;
  7015. }
  7016. }
  7017. declare module BABYLON {
  7018. /**
  7019. * Interface for cullable objects
  7020. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7021. */
  7022. export interface ICullable {
  7023. /**
  7024. * Checks if the object or part of the object is in the frustum
  7025. * @param frustumPlanes Camera near/planes
  7026. * @returns true if the object is in frustum otherwise false
  7027. */
  7028. isInFrustum(frustumPlanes: Plane[]): boolean;
  7029. /**
  7030. * Checks if a cullable object (mesh...) is in the camera frustum
  7031. * Unlike isInFrustum this cheks the full bounding box
  7032. * @param frustumPlanes Camera near/planes
  7033. * @returns true if the object is in frustum otherwise false
  7034. */
  7035. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7036. }
  7037. /**
  7038. * Info for a bounding data of a mesh
  7039. */
  7040. export class BoundingInfo implements ICullable {
  7041. /**
  7042. * Bounding box for the mesh
  7043. */
  7044. readonly boundingBox: BoundingBox;
  7045. /**
  7046. * Bounding sphere for the mesh
  7047. */
  7048. readonly boundingSphere: BoundingSphere;
  7049. private _isLocked;
  7050. private static readonly TmpVector3;
  7051. /**
  7052. * Constructs bounding info
  7053. * @param minimum min vector of the bounding box/sphere
  7054. * @param maximum max vector of the bounding box/sphere
  7055. * @param worldMatrix defines the new world matrix
  7056. */
  7057. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7058. /**
  7059. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7060. * @param min defines the new minimum vector (in local space)
  7061. * @param max defines the new maximum vector (in local space)
  7062. * @param worldMatrix defines the new world matrix
  7063. */
  7064. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7065. /**
  7066. * min vector of the bounding box/sphere
  7067. */
  7068. get minimum(): Vector3;
  7069. /**
  7070. * max vector of the bounding box/sphere
  7071. */
  7072. get maximum(): Vector3;
  7073. /**
  7074. * If the info is locked and won't be updated to avoid perf overhead
  7075. */
  7076. get isLocked(): boolean;
  7077. set isLocked(value: boolean);
  7078. /**
  7079. * Updates the bounding sphere and box
  7080. * @param world world matrix to be used to update
  7081. */
  7082. update(world: DeepImmutable<Matrix>): void;
  7083. /**
  7084. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7085. * @param center New center of the bounding info
  7086. * @param extend New extend of the bounding info
  7087. * @returns the current bounding info
  7088. */
  7089. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7090. /**
  7091. * Scale the current bounding info by applying a scale factor
  7092. * @param factor defines the scale factor to apply
  7093. * @returns the current bounding info
  7094. */
  7095. scale(factor: number): BoundingInfo;
  7096. /**
  7097. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7098. * @param frustumPlanes defines the frustum to test
  7099. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7100. * @returns true if the bounding info is in the frustum planes
  7101. */
  7102. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7103. /**
  7104. * Gets the world distance between the min and max points of the bounding box
  7105. */
  7106. get diagonalLength(): number;
  7107. /**
  7108. * Checks if a cullable object (mesh...) is in the camera frustum
  7109. * Unlike isInFrustum this cheks the full bounding box
  7110. * @param frustumPlanes Camera near/planes
  7111. * @returns true if the object is in frustum otherwise false
  7112. */
  7113. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7114. /** @hidden */
  7115. _checkCollision(collider: Collider): boolean;
  7116. /**
  7117. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7118. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7119. * @param point the point to check intersection with
  7120. * @returns if the point intersects
  7121. */
  7122. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7123. /**
  7124. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7125. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7126. * @param boundingInfo the bounding info to check intersection with
  7127. * @param precise if the intersection should be done using OBB
  7128. * @returns if the bounding info intersects
  7129. */
  7130. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7131. }
  7132. }
  7133. declare module BABYLON {
  7134. /**
  7135. * Extracts minimum and maximum values from a list of indexed positions
  7136. * @param positions defines the positions to use
  7137. * @param indices defines the indices to the positions
  7138. * @param indexStart defines the start index
  7139. * @param indexCount defines the end index
  7140. * @param bias defines bias value to add to the result
  7141. * @return minimum and maximum values
  7142. */
  7143. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7144. minimum: Vector3;
  7145. maximum: Vector3;
  7146. };
  7147. /**
  7148. * Extracts minimum and maximum values from a list of positions
  7149. * @param positions defines the positions to use
  7150. * @param start defines the start index in the positions array
  7151. * @param count defines the number of positions to handle
  7152. * @param bias defines bias value to add to the result
  7153. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7154. * @return minimum and maximum values
  7155. */
  7156. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7157. minimum: Vector3;
  7158. maximum: Vector3;
  7159. };
  7160. }
  7161. declare module BABYLON {
  7162. /** @hidden */
  7163. export class WebGLDataBuffer extends DataBuffer {
  7164. private _buffer;
  7165. constructor(resource: WebGLBuffer);
  7166. get underlyingResource(): any;
  7167. }
  7168. }
  7169. declare module BABYLON {
  7170. /** @hidden */
  7171. export class WebGLPipelineContext implements IPipelineContext {
  7172. engine: ThinEngine;
  7173. program: Nullable<WebGLProgram>;
  7174. context?: WebGLRenderingContext;
  7175. vertexShader?: WebGLShader;
  7176. fragmentShader?: WebGLShader;
  7177. isParallelCompiled: boolean;
  7178. onCompiled?: () => void;
  7179. transformFeedback?: WebGLTransformFeedback | null;
  7180. vertexCompilationError: Nullable<string>;
  7181. fragmentCompilationError: Nullable<string>;
  7182. programLinkError: Nullable<string>;
  7183. programValidationError: Nullable<string>;
  7184. get isAsync(): boolean;
  7185. get isReady(): boolean;
  7186. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7187. }
  7188. }
  7189. declare module BABYLON {
  7190. interface ThinEngine {
  7191. /**
  7192. * Create an uniform buffer
  7193. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7194. * @param elements defines the content of the uniform buffer
  7195. * @returns the webGL uniform buffer
  7196. */
  7197. createUniformBuffer(elements: FloatArray): DataBuffer;
  7198. /**
  7199. * Create a dynamic uniform buffer
  7200. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7201. * @param elements defines the content of the uniform buffer
  7202. * @returns the webGL uniform buffer
  7203. */
  7204. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7205. /**
  7206. * Update an existing uniform buffer
  7207. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7208. * @param uniformBuffer defines the target uniform buffer
  7209. * @param elements defines the content to update
  7210. * @param offset defines the offset in the uniform buffer where update should start
  7211. * @param count defines the size of the data to update
  7212. */
  7213. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7214. /**
  7215. * Bind an uniform buffer to the current webGL context
  7216. * @param buffer defines the buffer to bind
  7217. */
  7218. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7219. /**
  7220. * Bind a buffer to the current webGL context at a given location
  7221. * @param buffer defines the buffer to bind
  7222. * @param location defines the index where to bind the buffer
  7223. */
  7224. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7225. /**
  7226. * Bind a specific block at a given index in a specific shader program
  7227. * @param pipelineContext defines the pipeline context to use
  7228. * @param blockName defines the block name
  7229. * @param index defines the index where to bind the block
  7230. */
  7231. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7232. }
  7233. }
  7234. declare module BABYLON {
  7235. /**
  7236. * Uniform buffer objects.
  7237. *
  7238. * Handles blocks of uniform on the GPU.
  7239. *
  7240. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7241. *
  7242. * For more information, please refer to :
  7243. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7244. */
  7245. export class UniformBuffer {
  7246. private _engine;
  7247. private _buffer;
  7248. private _data;
  7249. private _bufferData;
  7250. private _dynamic?;
  7251. private _uniformLocations;
  7252. private _uniformSizes;
  7253. private _uniformLocationPointer;
  7254. private _needSync;
  7255. private _noUBO;
  7256. private _currentEffect;
  7257. /** @hidden */
  7258. _alreadyBound: boolean;
  7259. private static _MAX_UNIFORM_SIZE;
  7260. private static _tempBuffer;
  7261. /**
  7262. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7263. * This is dynamic to allow compat with webgl 1 and 2.
  7264. * You will need to pass the name of the uniform as well as the value.
  7265. */
  7266. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7267. /**
  7268. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7269. * This is dynamic to allow compat with webgl 1 and 2.
  7270. * You will need to pass the name of the uniform as well as the value.
  7271. */
  7272. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7273. /**
  7274. * Lambda to Update a single float in a uniform buffer.
  7275. * This is dynamic to allow compat with webgl 1 and 2.
  7276. * You will need to pass the name of the uniform as well as the value.
  7277. */
  7278. updateFloat: (name: string, x: number) => void;
  7279. /**
  7280. * Lambda to Update a vec2 of float in a uniform buffer.
  7281. * This is dynamic to allow compat with webgl 1 and 2.
  7282. * You will need to pass the name of the uniform as well as the value.
  7283. */
  7284. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7285. /**
  7286. * Lambda to Update a vec3 of float in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7291. /**
  7292. * Lambda to Update a vec4 of float in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7297. /**
  7298. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateMatrix: (name: string, mat: Matrix) => void;
  7303. /**
  7304. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateVector3: (name: string, vector: Vector3) => void;
  7309. /**
  7310. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateVector4: (name: string, vector: Vector4) => void;
  7315. /**
  7316. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7321. /**
  7322. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7327. /**
  7328. * Instantiates a new Uniform buffer objects.
  7329. *
  7330. * Handles blocks of uniform on the GPU.
  7331. *
  7332. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7333. *
  7334. * For more information, please refer to :
  7335. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7336. * @param engine Define the engine the buffer is associated with
  7337. * @param data Define the data contained in the buffer
  7338. * @param dynamic Define if the buffer is updatable
  7339. */
  7340. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7341. /**
  7342. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7343. * or just falling back on setUniformXXX calls.
  7344. */
  7345. get useUbo(): boolean;
  7346. /**
  7347. * Indicates if the WebGL underlying uniform buffer is in sync
  7348. * with the javascript cache data.
  7349. */
  7350. get isSync(): boolean;
  7351. /**
  7352. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7353. * Also, a dynamic UniformBuffer will disable cache verification and always
  7354. * update the underlying WebGL uniform buffer to the GPU.
  7355. * @returns if Dynamic, otherwise false
  7356. */
  7357. isDynamic(): boolean;
  7358. /**
  7359. * The data cache on JS side.
  7360. * @returns the underlying data as a float array
  7361. */
  7362. getData(): Float32Array;
  7363. /**
  7364. * The underlying WebGL Uniform buffer.
  7365. * @returns the webgl buffer
  7366. */
  7367. getBuffer(): Nullable<DataBuffer>;
  7368. /**
  7369. * std140 layout specifies how to align data within an UBO structure.
  7370. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7371. * for specs.
  7372. */
  7373. private _fillAlignment;
  7374. /**
  7375. * Adds an uniform in the buffer.
  7376. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7377. * for the layout to be correct !
  7378. * @param name Name of the uniform, as used in the uniform block in the shader.
  7379. * @param size Data size, or data directly.
  7380. */
  7381. addUniform(name: string, size: number | number[]): void;
  7382. /**
  7383. * Adds a Matrix 4x4 to the uniform buffer.
  7384. * @param name Name of the uniform, as used in the uniform block in the shader.
  7385. * @param mat A 4x4 matrix.
  7386. */
  7387. addMatrix(name: string, mat: Matrix): void;
  7388. /**
  7389. * Adds a vec2 to the uniform buffer.
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param x Define the x component value of the vec2
  7392. * @param y Define the y component value of the vec2
  7393. */
  7394. addFloat2(name: string, x: number, y: number): void;
  7395. /**
  7396. * Adds a vec3 to the uniform buffer.
  7397. * @param name Name of the uniform, as used in the uniform block in the shader.
  7398. * @param x Define the x component value of the vec3
  7399. * @param y Define the y component value of the vec3
  7400. * @param z Define the z component value of the vec3
  7401. */
  7402. addFloat3(name: string, x: number, y: number, z: number): void;
  7403. /**
  7404. * Adds a vec3 to the uniform buffer.
  7405. * @param name Name of the uniform, as used in the uniform block in the shader.
  7406. * @param color Define the vec3 from a Color
  7407. */
  7408. addColor3(name: string, color: Color3): void;
  7409. /**
  7410. * Adds a vec4 to the uniform buffer.
  7411. * @param name Name of the uniform, as used in the uniform block in the shader.
  7412. * @param color Define the rgb components from a Color
  7413. * @param alpha Define the a component of the vec4
  7414. */
  7415. addColor4(name: string, color: Color3, alpha: number): void;
  7416. /**
  7417. * Adds a vec3 to the uniform buffer.
  7418. * @param name Name of the uniform, as used in the uniform block in the shader.
  7419. * @param vector Define the vec3 components from a Vector
  7420. */
  7421. addVector3(name: string, vector: Vector3): void;
  7422. /**
  7423. * Adds a Matrix 3x3 to the uniform buffer.
  7424. * @param name Name of the uniform, as used in the uniform block in the shader.
  7425. */
  7426. addMatrix3x3(name: string): void;
  7427. /**
  7428. * Adds a Matrix 2x2 to the uniform buffer.
  7429. * @param name Name of the uniform, as used in the uniform block in the shader.
  7430. */
  7431. addMatrix2x2(name: string): void;
  7432. /**
  7433. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7434. */
  7435. create(): void;
  7436. /** @hidden */
  7437. _rebuild(): void;
  7438. /**
  7439. * Updates the WebGL Uniform Buffer on the GPU.
  7440. * If the `dynamic` flag is set to true, no cache comparison is done.
  7441. * Otherwise, the buffer will be updated only if the cache differs.
  7442. */
  7443. update(): void;
  7444. /**
  7445. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7446. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7447. * @param data Define the flattened data
  7448. * @param size Define the size of the data.
  7449. */
  7450. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7451. private _valueCache;
  7452. private _cacheMatrix;
  7453. private _updateMatrix3x3ForUniform;
  7454. private _updateMatrix3x3ForEffect;
  7455. private _updateMatrix2x2ForEffect;
  7456. private _updateMatrix2x2ForUniform;
  7457. private _updateFloatForEffect;
  7458. private _updateFloatForUniform;
  7459. private _updateFloat2ForEffect;
  7460. private _updateFloat2ForUniform;
  7461. private _updateFloat3ForEffect;
  7462. private _updateFloat3ForUniform;
  7463. private _updateFloat4ForEffect;
  7464. private _updateFloat4ForUniform;
  7465. private _updateMatrixForEffect;
  7466. private _updateMatrixForUniform;
  7467. private _updateVector3ForEffect;
  7468. private _updateVector3ForUniform;
  7469. private _updateVector4ForEffect;
  7470. private _updateVector4ForUniform;
  7471. private _updateColor3ForEffect;
  7472. private _updateColor3ForUniform;
  7473. private _updateColor4ForEffect;
  7474. private _updateColor4ForUniform;
  7475. /**
  7476. * Sets a sampler uniform on the effect.
  7477. * @param name Define the name of the sampler.
  7478. * @param texture Define the texture to set in the sampler
  7479. */
  7480. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7481. /**
  7482. * Directly updates the value of the uniform in the cache AND on the GPU.
  7483. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7484. * @param data Define the flattened data
  7485. */
  7486. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7487. /**
  7488. * Binds this uniform buffer to an effect.
  7489. * @param effect Define the effect to bind the buffer to
  7490. * @param name Name of the uniform block in the shader.
  7491. */
  7492. bindToEffect(effect: Effect, name: string): void;
  7493. /**
  7494. * Disposes the uniform buffer.
  7495. */
  7496. dispose(): void;
  7497. }
  7498. }
  7499. declare module BABYLON {
  7500. /**
  7501. * Enum that determines the text-wrapping mode to use.
  7502. */
  7503. export enum InspectableType {
  7504. /**
  7505. * Checkbox for booleans
  7506. */
  7507. Checkbox = 0,
  7508. /**
  7509. * Sliders for numbers
  7510. */
  7511. Slider = 1,
  7512. /**
  7513. * Vector3
  7514. */
  7515. Vector3 = 2,
  7516. /**
  7517. * Quaternions
  7518. */
  7519. Quaternion = 3,
  7520. /**
  7521. * Color3
  7522. */
  7523. Color3 = 4,
  7524. /**
  7525. * String
  7526. */
  7527. String = 5
  7528. }
  7529. /**
  7530. * Interface used to define custom inspectable properties.
  7531. * This interface is used by the inspector to display custom property grids
  7532. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7533. */
  7534. export interface IInspectable {
  7535. /**
  7536. * Gets the label to display
  7537. */
  7538. label: string;
  7539. /**
  7540. * Gets the name of the property to edit
  7541. */
  7542. propertyName: string;
  7543. /**
  7544. * Gets the type of the editor to use
  7545. */
  7546. type: InspectableType;
  7547. /**
  7548. * Gets the minimum value of the property when using in "slider" mode
  7549. */
  7550. min?: number;
  7551. /**
  7552. * Gets the maximum value of the property when using in "slider" mode
  7553. */
  7554. max?: number;
  7555. /**
  7556. * Gets the setp to use when using in "slider" mode
  7557. */
  7558. step?: number;
  7559. }
  7560. }
  7561. declare module BABYLON {
  7562. /**
  7563. * Class used to provide helper for timing
  7564. */
  7565. export class TimingTools {
  7566. /**
  7567. * Polyfill for setImmediate
  7568. * @param action defines the action to execute after the current execution block
  7569. */
  7570. static SetImmediate(action: () => void): void;
  7571. }
  7572. }
  7573. declare module BABYLON {
  7574. /**
  7575. * Class used to enable instatition of objects by class name
  7576. */
  7577. export class InstantiationTools {
  7578. /**
  7579. * Use this object to register external classes like custom textures or material
  7580. * to allow the laoders to instantiate them
  7581. */
  7582. static RegisteredExternalClasses: {
  7583. [key: string]: Object;
  7584. };
  7585. /**
  7586. * Tries to instantiate a new object from a given class name
  7587. * @param className defines the class name to instantiate
  7588. * @returns the new object or null if the system was not able to do the instantiation
  7589. */
  7590. static Instantiate(className: string): any;
  7591. }
  7592. }
  7593. declare module BABYLON {
  7594. /**
  7595. * Define options used to create a depth texture
  7596. */
  7597. export class DepthTextureCreationOptions {
  7598. /** Specifies whether or not a stencil should be allocated in the texture */
  7599. generateStencil?: boolean;
  7600. /** Specifies whether or not bilinear filtering is enable on the texture */
  7601. bilinearFiltering?: boolean;
  7602. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7603. comparisonFunction?: number;
  7604. /** Specifies if the created texture is a cube texture */
  7605. isCube?: boolean;
  7606. }
  7607. }
  7608. declare module BABYLON {
  7609. interface ThinEngine {
  7610. /**
  7611. * Creates a depth stencil cube texture.
  7612. * This is only available in WebGL 2.
  7613. * @param size The size of face edge in the cube texture.
  7614. * @param options The options defining the cube texture.
  7615. * @returns The cube texture
  7616. */
  7617. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7618. /**
  7619. * Creates a cube texture
  7620. * @param rootUrl defines the url where the files to load is located
  7621. * @param scene defines the current scene
  7622. * @param files defines the list of files to load (1 per face)
  7623. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7624. * @param onLoad defines an optional callback raised when the texture is loaded
  7625. * @param onError defines an optional callback raised if there is an issue to load the texture
  7626. * @param format defines the format of the data
  7627. * @param forcedExtension defines the extension to use to pick the right loader
  7628. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7629. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7630. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7631. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7632. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  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>, excludeLoaders: Array<IInternalTextureLoader>): 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. * The url of the texture
  7687. */
  7688. url: string;
  7689. /**
  7690. * Gets or sets the center of the bounding box associated with the cube texture.
  7691. * It must define where the camera used to render the texture was set
  7692. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7693. */
  7694. boundingBoxPosition: Vector3;
  7695. private _boundingBoxSize;
  7696. /**
  7697. * Gets or sets the size of the bounding box associated with the cube texture
  7698. * When defined, the cubemap will switch to local mode
  7699. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7700. * @example https://www.babylonjs-playground.com/#RNASML
  7701. */
  7702. set boundingBoxSize(value: Vector3);
  7703. /**
  7704. * Returns the bounding box size
  7705. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7706. */
  7707. get boundingBoxSize(): Vector3;
  7708. protected _rotationY: number;
  7709. /**
  7710. * Sets texture matrix rotation angle around Y axis in radians.
  7711. */
  7712. set rotationY(value: number);
  7713. /**
  7714. * Gets texture matrix rotation angle around Y axis radians.
  7715. */
  7716. get rotationY(): number;
  7717. /**
  7718. * Are mip maps generated for this texture or not.
  7719. */
  7720. get noMipmap(): boolean;
  7721. private _noMipmap;
  7722. private _files;
  7723. protected _forcedExtension: Nullable<string>;
  7724. private _extensions;
  7725. private _textureMatrix;
  7726. private _format;
  7727. private _createPolynomials;
  7728. /** @hidden */
  7729. _prefiltered: boolean;
  7730. /**
  7731. * Creates a cube texture from an array of image urls
  7732. * @param files defines an array of image urls
  7733. * @param scene defines the hosting scene
  7734. * @param noMipmap specifies if mip maps are not used
  7735. * @returns a cube texture
  7736. */
  7737. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7738. /**
  7739. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7740. * @param url defines the url of the prefiltered texture
  7741. * @param scene defines the scene the texture is attached to
  7742. * @param forcedExtension defines the extension of the file if different from the url
  7743. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7744. * @return the prefiltered texture
  7745. */
  7746. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7747. /**
  7748. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7749. * as prefiltered data.
  7750. * @param rootUrl defines the url of the texture or the root name of the six images
  7751. * @param scene defines the scene the texture is attached to
  7752. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7753. * @param noMipmap defines if mipmaps should be created or not
  7754. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7755. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7756. * @param onError defines a callback triggered in case of error during load
  7757. * @param format defines the internal format to use for the texture once loaded
  7758. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7759. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7760. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7761. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7762. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7763. * @return the cube texture
  7764. */
  7765. 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);
  7766. /**
  7767. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7768. */
  7769. get isPrefiltered(): boolean;
  7770. /**
  7771. * Get the current class name of the texture useful for serialization or dynamic coding.
  7772. * @returns "CubeTexture"
  7773. */
  7774. getClassName(): string;
  7775. /**
  7776. * Update the url (and optional buffer) of this texture if url was null during construction.
  7777. * @param url the url of the texture
  7778. * @param forcedExtension defines the extension to use
  7779. * @param onLoad callback called when the texture is loaded (defaults to null)
  7780. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7781. */
  7782. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7783. /**
  7784. * Delays loading of the cube texture
  7785. * @param forcedExtension defines the extension to use
  7786. */
  7787. delayLoad(forcedExtension?: string): void;
  7788. /**
  7789. * Returns the reflection texture matrix
  7790. * @returns the reflection texture matrix
  7791. */
  7792. getReflectionTextureMatrix(): Matrix;
  7793. /**
  7794. * Sets the reflection texture matrix
  7795. * @param value Reflection texture matrix
  7796. */
  7797. setReflectionTextureMatrix(value: Matrix): void;
  7798. /**
  7799. * Parses text to create a cube texture
  7800. * @param parsedTexture define the serialized text to read from
  7801. * @param scene defines the hosting scene
  7802. * @param rootUrl defines the root url of the cube texture
  7803. * @returns a cube texture
  7804. */
  7805. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7806. /**
  7807. * Makes a clone, or deep copy, of the cube texture
  7808. * @returns a new cube texture
  7809. */
  7810. clone(): CubeTexture;
  7811. }
  7812. }
  7813. declare module BABYLON {
  7814. /**
  7815. * Manages the defines for the Material
  7816. */
  7817. export class MaterialDefines {
  7818. /** @hidden */
  7819. protected _keys: string[];
  7820. private _isDirty;
  7821. /** @hidden */
  7822. _renderId: number;
  7823. /** @hidden */
  7824. _areLightsDirty: boolean;
  7825. /** @hidden */
  7826. _areLightsDisposed: boolean;
  7827. /** @hidden */
  7828. _areAttributesDirty: boolean;
  7829. /** @hidden */
  7830. _areTexturesDirty: boolean;
  7831. /** @hidden */
  7832. _areFresnelDirty: boolean;
  7833. /** @hidden */
  7834. _areMiscDirty: boolean;
  7835. /** @hidden */
  7836. _areImageProcessingDirty: boolean;
  7837. /** @hidden */
  7838. _normals: boolean;
  7839. /** @hidden */
  7840. _uvs: boolean;
  7841. /** @hidden */
  7842. _needNormals: boolean;
  7843. /** @hidden */
  7844. _needUVs: boolean;
  7845. [id: string]: any;
  7846. /**
  7847. * Specifies if the material needs to be re-calculated
  7848. */
  7849. get isDirty(): boolean;
  7850. /**
  7851. * Marks the material to indicate that it has been re-calculated
  7852. */
  7853. markAsProcessed(): void;
  7854. /**
  7855. * Marks the material to indicate that it needs to be re-calculated
  7856. */
  7857. markAsUnprocessed(): void;
  7858. /**
  7859. * Marks the material to indicate all of its defines need to be re-calculated
  7860. */
  7861. markAllAsDirty(): void;
  7862. /**
  7863. * Marks the material to indicate that image processing needs to be re-calculated
  7864. */
  7865. markAsImageProcessingDirty(): void;
  7866. /**
  7867. * Marks the material to indicate the lights need to be re-calculated
  7868. * @param disposed Defines whether the light is dirty due to dispose or not
  7869. */
  7870. markAsLightDirty(disposed?: boolean): void;
  7871. /**
  7872. * Marks the attribute state as changed
  7873. */
  7874. markAsAttributesDirty(): void;
  7875. /**
  7876. * Marks the texture state as changed
  7877. */
  7878. markAsTexturesDirty(): void;
  7879. /**
  7880. * Marks the fresnel state as changed
  7881. */
  7882. markAsFresnelDirty(): void;
  7883. /**
  7884. * Marks the misc state as changed
  7885. */
  7886. markAsMiscDirty(): void;
  7887. /**
  7888. * Rebuilds the material defines
  7889. */
  7890. rebuild(): void;
  7891. /**
  7892. * Specifies if two material defines are equal
  7893. * @param other - A material define instance to compare to
  7894. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7895. */
  7896. isEqual(other: MaterialDefines): boolean;
  7897. /**
  7898. * Clones this instance's defines to another instance
  7899. * @param other - material defines to clone values to
  7900. */
  7901. cloneTo(other: MaterialDefines): void;
  7902. /**
  7903. * Resets the material define values
  7904. */
  7905. reset(): void;
  7906. /**
  7907. * Converts the material define values to a string
  7908. * @returns - String of material define information
  7909. */
  7910. toString(): string;
  7911. }
  7912. }
  7913. declare module BABYLON {
  7914. /**
  7915. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7916. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7917. * 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;
  7918. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7919. */
  7920. export class ColorCurves {
  7921. private _dirty;
  7922. private _tempColor;
  7923. private _globalCurve;
  7924. private _highlightsCurve;
  7925. private _midtonesCurve;
  7926. private _shadowsCurve;
  7927. private _positiveCurve;
  7928. private _negativeCurve;
  7929. private _globalHue;
  7930. private _globalDensity;
  7931. private _globalSaturation;
  7932. private _globalExposure;
  7933. /**
  7934. * Gets the global Hue value.
  7935. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7936. */
  7937. get globalHue(): number;
  7938. /**
  7939. * Sets the global Hue value.
  7940. * 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).
  7941. */
  7942. set globalHue(value: number);
  7943. /**
  7944. * Gets the global Density value.
  7945. * 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.
  7946. * Values less than zero provide a filter of opposite hue.
  7947. */
  7948. get globalDensity(): number;
  7949. /**
  7950. * Sets the global Density value.
  7951. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7952. * Values less than zero provide a filter of opposite hue.
  7953. */
  7954. set globalDensity(value: number);
  7955. /**
  7956. * Gets the global Saturation value.
  7957. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7958. */
  7959. get globalSaturation(): number;
  7960. /**
  7961. * Sets the global Saturation value.
  7962. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7963. */
  7964. set globalSaturation(value: number);
  7965. /**
  7966. * Gets the global Exposure value.
  7967. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7968. */
  7969. get globalExposure(): number;
  7970. /**
  7971. * Sets the global Exposure value.
  7972. * 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.
  7973. */
  7974. set globalExposure(value: number);
  7975. private _highlightsHue;
  7976. private _highlightsDensity;
  7977. private _highlightsSaturation;
  7978. private _highlightsExposure;
  7979. /**
  7980. * Gets the highlights Hue value.
  7981. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7982. */
  7983. get highlightsHue(): number;
  7984. /**
  7985. * Sets the highlights Hue value.
  7986. * 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).
  7987. */
  7988. set highlightsHue(value: number);
  7989. /**
  7990. * Gets the highlights Density value.
  7991. * 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.
  7992. * Values less than zero provide a filter of opposite hue.
  7993. */
  7994. get highlightsDensity(): number;
  7995. /**
  7996. * Sets the highlights Density value.
  7997. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7998. * Values less than zero provide a filter of opposite hue.
  7999. */
  8000. set highlightsDensity(value: number);
  8001. /**
  8002. * Gets the highlights Saturation value.
  8003. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8004. */
  8005. get highlightsSaturation(): number;
  8006. /**
  8007. * Sets the highlights Saturation value.
  8008. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8009. */
  8010. set highlightsSaturation(value: number);
  8011. /**
  8012. * Gets the highlights Exposure value.
  8013. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8014. */
  8015. get highlightsExposure(): number;
  8016. /**
  8017. * Sets the highlights Exposure value.
  8018. * 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.
  8019. */
  8020. set highlightsExposure(value: number);
  8021. private _midtonesHue;
  8022. private _midtonesDensity;
  8023. private _midtonesSaturation;
  8024. private _midtonesExposure;
  8025. /**
  8026. * Gets the midtones Hue value.
  8027. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8028. */
  8029. get midtonesHue(): number;
  8030. /**
  8031. * Sets the midtones Hue value.
  8032. * 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).
  8033. */
  8034. set midtonesHue(value: number);
  8035. /**
  8036. * Gets the midtones Density value.
  8037. * 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.
  8038. * Values less than zero provide a filter of opposite hue.
  8039. */
  8040. get midtonesDensity(): number;
  8041. /**
  8042. * Sets the midtones Density value.
  8043. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8044. * Values less than zero provide a filter of opposite hue.
  8045. */
  8046. set midtonesDensity(value: number);
  8047. /**
  8048. * Gets the midtones Saturation value.
  8049. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8050. */
  8051. get midtonesSaturation(): number;
  8052. /**
  8053. * Sets the midtones Saturation value.
  8054. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8055. */
  8056. set midtonesSaturation(value: number);
  8057. /**
  8058. * Gets the midtones Exposure value.
  8059. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8060. */
  8061. get midtonesExposure(): number;
  8062. /**
  8063. * Sets the midtones Exposure value.
  8064. * 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.
  8065. */
  8066. set midtonesExposure(value: number);
  8067. private _shadowsHue;
  8068. private _shadowsDensity;
  8069. private _shadowsSaturation;
  8070. private _shadowsExposure;
  8071. /**
  8072. * Gets the shadows Hue value.
  8073. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8074. */
  8075. get shadowsHue(): number;
  8076. /**
  8077. * Sets the shadows Hue value.
  8078. * 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).
  8079. */
  8080. set shadowsHue(value: number);
  8081. /**
  8082. * Gets the shadows Density value.
  8083. * 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.
  8084. * Values less than zero provide a filter of opposite hue.
  8085. */
  8086. get shadowsDensity(): number;
  8087. /**
  8088. * Sets the shadows Density value.
  8089. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8090. * Values less than zero provide a filter of opposite hue.
  8091. */
  8092. set shadowsDensity(value: number);
  8093. /**
  8094. * Gets the shadows Saturation value.
  8095. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8096. */
  8097. get shadowsSaturation(): number;
  8098. /**
  8099. * Sets the shadows Saturation value.
  8100. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8101. */
  8102. set shadowsSaturation(value: number);
  8103. /**
  8104. * Gets the shadows Exposure value.
  8105. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8106. */
  8107. get shadowsExposure(): number;
  8108. /**
  8109. * Sets the shadows Exposure value.
  8110. * 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.
  8111. */
  8112. set shadowsExposure(value: number);
  8113. /**
  8114. * Returns the class name
  8115. * @returns The class name
  8116. */
  8117. getClassName(): string;
  8118. /**
  8119. * Binds the color curves to the shader.
  8120. * @param colorCurves The color curve to bind
  8121. * @param effect The effect to bind to
  8122. * @param positiveUniform The positive uniform shader parameter
  8123. * @param neutralUniform The neutral uniform shader parameter
  8124. * @param negativeUniform The negative uniform shader parameter
  8125. */
  8126. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8127. /**
  8128. * Prepare the list of uniforms associated with the ColorCurves effects.
  8129. * @param uniformsList The list of uniforms used in the effect
  8130. */
  8131. static PrepareUniforms(uniformsList: string[]): void;
  8132. /**
  8133. * Returns color grading data based on a hue, density, saturation and exposure value.
  8134. * @param filterHue The hue of the color filter.
  8135. * @param filterDensity The density of the color filter.
  8136. * @param saturation The saturation.
  8137. * @param exposure The exposure.
  8138. * @param result The result data container.
  8139. */
  8140. private getColorGradingDataToRef;
  8141. /**
  8142. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8143. * @param value The input slider value in range [-100,100].
  8144. * @returns Adjusted value.
  8145. */
  8146. private static applyColorGradingSliderNonlinear;
  8147. /**
  8148. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8149. * @param hue The hue (H) input.
  8150. * @param saturation The saturation (S) input.
  8151. * @param brightness The brightness (B) input.
  8152. * @result An RGBA color represented as Vector4.
  8153. */
  8154. private static fromHSBToRef;
  8155. /**
  8156. * Returns a value clamped between min and max
  8157. * @param value The value to clamp
  8158. * @param min The minimum of value
  8159. * @param max The maximum of value
  8160. * @returns The clamped value.
  8161. */
  8162. private static clamp;
  8163. /**
  8164. * Clones the current color curve instance.
  8165. * @return The cloned curves
  8166. */
  8167. clone(): ColorCurves;
  8168. /**
  8169. * Serializes the current color curve instance to a json representation.
  8170. * @return a JSON representation
  8171. */
  8172. serialize(): any;
  8173. /**
  8174. * Parses the color curve from a json representation.
  8175. * @param source the JSON source to parse
  8176. * @return The parsed curves
  8177. */
  8178. static Parse(source: any): ColorCurves;
  8179. }
  8180. }
  8181. declare module BABYLON {
  8182. /**
  8183. * Interface to follow in your material defines to integrate easily the
  8184. * Image proccessing functions.
  8185. * @hidden
  8186. */
  8187. export interface IImageProcessingConfigurationDefines {
  8188. IMAGEPROCESSING: boolean;
  8189. VIGNETTE: boolean;
  8190. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8191. VIGNETTEBLENDMODEOPAQUE: boolean;
  8192. TONEMAPPING: boolean;
  8193. TONEMAPPING_ACES: boolean;
  8194. CONTRAST: boolean;
  8195. EXPOSURE: boolean;
  8196. COLORCURVES: boolean;
  8197. COLORGRADING: boolean;
  8198. COLORGRADING3D: boolean;
  8199. SAMPLER3DGREENDEPTH: boolean;
  8200. SAMPLER3DBGRMAP: boolean;
  8201. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8202. }
  8203. /**
  8204. * @hidden
  8205. */
  8206. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8207. IMAGEPROCESSING: boolean;
  8208. VIGNETTE: boolean;
  8209. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8210. VIGNETTEBLENDMODEOPAQUE: boolean;
  8211. TONEMAPPING: boolean;
  8212. TONEMAPPING_ACES: boolean;
  8213. CONTRAST: boolean;
  8214. COLORCURVES: boolean;
  8215. COLORGRADING: boolean;
  8216. COLORGRADING3D: boolean;
  8217. SAMPLER3DGREENDEPTH: boolean;
  8218. SAMPLER3DBGRMAP: boolean;
  8219. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8220. EXPOSURE: boolean;
  8221. constructor();
  8222. }
  8223. /**
  8224. * This groups together the common properties used for image processing either in direct forward pass
  8225. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8226. * or not.
  8227. */
  8228. export class ImageProcessingConfiguration {
  8229. /**
  8230. * Default tone mapping applied in BabylonJS.
  8231. */
  8232. static readonly TONEMAPPING_STANDARD: number;
  8233. /**
  8234. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8235. * to other engines rendering to increase portability.
  8236. */
  8237. static readonly TONEMAPPING_ACES: number;
  8238. /**
  8239. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8240. */
  8241. colorCurves: Nullable<ColorCurves>;
  8242. private _colorCurvesEnabled;
  8243. /**
  8244. * Gets wether the color curves effect is enabled.
  8245. */
  8246. get colorCurvesEnabled(): boolean;
  8247. /**
  8248. * Sets wether the color curves effect is enabled.
  8249. */
  8250. set colorCurvesEnabled(value: boolean);
  8251. private _colorGradingTexture;
  8252. /**
  8253. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8254. */
  8255. get colorGradingTexture(): Nullable<BaseTexture>;
  8256. /**
  8257. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8258. */
  8259. set colorGradingTexture(value: Nullable<BaseTexture>);
  8260. private _colorGradingEnabled;
  8261. /**
  8262. * Gets wether the color grading effect is enabled.
  8263. */
  8264. get colorGradingEnabled(): boolean;
  8265. /**
  8266. * Sets wether the color grading effect is enabled.
  8267. */
  8268. set colorGradingEnabled(value: boolean);
  8269. private _colorGradingWithGreenDepth;
  8270. /**
  8271. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8272. */
  8273. get colorGradingWithGreenDepth(): boolean;
  8274. /**
  8275. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8276. */
  8277. set colorGradingWithGreenDepth(value: boolean);
  8278. private _colorGradingBGR;
  8279. /**
  8280. * Gets wether the color grading texture contains BGR values.
  8281. */
  8282. get colorGradingBGR(): boolean;
  8283. /**
  8284. * Sets wether the color grading texture contains BGR values.
  8285. */
  8286. set colorGradingBGR(value: boolean);
  8287. /** @hidden */
  8288. _exposure: number;
  8289. /**
  8290. * Gets the Exposure used in the effect.
  8291. */
  8292. get exposure(): number;
  8293. /**
  8294. * Sets the Exposure used in the effect.
  8295. */
  8296. set exposure(value: number);
  8297. private _toneMappingEnabled;
  8298. /**
  8299. * Gets wether the tone mapping effect is enabled.
  8300. */
  8301. get toneMappingEnabled(): boolean;
  8302. /**
  8303. * Sets wether the tone mapping effect is enabled.
  8304. */
  8305. set toneMappingEnabled(value: boolean);
  8306. private _toneMappingType;
  8307. /**
  8308. * Gets the type of tone mapping effect.
  8309. */
  8310. get toneMappingType(): number;
  8311. /**
  8312. * Sets the type of tone mapping effect used in BabylonJS.
  8313. */
  8314. set toneMappingType(value: number);
  8315. protected _contrast: number;
  8316. /**
  8317. * Gets the contrast used in the effect.
  8318. */
  8319. get contrast(): number;
  8320. /**
  8321. * Sets the contrast used in the effect.
  8322. */
  8323. set contrast(value: number);
  8324. /**
  8325. * Vignette stretch size.
  8326. */
  8327. vignetteStretch: number;
  8328. /**
  8329. * Vignette centre X Offset.
  8330. */
  8331. vignetteCentreX: number;
  8332. /**
  8333. * Vignette centre Y Offset.
  8334. */
  8335. vignetteCentreY: number;
  8336. /**
  8337. * Vignette weight or intensity of the vignette effect.
  8338. */
  8339. vignetteWeight: number;
  8340. /**
  8341. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8342. * if vignetteEnabled is set to true.
  8343. */
  8344. vignetteColor: Color4;
  8345. /**
  8346. * Camera field of view used by the Vignette effect.
  8347. */
  8348. vignetteCameraFov: number;
  8349. private _vignetteBlendMode;
  8350. /**
  8351. * Gets the vignette blend mode allowing different kind of effect.
  8352. */
  8353. get vignetteBlendMode(): number;
  8354. /**
  8355. * Sets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. set vignetteBlendMode(value: number);
  8358. private _vignetteEnabled;
  8359. /**
  8360. * Gets wether the vignette effect is enabled.
  8361. */
  8362. get vignetteEnabled(): boolean;
  8363. /**
  8364. * Sets wether the vignette effect is enabled.
  8365. */
  8366. set vignetteEnabled(value: boolean);
  8367. private _applyByPostProcess;
  8368. /**
  8369. * Gets wether the image processing is applied through a post process or not.
  8370. */
  8371. get applyByPostProcess(): boolean;
  8372. /**
  8373. * Sets wether the image processing is applied through a post process or not.
  8374. */
  8375. set applyByPostProcess(value: boolean);
  8376. private _isEnabled;
  8377. /**
  8378. * Gets wether the image processing is enabled or not.
  8379. */
  8380. get isEnabled(): boolean;
  8381. /**
  8382. * Sets wether the image processing is enabled or not.
  8383. */
  8384. set isEnabled(value: boolean);
  8385. /**
  8386. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8387. */
  8388. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8389. /**
  8390. * Method called each time the image processing information changes requires to recompile the effect.
  8391. */
  8392. protected _updateParameters(): void;
  8393. /**
  8394. * Gets the current class name.
  8395. * @return "ImageProcessingConfiguration"
  8396. */
  8397. getClassName(): string;
  8398. /**
  8399. * Prepare the list of uniforms associated with the Image Processing effects.
  8400. * @param uniforms The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of samplers associated with the Image Processing effects.
  8406. * @param samplersList The list of uniforms used in the effect
  8407. * @param defines the list of defines currently in use
  8408. */
  8409. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8410. /**
  8411. * Prepare the list of defines associated to the shader.
  8412. * @param defines the list of defines to complete
  8413. * @param forPostProcess Define if we are currently in post process mode or not
  8414. */
  8415. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8416. /**
  8417. * Returns true if all the image processing information are ready.
  8418. * @returns True if ready, otherwise, false
  8419. */
  8420. isReady(): boolean;
  8421. /**
  8422. * Binds the image processing to the shader.
  8423. * @param effect The effect to bind to
  8424. * @param overrideAspectRatio Override the aspect ratio of the effect
  8425. */
  8426. bind(effect: Effect, overrideAspectRatio?: number): void;
  8427. /**
  8428. * Clones the current image processing instance.
  8429. * @return The cloned image processing
  8430. */
  8431. clone(): ImageProcessingConfiguration;
  8432. /**
  8433. * Serializes the current image processing instance to a json representation.
  8434. * @return a JSON representation
  8435. */
  8436. serialize(): any;
  8437. /**
  8438. * Parses the image processing from a json representation.
  8439. * @param source the JSON source to parse
  8440. * @return The parsed image processing
  8441. */
  8442. static Parse(source: any): ImageProcessingConfiguration;
  8443. private static _VIGNETTEMODE_MULTIPLY;
  8444. private static _VIGNETTEMODE_OPAQUE;
  8445. /**
  8446. * Used to apply the vignette as a mix with the pixel color.
  8447. */
  8448. static get VIGNETTEMODE_MULTIPLY(): number;
  8449. /**
  8450. * Used to apply the vignette as a replacement of the pixel color.
  8451. */
  8452. static get VIGNETTEMODE_OPAQUE(): number;
  8453. }
  8454. }
  8455. declare module BABYLON {
  8456. /** @hidden */
  8457. export var postprocessVertexShader: {
  8458. name: string;
  8459. shader: string;
  8460. };
  8461. }
  8462. declare module BABYLON {
  8463. interface ThinEngine {
  8464. /**
  8465. * Creates a new render target texture
  8466. * @param size defines the size of the texture
  8467. * @param options defines the options used to create the texture
  8468. * @returns a new render target texture stored in an InternalTexture
  8469. */
  8470. createRenderTargetTexture(size: number | {
  8471. width: number;
  8472. height: number;
  8473. layers?: number;
  8474. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8475. /**
  8476. * Creates a depth stencil texture.
  8477. * This is only available in WebGL 2 or with the depth texture extension available.
  8478. * @param size The size of face edge in the texture.
  8479. * @param options The options defining the texture.
  8480. * @returns The texture
  8481. */
  8482. createDepthStencilTexture(size: number | {
  8483. width: number;
  8484. height: number;
  8485. layers?: number;
  8486. }, options: DepthTextureCreationOptions): InternalTexture;
  8487. /** @hidden */
  8488. _createDepthStencilTexture(size: number | {
  8489. width: number;
  8490. height: number;
  8491. layers?: number;
  8492. }, options: DepthTextureCreationOptions): InternalTexture;
  8493. }
  8494. }
  8495. declare module BABYLON {
  8496. /** Defines supported spaces */
  8497. export enum Space {
  8498. /** Local (object) space */
  8499. LOCAL = 0,
  8500. /** World space */
  8501. WORLD = 1,
  8502. /** Bone space */
  8503. BONE = 2
  8504. }
  8505. /** Defines the 3 main axes */
  8506. export class Axis {
  8507. /** X axis */
  8508. static X: Vector3;
  8509. /** Y axis */
  8510. static Y: Vector3;
  8511. /** Z axis */
  8512. static Z: Vector3;
  8513. }
  8514. }
  8515. declare module BABYLON {
  8516. /**
  8517. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8518. * This is the base of the follow, arc rotate cameras and Free camera
  8519. * @see http://doc.babylonjs.com/features/cameras
  8520. */
  8521. export class TargetCamera extends Camera {
  8522. private static _RigCamTransformMatrix;
  8523. private static _TargetTransformMatrix;
  8524. private static _TargetFocalPoint;
  8525. /**
  8526. * Define the current direction the camera is moving to
  8527. */
  8528. cameraDirection: Vector3;
  8529. /**
  8530. * Define the current rotation the camera is rotating to
  8531. */
  8532. cameraRotation: Vector2;
  8533. /**
  8534. * When set, the up vector of the camera will be updated by the rotation of the camera
  8535. */
  8536. updateUpVectorFromRotation: boolean;
  8537. private _tmpQuaternion;
  8538. /**
  8539. * Define the current rotation of the camera
  8540. */
  8541. rotation: Vector3;
  8542. /**
  8543. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8544. */
  8545. rotationQuaternion: Quaternion;
  8546. /**
  8547. * Define the current speed of the camera
  8548. */
  8549. speed: number;
  8550. /**
  8551. * Add constraint to the camera to prevent it to move freely in all directions and
  8552. * around all axis.
  8553. */
  8554. noRotationConstraint: boolean;
  8555. /**
  8556. * Define the current target of the camera as an object or a position.
  8557. */
  8558. lockedTarget: any;
  8559. /** @hidden */
  8560. _currentTarget: Vector3;
  8561. /** @hidden */
  8562. _initialFocalDistance: number;
  8563. /** @hidden */
  8564. _viewMatrix: Matrix;
  8565. /** @hidden */
  8566. _camMatrix: Matrix;
  8567. /** @hidden */
  8568. _cameraTransformMatrix: Matrix;
  8569. /** @hidden */
  8570. _cameraRotationMatrix: Matrix;
  8571. /** @hidden */
  8572. _referencePoint: Vector3;
  8573. /** @hidden */
  8574. _transformedReferencePoint: Vector3;
  8575. protected _globalCurrentTarget: Vector3;
  8576. protected _globalCurrentUpVector: Vector3;
  8577. /** @hidden */
  8578. _reset: () => void;
  8579. private _defaultUp;
  8580. /**
  8581. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8582. * This is the base of the follow, arc rotate cameras and Free camera
  8583. * @see http://doc.babylonjs.com/features/cameras
  8584. * @param name Defines the name of the camera in the scene
  8585. * @param position Defines the start position of the camera in the scene
  8586. * @param scene Defines the scene the camera belongs to
  8587. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8588. */
  8589. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8590. /**
  8591. * Gets the position in front of the camera at a given distance.
  8592. * @param distance The distance from the camera we want the position to be
  8593. * @returns the position
  8594. */
  8595. getFrontPosition(distance: number): Vector3;
  8596. /** @hidden */
  8597. _getLockedTargetPosition(): Nullable<Vector3>;
  8598. private _storedPosition;
  8599. private _storedRotation;
  8600. private _storedRotationQuaternion;
  8601. /**
  8602. * Store current camera state of the camera (fov, position, rotation, etc..)
  8603. * @returns the camera
  8604. */
  8605. storeState(): Camera;
  8606. /**
  8607. * Restored camera state. You must call storeState() first
  8608. * @returns whether it was successful or not
  8609. * @hidden
  8610. */
  8611. _restoreStateValues(): boolean;
  8612. /** @hidden */
  8613. _initCache(): void;
  8614. /** @hidden */
  8615. _updateCache(ignoreParentClass?: boolean): void;
  8616. /** @hidden */
  8617. _isSynchronizedViewMatrix(): boolean;
  8618. /** @hidden */
  8619. _computeLocalCameraSpeed(): number;
  8620. /**
  8621. * Defines the target the camera should look at.
  8622. * @param target Defines the new target as a Vector or a mesh
  8623. */
  8624. setTarget(target: Vector3): void;
  8625. /**
  8626. * Return the current target position of the camera. This value is expressed in local space.
  8627. * @returns the target position
  8628. */
  8629. getTarget(): Vector3;
  8630. /** @hidden */
  8631. _decideIfNeedsToMove(): boolean;
  8632. /** @hidden */
  8633. _updatePosition(): void;
  8634. /** @hidden */
  8635. _checkInputs(): void;
  8636. protected _updateCameraRotationMatrix(): void;
  8637. /**
  8638. * 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)
  8639. * @returns the current camera
  8640. */
  8641. private _rotateUpVectorWithCameraRotationMatrix;
  8642. private _cachedRotationZ;
  8643. private _cachedQuaternionRotationZ;
  8644. /** @hidden */
  8645. _getViewMatrix(): Matrix;
  8646. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8647. /**
  8648. * @hidden
  8649. */
  8650. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8651. /**
  8652. * @hidden
  8653. */
  8654. _updateRigCameras(): void;
  8655. private _getRigCamPositionAndTarget;
  8656. /**
  8657. * Gets the current object class name.
  8658. * @return the class name
  8659. */
  8660. getClassName(): string;
  8661. }
  8662. }
  8663. declare module BABYLON {
  8664. /**
  8665. * Gather the list of keyboard event types as constants.
  8666. */
  8667. export class KeyboardEventTypes {
  8668. /**
  8669. * The keydown event is fired when a key becomes active (pressed).
  8670. */
  8671. static readonly KEYDOWN: number;
  8672. /**
  8673. * The keyup event is fired when a key has been released.
  8674. */
  8675. static readonly KEYUP: number;
  8676. }
  8677. /**
  8678. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8679. */
  8680. export class KeyboardInfo {
  8681. /**
  8682. * Defines the type of event (KeyboardEventTypes)
  8683. */
  8684. type: number;
  8685. /**
  8686. * Defines the related dom event
  8687. */
  8688. event: KeyboardEvent;
  8689. /**
  8690. * Instantiates a new keyboard info.
  8691. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8692. * @param type Defines the type of event (KeyboardEventTypes)
  8693. * @param event Defines the related dom event
  8694. */
  8695. constructor(
  8696. /**
  8697. * Defines the type of event (KeyboardEventTypes)
  8698. */
  8699. type: number,
  8700. /**
  8701. * Defines the related dom event
  8702. */
  8703. event: KeyboardEvent);
  8704. }
  8705. /**
  8706. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8707. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8708. */
  8709. export class KeyboardInfoPre extends KeyboardInfo {
  8710. /**
  8711. * Defines the type of event (KeyboardEventTypes)
  8712. */
  8713. type: number;
  8714. /**
  8715. * Defines the related dom event
  8716. */
  8717. event: KeyboardEvent;
  8718. /**
  8719. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8720. */
  8721. skipOnPointerObservable: boolean;
  8722. /**
  8723. * Instantiates a new keyboard pre info.
  8724. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8725. * @param type Defines the type of event (KeyboardEventTypes)
  8726. * @param event Defines the related dom event
  8727. */
  8728. constructor(
  8729. /**
  8730. * Defines the type of event (KeyboardEventTypes)
  8731. */
  8732. type: number,
  8733. /**
  8734. * Defines the related dom event
  8735. */
  8736. event: KeyboardEvent);
  8737. }
  8738. }
  8739. declare module BABYLON {
  8740. /**
  8741. * Manage the keyboard inputs to control the movement of a free camera.
  8742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8743. */
  8744. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8745. /**
  8746. * Defines the camera the input is attached to.
  8747. */
  8748. camera: FreeCamera;
  8749. /**
  8750. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8751. */
  8752. keysUp: number[];
  8753. /**
  8754. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8755. */
  8756. keysDown: number[];
  8757. /**
  8758. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8759. */
  8760. keysLeft: number[];
  8761. /**
  8762. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8763. */
  8764. keysRight: number[];
  8765. private _keys;
  8766. private _onCanvasBlurObserver;
  8767. private _onKeyboardObserver;
  8768. private _engine;
  8769. private _scene;
  8770. /**
  8771. * Attach the input controls to a specific dom element to get the input from.
  8772. * @param element Defines the element the controls should be listened from
  8773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8774. */
  8775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8776. /**
  8777. * Detach the current controls from the specified dom element.
  8778. * @param element Defines the element to stop listening the inputs from
  8779. */
  8780. detachControl(element: Nullable<HTMLElement>): void;
  8781. /**
  8782. * Update the current camera state depending on the inputs that have been used this frame.
  8783. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8784. */
  8785. checkInputs(): void;
  8786. /**
  8787. * Gets the class name of the current intput.
  8788. * @returns the class name
  8789. */
  8790. getClassName(): string;
  8791. /** @hidden */
  8792. _onLostFocus(): void;
  8793. /**
  8794. * Get the friendly name associated with the input class.
  8795. * @returns the input friendly name
  8796. */
  8797. getSimpleName(): string;
  8798. }
  8799. }
  8800. declare module BABYLON {
  8801. /**
  8802. * Interface describing all the common properties and methods a shadow light needs to implement.
  8803. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8804. * as well as binding the different shadow properties to the effects.
  8805. */
  8806. export interface IShadowLight extends Light {
  8807. /**
  8808. * The light id in the scene (used in scene.findLighById for instance)
  8809. */
  8810. id: string;
  8811. /**
  8812. * The position the shdow will be casted from.
  8813. */
  8814. position: Vector3;
  8815. /**
  8816. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8817. */
  8818. direction: Vector3;
  8819. /**
  8820. * The transformed position. Position of the light in world space taking parenting in account.
  8821. */
  8822. transformedPosition: Vector3;
  8823. /**
  8824. * The transformed direction. Direction of the light in world space taking parenting in account.
  8825. */
  8826. transformedDirection: Vector3;
  8827. /**
  8828. * The friendly name of the light in the scene.
  8829. */
  8830. name: string;
  8831. /**
  8832. * Defines the shadow projection clipping minimum z value.
  8833. */
  8834. shadowMinZ: number;
  8835. /**
  8836. * Defines the shadow projection clipping maximum z value.
  8837. */
  8838. shadowMaxZ: number;
  8839. /**
  8840. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8841. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8842. */
  8843. computeTransformedInformation(): boolean;
  8844. /**
  8845. * Gets the scene the light belongs to.
  8846. * @returns The scene
  8847. */
  8848. getScene(): Scene;
  8849. /**
  8850. * Callback defining a custom Projection Matrix Builder.
  8851. * This can be used to override the default projection matrix computation.
  8852. */
  8853. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8854. /**
  8855. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8856. * @param matrix The materix to updated with the projection information
  8857. * @param viewMatrix The transform matrix of the light
  8858. * @param renderList The list of mesh to render in the map
  8859. * @returns The current light
  8860. */
  8861. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8862. /**
  8863. * Gets the current depth scale used in ESM.
  8864. * @returns The scale
  8865. */
  8866. getDepthScale(): number;
  8867. /**
  8868. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8869. * @returns true if a cube texture needs to be use
  8870. */
  8871. needCube(): boolean;
  8872. /**
  8873. * Detects if the projection matrix requires to be recomputed this frame.
  8874. * @returns true if it requires to be recomputed otherwise, false.
  8875. */
  8876. needProjectionMatrixCompute(): boolean;
  8877. /**
  8878. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8879. */
  8880. forceProjectionMatrixCompute(): void;
  8881. /**
  8882. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8883. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8884. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8885. */
  8886. getShadowDirection(faceIndex?: number): Vector3;
  8887. /**
  8888. * Gets the minZ used for shadow according to both the scene and the light.
  8889. * @param activeCamera The camera we are returning the min for
  8890. * @returns the depth min z
  8891. */
  8892. getDepthMinZ(activeCamera: Camera): number;
  8893. /**
  8894. * Gets the maxZ used for shadow according to both the scene and the light.
  8895. * @param activeCamera The camera we are returning the max for
  8896. * @returns the depth max z
  8897. */
  8898. getDepthMaxZ(activeCamera: Camera): number;
  8899. }
  8900. /**
  8901. * Base implementation IShadowLight
  8902. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8903. */
  8904. export abstract class ShadowLight extends Light implements IShadowLight {
  8905. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8906. protected _position: Vector3;
  8907. protected _setPosition(value: Vector3): void;
  8908. /**
  8909. * Sets the position the shadow will be casted from. Also use as the light position for both
  8910. * point and spot lights.
  8911. */
  8912. get position(): Vector3;
  8913. /**
  8914. * Sets the position the shadow will be casted from. Also use as the light position for both
  8915. * point and spot lights.
  8916. */
  8917. set position(value: Vector3);
  8918. protected _direction: Vector3;
  8919. protected _setDirection(value: Vector3): void;
  8920. /**
  8921. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8922. * Also use as the light direction on spot and directional lights.
  8923. */
  8924. get direction(): Vector3;
  8925. /**
  8926. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8927. * Also use as the light direction on spot and directional lights.
  8928. */
  8929. set direction(value: Vector3);
  8930. protected _shadowMinZ: number;
  8931. /**
  8932. * Gets the shadow projection clipping minimum z value.
  8933. */
  8934. get shadowMinZ(): number;
  8935. /**
  8936. * Sets the shadow projection clipping minimum z value.
  8937. */
  8938. set shadowMinZ(value: number);
  8939. protected _shadowMaxZ: number;
  8940. /**
  8941. * Sets the shadow projection clipping maximum z value.
  8942. */
  8943. get shadowMaxZ(): number;
  8944. /**
  8945. * Gets the shadow projection clipping maximum z value.
  8946. */
  8947. set shadowMaxZ(value: number);
  8948. /**
  8949. * Callback defining a custom Projection Matrix Builder.
  8950. * This can be used to override the default projection matrix computation.
  8951. */
  8952. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8953. /**
  8954. * The transformed position. Position of the light in world space taking parenting in account.
  8955. */
  8956. transformedPosition: Vector3;
  8957. /**
  8958. * The transformed direction. Direction of the light in world space taking parenting in account.
  8959. */
  8960. transformedDirection: Vector3;
  8961. private _needProjectionMatrixCompute;
  8962. /**
  8963. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8964. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8965. */
  8966. computeTransformedInformation(): boolean;
  8967. /**
  8968. * Return the depth scale used for the shadow map.
  8969. * @returns the depth scale.
  8970. */
  8971. getDepthScale(): number;
  8972. /**
  8973. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8974. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8975. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8976. */
  8977. getShadowDirection(faceIndex?: number): Vector3;
  8978. /**
  8979. * Returns the ShadowLight absolute position in the World.
  8980. * @returns the position vector in world space
  8981. */
  8982. getAbsolutePosition(): Vector3;
  8983. /**
  8984. * Sets the ShadowLight direction toward the passed target.
  8985. * @param target The point to target in local space
  8986. * @returns the updated ShadowLight direction
  8987. */
  8988. setDirectionToTarget(target: Vector3): Vector3;
  8989. /**
  8990. * Returns the light rotation in euler definition.
  8991. * @returns the x y z rotation in local space.
  8992. */
  8993. getRotation(): Vector3;
  8994. /**
  8995. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8996. * @returns true if a cube texture needs to be use
  8997. */
  8998. needCube(): boolean;
  8999. /**
  9000. * Detects if the projection matrix requires to be recomputed this frame.
  9001. * @returns true if it requires to be recomputed otherwise, false.
  9002. */
  9003. needProjectionMatrixCompute(): boolean;
  9004. /**
  9005. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9006. */
  9007. forceProjectionMatrixCompute(): void;
  9008. /** @hidden */
  9009. _initCache(): void;
  9010. /** @hidden */
  9011. _isSynchronized(): boolean;
  9012. /**
  9013. * Computes the world matrix of the node
  9014. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9015. * @returns the world matrix
  9016. */
  9017. computeWorldMatrix(force?: boolean): Matrix;
  9018. /**
  9019. * Gets the minZ used for shadow according to both the scene and the light.
  9020. * @param activeCamera The camera we are returning the min for
  9021. * @returns the depth min z
  9022. */
  9023. getDepthMinZ(activeCamera: Camera): number;
  9024. /**
  9025. * Gets the maxZ used for shadow according to both the scene and the light.
  9026. * @param activeCamera The camera we are returning the max for
  9027. * @returns the depth max z
  9028. */
  9029. getDepthMaxZ(activeCamera: Camera): number;
  9030. /**
  9031. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9032. * @param matrix The materix to updated with the projection information
  9033. * @param viewMatrix The transform matrix of the light
  9034. * @param renderList The list of mesh to render in the map
  9035. * @returns The current light
  9036. */
  9037. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9038. }
  9039. }
  9040. declare module BABYLON {
  9041. /**
  9042. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9043. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9044. */
  9045. export class EffectFallbacks implements IEffectFallbacks {
  9046. private _defines;
  9047. private _currentRank;
  9048. private _maxRank;
  9049. private _mesh;
  9050. /**
  9051. * Removes the fallback from the bound mesh.
  9052. */
  9053. unBindMesh(): void;
  9054. /**
  9055. * Adds a fallback on the specified property.
  9056. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9057. * @param define The name of the define in the shader
  9058. */
  9059. addFallback(rank: number, define: string): void;
  9060. /**
  9061. * Sets the mesh to use CPU skinning when needing to fallback.
  9062. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9063. * @param mesh The mesh to use the fallbacks.
  9064. */
  9065. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9066. /**
  9067. * Checks to see if more fallbacks are still availible.
  9068. */
  9069. get hasMoreFallbacks(): boolean;
  9070. /**
  9071. * Removes the defines that should be removed when falling back.
  9072. * @param currentDefines defines the current define statements for the shader.
  9073. * @param effect defines the current effect we try to compile
  9074. * @returns The resulting defines with defines of the current rank removed.
  9075. */
  9076. reduce(currentDefines: string, effect: Effect): string;
  9077. }
  9078. }
  9079. declare module BABYLON {
  9080. /**
  9081. * "Static Class" containing the most commonly used helper while dealing with material for
  9082. * rendering purpose.
  9083. *
  9084. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9085. *
  9086. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9087. */
  9088. export class MaterialHelper {
  9089. /**
  9090. * Bind the current view position to an effect.
  9091. * @param effect The effect to be bound
  9092. * @param scene The scene the eyes position is used from
  9093. */
  9094. static BindEyePosition(effect: Effect, scene: Scene): void;
  9095. /**
  9096. * Helps preparing the defines values about the UVs in used in the effect.
  9097. * UVs are shared as much as we can accross channels in the shaders.
  9098. * @param texture The texture we are preparing the UVs for
  9099. * @param defines The defines to update
  9100. * @param key The channel key "diffuse", "specular"... used in the shader
  9101. */
  9102. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9103. /**
  9104. * Binds a texture matrix value to its corrsponding uniform
  9105. * @param texture The texture to bind the matrix for
  9106. * @param uniformBuffer The uniform buffer receivin the data
  9107. * @param key The channel key "diffuse", "specular"... used in the shader
  9108. */
  9109. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9110. /**
  9111. * Gets the current status of the fog (should it be enabled?)
  9112. * @param mesh defines the mesh to evaluate for fog support
  9113. * @param scene defines the hosting scene
  9114. * @returns true if fog must be enabled
  9115. */
  9116. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9117. /**
  9118. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9119. * @param mesh defines the current mesh
  9120. * @param scene defines the current scene
  9121. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9122. * @param pointsCloud defines if point cloud rendering has to be turned on
  9123. * @param fogEnabled defines if fog has to be turned on
  9124. * @param alphaTest defines if alpha testing has to be turned on
  9125. * @param defines defines the current list of defines
  9126. */
  9127. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9128. /**
  9129. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9130. * @param scene defines the current scene
  9131. * @param engine defines the current engine
  9132. * @param defines specifies the list of active defines
  9133. * @param useInstances defines if instances have to be turned on
  9134. * @param useClipPlane defines if clip plane have to be turned on
  9135. */
  9136. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9137. /**
  9138. * Prepares the defines for bones
  9139. * @param mesh The mesh containing the geometry data we will draw
  9140. * @param defines The defines to update
  9141. */
  9142. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9143. /**
  9144. * Prepares the defines for morph targets
  9145. * @param mesh The mesh containing the geometry data we will draw
  9146. * @param defines The defines to update
  9147. */
  9148. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9149. /**
  9150. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9151. * @param mesh The mesh containing the geometry data we will draw
  9152. * @param defines The defines to update
  9153. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9154. * @param useBones Precise whether bones should be used or not (override mesh info)
  9155. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9156. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9157. * @returns false if defines are considered not dirty and have not been checked
  9158. */
  9159. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9160. /**
  9161. * Prepares the defines related to multiview
  9162. * @param scene The scene we are intending to draw
  9163. * @param defines The defines to update
  9164. */
  9165. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9166. /**
  9167. * Prepares the defines related to the light information passed in parameter
  9168. * @param scene The scene we are intending to draw
  9169. * @param mesh The mesh the effect is compiling for
  9170. * @param light The light the effect is compiling for
  9171. * @param lightIndex The index of the light
  9172. * @param defines The defines to update
  9173. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9174. * @param state Defines the current state regarding what is needed (normals, etc...)
  9175. */
  9176. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9177. needNormals: boolean;
  9178. needRebuild: boolean;
  9179. shadowEnabled: boolean;
  9180. specularEnabled: boolean;
  9181. lightmapMode: boolean;
  9182. }): void;
  9183. /**
  9184. * Prepares the defines related to the light information passed in parameter
  9185. * @param scene The scene we are intending to draw
  9186. * @param mesh The mesh the effect is compiling for
  9187. * @param defines The defines to update
  9188. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9189. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9190. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9191. * @returns true if normals will be required for the rest of the effect
  9192. */
  9193. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9194. /**
  9195. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9196. * @param lightIndex defines the light index
  9197. * @param uniformsList The uniform list
  9198. * @param samplersList The sampler list
  9199. * @param projectedLightTexture defines if projected texture must be used
  9200. * @param uniformBuffersList defines an optional list of uniform buffers
  9201. */
  9202. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9203. /**
  9204. * Prepares the uniforms and samplers list to be used in the effect
  9205. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9206. * @param samplersList The sampler list
  9207. * @param defines The defines helping in the list generation
  9208. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9209. */
  9210. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9211. /**
  9212. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9213. * @param defines The defines to update while falling back
  9214. * @param fallbacks The authorized effect fallbacks
  9215. * @param maxSimultaneousLights The maximum number of lights allowed
  9216. * @param rank the current rank of the Effect
  9217. * @returns The newly affected rank
  9218. */
  9219. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9220. private static _TmpMorphInfluencers;
  9221. /**
  9222. * Prepares the list of attributes required for morph targets according to the effect defines.
  9223. * @param attribs The current list of supported attribs
  9224. * @param mesh The mesh to prepare the morph targets attributes for
  9225. * @param influencers The number of influencers
  9226. */
  9227. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9228. /**
  9229. * Prepares the list of attributes required for morph targets according to the effect defines.
  9230. * @param attribs The current list of supported attribs
  9231. * @param mesh The mesh to prepare the morph targets attributes for
  9232. * @param defines The current Defines of the effect
  9233. */
  9234. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9235. /**
  9236. * Prepares the list of attributes required for bones according to the effect defines.
  9237. * @param attribs The current list of supported attribs
  9238. * @param mesh The mesh to prepare the bones attributes for
  9239. * @param defines The current Defines of the effect
  9240. * @param fallbacks The current efffect fallback strategy
  9241. */
  9242. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9243. /**
  9244. * Check and prepare the list of attributes required for instances according to the effect defines.
  9245. * @param attribs The current list of supported attribs
  9246. * @param defines The current MaterialDefines of the effect
  9247. */
  9248. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9249. /**
  9250. * Add the list of attributes required for instances to the attribs array.
  9251. * @param attribs The current list of supported attribs
  9252. */
  9253. static PushAttributesForInstances(attribs: string[]): void;
  9254. /**
  9255. * Binds the light information to the effect.
  9256. * @param light The light containing the generator
  9257. * @param effect The effect we are binding the data to
  9258. * @param lightIndex The light index in the effect used to render
  9259. */
  9260. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9261. /**
  9262. * Binds the lights information from the scene to the effect for the given mesh.
  9263. * @param light Light to bind
  9264. * @param lightIndex Light index
  9265. * @param scene The scene where the light belongs to
  9266. * @param effect The effect we are binding the data to
  9267. * @param useSpecular Defines if specular is supported
  9268. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9269. */
  9270. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9271. /**
  9272. * Binds the lights information from the scene to the effect for the given mesh.
  9273. * @param scene The scene the lights belongs to
  9274. * @param mesh The mesh we are binding the information to render
  9275. * @param effect The effect we are binding the data to
  9276. * @param defines The generated defines for the effect
  9277. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9278. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9279. */
  9280. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9281. private static _tempFogColor;
  9282. /**
  9283. * Binds the fog information from the scene to the effect for the given mesh.
  9284. * @param scene The scene the lights belongs to
  9285. * @param mesh The mesh we are binding the information to render
  9286. * @param effect The effect we are binding the data to
  9287. * @param linearSpace Defines if the fog effect is applied in linear space
  9288. */
  9289. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9290. /**
  9291. * Binds the bones information from the mesh to the effect.
  9292. * @param mesh The mesh we are binding the information to render
  9293. * @param effect The effect we are binding the data to
  9294. */
  9295. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9296. /**
  9297. * Binds the morph targets information from the mesh to the effect.
  9298. * @param abstractMesh The mesh we are binding the information to render
  9299. * @param effect The effect we are binding the data to
  9300. */
  9301. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9302. /**
  9303. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9304. * @param defines The generated defines used in the effect
  9305. * @param effect The effect we are binding the data to
  9306. * @param scene The scene we are willing to render with logarithmic scale for
  9307. */
  9308. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9309. /**
  9310. * Binds the clip plane information from the scene to the effect.
  9311. * @param scene The scene the clip plane information are extracted from
  9312. * @param effect The effect we are binding the data to
  9313. */
  9314. static BindClipPlane(effect: Effect, scene: Scene): void;
  9315. }
  9316. }
  9317. declare module BABYLON {
  9318. /** @hidden */
  9319. export var packingFunctions: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module BABYLON {
  9325. /** @hidden */
  9326. export var clipPlaneFragmentDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module BABYLON {
  9332. /** @hidden */
  9333. export var clipPlaneFragment: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var shadowMapPixelShader: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var bonesDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var morphTargetsVertexGlobalDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var morphTargetsVertexDeclaration: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var instancesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var helperFunctions: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var clipPlaneVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var morphTargetsVertex: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var instancesVertex: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var bonesVertex: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var clipPlaneVertex: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var shadowMapVertexShader: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /** @hidden */
  9424. export var depthBoxBlurPixelShader: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module BABYLON {
  9430. /**
  9431. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9432. */
  9433. export interface ICustomShaderOptions {
  9434. /**
  9435. * Gets or sets the custom shader name to use
  9436. */
  9437. shaderName: string;
  9438. /**
  9439. * The list of attribute names used in the shader
  9440. */
  9441. attributes?: string[];
  9442. /**
  9443. * The list of unifrom names used in the shader
  9444. */
  9445. uniforms?: string[];
  9446. /**
  9447. * The list of sampler names used in the shader
  9448. */
  9449. samplers?: string[];
  9450. /**
  9451. * The list of defines used in the shader
  9452. */
  9453. defines?: string[];
  9454. }
  9455. /**
  9456. * Interface to implement to create a shadow generator compatible with BJS.
  9457. */
  9458. export interface IShadowGenerator {
  9459. /**
  9460. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9461. * @returns The render target texture if present otherwise, null
  9462. */
  9463. getShadowMap(): Nullable<RenderTargetTexture>;
  9464. /**
  9465. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9466. * @param subMesh The submesh we want to render in the shadow map
  9467. * @param useInstances Defines wether will draw in the map using instances
  9468. * @returns true if ready otherwise, false
  9469. */
  9470. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9471. /**
  9472. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9473. * @param defines Defines of the material we want to update
  9474. * @param lightIndex Index of the light in the enabled light list of the material
  9475. */
  9476. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9477. /**
  9478. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9479. * defined in the generator but impacting the effect).
  9480. * It implies the unifroms available on the materials are the standard BJS ones.
  9481. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9482. * @param effect The effect we are binfing the information for
  9483. */
  9484. bindShadowLight(lightIndex: string, effect: Effect): void;
  9485. /**
  9486. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9487. * (eq to shadow prjection matrix * light transform matrix)
  9488. * @returns The transform matrix used to create the shadow map
  9489. */
  9490. getTransformMatrix(): Matrix;
  9491. /**
  9492. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9493. * Cube and 2D textures for instance.
  9494. */
  9495. recreateShadowMap(): void;
  9496. /**
  9497. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9498. * @param onCompiled Callback triggered at the and of the effects compilation
  9499. * @param options Sets of optional options forcing the compilation with different modes
  9500. */
  9501. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9502. useInstances: boolean;
  9503. }>): void;
  9504. /**
  9505. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9506. * @param options Sets of optional options forcing the compilation with different modes
  9507. * @returns A promise that resolves when the compilation completes
  9508. */
  9509. forceCompilationAsync(options?: Partial<{
  9510. useInstances: boolean;
  9511. }>): Promise<void>;
  9512. /**
  9513. * Serializes the shadow generator setup to a json object.
  9514. * @returns The serialized JSON object
  9515. */
  9516. serialize(): any;
  9517. /**
  9518. * Disposes the Shadow map and related Textures and effects.
  9519. */
  9520. dispose(): void;
  9521. }
  9522. /**
  9523. * Default implementation IShadowGenerator.
  9524. * This is the main object responsible of generating shadows in the framework.
  9525. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9526. */
  9527. export class ShadowGenerator implements IShadowGenerator {
  9528. /**
  9529. * Name of the shadow generator class
  9530. */
  9531. static CLASSNAME: string;
  9532. /**
  9533. * Shadow generator mode None: no filtering applied.
  9534. */
  9535. static readonly FILTER_NONE: number;
  9536. /**
  9537. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9538. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9539. */
  9540. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9541. /**
  9542. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9543. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9544. */
  9545. static readonly FILTER_POISSONSAMPLING: number;
  9546. /**
  9547. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9548. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9549. */
  9550. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9551. /**
  9552. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9553. * edge artifacts on steep falloff.
  9554. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9555. */
  9556. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9557. /**
  9558. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9559. * edge artifacts on steep falloff.
  9560. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9561. */
  9562. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9563. /**
  9564. * Shadow generator mode PCF: Percentage Closer Filtering
  9565. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9566. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9567. */
  9568. static readonly FILTER_PCF: number;
  9569. /**
  9570. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9571. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9572. * Contact Hardening
  9573. */
  9574. static readonly FILTER_PCSS: number;
  9575. /**
  9576. * Reserved for PCF and PCSS
  9577. * Highest Quality.
  9578. *
  9579. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9580. *
  9581. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9582. */
  9583. static readonly QUALITY_HIGH: number;
  9584. /**
  9585. * Reserved for PCF and PCSS
  9586. * Good tradeoff for quality/perf cross devices
  9587. *
  9588. * Execute PCF on a 3*3 kernel.
  9589. *
  9590. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9591. */
  9592. static readonly QUALITY_MEDIUM: number;
  9593. /**
  9594. * Reserved for PCF and PCSS
  9595. * The lowest quality but the fastest.
  9596. *
  9597. * Execute PCF on a 1*1 kernel.
  9598. *
  9599. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9600. */
  9601. static readonly QUALITY_LOW: number;
  9602. /** Gets or sets the custom shader name to use */
  9603. customShaderOptions: ICustomShaderOptions;
  9604. /**
  9605. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9606. */
  9607. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9608. /**
  9609. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9610. */
  9611. onAfterShadowMapRenderObservable: Observable<Effect>;
  9612. /**
  9613. * Observable triggered before a mesh is rendered in the shadow map.
  9614. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9615. */
  9616. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9617. /**
  9618. * Observable triggered after a mesh is rendered in the shadow map.
  9619. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9620. */
  9621. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9622. protected _bias: number;
  9623. /**
  9624. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9625. */
  9626. get bias(): number;
  9627. /**
  9628. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9629. */
  9630. set bias(bias: number);
  9631. protected _normalBias: number;
  9632. /**
  9633. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9634. */
  9635. get normalBias(): number;
  9636. /**
  9637. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9638. */
  9639. set normalBias(normalBias: number);
  9640. protected _blurBoxOffset: number;
  9641. /**
  9642. * Gets the blur box offset: offset applied during the blur pass.
  9643. * Only useful if useKernelBlur = false
  9644. */
  9645. get blurBoxOffset(): number;
  9646. /**
  9647. * Sets the blur box offset: offset applied during the blur pass.
  9648. * Only useful if useKernelBlur = false
  9649. */
  9650. set blurBoxOffset(value: number);
  9651. protected _blurScale: number;
  9652. /**
  9653. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9654. * 2 means half of the size.
  9655. */
  9656. get blurScale(): number;
  9657. /**
  9658. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9659. * 2 means half of the size.
  9660. */
  9661. set blurScale(value: number);
  9662. protected _blurKernel: number;
  9663. /**
  9664. * Gets the blur kernel: kernel size of the blur pass.
  9665. * Only useful if useKernelBlur = true
  9666. */
  9667. get blurKernel(): number;
  9668. /**
  9669. * Sets the blur kernel: kernel size of the blur pass.
  9670. * Only useful if useKernelBlur = true
  9671. */
  9672. set blurKernel(value: number);
  9673. protected _useKernelBlur: boolean;
  9674. /**
  9675. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9676. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9677. */
  9678. get useKernelBlur(): boolean;
  9679. /**
  9680. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9681. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9682. */
  9683. set useKernelBlur(value: boolean);
  9684. protected _depthScale: number;
  9685. /**
  9686. * Gets the depth scale used in ESM mode.
  9687. */
  9688. get depthScale(): number;
  9689. /**
  9690. * Sets the depth scale used in ESM mode.
  9691. * This can override the scale stored on the light.
  9692. */
  9693. set depthScale(value: number);
  9694. protected _validateFilter(filter: number): number;
  9695. protected _filter: number;
  9696. /**
  9697. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9698. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9699. */
  9700. get filter(): number;
  9701. /**
  9702. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9703. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9704. */
  9705. set filter(value: number);
  9706. /**
  9707. * Gets if the current filter is set to Poisson Sampling.
  9708. */
  9709. get usePoissonSampling(): boolean;
  9710. /**
  9711. * Sets the current filter to Poisson Sampling.
  9712. */
  9713. set usePoissonSampling(value: boolean);
  9714. /**
  9715. * Gets if the current filter is set to ESM.
  9716. */
  9717. get useExponentialShadowMap(): boolean;
  9718. /**
  9719. * Sets the current filter is to ESM.
  9720. */
  9721. set useExponentialShadowMap(value: boolean);
  9722. /**
  9723. * Gets if the current filter is set to filtered ESM.
  9724. */
  9725. get useBlurExponentialShadowMap(): boolean;
  9726. /**
  9727. * Gets if the current filter is set to filtered ESM.
  9728. */
  9729. set useBlurExponentialShadowMap(value: boolean);
  9730. /**
  9731. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9732. * exponential to prevent steep falloff artifacts).
  9733. */
  9734. get useCloseExponentialShadowMap(): boolean;
  9735. /**
  9736. * Sets the current filter to "close ESM" (using the inverse of the
  9737. * exponential to prevent steep falloff artifacts).
  9738. */
  9739. set useCloseExponentialShadowMap(value: boolean);
  9740. /**
  9741. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9742. * exponential to prevent steep falloff artifacts).
  9743. */
  9744. get useBlurCloseExponentialShadowMap(): boolean;
  9745. /**
  9746. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9747. * exponential to prevent steep falloff artifacts).
  9748. */
  9749. set useBlurCloseExponentialShadowMap(value: boolean);
  9750. /**
  9751. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9752. */
  9753. get usePercentageCloserFiltering(): boolean;
  9754. /**
  9755. * Sets the current filter to "PCF" (percentage closer filtering).
  9756. */
  9757. set usePercentageCloserFiltering(value: boolean);
  9758. protected _filteringQuality: number;
  9759. /**
  9760. * Gets the PCF or PCSS Quality.
  9761. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9762. */
  9763. get filteringQuality(): number;
  9764. /**
  9765. * Sets the PCF or PCSS Quality.
  9766. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9767. */
  9768. set filteringQuality(filteringQuality: number);
  9769. /**
  9770. * Gets if the current filter is set to "PCSS" (contact hardening).
  9771. */
  9772. get useContactHardeningShadow(): boolean;
  9773. /**
  9774. * Sets the current filter to "PCSS" (contact hardening).
  9775. */
  9776. set useContactHardeningShadow(value: boolean);
  9777. protected _contactHardeningLightSizeUVRatio: number;
  9778. /**
  9779. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9780. * Using a ratio helps keeping shape stability independently of the map size.
  9781. *
  9782. * It does not account for the light projection as it was having too much
  9783. * instability during the light setup or during light position changes.
  9784. *
  9785. * Only valid if useContactHardeningShadow is true.
  9786. */
  9787. get contactHardeningLightSizeUVRatio(): number;
  9788. /**
  9789. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9790. * Using a ratio helps keeping shape stability independently of the map size.
  9791. *
  9792. * It does not account for the light projection as it was having too much
  9793. * instability during the light setup or during light position changes.
  9794. *
  9795. * Only valid if useContactHardeningShadow is true.
  9796. */
  9797. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9798. protected _darkness: number;
  9799. /** Gets or sets the actual darkness of a shadow */
  9800. get darkness(): number;
  9801. set darkness(value: number);
  9802. /**
  9803. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9804. * 0 means strongest and 1 would means no shadow.
  9805. * @returns the darkness.
  9806. */
  9807. getDarkness(): number;
  9808. /**
  9809. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9810. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9811. * @returns the shadow generator allowing fluent coding.
  9812. */
  9813. setDarkness(darkness: number): ShadowGenerator;
  9814. protected _transparencyShadow: boolean;
  9815. /** Gets or sets the ability to have transparent shadow */
  9816. get transparencyShadow(): boolean;
  9817. set transparencyShadow(value: boolean);
  9818. /**
  9819. * Sets the ability to have transparent shadow (boolean).
  9820. * @param transparent True if transparent else False
  9821. * @returns the shadow generator allowing fluent coding
  9822. */
  9823. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9824. protected _shadowMap: Nullable<RenderTargetTexture>;
  9825. protected _shadowMap2: Nullable<RenderTargetTexture>;
  9826. /**
  9827. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9828. * @returns The render target texture if present otherwise, null
  9829. */
  9830. getShadowMap(): Nullable<RenderTargetTexture>;
  9831. /**
  9832. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9833. * @returns The render target texture if the shadow map is present otherwise, null
  9834. */
  9835. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9836. /**
  9837. * Gets the class name of that object
  9838. * @returns "ShadowGenerator"
  9839. */
  9840. getClassName(): string;
  9841. /**
  9842. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9843. * @param mesh Mesh to add
  9844. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9845. * @returns the Shadow Generator itself
  9846. */
  9847. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9848. /**
  9849. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9850. * @param mesh Mesh to remove
  9851. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9852. * @returns the Shadow Generator itself
  9853. */
  9854. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9855. /**
  9856. * Controls the extent to which the shadows fade out at the edge of the frustum
  9857. */
  9858. frustumEdgeFalloff: number;
  9859. protected _light: IShadowLight;
  9860. /**
  9861. * Returns the associated light object.
  9862. * @returns the light generating the shadow
  9863. */
  9864. getLight(): IShadowLight;
  9865. /**
  9866. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9867. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9868. * It might on the other hand introduce peter panning.
  9869. */
  9870. forceBackFacesOnly: boolean;
  9871. protected _scene: Scene;
  9872. protected _lightDirection: Vector3;
  9873. protected _effect: Effect;
  9874. protected _viewMatrix: Matrix;
  9875. protected _projectionMatrix: Matrix;
  9876. protected _transformMatrix: Matrix;
  9877. protected _cachedPosition: Vector3;
  9878. protected _cachedDirection: Vector3;
  9879. protected _cachedDefines: string;
  9880. protected _currentRenderID: number;
  9881. protected _boxBlurPostprocess: Nullable<PostProcess>;
  9882. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  9883. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  9884. protected _blurPostProcesses: PostProcess[];
  9885. protected _mapSize: number;
  9886. protected _currentFaceIndex: number;
  9887. protected _currentFaceIndexCache: number;
  9888. protected _textureType: number;
  9889. protected _defaultTextureMatrix: Matrix;
  9890. protected _storedUniqueId: Nullable<number>;
  9891. /** @hidden */
  9892. static _SceneComponentInitialization: (scene: Scene) => void;
  9893. /**
  9894. * Creates a ShadowGenerator object.
  9895. * A ShadowGenerator is the required tool to use the shadows.
  9896. * Each light casting shadows needs to use its own ShadowGenerator.
  9897. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9898. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9899. * @param light The light object generating the shadows.
  9900. * @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.
  9901. */
  9902. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9903. protected _initializeGenerator(): void;
  9904. protected _createTargetRenderTexture(): void;
  9905. protected _initializeShadowMap(): void;
  9906. protected _initializeBlurRTTAndPostProcesses(): void;
  9907. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  9908. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  9909. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  9910. protected _applyFilterValues(): void;
  9911. /**
  9912. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9913. * @param onCompiled Callback triggered at the and of the effects compilation
  9914. * @param options Sets of optional options forcing the compilation with different modes
  9915. */
  9916. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9917. useInstances: boolean;
  9918. }>): void;
  9919. /**
  9920. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9921. * @param options Sets of optional options forcing the compilation with different modes
  9922. * @returns A promise that resolves when the compilation completes
  9923. */
  9924. forceCompilationAsync(options?: Partial<{
  9925. useInstances: boolean;
  9926. }>): Promise<void>;
  9927. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  9928. /**
  9929. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9930. * @param subMesh The submesh we want to render in the shadow map
  9931. * @param useInstances Defines wether will draw in the map using instances
  9932. * @returns true if ready otherwise, false
  9933. */
  9934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9935. /**
  9936. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9937. * @param defines Defines of the material we want to update
  9938. * @param lightIndex Index of the light in the enabled light list of the material
  9939. */
  9940. prepareDefines(defines: any, lightIndex: number): void;
  9941. /**
  9942. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9943. * defined in the generator but impacting the effect).
  9944. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9945. * @param effect The effect we are binfing the information for
  9946. */
  9947. bindShadowLight(lightIndex: string, effect: Effect): void;
  9948. /**
  9949. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9950. * (eq to shadow prjection matrix * light transform matrix)
  9951. * @returns The transform matrix used to create the shadow map
  9952. */
  9953. getTransformMatrix(): Matrix;
  9954. /**
  9955. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9956. * Cube and 2D textures for instance.
  9957. */
  9958. recreateShadowMap(): void;
  9959. protected _disposeBlurPostProcesses(): void;
  9960. protected _disposeRTTandPostProcesses(): void;
  9961. /**
  9962. * Disposes the ShadowGenerator.
  9963. * Returns nothing.
  9964. */
  9965. dispose(): void;
  9966. /**
  9967. * Serializes the shadow generator setup to a json object.
  9968. * @returns The serialized JSON object
  9969. */
  9970. serialize(): any;
  9971. /**
  9972. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9973. * @param parsedShadowGenerator The JSON object to parse
  9974. * @param scene The scene to create the shadow map for
  9975. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  9976. * @returns The parsed shadow generator
  9977. */
  9978. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  9979. }
  9980. }
  9981. declare module BABYLON {
  9982. /**
  9983. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9984. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9985. * 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.
  9986. */
  9987. export abstract class Light extends Node {
  9988. /**
  9989. * Falloff Default: light is falling off following the material specification:
  9990. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9991. */
  9992. static readonly FALLOFF_DEFAULT: number;
  9993. /**
  9994. * Falloff Physical: light is falling off following the inverse squared distance law.
  9995. */
  9996. static readonly FALLOFF_PHYSICAL: number;
  9997. /**
  9998. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9999. * to enhance interoperability with other engines.
  10000. */
  10001. static readonly FALLOFF_GLTF: number;
  10002. /**
  10003. * Falloff Standard: light is falling off like in the standard material
  10004. * to enhance interoperability with other materials.
  10005. */
  10006. static readonly FALLOFF_STANDARD: number;
  10007. /**
  10008. * If every light affecting the material is in this lightmapMode,
  10009. * material.lightmapTexture adds or multiplies
  10010. * (depends on material.useLightmapAsShadowmap)
  10011. * after every other light calculations.
  10012. */
  10013. static readonly LIGHTMAP_DEFAULT: number;
  10014. /**
  10015. * material.lightmapTexture as only diffuse lighting from this light
  10016. * adds only specular lighting from this light
  10017. * adds dynamic shadows
  10018. */
  10019. static readonly LIGHTMAP_SPECULAR: number;
  10020. /**
  10021. * material.lightmapTexture as only lighting
  10022. * no light calculation from this light
  10023. * only adds dynamic shadows from this light
  10024. */
  10025. static readonly LIGHTMAP_SHADOWSONLY: number;
  10026. /**
  10027. * Each light type uses the default quantity according to its type:
  10028. * point/spot lights use luminous intensity
  10029. * directional lights use illuminance
  10030. */
  10031. static readonly INTENSITYMODE_AUTOMATIC: number;
  10032. /**
  10033. * lumen (lm)
  10034. */
  10035. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10036. /**
  10037. * candela (lm/sr)
  10038. */
  10039. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10040. /**
  10041. * lux (lm/m^2)
  10042. */
  10043. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10044. /**
  10045. * nit (cd/m^2)
  10046. */
  10047. static readonly INTENSITYMODE_LUMINANCE: number;
  10048. /**
  10049. * Light type const id of the point light.
  10050. */
  10051. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10052. /**
  10053. * Light type const id of the directional light.
  10054. */
  10055. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10056. /**
  10057. * Light type const id of the spot light.
  10058. */
  10059. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10060. /**
  10061. * Light type const id of the hemispheric light.
  10062. */
  10063. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10064. /**
  10065. * Diffuse gives the basic color to an object.
  10066. */
  10067. diffuse: Color3;
  10068. /**
  10069. * Specular produces a highlight color on an object.
  10070. * Note: This is note affecting PBR materials.
  10071. */
  10072. specular: Color3;
  10073. /**
  10074. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10075. * falling off base on range or angle.
  10076. * This can be set to any values in Light.FALLOFF_x.
  10077. *
  10078. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10079. * other types of materials.
  10080. */
  10081. falloffType: number;
  10082. /**
  10083. * Strength of the light.
  10084. * Note: By default it is define in the framework own unit.
  10085. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10086. */
  10087. intensity: number;
  10088. private _range;
  10089. protected _inverseSquaredRange: number;
  10090. /**
  10091. * Defines how far from the source the light is impacting in scene units.
  10092. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10093. */
  10094. get range(): number;
  10095. /**
  10096. * Defines how far from the source the light is impacting in scene units.
  10097. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10098. */
  10099. set range(value: number);
  10100. /**
  10101. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10102. * of light.
  10103. */
  10104. private _photometricScale;
  10105. private _intensityMode;
  10106. /**
  10107. * Gets the photometric scale used to interpret the intensity.
  10108. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10109. */
  10110. get intensityMode(): number;
  10111. /**
  10112. * Sets the photometric scale used to interpret the intensity.
  10113. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10114. */
  10115. set intensityMode(value: number);
  10116. private _radius;
  10117. /**
  10118. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10119. */
  10120. get radius(): number;
  10121. /**
  10122. * sets the light radius used by PBR Materials to simulate soft area lights.
  10123. */
  10124. set radius(value: number);
  10125. private _renderPriority;
  10126. /**
  10127. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10128. * exceeding the number allowed of the materials.
  10129. */
  10130. renderPriority: number;
  10131. private _shadowEnabled;
  10132. /**
  10133. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10134. * the current shadow generator.
  10135. */
  10136. get shadowEnabled(): boolean;
  10137. /**
  10138. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10139. * the current shadow generator.
  10140. */
  10141. set shadowEnabled(value: boolean);
  10142. private _includedOnlyMeshes;
  10143. /**
  10144. * Gets the only meshes impacted by this light.
  10145. */
  10146. get includedOnlyMeshes(): AbstractMesh[];
  10147. /**
  10148. * Sets the only meshes impacted by this light.
  10149. */
  10150. set includedOnlyMeshes(value: AbstractMesh[]);
  10151. private _excludedMeshes;
  10152. /**
  10153. * Gets the meshes not impacted by this light.
  10154. */
  10155. get excludedMeshes(): AbstractMesh[];
  10156. /**
  10157. * Sets the meshes not impacted by this light.
  10158. */
  10159. set excludedMeshes(value: AbstractMesh[]);
  10160. private _excludeWithLayerMask;
  10161. /**
  10162. * Gets the layer id use to find what meshes are not impacted by the light.
  10163. * Inactive if 0
  10164. */
  10165. get excludeWithLayerMask(): number;
  10166. /**
  10167. * Sets the layer id use to find what meshes are not impacted by the light.
  10168. * Inactive if 0
  10169. */
  10170. set excludeWithLayerMask(value: number);
  10171. private _includeOnlyWithLayerMask;
  10172. /**
  10173. * Gets the layer id use to find what meshes are impacted by the light.
  10174. * Inactive if 0
  10175. */
  10176. get includeOnlyWithLayerMask(): number;
  10177. /**
  10178. * Sets the layer id use to find what meshes are impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. set includeOnlyWithLayerMask(value: number);
  10182. private _lightmapMode;
  10183. /**
  10184. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10185. */
  10186. get lightmapMode(): number;
  10187. /**
  10188. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10189. */
  10190. set lightmapMode(value: number);
  10191. /**
  10192. * Shadow generator associted to the light.
  10193. * @hidden Internal use only.
  10194. */
  10195. _shadowGenerator: Nullable<IShadowGenerator>;
  10196. /**
  10197. * @hidden Internal use only.
  10198. */
  10199. _excludedMeshesIds: string[];
  10200. /**
  10201. * @hidden Internal use only.
  10202. */
  10203. _includedOnlyMeshesIds: string[];
  10204. /**
  10205. * The current light unifom buffer.
  10206. * @hidden Internal use only.
  10207. */
  10208. _uniformBuffer: UniformBuffer;
  10209. /** @hidden */
  10210. _renderId: number;
  10211. /**
  10212. * Creates a Light object in the scene.
  10213. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10214. * @param name The firendly name of the light
  10215. * @param scene The scene the light belongs too
  10216. */
  10217. constructor(name: string, scene: Scene);
  10218. protected abstract _buildUniformLayout(): void;
  10219. /**
  10220. * Sets the passed Effect "effect" with the Light information.
  10221. * @param effect The effect to update
  10222. * @param lightIndex The index of the light in the effect to update
  10223. * @returns The light
  10224. */
  10225. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10226. /**
  10227. * Sets the passed Effect "effect" with the Light textures.
  10228. * @param effect The effect to update
  10229. * @param lightIndex The index of the light in the effect to update
  10230. * @returns The light
  10231. */
  10232. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10233. /**
  10234. * Binds the lights information from the scene to the effect for the given mesh.
  10235. * @param lightIndex Light index
  10236. * @param scene The scene where the light belongs to
  10237. * @param effect The effect we are binding the data to
  10238. * @param useSpecular Defines if specular is supported
  10239. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10240. */
  10241. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10242. /**
  10243. * Sets the passed Effect "effect" with the Light information.
  10244. * @param effect The effect to update
  10245. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10246. * @returns The light
  10247. */
  10248. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10249. /**
  10250. * Returns the string "Light".
  10251. * @returns the class name
  10252. */
  10253. getClassName(): string;
  10254. /** @hidden */
  10255. readonly _isLight: boolean;
  10256. /**
  10257. * Converts the light information to a readable string for debug purpose.
  10258. * @param fullDetails Supports for multiple levels of logging within scene loading
  10259. * @returns the human readable light info
  10260. */
  10261. toString(fullDetails?: boolean): string;
  10262. /** @hidden */
  10263. protected _syncParentEnabledState(): void;
  10264. /**
  10265. * Set the enabled state of this node.
  10266. * @param value - the new enabled state
  10267. */
  10268. setEnabled(value: boolean): void;
  10269. /**
  10270. * Returns the Light associated shadow generator if any.
  10271. * @return the associated shadow generator.
  10272. */
  10273. getShadowGenerator(): Nullable<IShadowGenerator>;
  10274. /**
  10275. * Returns a Vector3, the absolute light position in the World.
  10276. * @returns the world space position of the light
  10277. */
  10278. getAbsolutePosition(): Vector3;
  10279. /**
  10280. * Specifies if the light will affect the passed mesh.
  10281. * @param mesh The mesh to test against the light
  10282. * @return true the mesh is affected otherwise, false.
  10283. */
  10284. canAffectMesh(mesh: AbstractMesh): boolean;
  10285. /**
  10286. * Sort function to order lights for rendering.
  10287. * @param a First Light object to compare to second.
  10288. * @param b Second Light object to compare first.
  10289. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10290. */
  10291. static CompareLightsPriority(a: Light, b: Light): number;
  10292. /**
  10293. * Releases resources associated with this node.
  10294. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10295. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10296. */
  10297. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10298. /**
  10299. * Returns the light type ID (integer).
  10300. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10301. */
  10302. getTypeID(): number;
  10303. /**
  10304. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10305. * @returns the scaled intensity in intensity mode unit
  10306. */
  10307. getScaledIntensity(): number;
  10308. /**
  10309. * Returns a new Light object, named "name", from the current one.
  10310. * @param name The name of the cloned light
  10311. * @returns the new created light
  10312. */
  10313. clone(name: string): Nullable<Light>;
  10314. /**
  10315. * Serializes the current light into a Serialization object.
  10316. * @returns the serialized object.
  10317. */
  10318. serialize(): any;
  10319. /**
  10320. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10321. * This new light is named "name" and added to the passed scene.
  10322. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10323. * @param name The friendly name of the light
  10324. * @param scene The scene the new light will belong to
  10325. * @returns the constructor function
  10326. */
  10327. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10328. /**
  10329. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10330. * @param parsedLight The JSON representation of the light
  10331. * @param scene The scene to create the parsed light in
  10332. * @returns the created light after parsing
  10333. */
  10334. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10335. private _hookArrayForExcluded;
  10336. private _hookArrayForIncludedOnly;
  10337. private _resyncMeshes;
  10338. /**
  10339. * Forces the meshes to update their light related information in their rendering used effects
  10340. * @hidden Internal Use Only
  10341. */
  10342. _markMeshesAsLightDirty(): void;
  10343. /**
  10344. * Recomputes the cached photometric scale if needed.
  10345. */
  10346. private _computePhotometricScale;
  10347. /**
  10348. * Returns the Photometric Scale according to the light type and intensity mode.
  10349. */
  10350. private _getPhotometricScale;
  10351. /**
  10352. * Reorder the light in the scene according to their defined priority.
  10353. * @hidden Internal Use Only
  10354. */
  10355. _reorderLightsInScene(): void;
  10356. /**
  10357. * Prepares the list of defines specific to the light type.
  10358. * @param defines the list of defines
  10359. * @param lightIndex defines the index of the light for the effect
  10360. */
  10361. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10362. }
  10363. }
  10364. declare module BABYLON {
  10365. /**
  10366. * Interface used to define Action
  10367. */
  10368. export interface IAction {
  10369. /**
  10370. * Trigger for the action
  10371. */
  10372. trigger: number;
  10373. /** Options of the trigger */
  10374. triggerOptions: any;
  10375. /**
  10376. * Gets the trigger parameters
  10377. * @returns the trigger parameters
  10378. */
  10379. getTriggerParameter(): any;
  10380. /**
  10381. * Internal only - executes current action event
  10382. * @hidden
  10383. */
  10384. _executeCurrent(evt?: ActionEvent): void;
  10385. /**
  10386. * Serialize placeholder for child classes
  10387. * @param parent of child
  10388. * @returns the serialized object
  10389. */
  10390. serialize(parent: any): any;
  10391. /**
  10392. * Internal only
  10393. * @hidden
  10394. */
  10395. _prepare(): void;
  10396. /**
  10397. * Internal only - manager for action
  10398. * @hidden
  10399. */
  10400. _actionManager: AbstractActionManager;
  10401. /**
  10402. * Adds action to chain of actions, may be a DoNothingAction
  10403. * @param action defines the next action to execute
  10404. * @returns The action passed in
  10405. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10406. */
  10407. then(action: IAction): IAction;
  10408. }
  10409. /**
  10410. * The action to be carried out following a trigger
  10411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10412. */
  10413. export class Action implements IAction {
  10414. /** the trigger, with or without parameters, for the action */
  10415. triggerOptions: any;
  10416. /**
  10417. * Trigger for the action
  10418. */
  10419. trigger: number;
  10420. /**
  10421. * Internal only - manager for action
  10422. * @hidden
  10423. */
  10424. _actionManager: ActionManager;
  10425. private _nextActiveAction;
  10426. private _child;
  10427. private _condition?;
  10428. private _triggerParameter;
  10429. /**
  10430. * An event triggered prior to action being executed.
  10431. */
  10432. onBeforeExecuteObservable: Observable<Action>;
  10433. /**
  10434. * Creates a new Action
  10435. * @param triggerOptions the trigger, with or without parameters, for the action
  10436. * @param condition an optional determinant of action
  10437. */
  10438. constructor(
  10439. /** the trigger, with or without parameters, for the action */
  10440. triggerOptions: any, condition?: Condition);
  10441. /**
  10442. * Internal only
  10443. * @hidden
  10444. */
  10445. _prepare(): void;
  10446. /**
  10447. * Gets the trigger parameters
  10448. * @returns the trigger parameters
  10449. */
  10450. getTriggerParameter(): any;
  10451. /**
  10452. * Internal only - executes current action event
  10453. * @hidden
  10454. */
  10455. _executeCurrent(evt?: ActionEvent): void;
  10456. /**
  10457. * Execute placeholder for child classes
  10458. * @param evt optional action event
  10459. */
  10460. execute(evt?: ActionEvent): void;
  10461. /**
  10462. * Skips to next active action
  10463. */
  10464. skipToNextActiveAction(): void;
  10465. /**
  10466. * Adds action to chain of actions, may be a DoNothingAction
  10467. * @param action defines the next action to execute
  10468. * @returns The action passed in
  10469. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10470. */
  10471. then(action: Action): Action;
  10472. /**
  10473. * Internal only
  10474. * @hidden
  10475. */
  10476. _getProperty(propertyPath: string): string;
  10477. /**
  10478. * Internal only
  10479. * @hidden
  10480. */
  10481. _getEffectiveTarget(target: any, propertyPath: string): any;
  10482. /**
  10483. * Serialize placeholder for child classes
  10484. * @param parent of child
  10485. * @returns the serialized object
  10486. */
  10487. serialize(parent: any): any;
  10488. /**
  10489. * Internal only called by serialize
  10490. * @hidden
  10491. */
  10492. protected _serialize(serializedAction: any, parent?: any): any;
  10493. /**
  10494. * Internal only
  10495. * @hidden
  10496. */
  10497. static _SerializeValueAsString: (value: any) => string;
  10498. /**
  10499. * Internal only
  10500. * @hidden
  10501. */
  10502. static _GetTargetProperty: (target: Node | Scene) => {
  10503. name: string;
  10504. targetType: string;
  10505. value: string;
  10506. };
  10507. }
  10508. }
  10509. declare module BABYLON {
  10510. /**
  10511. * A Condition applied to an Action
  10512. */
  10513. export class Condition {
  10514. /**
  10515. * Internal only - manager for action
  10516. * @hidden
  10517. */
  10518. _actionManager: ActionManager;
  10519. /**
  10520. * Internal only
  10521. * @hidden
  10522. */
  10523. _evaluationId: number;
  10524. /**
  10525. * Internal only
  10526. * @hidden
  10527. */
  10528. _currentResult: boolean;
  10529. /**
  10530. * Creates a new Condition
  10531. * @param actionManager the manager of the action the condition is applied to
  10532. */
  10533. constructor(actionManager: ActionManager);
  10534. /**
  10535. * Check if the current condition is valid
  10536. * @returns a boolean
  10537. */
  10538. isValid(): boolean;
  10539. /**
  10540. * Internal only
  10541. * @hidden
  10542. */
  10543. _getProperty(propertyPath: string): string;
  10544. /**
  10545. * Internal only
  10546. * @hidden
  10547. */
  10548. _getEffectiveTarget(target: any, propertyPath: string): any;
  10549. /**
  10550. * Serialize placeholder for child classes
  10551. * @returns the serialized object
  10552. */
  10553. serialize(): any;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. protected _serialize(serializedCondition: any): any;
  10559. }
  10560. /**
  10561. * Defines specific conditional operators as extensions of Condition
  10562. */
  10563. export class ValueCondition extends Condition {
  10564. /** path to specify the property of the target the conditional operator uses */
  10565. propertyPath: string;
  10566. /** the value compared by the conditional operator against the current value of the property */
  10567. value: any;
  10568. /** the conditional operator, default ValueCondition.IsEqual */
  10569. operator: number;
  10570. /**
  10571. * Internal only
  10572. * @hidden
  10573. */
  10574. private static _IsEqual;
  10575. /**
  10576. * Internal only
  10577. * @hidden
  10578. */
  10579. private static _IsDifferent;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. private static _IsGreater;
  10585. /**
  10586. * Internal only
  10587. * @hidden
  10588. */
  10589. private static _IsLesser;
  10590. /**
  10591. * returns the number for IsEqual
  10592. */
  10593. static get IsEqual(): number;
  10594. /**
  10595. * Returns the number for IsDifferent
  10596. */
  10597. static get IsDifferent(): number;
  10598. /**
  10599. * Returns the number for IsGreater
  10600. */
  10601. static get IsGreater(): number;
  10602. /**
  10603. * Returns the number for IsLesser
  10604. */
  10605. static get IsLesser(): number;
  10606. /**
  10607. * Internal only The action manager for the condition
  10608. * @hidden
  10609. */
  10610. _actionManager: ActionManager;
  10611. /**
  10612. * Internal only
  10613. * @hidden
  10614. */
  10615. private _target;
  10616. /**
  10617. * Internal only
  10618. * @hidden
  10619. */
  10620. private _effectiveTarget;
  10621. /**
  10622. * Internal only
  10623. * @hidden
  10624. */
  10625. private _property;
  10626. /**
  10627. * Creates a new ValueCondition
  10628. * @param actionManager manager for the action the condition applies to
  10629. * @param target for the action
  10630. * @param propertyPath path to specify the property of the target the conditional operator uses
  10631. * @param value the value compared by the conditional operator against the current value of the property
  10632. * @param operator the conditional operator, default ValueCondition.IsEqual
  10633. */
  10634. constructor(actionManager: ActionManager, target: any,
  10635. /** path to specify the property of the target the conditional operator uses */
  10636. propertyPath: string,
  10637. /** the value compared by the conditional operator against the current value of the property */
  10638. value: any,
  10639. /** the conditional operator, default ValueCondition.IsEqual */
  10640. operator?: number);
  10641. /**
  10642. * Compares the given value with the property value for the specified conditional operator
  10643. * @returns the result of the comparison
  10644. */
  10645. isValid(): boolean;
  10646. /**
  10647. * Serialize the ValueCondition into a JSON compatible object
  10648. * @returns serialization object
  10649. */
  10650. serialize(): any;
  10651. /**
  10652. * Gets the name of the conditional operator for the ValueCondition
  10653. * @param operator the conditional operator
  10654. * @returns the name
  10655. */
  10656. static GetOperatorName(operator: number): string;
  10657. }
  10658. /**
  10659. * Defines a predicate condition as an extension of Condition
  10660. */
  10661. export class PredicateCondition extends Condition {
  10662. /** defines the predicate function used to validate the condition */
  10663. predicate: () => boolean;
  10664. /**
  10665. * Internal only - manager for action
  10666. * @hidden
  10667. */
  10668. _actionManager: ActionManager;
  10669. /**
  10670. * Creates a new PredicateCondition
  10671. * @param actionManager manager for the action the condition applies to
  10672. * @param predicate defines the predicate function used to validate the condition
  10673. */
  10674. constructor(actionManager: ActionManager,
  10675. /** defines the predicate function used to validate the condition */
  10676. predicate: () => boolean);
  10677. /**
  10678. * @returns the validity of the predicate condition
  10679. */
  10680. isValid(): boolean;
  10681. }
  10682. /**
  10683. * Defines a state condition as an extension of Condition
  10684. */
  10685. export class StateCondition extends Condition {
  10686. /** Value to compare with target state */
  10687. value: string;
  10688. /**
  10689. * Internal only - manager for action
  10690. * @hidden
  10691. */
  10692. _actionManager: ActionManager;
  10693. /**
  10694. * Internal only
  10695. * @hidden
  10696. */
  10697. private _target;
  10698. /**
  10699. * Creates a new StateCondition
  10700. * @param actionManager manager for the action the condition applies to
  10701. * @param target of the condition
  10702. * @param value to compare with target state
  10703. */
  10704. constructor(actionManager: ActionManager, target: any,
  10705. /** Value to compare with target state */
  10706. value: string);
  10707. /**
  10708. * Gets a boolean indicating if the current condition is met
  10709. * @returns the validity of the state
  10710. */
  10711. isValid(): boolean;
  10712. /**
  10713. * Serialize the StateCondition into a JSON compatible object
  10714. * @returns serialization object
  10715. */
  10716. serialize(): any;
  10717. }
  10718. }
  10719. declare module BABYLON {
  10720. /**
  10721. * This defines an action responsible to toggle a boolean once triggered.
  10722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10723. */
  10724. export class SwitchBooleanAction extends Action {
  10725. /**
  10726. * The path to the boolean property in the target object
  10727. */
  10728. propertyPath: string;
  10729. private _target;
  10730. private _effectiveTarget;
  10731. private _property;
  10732. /**
  10733. * Instantiate the action
  10734. * @param triggerOptions defines the trigger options
  10735. * @param target defines the object containing the boolean
  10736. * @param propertyPath defines the path to the boolean property in the target object
  10737. * @param condition defines the trigger related conditions
  10738. */
  10739. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10740. /** @hidden */
  10741. _prepare(): void;
  10742. /**
  10743. * Execute the action toggle the boolean value.
  10744. */
  10745. execute(): void;
  10746. /**
  10747. * Serializes the actions and its related information.
  10748. * @param parent defines the object to serialize in
  10749. * @returns the serialized object
  10750. */
  10751. serialize(parent: any): any;
  10752. }
  10753. /**
  10754. * This defines an action responsible to set a the state field of the target
  10755. * to a desired value once triggered.
  10756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10757. */
  10758. export class SetStateAction extends Action {
  10759. /**
  10760. * The value to store in the state field.
  10761. */
  10762. value: string;
  10763. private _target;
  10764. /**
  10765. * Instantiate the action
  10766. * @param triggerOptions defines the trigger options
  10767. * @param target defines the object containing the state property
  10768. * @param value defines the value to store in the state field
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10772. /**
  10773. * Execute the action and store the value on the target state property.
  10774. */
  10775. execute(): void;
  10776. /**
  10777. * Serializes the actions and its related information.
  10778. * @param parent defines the object to serialize in
  10779. * @returns the serialized object
  10780. */
  10781. serialize(parent: any): any;
  10782. }
  10783. /**
  10784. * This defines an action responsible to set a property of the target
  10785. * to a desired value once triggered.
  10786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10787. */
  10788. export class SetValueAction extends Action {
  10789. /**
  10790. * The path of the property to set in the target.
  10791. */
  10792. propertyPath: string;
  10793. /**
  10794. * The value to set in the property
  10795. */
  10796. value: any;
  10797. private _target;
  10798. private _effectiveTarget;
  10799. private _property;
  10800. /**
  10801. * Instantiate the action
  10802. * @param triggerOptions defines the trigger options
  10803. * @param target defines the object containing the property
  10804. * @param propertyPath defines the path of the property to set in the target
  10805. * @param value defines the value to set in the property
  10806. * @param condition defines the trigger related conditions
  10807. */
  10808. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10809. /** @hidden */
  10810. _prepare(): void;
  10811. /**
  10812. * Execute the action and set the targetted property to the desired value.
  10813. */
  10814. execute(): void;
  10815. /**
  10816. * Serializes the actions and its related information.
  10817. * @param parent defines the object to serialize in
  10818. * @returns the serialized object
  10819. */
  10820. serialize(parent: any): any;
  10821. }
  10822. /**
  10823. * This defines an action responsible to increment the target value
  10824. * to a desired value once triggered.
  10825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10826. */
  10827. export class IncrementValueAction extends Action {
  10828. /**
  10829. * The path of the property to increment in the target.
  10830. */
  10831. propertyPath: string;
  10832. /**
  10833. * The value we should increment the property by.
  10834. */
  10835. value: any;
  10836. private _target;
  10837. private _effectiveTarget;
  10838. private _property;
  10839. /**
  10840. * Instantiate the action
  10841. * @param triggerOptions defines the trigger options
  10842. * @param target defines the object containing the property
  10843. * @param propertyPath defines the path of the property to increment in the target
  10844. * @param value defines the value value we should increment the property by
  10845. * @param condition defines the trigger related conditions
  10846. */
  10847. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10848. /** @hidden */
  10849. _prepare(): void;
  10850. /**
  10851. * Execute the action and increment the target of the value amount.
  10852. */
  10853. execute(): void;
  10854. /**
  10855. * Serializes the actions and its related information.
  10856. * @param parent defines the object to serialize in
  10857. * @returns the serialized object
  10858. */
  10859. serialize(parent: any): any;
  10860. }
  10861. /**
  10862. * This defines an action responsible to start an animation once triggered.
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10864. */
  10865. export class PlayAnimationAction extends Action {
  10866. /**
  10867. * Where the animation should start (animation frame)
  10868. */
  10869. from: number;
  10870. /**
  10871. * Where the animation should stop (animation frame)
  10872. */
  10873. to: number;
  10874. /**
  10875. * Define if the animation should loop or stop after the first play.
  10876. */
  10877. loop?: boolean;
  10878. private _target;
  10879. /**
  10880. * Instantiate the action
  10881. * @param triggerOptions defines the trigger options
  10882. * @param target defines the target animation or animation name
  10883. * @param from defines from where the animation should start (animation frame)
  10884. * @param end defines where the animation should stop (animation frame)
  10885. * @param loop defines if the animation should loop or stop after the first play
  10886. * @param condition defines the trigger related conditions
  10887. */
  10888. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10889. /** @hidden */
  10890. _prepare(): void;
  10891. /**
  10892. * Execute the action and play the animation.
  10893. */
  10894. execute(): void;
  10895. /**
  10896. * Serializes the actions and its related information.
  10897. * @param parent defines the object to serialize in
  10898. * @returns the serialized object
  10899. */
  10900. serialize(parent: any): any;
  10901. }
  10902. /**
  10903. * This defines an action responsible to stop an animation once triggered.
  10904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10905. */
  10906. export class StopAnimationAction extends Action {
  10907. private _target;
  10908. /**
  10909. * Instantiate the action
  10910. * @param triggerOptions defines the trigger options
  10911. * @param target defines the target animation or animation name
  10912. * @param condition defines the trigger related conditions
  10913. */
  10914. constructor(triggerOptions: any, target: any, condition?: Condition);
  10915. /** @hidden */
  10916. _prepare(): void;
  10917. /**
  10918. * Execute the action and stop the animation.
  10919. */
  10920. execute(): void;
  10921. /**
  10922. * Serializes the actions and its related information.
  10923. * @param parent defines the object to serialize in
  10924. * @returns the serialized object
  10925. */
  10926. serialize(parent: any): any;
  10927. }
  10928. /**
  10929. * This defines an action responsible that does nothing once triggered.
  10930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10931. */
  10932. export class DoNothingAction extends Action {
  10933. /**
  10934. * Instantiate the action
  10935. * @param triggerOptions defines the trigger options
  10936. * @param condition defines the trigger related conditions
  10937. */
  10938. constructor(triggerOptions?: any, condition?: Condition);
  10939. /**
  10940. * Execute the action and do nothing.
  10941. */
  10942. execute(): void;
  10943. /**
  10944. * Serializes the actions and its related information.
  10945. * @param parent defines the object to serialize in
  10946. * @returns the serialized object
  10947. */
  10948. serialize(parent: any): any;
  10949. }
  10950. /**
  10951. * This defines an action responsible to trigger several actions once triggered.
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10953. */
  10954. export class CombineAction extends Action {
  10955. /**
  10956. * The list of aggregated animations to run.
  10957. */
  10958. children: Action[];
  10959. /**
  10960. * Instantiate the action
  10961. * @param triggerOptions defines the trigger options
  10962. * @param children defines the list of aggregated animations to run
  10963. * @param condition defines the trigger related conditions
  10964. */
  10965. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10966. /** @hidden */
  10967. _prepare(): void;
  10968. /**
  10969. * Execute the action and executes all the aggregated actions.
  10970. */
  10971. execute(evt: ActionEvent): void;
  10972. /**
  10973. * Serializes the actions and its related information.
  10974. * @param parent defines the object to serialize in
  10975. * @returns the serialized object
  10976. */
  10977. serialize(parent: any): any;
  10978. }
  10979. /**
  10980. * This defines an action responsible to run code (external event) once triggered.
  10981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10982. */
  10983. export class ExecuteCodeAction extends Action {
  10984. /**
  10985. * The callback function to run.
  10986. */
  10987. func: (evt: ActionEvent) => void;
  10988. /**
  10989. * Instantiate the action
  10990. * @param triggerOptions defines the trigger options
  10991. * @param func defines the callback function to run
  10992. * @param condition defines the trigger related conditions
  10993. */
  10994. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10995. /**
  10996. * Execute the action and run the attached code.
  10997. */
  10998. execute(evt: ActionEvent): void;
  10999. }
  11000. /**
  11001. * This defines an action responsible to set the parent property of the target once triggered.
  11002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11003. */
  11004. export class SetParentAction extends Action {
  11005. private _parent;
  11006. private _target;
  11007. /**
  11008. * Instantiate the action
  11009. * @param triggerOptions defines the trigger options
  11010. * @param target defines the target containing the parent property
  11011. * @param parent defines from where the animation should start (animation frame)
  11012. * @param condition defines the trigger related conditions
  11013. */
  11014. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11015. /** @hidden */
  11016. _prepare(): void;
  11017. /**
  11018. * Execute the action and set the parent property.
  11019. */
  11020. execute(): void;
  11021. /**
  11022. * Serializes the actions and its related information.
  11023. * @param parent defines the object to serialize in
  11024. * @returns the serialized object
  11025. */
  11026. serialize(parent: any): any;
  11027. }
  11028. }
  11029. declare module BABYLON {
  11030. /**
  11031. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11032. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11034. */
  11035. export class ActionManager extends AbstractActionManager {
  11036. /**
  11037. * Nothing
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11039. */
  11040. static readonly NothingTrigger: number;
  11041. /**
  11042. * On pick
  11043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11044. */
  11045. static readonly OnPickTrigger: number;
  11046. /**
  11047. * On left pick
  11048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11049. */
  11050. static readonly OnLeftPickTrigger: number;
  11051. /**
  11052. * On right pick
  11053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11054. */
  11055. static readonly OnRightPickTrigger: number;
  11056. /**
  11057. * On center pick
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11059. */
  11060. static readonly OnCenterPickTrigger: number;
  11061. /**
  11062. * On pick down
  11063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11064. */
  11065. static readonly OnPickDownTrigger: number;
  11066. /**
  11067. * On double pick
  11068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11069. */
  11070. static readonly OnDoublePickTrigger: number;
  11071. /**
  11072. * On pick up
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnPickUpTrigger: number;
  11076. /**
  11077. * On pick out.
  11078. * This trigger will only be raised if you also declared a OnPickDown
  11079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11080. */
  11081. static readonly OnPickOutTrigger: number;
  11082. /**
  11083. * On long press
  11084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11085. */
  11086. static readonly OnLongPressTrigger: number;
  11087. /**
  11088. * On pointer over
  11089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11090. */
  11091. static readonly OnPointerOverTrigger: number;
  11092. /**
  11093. * On pointer out
  11094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11095. */
  11096. static readonly OnPointerOutTrigger: number;
  11097. /**
  11098. * On every frame
  11099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11100. */
  11101. static readonly OnEveryFrameTrigger: number;
  11102. /**
  11103. * On intersection enter
  11104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11105. */
  11106. static readonly OnIntersectionEnterTrigger: number;
  11107. /**
  11108. * On intersection exit
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11110. */
  11111. static readonly OnIntersectionExitTrigger: number;
  11112. /**
  11113. * On key down
  11114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11115. */
  11116. static readonly OnKeyDownTrigger: number;
  11117. /**
  11118. * On key up
  11119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11120. */
  11121. static readonly OnKeyUpTrigger: number;
  11122. private _scene;
  11123. /**
  11124. * Creates a new action manager
  11125. * @param scene defines the hosting scene
  11126. */
  11127. constructor(scene: Scene);
  11128. /**
  11129. * Releases all associated resources
  11130. */
  11131. dispose(): void;
  11132. /**
  11133. * Gets hosting scene
  11134. * @returns the hosting scene
  11135. */
  11136. getScene(): Scene;
  11137. /**
  11138. * Does this action manager handles actions of any of the given triggers
  11139. * @param triggers defines the triggers to be tested
  11140. * @return a boolean indicating whether one (or more) of the triggers is handled
  11141. */
  11142. hasSpecificTriggers(triggers: number[]): boolean;
  11143. /**
  11144. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11145. * speed.
  11146. * @param triggerA defines the trigger to be tested
  11147. * @param triggerB defines the trigger to be tested
  11148. * @return a boolean indicating whether one (or more) of the triggers is handled
  11149. */
  11150. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11151. /**
  11152. * Does this action manager handles actions of a given trigger
  11153. * @param trigger defines the trigger to be tested
  11154. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11155. * @return whether the trigger is handled
  11156. */
  11157. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11158. /**
  11159. * Does this action manager has pointer triggers
  11160. */
  11161. get hasPointerTriggers(): boolean;
  11162. /**
  11163. * Does this action manager has pick triggers
  11164. */
  11165. get hasPickTriggers(): boolean;
  11166. /**
  11167. * Registers an action to this action manager
  11168. * @param action defines the action to be registered
  11169. * @return the action amended (prepared) after registration
  11170. */
  11171. registerAction(action: IAction): Nullable<IAction>;
  11172. /**
  11173. * Unregisters an action to this action manager
  11174. * @param action defines the action to be unregistered
  11175. * @return a boolean indicating whether the action has been unregistered
  11176. */
  11177. unregisterAction(action: IAction): Boolean;
  11178. /**
  11179. * Process a specific trigger
  11180. * @param trigger defines the trigger to process
  11181. * @param evt defines the event details to be processed
  11182. */
  11183. processTrigger(trigger: number, evt?: IActionEvent): void;
  11184. /** @hidden */
  11185. _getEffectiveTarget(target: any, propertyPath: string): any;
  11186. /** @hidden */
  11187. _getProperty(propertyPath: string): string;
  11188. /**
  11189. * Serialize this manager to a JSON object
  11190. * @param name defines the property name to store this manager
  11191. * @returns a JSON representation of this manager
  11192. */
  11193. serialize(name: string): any;
  11194. /**
  11195. * Creates a new ActionManager from a JSON data
  11196. * @param parsedActions defines the JSON data to read from
  11197. * @param object defines the hosting mesh
  11198. * @param scene defines the hosting scene
  11199. */
  11200. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11201. /**
  11202. * Get a trigger name by index
  11203. * @param trigger defines the trigger index
  11204. * @returns a trigger name
  11205. */
  11206. static GetTriggerName(trigger: number): string;
  11207. }
  11208. }
  11209. declare module BABYLON {
  11210. /**
  11211. * Class representing a ray with position and direction
  11212. */
  11213. export class Ray {
  11214. /** origin point */
  11215. origin: Vector3;
  11216. /** direction */
  11217. direction: Vector3;
  11218. /** length of the ray */
  11219. length: number;
  11220. private static readonly TmpVector3;
  11221. private _tmpRay;
  11222. /**
  11223. * Creates a new ray
  11224. * @param origin origin point
  11225. * @param direction direction
  11226. * @param length length of the ray
  11227. */
  11228. constructor(
  11229. /** origin point */
  11230. origin: Vector3,
  11231. /** direction */
  11232. direction: Vector3,
  11233. /** length of the ray */
  11234. length?: number);
  11235. /**
  11236. * Checks if the ray intersects a box
  11237. * @param minimum bound of the box
  11238. * @param maximum bound of the box
  11239. * @param intersectionTreshold extra extend to be added to the box in all direction
  11240. * @returns if the box was hit
  11241. */
  11242. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11243. /**
  11244. * Checks if the ray intersects a box
  11245. * @param box the bounding box to check
  11246. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11247. * @returns if the box was hit
  11248. */
  11249. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11250. /**
  11251. * If the ray hits a sphere
  11252. * @param sphere the bounding sphere to check
  11253. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11254. * @returns true if it hits the sphere
  11255. */
  11256. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11257. /**
  11258. * If the ray hits a triange
  11259. * @param vertex0 triangle vertex
  11260. * @param vertex1 triangle vertex
  11261. * @param vertex2 triangle vertex
  11262. * @returns intersection information if hit
  11263. */
  11264. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11265. /**
  11266. * Checks if ray intersects a plane
  11267. * @param plane the plane to check
  11268. * @returns the distance away it was hit
  11269. */
  11270. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11271. /**
  11272. * Calculate the intercept of a ray on a given axis
  11273. * @param axis to check 'x' | 'y' | 'z'
  11274. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11275. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11276. */
  11277. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11278. /**
  11279. * Checks if ray intersects a mesh
  11280. * @param mesh the mesh to check
  11281. * @param fastCheck if only the bounding box should checked
  11282. * @returns picking info of the intersecton
  11283. */
  11284. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11285. /**
  11286. * Checks if ray intersects a mesh
  11287. * @param meshes the meshes to check
  11288. * @param fastCheck if only the bounding box should checked
  11289. * @param results array to store result in
  11290. * @returns Array of picking infos
  11291. */
  11292. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11293. private _comparePickingInfo;
  11294. private static smallnum;
  11295. private static rayl;
  11296. /**
  11297. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11298. * @param sega the first point of the segment to test the intersection against
  11299. * @param segb the second point of the segment to test the intersection against
  11300. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11301. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11302. */
  11303. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11304. /**
  11305. * Update the ray from viewport position
  11306. * @param x position
  11307. * @param y y position
  11308. * @param viewportWidth viewport width
  11309. * @param viewportHeight viewport height
  11310. * @param world world matrix
  11311. * @param view view matrix
  11312. * @param projection projection matrix
  11313. * @returns this ray updated
  11314. */
  11315. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11316. /**
  11317. * Creates a ray with origin and direction of 0,0,0
  11318. * @returns the new ray
  11319. */
  11320. static Zero(): Ray;
  11321. /**
  11322. * Creates a new ray from screen space and viewport
  11323. * @param x position
  11324. * @param y y position
  11325. * @param viewportWidth viewport width
  11326. * @param viewportHeight viewport height
  11327. * @param world world matrix
  11328. * @param view view matrix
  11329. * @param projection projection matrix
  11330. * @returns new ray
  11331. */
  11332. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11333. /**
  11334. * 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
  11335. * transformed to the given world matrix.
  11336. * @param origin The origin point
  11337. * @param end The end point
  11338. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11339. * @returns the new ray
  11340. */
  11341. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11342. /**
  11343. * Transforms a ray by a matrix
  11344. * @param ray ray to transform
  11345. * @param matrix matrix to apply
  11346. * @returns the resulting new ray
  11347. */
  11348. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11349. /**
  11350. * Transforms a ray by a matrix
  11351. * @param ray ray to transform
  11352. * @param matrix matrix to apply
  11353. * @param result ray to store result in
  11354. */
  11355. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11356. /**
  11357. * Unproject a ray from screen space to object space
  11358. * @param sourceX defines the screen space x coordinate to use
  11359. * @param sourceY defines the screen space y coordinate to use
  11360. * @param viewportWidth defines the current width of the viewport
  11361. * @param viewportHeight defines the current height of the viewport
  11362. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11363. * @param view defines the view matrix to use
  11364. * @param projection defines the projection matrix to use
  11365. */
  11366. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11367. }
  11368. /**
  11369. * Type used to define predicate used to select faces when a mesh intersection is detected
  11370. */
  11371. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11372. interface Scene {
  11373. /** @hidden */
  11374. _tempPickingRay: Nullable<Ray>;
  11375. /** @hidden */
  11376. _cachedRayForTransform: Ray;
  11377. /** @hidden */
  11378. _pickWithRayInverseMatrix: Matrix;
  11379. /** @hidden */
  11380. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11381. /** @hidden */
  11382. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11383. }
  11384. }
  11385. declare module BABYLON {
  11386. /**
  11387. * Groups all the scene component constants in one place to ease maintenance.
  11388. * @hidden
  11389. */
  11390. export class SceneComponentConstants {
  11391. static readonly NAME_EFFECTLAYER: string;
  11392. static readonly NAME_LAYER: string;
  11393. static readonly NAME_LENSFLARESYSTEM: string;
  11394. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11395. static readonly NAME_PARTICLESYSTEM: string;
  11396. static readonly NAME_GAMEPAD: string;
  11397. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11398. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11399. static readonly NAME_DEPTHRENDERER: string;
  11400. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11401. static readonly NAME_SPRITE: string;
  11402. static readonly NAME_OUTLINERENDERER: string;
  11403. static readonly NAME_PROCEDURALTEXTURE: string;
  11404. static readonly NAME_SHADOWGENERATOR: string;
  11405. static readonly NAME_OCTREE: string;
  11406. static readonly NAME_PHYSICSENGINE: string;
  11407. static readonly NAME_AUDIO: string;
  11408. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11409. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11410. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11411. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11412. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11413. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11414. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11415. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11416. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11417. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11418. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11419. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11420. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11421. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11422. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11423. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11424. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11425. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11426. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11427. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11428. static readonly STEP_AFTERRENDER_AUDIO: number;
  11429. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11430. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11431. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11432. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11433. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11434. static readonly STEP_POINTERMOVE_SPRITE: number;
  11435. static readonly STEP_POINTERDOWN_SPRITE: number;
  11436. static readonly STEP_POINTERUP_SPRITE: number;
  11437. }
  11438. /**
  11439. * This represents a scene component.
  11440. *
  11441. * This is used to decouple the dependency the scene is having on the different workloads like
  11442. * layers, post processes...
  11443. */
  11444. export interface ISceneComponent {
  11445. /**
  11446. * The name of the component. Each component must have a unique name.
  11447. */
  11448. name: string;
  11449. /**
  11450. * The scene the component belongs to.
  11451. */
  11452. scene: Scene;
  11453. /**
  11454. * Register the component to one instance of a scene.
  11455. */
  11456. register(): void;
  11457. /**
  11458. * Rebuilds the elements related to this component in case of
  11459. * context lost for instance.
  11460. */
  11461. rebuild(): void;
  11462. /**
  11463. * Disposes the component and the associated ressources.
  11464. */
  11465. dispose(): void;
  11466. }
  11467. /**
  11468. * This represents a SERIALIZABLE scene component.
  11469. *
  11470. * This extends Scene Component to add Serialization methods on top.
  11471. */
  11472. export interface ISceneSerializableComponent extends ISceneComponent {
  11473. /**
  11474. * Adds all the elements from the container to the scene
  11475. * @param container the container holding the elements
  11476. */
  11477. addFromContainer(container: AbstractScene): void;
  11478. /**
  11479. * Removes all the elements in the container from the scene
  11480. * @param container contains the elements to remove
  11481. * @param dispose if the removed element should be disposed (default: false)
  11482. */
  11483. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11484. /**
  11485. * Serializes the component data to the specified json object
  11486. * @param serializationObject The object to serialize to
  11487. */
  11488. serialize(serializationObject: any): void;
  11489. }
  11490. /**
  11491. * Strong typing of a Mesh related stage step action
  11492. */
  11493. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11494. /**
  11495. * Strong typing of a Evaluate Sub Mesh related stage step action
  11496. */
  11497. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11498. /**
  11499. * Strong typing of a Active Mesh related stage step action
  11500. */
  11501. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11502. /**
  11503. * Strong typing of a Camera related stage step action
  11504. */
  11505. export type CameraStageAction = (camera: Camera) => void;
  11506. /**
  11507. * Strong typing of a Camera Frame buffer related stage step action
  11508. */
  11509. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11510. /**
  11511. * Strong typing of a Render Target related stage step action
  11512. */
  11513. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11514. /**
  11515. * Strong typing of a RenderingGroup related stage step action
  11516. */
  11517. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11518. /**
  11519. * Strong typing of a Mesh Render related stage step action
  11520. */
  11521. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11522. /**
  11523. * Strong typing of a simple stage step action
  11524. */
  11525. export type SimpleStageAction = () => void;
  11526. /**
  11527. * Strong typing of a render target action.
  11528. */
  11529. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11530. /**
  11531. * Strong typing of a pointer move action.
  11532. */
  11533. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11534. /**
  11535. * Strong typing of a pointer up/down action.
  11536. */
  11537. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11538. /**
  11539. * Representation of a stage in the scene (Basically a list of ordered steps)
  11540. * @hidden
  11541. */
  11542. export class Stage<T extends Function> extends Array<{
  11543. index: number;
  11544. component: ISceneComponent;
  11545. action: T;
  11546. }> {
  11547. /**
  11548. * Hide ctor from the rest of the world.
  11549. * @param items The items to add.
  11550. */
  11551. private constructor();
  11552. /**
  11553. * Creates a new Stage.
  11554. * @returns A new instance of a Stage
  11555. */
  11556. static Create<T extends Function>(): Stage<T>;
  11557. /**
  11558. * Registers a step in an ordered way in the targeted stage.
  11559. * @param index Defines the position to register the step in
  11560. * @param component Defines the component attached to the step
  11561. * @param action Defines the action to launch during the step
  11562. */
  11563. registerStep(index: number, component: ISceneComponent, action: T): void;
  11564. /**
  11565. * Clears all the steps from the stage.
  11566. */
  11567. clear(): void;
  11568. }
  11569. }
  11570. declare module BABYLON {
  11571. interface Scene {
  11572. /** @hidden */
  11573. _pointerOverSprite: Nullable<Sprite>;
  11574. /** @hidden */
  11575. _pickedDownSprite: Nullable<Sprite>;
  11576. /** @hidden */
  11577. _tempSpritePickingRay: Nullable<Ray>;
  11578. /**
  11579. * All of the sprite managers added to this scene
  11580. * @see http://doc.babylonjs.com/babylon101/sprites
  11581. */
  11582. spriteManagers: Array<ISpriteManager>;
  11583. /**
  11584. * An event triggered when sprites rendering is about to start
  11585. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11586. */
  11587. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11588. /**
  11589. * An event triggered when sprites rendering is done
  11590. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11591. */
  11592. onAfterSpritesRenderingObservable: Observable<Scene>;
  11593. /** @hidden */
  11594. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11595. /** Launch a ray to try to pick a sprite in the scene
  11596. * @param x position on screen
  11597. * @param y position on screen
  11598. * @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
  11599. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11600. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11601. * @returns a PickingInfo
  11602. */
  11603. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11604. /** Use the given ray to pick a sprite in the scene
  11605. * @param ray The ray (in world space) to use to pick meshes
  11606. * @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
  11607. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11608. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11609. * @returns a PickingInfo
  11610. */
  11611. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11612. /** @hidden */
  11613. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11614. /** Launch a ray to try to pick sprites in the scene
  11615. * @param x position on screen
  11616. * @param y position on screen
  11617. * @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
  11618. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11619. * @returns a PickingInfo array
  11620. */
  11621. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11622. /** Use the given ray to pick sprites in the scene
  11623. * @param ray The ray (in world space) to use to pick meshes
  11624. * @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
  11625. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11626. * @returns a PickingInfo array
  11627. */
  11628. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11629. /**
  11630. * Force the sprite under the pointer
  11631. * @param sprite defines the sprite to use
  11632. */
  11633. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11634. /**
  11635. * Gets the sprite under the pointer
  11636. * @returns a Sprite or null if no sprite is under the pointer
  11637. */
  11638. getPointerOverSprite(): Nullable<Sprite>;
  11639. }
  11640. /**
  11641. * Defines the sprite scene component responsible to manage sprites
  11642. * in a given scene.
  11643. */
  11644. export class SpriteSceneComponent implements ISceneComponent {
  11645. /**
  11646. * The component name helpfull to identify the component in the list of scene components.
  11647. */
  11648. readonly name: string;
  11649. /**
  11650. * The scene the component belongs to.
  11651. */
  11652. scene: Scene;
  11653. /** @hidden */
  11654. private _spritePredicate;
  11655. /**
  11656. * Creates a new instance of the component for the given scene
  11657. * @param scene Defines the scene to register the component in
  11658. */
  11659. constructor(scene: Scene);
  11660. /**
  11661. * Registers the component in a given scene
  11662. */
  11663. register(): void;
  11664. /**
  11665. * Rebuilds the elements related to this component in case of
  11666. * context lost for instance.
  11667. */
  11668. rebuild(): void;
  11669. /**
  11670. * Disposes the component and the associated ressources.
  11671. */
  11672. dispose(): void;
  11673. private _pickSpriteButKeepRay;
  11674. private _pointerMove;
  11675. private _pointerDown;
  11676. private _pointerUp;
  11677. }
  11678. }
  11679. declare module BABYLON {
  11680. /** @hidden */
  11681. export var fogFragmentDeclaration: {
  11682. name: string;
  11683. shader: string;
  11684. };
  11685. }
  11686. declare module BABYLON {
  11687. /** @hidden */
  11688. export var fogFragment: {
  11689. name: string;
  11690. shader: string;
  11691. };
  11692. }
  11693. declare module BABYLON {
  11694. /** @hidden */
  11695. export var spritesPixelShader: {
  11696. name: string;
  11697. shader: string;
  11698. };
  11699. }
  11700. declare module BABYLON {
  11701. /** @hidden */
  11702. export var fogVertexDeclaration: {
  11703. name: string;
  11704. shader: string;
  11705. };
  11706. }
  11707. declare module BABYLON {
  11708. /** @hidden */
  11709. export var spritesVertexShader: {
  11710. name: string;
  11711. shader: string;
  11712. };
  11713. }
  11714. declare module BABYLON {
  11715. /**
  11716. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11717. */
  11718. export interface ISpriteManager extends IDisposable {
  11719. /**
  11720. * Restricts the camera to viewing objects with the same layerMask.
  11721. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11722. */
  11723. layerMask: number;
  11724. /**
  11725. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11726. */
  11727. isPickable: boolean;
  11728. /**
  11729. * Specifies the rendering group id for this mesh (0 by default)
  11730. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11731. */
  11732. renderingGroupId: number;
  11733. /**
  11734. * Defines the list of sprites managed by the manager.
  11735. */
  11736. sprites: Array<Sprite>;
  11737. /**
  11738. * Tests the intersection of a sprite with a specific ray.
  11739. * @param ray The ray we are sending to test the collision
  11740. * @param camera The camera space we are sending rays in
  11741. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11742. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11743. * @returns picking info or null.
  11744. */
  11745. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11746. /**
  11747. * Intersects the sprites with a ray
  11748. * @param ray defines the ray to intersect with
  11749. * @param camera defines the current active camera
  11750. * @param predicate defines a predicate used to select candidate sprites
  11751. * @returns null if no hit or a PickingInfo array
  11752. */
  11753. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11754. /**
  11755. * Renders the list of sprites on screen.
  11756. */
  11757. render(): void;
  11758. }
  11759. /**
  11760. * Class used to manage multiple sprites on the same spritesheet
  11761. * @see http://doc.babylonjs.com/babylon101/sprites
  11762. */
  11763. export class SpriteManager implements ISpriteManager {
  11764. /** defines the manager's name */
  11765. name: string;
  11766. /** Gets the list of sprites */
  11767. sprites: Sprite[];
  11768. /** Gets or sets the rendering group id (0 by default) */
  11769. renderingGroupId: number;
  11770. /** Gets or sets camera layer mask */
  11771. layerMask: number;
  11772. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11773. fogEnabled: boolean;
  11774. /** Gets or sets a boolean indicating if the sprites are pickable */
  11775. isPickable: boolean;
  11776. /** Defines the default width of a cell in the spritesheet */
  11777. cellWidth: number;
  11778. /** Defines the default height of a cell in the spritesheet */
  11779. cellHeight: number;
  11780. /** Associative array from JSON sprite data file */
  11781. private _cellData;
  11782. /** Array of sprite names from JSON sprite data file */
  11783. private _spriteMap;
  11784. /** True when packed cell data from JSON file is ready*/
  11785. private _packedAndReady;
  11786. /**
  11787. * An event triggered when the manager is disposed.
  11788. */
  11789. onDisposeObservable: Observable<SpriteManager>;
  11790. private _onDisposeObserver;
  11791. /**
  11792. * Callback called when the manager is disposed
  11793. */
  11794. set onDispose(callback: () => void);
  11795. private _capacity;
  11796. private _fromPacked;
  11797. private _spriteTexture;
  11798. private _epsilon;
  11799. private _scene;
  11800. private _vertexData;
  11801. private _buffer;
  11802. private _vertexBuffers;
  11803. private _indexBuffer;
  11804. private _effectBase;
  11805. private _effectFog;
  11806. /**
  11807. * Gets or sets the spritesheet texture
  11808. */
  11809. get texture(): Texture;
  11810. set texture(value: Texture);
  11811. /**
  11812. * Creates a new sprite manager
  11813. * @param name defines the manager's name
  11814. * @param imgUrl defines the sprite sheet url
  11815. * @param capacity defines the maximum allowed number of sprites
  11816. * @param cellSize defines the size of a sprite cell
  11817. * @param scene defines the hosting scene
  11818. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11819. * @param samplingMode defines the smapling mode to use with spritesheet
  11820. * @param fromPacked set to false; do not alter
  11821. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11822. */
  11823. constructor(
  11824. /** defines the manager's name */
  11825. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11826. private _makePacked;
  11827. private _appendSpriteVertex;
  11828. /**
  11829. * Intersects the sprites with a ray
  11830. * @param ray defines the ray to intersect with
  11831. * @param camera defines the current active camera
  11832. * @param predicate defines a predicate used to select candidate sprites
  11833. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11834. * @returns null if no hit or a PickingInfo
  11835. */
  11836. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11837. /**
  11838. * Intersects the sprites with a ray
  11839. * @param ray defines the ray to intersect with
  11840. * @param camera defines the current active camera
  11841. * @param predicate defines a predicate used to select candidate sprites
  11842. * @returns null if no hit or a PickingInfo array
  11843. */
  11844. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11845. /**
  11846. * Render all child sprites
  11847. */
  11848. render(): void;
  11849. /**
  11850. * Release associated resources
  11851. */
  11852. dispose(): void;
  11853. }
  11854. }
  11855. declare module BABYLON {
  11856. /**
  11857. * Class used to represent a sprite
  11858. * @see http://doc.babylonjs.com/babylon101/sprites
  11859. */
  11860. export class Sprite {
  11861. /** defines the name */
  11862. name: string;
  11863. /** Gets or sets the current world position */
  11864. position: Vector3;
  11865. /** Gets or sets the main color */
  11866. color: Color4;
  11867. /** Gets or sets the width */
  11868. width: number;
  11869. /** Gets or sets the height */
  11870. height: number;
  11871. /** Gets or sets rotation angle */
  11872. angle: number;
  11873. /** Gets or sets the cell index in the sprite sheet */
  11874. cellIndex: number;
  11875. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11876. cellRef: string;
  11877. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11878. invertU: number;
  11879. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11880. invertV: number;
  11881. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11882. disposeWhenFinishedAnimating: boolean;
  11883. /** Gets the list of attached animations */
  11884. animations: Animation[];
  11885. /** Gets or sets a boolean indicating if the sprite can be picked */
  11886. isPickable: boolean;
  11887. /**
  11888. * Gets or sets the associated action manager
  11889. */
  11890. actionManager: Nullable<ActionManager>;
  11891. private _animationStarted;
  11892. private _loopAnimation;
  11893. private _fromIndex;
  11894. private _toIndex;
  11895. private _delay;
  11896. private _direction;
  11897. private _manager;
  11898. private _time;
  11899. private _onAnimationEnd;
  11900. /**
  11901. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11902. */
  11903. isVisible: boolean;
  11904. /**
  11905. * Gets or sets the sprite size
  11906. */
  11907. get size(): number;
  11908. set size(value: number);
  11909. /**
  11910. * Creates a new Sprite
  11911. * @param name defines the name
  11912. * @param manager defines the manager
  11913. */
  11914. constructor(
  11915. /** defines the name */
  11916. name: string, manager: ISpriteManager);
  11917. /**
  11918. * Starts an animation
  11919. * @param from defines the initial key
  11920. * @param to defines the end key
  11921. * @param loop defines if the animation must loop
  11922. * @param delay defines the start delay (in ms)
  11923. * @param onAnimationEnd defines a callback to call when animation ends
  11924. */
  11925. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11926. /** Stops current animation (if any) */
  11927. stopAnimation(): void;
  11928. /** @hidden */
  11929. _animate(deltaTime: number): void;
  11930. /** Release associated resources */
  11931. dispose(): void;
  11932. }
  11933. }
  11934. declare module BABYLON {
  11935. /**
  11936. * Information about the result of picking within a scene
  11937. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11938. */
  11939. export class PickingInfo {
  11940. /** @hidden */
  11941. _pickingUnavailable: boolean;
  11942. /**
  11943. * If the pick collided with an object
  11944. */
  11945. hit: boolean;
  11946. /**
  11947. * Distance away where the pick collided
  11948. */
  11949. distance: number;
  11950. /**
  11951. * The location of pick collision
  11952. */
  11953. pickedPoint: Nullable<Vector3>;
  11954. /**
  11955. * The mesh corresponding the the pick collision
  11956. */
  11957. pickedMesh: Nullable<AbstractMesh>;
  11958. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11959. bu: number;
  11960. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11961. bv: number;
  11962. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11963. faceId: number;
  11964. /** Id of the the submesh that was picked */
  11965. subMeshId: number;
  11966. /** If a sprite was picked, this will be the sprite the pick collided with */
  11967. pickedSprite: Nullable<Sprite>;
  11968. /**
  11969. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11970. */
  11971. originMesh: Nullable<AbstractMesh>;
  11972. /**
  11973. * The ray that was used to perform the picking.
  11974. */
  11975. ray: Nullable<Ray>;
  11976. /**
  11977. * Gets the normal correspodning to the face the pick collided with
  11978. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11979. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11980. * @returns The normal correspodning to the face the pick collided with
  11981. */
  11982. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11983. /**
  11984. * Gets the texture coordinates of where the pick occured
  11985. * @returns the vector containing the coordnates of the texture
  11986. */
  11987. getTextureCoordinates(): Nullable<Vector2>;
  11988. }
  11989. }
  11990. declare module BABYLON {
  11991. /**
  11992. * Gather the list of pointer event types as constants.
  11993. */
  11994. export class PointerEventTypes {
  11995. /**
  11996. * 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.
  11997. */
  11998. static readonly POINTERDOWN: number;
  11999. /**
  12000. * The pointerup event is fired when a pointer is no longer active.
  12001. */
  12002. static readonly POINTERUP: number;
  12003. /**
  12004. * The pointermove event is fired when a pointer changes coordinates.
  12005. */
  12006. static readonly POINTERMOVE: number;
  12007. /**
  12008. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12009. */
  12010. static readonly POINTERWHEEL: number;
  12011. /**
  12012. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12013. */
  12014. static readonly POINTERPICK: number;
  12015. /**
  12016. * The pointertap event is fired when a the object has been touched and released without drag.
  12017. */
  12018. static readonly POINTERTAP: number;
  12019. /**
  12020. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12021. */
  12022. static readonly POINTERDOUBLETAP: number;
  12023. }
  12024. /**
  12025. * Base class of pointer info types.
  12026. */
  12027. export class PointerInfoBase {
  12028. /**
  12029. * Defines the type of event (PointerEventTypes)
  12030. */
  12031. type: number;
  12032. /**
  12033. * Defines the related dom event
  12034. */
  12035. event: PointerEvent | MouseWheelEvent;
  12036. /**
  12037. * Instantiates the base class of pointers info.
  12038. * @param type Defines the type of event (PointerEventTypes)
  12039. * @param event Defines the related dom event
  12040. */
  12041. constructor(
  12042. /**
  12043. * Defines the type of event (PointerEventTypes)
  12044. */
  12045. type: number,
  12046. /**
  12047. * Defines the related dom event
  12048. */
  12049. event: PointerEvent | MouseWheelEvent);
  12050. }
  12051. /**
  12052. * This class is used to store pointer related info for the onPrePointerObservable event.
  12053. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12054. */
  12055. export class PointerInfoPre extends PointerInfoBase {
  12056. /**
  12057. * Ray from a pointer if availible (eg. 6dof controller)
  12058. */
  12059. ray: Nullable<Ray>;
  12060. /**
  12061. * Defines the local position of the pointer on the canvas.
  12062. */
  12063. localPosition: Vector2;
  12064. /**
  12065. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12066. */
  12067. skipOnPointerObservable: boolean;
  12068. /**
  12069. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12070. * @param type Defines the type of event (PointerEventTypes)
  12071. * @param event Defines the related dom event
  12072. * @param localX Defines the local x coordinates of the pointer when the event occured
  12073. * @param localY Defines the local y coordinates of the pointer when the event occured
  12074. */
  12075. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12076. }
  12077. /**
  12078. * This type contains all the data related to a pointer event in Babylon.js.
  12079. * 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.
  12080. */
  12081. export class PointerInfo extends PointerInfoBase {
  12082. /**
  12083. * Defines the picking info associated to the info (if any)\
  12084. */
  12085. pickInfo: Nullable<PickingInfo>;
  12086. /**
  12087. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12088. * @param type Defines the type of event (PointerEventTypes)
  12089. * @param event Defines the related dom event
  12090. * @param pickInfo Defines the picking info associated to the info (if any)\
  12091. */
  12092. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12093. /**
  12094. * Defines the picking info associated to the info (if any)\
  12095. */
  12096. pickInfo: Nullable<PickingInfo>);
  12097. }
  12098. /**
  12099. * Data relating to a touch event on the screen.
  12100. */
  12101. export interface PointerTouch {
  12102. /**
  12103. * X coordinate of touch.
  12104. */
  12105. x: number;
  12106. /**
  12107. * Y coordinate of touch.
  12108. */
  12109. y: number;
  12110. /**
  12111. * Id of touch. Unique for each finger.
  12112. */
  12113. pointerId: number;
  12114. /**
  12115. * Event type passed from DOM.
  12116. */
  12117. type: any;
  12118. }
  12119. }
  12120. declare module BABYLON {
  12121. /**
  12122. * Manage the mouse inputs to control the movement of a free camera.
  12123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12124. */
  12125. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12126. /**
  12127. * Define if touch is enabled in the mouse input
  12128. */
  12129. touchEnabled: boolean;
  12130. /**
  12131. * Defines the camera the input is attached to.
  12132. */
  12133. camera: FreeCamera;
  12134. /**
  12135. * Defines the buttons associated with the input to handle camera move.
  12136. */
  12137. buttons: number[];
  12138. /**
  12139. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12140. */
  12141. angularSensibility: number;
  12142. private _pointerInput;
  12143. private _onMouseMove;
  12144. private _observer;
  12145. private previousPosition;
  12146. /**
  12147. * Observable for when a pointer move event occurs containing the move offset
  12148. */
  12149. onPointerMovedObservable: Observable<{
  12150. offsetX: number;
  12151. offsetY: number;
  12152. }>;
  12153. /**
  12154. * @hidden
  12155. * If the camera should be rotated automatically based on pointer movement
  12156. */
  12157. _allowCameraRotation: boolean;
  12158. /**
  12159. * Manage the mouse inputs to control the movement of a free camera.
  12160. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12161. * @param touchEnabled Defines if touch is enabled or not
  12162. */
  12163. constructor(
  12164. /**
  12165. * Define if touch is enabled in the mouse input
  12166. */
  12167. touchEnabled?: boolean);
  12168. /**
  12169. * Attach the input controls to a specific dom element to get the input from.
  12170. * @param element Defines the element the controls should be listened from
  12171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12172. */
  12173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12174. /**
  12175. * Called on JS contextmenu event.
  12176. * Override this method to provide functionality.
  12177. */
  12178. protected onContextMenu(evt: PointerEvent): void;
  12179. /**
  12180. * Detach the current controls from the specified dom element.
  12181. * @param element Defines the element to stop listening the inputs from
  12182. */
  12183. detachControl(element: Nullable<HTMLElement>): void;
  12184. /**
  12185. * Gets the class name of the current intput.
  12186. * @returns the class name
  12187. */
  12188. getClassName(): string;
  12189. /**
  12190. * Get the friendly name associated with the input class.
  12191. * @returns the input friendly name
  12192. */
  12193. getSimpleName(): string;
  12194. }
  12195. }
  12196. declare module BABYLON {
  12197. /**
  12198. * Manage the touch inputs to control the movement of a free camera.
  12199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12200. */
  12201. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12202. /**
  12203. * Defines the camera the input is attached to.
  12204. */
  12205. camera: FreeCamera;
  12206. /**
  12207. * Defines the touch sensibility for rotation.
  12208. * The higher the faster.
  12209. */
  12210. touchAngularSensibility: number;
  12211. /**
  12212. * Defines the touch sensibility for move.
  12213. * The higher the faster.
  12214. */
  12215. touchMoveSensibility: number;
  12216. private _offsetX;
  12217. private _offsetY;
  12218. private _pointerPressed;
  12219. private _pointerInput;
  12220. private _observer;
  12221. private _onLostFocus;
  12222. /**
  12223. * Attach the input controls to a specific dom element to get the input from.
  12224. * @param element Defines the element the controls should be listened from
  12225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12226. */
  12227. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12228. /**
  12229. * Detach the current controls from the specified dom element.
  12230. * @param element Defines the element to stop listening the inputs from
  12231. */
  12232. detachControl(element: Nullable<HTMLElement>): void;
  12233. /**
  12234. * Update the current camera state depending on the inputs that have been used this frame.
  12235. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12236. */
  12237. checkInputs(): void;
  12238. /**
  12239. * Gets the class name of the current intput.
  12240. * @returns the class name
  12241. */
  12242. getClassName(): string;
  12243. /**
  12244. * Get the friendly name associated with the input class.
  12245. * @returns the input friendly name
  12246. */
  12247. getSimpleName(): string;
  12248. }
  12249. }
  12250. declare module BABYLON {
  12251. /**
  12252. * Default Inputs manager for the FreeCamera.
  12253. * It groups all the default supported inputs for ease of use.
  12254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12255. */
  12256. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12257. /**
  12258. * @hidden
  12259. */
  12260. _mouseInput: Nullable<FreeCameraMouseInput>;
  12261. /**
  12262. * Instantiates a new FreeCameraInputsManager.
  12263. * @param camera Defines the camera the inputs belong to
  12264. */
  12265. constructor(camera: FreeCamera);
  12266. /**
  12267. * Add keyboard input support to the input manager.
  12268. * @returns the current input manager
  12269. */
  12270. addKeyboard(): FreeCameraInputsManager;
  12271. /**
  12272. * Add mouse input support to the input manager.
  12273. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12274. * @returns the current input manager
  12275. */
  12276. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12277. /**
  12278. * Removes the mouse input support from the manager
  12279. * @returns the current input manager
  12280. */
  12281. removeMouse(): FreeCameraInputsManager;
  12282. /**
  12283. * Add touch input support to the input manager.
  12284. * @returns the current input manager
  12285. */
  12286. addTouch(): FreeCameraInputsManager;
  12287. /**
  12288. * Remove all attached input methods from a camera
  12289. */
  12290. clear(): void;
  12291. }
  12292. }
  12293. declare module BABYLON {
  12294. /**
  12295. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12296. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12297. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12298. */
  12299. export class FreeCamera extends TargetCamera {
  12300. /**
  12301. * Define the collision ellipsoid of the camera.
  12302. * This is helpful to simulate a camera body like the player body around the camera
  12303. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12304. */
  12305. ellipsoid: Vector3;
  12306. /**
  12307. * Define an offset for the position of the ellipsoid around the camera.
  12308. * This can be helpful to determine the center of the body near the gravity center of the body
  12309. * instead of its head.
  12310. */
  12311. ellipsoidOffset: Vector3;
  12312. /**
  12313. * Enable or disable collisions of the camera with the rest of the scene objects.
  12314. */
  12315. checkCollisions: boolean;
  12316. /**
  12317. * Enable or disable gravity on the camera.
  12318. */
  12319. applyGravity: boolean;
  12320. /**
  12321. * Define the input manager associated to the camera.
  12322. */
  12323. inputs: FreeCameraInputsManager;
  12324. /**
  12325. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12326. * Higher values reduce sensitivity.
  12327. */
  12328. get angularSensibility(): number;
  12329. /**
  12330. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12331. * Higher values reduce sensitivity.
  12332. */
  12333. set angularSensibility(value: number);
  12334. /**
  12335. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12336. */
  12337. get keysUp(): number[];
  12338. set keysUp(value: number[]);
  12339. /**
  12340. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12341. */
  12342. get keysDown(): number[];
  12343. set keysDown(value: number[]);
  12344. /**
  12345. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12346. */
  12347. get keysLeft(): number[];
  12348. set keysLeft(value: number[]);
  12349. /**
  12350. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12351. */
  12352. get keysRight(): number[];
  12353. set keysRight(value: number[]);
  12354. /**
  12355. * Event raised when the camera collide with a mesh in the scene.
  12356. */
  12357. onCollide: (collidedMesh: AbstractMesh) => void;
  12358. private _collider;
  12359. private _needMoveForGravity;
  12360. private _oldPosition;
  12361. private _diffPosition;
  12362. private _newPosition;
  12363. /** @hidden */
  12364. _localDirection: Vector3;
  12365. /** @hidden */
  12366. _transformedDirection: Vector3;
  12367. /**
  12368. * Instantiates a Free Camera.
  12369. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12370. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12371. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12372. * @param name Define the name of the camera in the scene
  12373. * @param position Define the start position of the camera in the scene
  12374. * @param scene Define the scene the camera belongs to
  12375. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12376. */
  12377. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12378. /**
  12379. * Attached controls to the current camera.
  12380. * @param element Defines the element the controls should be listened from
  12381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12382. */
  12383. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12384. /**
  12385. * Detach the current controls from the camera.
  12386. * The camera will stop reacting to inputs.
  12387. * @param element Defines the element to stop listening the inputs from
  12388. */
  12389. detachControl(element: HTMLElement): void;
  12390. private _collisionMask;
  12391. /**
  12392. * Define a collision mask to limit the list of object the camera can collide with
  12393. */
  12394. get collisionMask(): number;
  12395. set collisionMask(mask: number);
  12396. /** @hidden */
  12397. _collideWithWorld(displacement: Vector3): void;
  12398. private _onCollisionPositionChange;
  12399. /** @hidden */
  12400. _checkInputs(): void;
  12401. /** @hidden */
  12402. _decideIfNeedsToMove(): boolean;
  12403. /** @hidden */
  12404. _updatePosition(): void;
  12405. /**
  12406. * Destroy the camera and release the current resources hold by it.
  12407. */
  12408. dispose(): void;
  12409. /**
  12410. * Gets the current object class name.
  12411. * @return the class name
  12412. */
  12413. getClassName(): string;
  12414. }
  12415. }
  12416. declare module BABYLON {
  12417. /**
  12418. * Represents a gamepad control stick position
  12419. */
  12420. export class StickValues {
  12421. /**
  12422. * The x component of the control stick
  12423. */
  12424. x: number;
  12425. /**
  12426. * The y component of the control stick
  12427. */
  12428. y: number;
  12429. /**
  12430. * Initializes the gamepad x and y control stick values
  12431. * @param x The x component of the gamepad control stick value
  12432. * @param y The y component of the gamepad control stick value
  12433. */
  12434. constructor(
  12435. /**
  12436. * The x component of the control stick
  12437. */
  12438. x: number,
  12439. /**
  12440. * The y component of the control stick
  12441. */
  12442. y: number);
  12443. }
  12444. /**
  12445. * An interface which manages callbacks for gamepad button changes
  12446. */
  12447. export interface GamepadButtonChanges {
  12448. /**
  12449. * Called when a gamepad has been changed
  12450. */
  12451. changed: boolean;
  12452. /**
  12453. * Called when a gamepad press event has been triggered
  12454. */
  12455. pressChanged: boolean;
  12456. /**
  12457. * Called when a touch event has been triggered
  12458. */
  12459. touchChanged: boolean;
  12460. /**
  12461. * Called when a value has changed
  12462. */
  12463. valueChanged: boolean;
  12464. }
  12465. /**
  12466. * Represents a gamepad
  12467. */
  12468. export class Gamepad {
  12469. /**
  12470. * The id of the gamepad
  12471. */
  12472. id: string;
  12473. /**
  12474. * The index of the gamepad
  12475. */
  12476. index: number;
  12477. /**
  12478. * The browser gamepad
  12479. */
  12480. browserGamepad: any;
  12481. /**
  12482. * Specifies what type of gamepad this represents
  12483. */
  12484. type: number;
  12485. private _leftStick;
  12486. private _rightStick;
  12487. /** @hidden */
  12488. _isConnected: boolean;
  12489. private _leftStickAxisX;
  12490. private _leftStickAxisY;
  12491. private _rightStickAxisX;
  12492. private _rightStickAxisY;
  12493. /**
  12494. * Triggered when the left control stick has been changed
  12495. */
  12496. private _onleftstickchanged;
  12497. /**
  12498. * Triggered when the right control stick has been changed
  12499. */
  12500. private _onrightstickchanged;
  12501. /**
  12502. * Represents a gamepad controller
  12503. */
  12504. static GAMEPAD: number;
  12505. /**
  12506. * Represents a generic controller
  12507. */
  12508. static GENERIC: number;
  12509. /**
  12510. * Represents an XBox controller
  12511. */
  12512. static XBOX: number;
  12513. /**
  12514. * Represents a pose-enabled controller
  12515. */
  12516. static POSE_ENABLED: number;
  12517. /**
  12518. * Represents an Dual Shock controller
  12519. */
  12520. static DUALSHOCK: number;
  12521. /**
  12522. * Specifies whether the left control stick should be Y-inverted
  12523. */
  12524. protected _invertLeftStickY: boolean;
  12525. /**
  12526. * Specifies if the gamepad has been connected
  12527. */
  12528. get isConnected(): boolean;
  12529. /**
  12530. * Initializes the gamepad
  12531. * @param id The id of the gamepad
  12532. * @param index The index of the gamepad
  12533. * @param browserGamepad The browser gamepad
  12534. * @param leftStickX The x component of the left joystick
  12535. * @param leftStickY The y component of the left joystick
  12536. * @param rightStickX The x component of the right joystick
  12537. * @param rightStickY The y component of the right joystick
  12538. */
  12539. constructor(
  12540. /**
  12541. * The id of the gamepad
  12542. */
  12543. id: string,
  12544. /**
  12545. * The index of the gamepad
  12546. */
  12547. index: number,
  12548. /**
  12549. * The browser gamepad
  12550. */
  12551. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12552. /**
  12553. * Callback triggered when the left joystick has changed
  12554. * @param callback
  12555. */
  12556. onleftstickchanged(callback: (values: StickValues) => void): void;
  12557. /**
  12558. * Callback triggered when the right joystick has changed
  12559. * @param callback
  12560. */
  12561. onrightstickchanged(callback: (values: StickValues) => void): void;
  12562. /**
  12563. * Gets the left joystick
  12564. */
  12565. get leftStick(): StickValues;
  12566. /**
  12567. * Sets the left joystick values
  12568. */
  12569. set leftStick(newValues: StickValues);
  12570. /**
  12571. * Gets the right joystick
  12572. */
  12573. get rightStick(): StickValues;
  12574. /**
  12575. * Sets the right joystick value
  12576. */
  12577. set rightStick(newValues: StickValues);
  12578. /**
  12579. * Updates the gamepad joystick positions
  12580. */
  12581. update(): void;
  12582. /**
  12583. * Disposes the gamepad
  12584. */
  12585. dispose(): void;
  12586. }
  12587. /**
  12588. * Represents a generic gamepad
  12589. */
  12590. export class GenericPad extends Gamepad {
  12591. private _buttons;
  12592. private _onbuttondown;
  12593. private _onbuttonup;
  12594. /**
  12595. * Observable triggered when a button has been pressed
  12596. */
  12597. onButtonDownObservable: Observable<number>;
  12598. /**
  12599. * Observable triggered when a button has been released
  12600. */
  12601. onButtonUpObservable: Observable<number>;
  12602. /**
  12603. * Callback triggered when a button has been pressed
  12604. * @param callback Called when a button has been pressed
  12605. */
  12606. onbuttondown(callback: (buttonPressed: number) => void): void;
  12607. /**
  12608. * Callback triggered when a button has been released
  12609. * @param callback Called when a button has been released
  12610. */
  12611. onbuttonup(callback: (buttonReleased: number) => void): void;
  12612. /**
  12613. * Initializes the generic gamepad
  12614. * @param id The id of the generic gamepad
  12615. * @param index The index of the generic gamepad
  12616. * @param browserGamepad The browser gamepad
  12617. */
  12618. constructor(id: string, index: number, browserGamepad: any);
  12619. private _setButtonValue;
  12620. /**
  12621. * Updates the generic gamepad
  12622. */
  12623. update(): void;
  12624. /**
  12625. * Disposes the generic gamepad
  12626. */
  12627. dispose(): void;
  12628. }
  12629. }
  12630. declare module BABYLON {
  12631. interface Engine {
  12632. /**
  12633. * Creates a raw texture
  12634. * @param data defines the data to store in the texture
  12635. * @param width defines the width of the texture
  12636. * @param height defines the height of the texture
  12637. * @param format defines the format of the data
  12638. * @param generateMipMaps defines if the engine should generate the mip levels
  12639. * @param invertY defines if data must be stored with Y axis inverted
  12640. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12641. * @param compression defines the compression used (null by default)
  12642. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12643. * @returns the raw texture inside an InternalTexture
  12644. */
  12645. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12646. /**
  12647. * Update a raw texture
  12648. * @param texture defines the texture to update
  12649. * @param data defines the data to store in the texture
  12650. * @param format defines the format of the data
  12651. * @param invertY defines if data must be stored with Y axis inverted
  12652. */
  12653. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12654. /**
  12655. * Update a raw texture
  12656. * @param texture defines the texture to update
  12657. * @param data defines the data to store in the texture
  12658. * @param format defines the format of the data
  12659. * @param invertY defines if data must be stored with Y axis inverted
  12660. * @param compression defines the compression used (null by default)
  12661. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12662. */
  12663. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12664. /**
  12665. * Creates a new raw cube texture
  12666. * @param data defines the array of data to use to create each face
  12667. * @param size defines the size of the textures
  12668. * @param format defines the format of the data
  12669. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12670. * @param generateMipMaps defines if the engine should generate the mip levels
  12671. * @param invertY defines if data must be stored with Y axis inverted
  12672. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12673. * @param compression defines the compression used (null by default)
  12674. * @returns the cube texture as an InternalTexture
  12675. */
  12676. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12677. /**
  12678. * Update a raw cube texture
  12679. * @param texture defines the texture to udpdate
  12680. * @param data defines the data to store
  12681. * @param format defines the data format
  12682. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12683. * @param invertY defines if data must be stored with Y axis inverted
  12684. */
  12685. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12686. /**
  12687. * Update a raw cube texture
  12688. * @param texture defines the texture to udpdate
  12689. * @param data defines the data to store
  12690. * @param format defines the data format
  12691. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12692. * @param invertY defines if data must be stored with Y axis inverted
  12693. * @param compression defines the compression used (null by default)
  12694. */
  12695. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12696. /**
  12697. * Update a raw cube texture
  12698. * @param texture defines the texture to udpdate
  12699. * @param data defines the data to store
  12700. * @param format defines the data format
  12701. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12702. * @param invertY defines if data must be stored with Y axis inverted
  12703. * @param compression defines the compression used (null by default)
  12704. * @param level defines which level of the texture to update
  12705. */
  12706. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12707. /**
  12708. * Creates a new raw cube texture from a specified url
  12709. * @param url defines the url where the data is located
  12710. * @param scene defines the current scene
  12711. * @param size defines the size of the textures
  12712. * @param format defines the format of the data
  12713. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12714. * @param noMipmap defines if the engine should avoid generating the mip levels
  12715. * @param callback defines a callback used to extract texture data from loaded data
  12716. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12717. * @param onLoad defines a callback called when texture is loaded
  12718. * @param onError defines a callback called if there is an error
  12719. * @returns the cube texture as an InternalTexture
  12720. */
  12721. 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;
  12722. /**
  12723. * Creates a new raw cube texture from a specified url
  12724. * @param url defines the url where the data is located
  12725. * @param scene defines the current scene
  12726. * @param size defines the size of the textures
  12727. * @param format defines the format of the data
  12728. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12729. * @param noMipmap defines if the engine should avoid generating the mip levels
  12730. * @param callback defines a callback used to extract texture data from loaded data
  12731. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12732. * @param onLoad defines a callback called when texture is loaded
  12733. * @param onError defines a callback called if there is an error
  12734. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12735. * @param invertY defines if data must be stored with Y axis inverted
  12736. * @returns the cube texture as an InternalTexture
  12737. */
  12738. 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;
  12739. /**
  12740. * Creates a new raw 3D texture
  12741. * @param data defines the data used to create the texture
  12742. * @param width defines the width of the texture
  12743. * @param height defines the height of the texture
  12744. * @param depth defines the depth of the texture
  12745. * @param format defines the format of the texture
  12746. * @param generateMipMaps defines if the engine must generate mip levels
  12747. * @param invertY defines if data must be stored with Y axis inverted
  12748. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12749. * @param compression defines the compressed used (can be null)
  12750. * @param textureType defines the compressed used (can be null)
  12751. * @returns a new raw 3D texture (stored in an InternalTexture)
  12752. */
  12753. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12754. /**
  12755. * Update a raw 3D texture
  12756. * @param texture defines the texture to update
  12757. * @param data defines the data to store
  12758. * @param format defines the data format
  12759. * @param invertY defines if data must be stored with Y axis inverted
  12760. */
  12761. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12762. /**
  12763. * Update a raw 3D texture
  12764. * @param texture defines the texture to update
  12765. * @param data defines the data to store
  12766. * @param format defines the data format
  12767. * @param invertY defines if data must be stored with Y axis inverted
  12768. * @param compression defines the used compression (can be null)
  12769. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12770. */
  12771. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12772. /**
  12773. * Creates a new raw 2D array texture
  12774. * @param data defines the data used to create the texture
  12775. * @param width defines the width of the texture
  12776. * @param height defines the height of the texture
  12777. * @param depth defines the number of layers of the texture
  12778. * @param format defines the format of the texture
  12779. * @param generateMipMaps defines if the engine must generate mip levels
  12780. * @param invertY defines if data must be stored with Y axis inverted
  12781. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12782. * @param compression defines the compressed used (can be null)
  12783. * @param textureType defines the compressed used (can be null)
  12784. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12785. */
  12786. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12787. /**
  12788. * Update a raw 2D array texture
  12789. * @param texture defines the texture to update
  12790. * @param data defines the data to store
  12791. * @param format defines the data format
  12792. * @param invertY defines if data must be stored with Y axis inverted
  12793. */
  12794. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12795. /**
  12796. * Update a raw 2D array texture
  12797. * @param texture defines the texture to update
  12798. * @param data defines the data to store
  12799. * @param format defines the data format
  12800. * @param invertY defines if data must be stored with Y axis inverted
  12801. * @param compression defines the used compression (can be null)
  12802. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12803. */
  12804. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12805. }
  12806. }
  12807. declare module BABYLON {
  12808. /**
  12809. * Raw texture can help creating a texture directly from an array of data.
  12810. * This can be super useful if you either get the data from an uncompressed source or
  12811. * if you wish to create your texture pixel by pixel.
  12812. */
  12813. export class RawTexture extends Texture {
  12814. /**
  12815. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12816. */
  12817. format: number;
  12818. private _engine;
  12819. /**
  12820. * Instantiates a new RawTexture.
  12821. * Raw texture can help creating a texture directly from an array of data.
  12822. * This can be super useful if you either get the data from an uncompressed source or
  12823. * if you wish to create your texture pixel by pixel.
  12824. * @param data define the array of data to use to create the texture
  12825. * @param width define the width of the texture
  12826. * @param height define the height of the texture
  12827. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12828. * @param scene define the scene the texture belongs to
  12829. * @param generateMipMaps define whether mip maps should be generated or not
  12830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12832. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12833. */
  12834. constructor(data: ArrayBufferView, width: number, height: number,
  12835. /**
  12836. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12837. */
  12838. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12839. /**
  12840. * Updates the texture underlying data.
  12841. * @param data Define the new data of the texture
  12842. */
  12843. update(data: ArrayBufferView): void;
  12844. /**
  12845. * Creates a luminance texture from some data.
  12846. * @param data Define the texture data
  12847. * @param width Define the width of the texture
  12848. * @param height Define the height of the texture
  12849. * @param scene Define the scene the texture belongs to
  12850. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12851. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12852. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12853. * @returns the luminance texture
  12854. */
  12855. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12856. /**
  12857. * Creates a luminance alpha texture from some data.
  12858. * @param data Define the texture data
  12859. * @param width Define the width of the texture
  12860. * @param height Define the height of the texture
  12861. * @param scene Define the scene the texture belongs to
  12862. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12863. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12864. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12865. * @returns the luminance alpha texture
  12866. */
  12867. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12868. /**
  12869. * Creates an alpha texture from some data.
  12870. * @param data Define the texture data
  12871. * @param width Define the width of the texture
  12872. * @param height Define the height of the texture
  12873. * @param scene Define the scene the texture belongs to
  12874. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12875. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12876. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12877. * @returns the alpha texture
  12878. */
  12879. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12880. /**
  12881. * Creates a RGB texture from some data.
  12882. * @param data Define the texture data
  12883. * @param width Define the width of the texture
  12884. * @param height Define the height of the texture
  12885. * @param scene Define the scene the texture belongs to
  12886. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12887. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12888. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12889. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12890. * @returns the RGB alpha texture
  12891. */
  12892. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12893. /**
  12894. * Creates a RGBA texture from some data.
  12895. * @param data Define the texture data
  12896. * @param width Define the width of the texture
  12897. * @param height Define the height of the texture
  12898. * @param scene Define the scene the texture belongs to
  12899. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12900. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12901. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12902. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12903. * @returns the RGBA texture
  12904. */
  12905. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12906. /**
  12907. * Creates a R texture from some data.
  12908. * @param data Define the texture data
  12909. * @param width Define the width of the texture
  12910. * @param height Define the height of the texture
  12911. * @param scene Define the scene the texture belongs to
  12912. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12913. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12914. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12915. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12916. * @returns the R texture
  12917. */
  12918. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12919. }
  12920. }
  12921. declare module BABYLON {
  12922. /**
  12923. * Interface for the size containing width and height
  12924. */
  12925. export interface ISize {
  12926. /**
  12927. * Width
  12928. */
  12929. width: number;
  12930. /**
  12931. * Heighht
  12932. */
  12933. height: number;
  12934. }
  12935. /**
  12936. * Size containing widht and height
  12937. */
  12938. export class Size implements ISize {
  12939. /**
  12940. * Width
  12941. */
  12942. width: number;
  12943. /**
  12944. * Height
  12945. */
  12946. height: number;
  12947. /**
  12948. * Creates a Size object from the given width and height (floats).
  12949. * @param width width of the new size
  12950. * @param height height of the new size
  12951. */
  12952. constructor(width: number, height: number);
  12953. /**
  12954. * Returns a string with the Size width and height
  12955. * @returns a string with the Size width and height
  12956. */
  12957. toString(): string;
  12958. /**
  12959. * "Size"
  12960. * @returns the string "Size"
  12961. */
  12962. getClassName(): string;
  12963. /**
  12964. * Returns the Size hash code.
  12965. * @returns a hash code for a unique width and height
  12966. */
  12967. getHashCode(): number;
  12968. /**
  12969. * Updates the current size from the given one.
  12970. * @param src the given size
  12971. */
  12972. copyFrom(src: Size): void;
  12973. /**
  12974. * Updates in place the current Size from the given floats.
  12975. * @param width width of the new size
  12976. * @param height height of the new size
  12977. * @returns the updated Size.
  12978. */
  12979. copyFromFloats(width: number, height: number): Size;
  12980. /**
  12981. * Updates in place the current Size from the given floats.
  12982. * @param width width to set
  12983. * @param height height to set
  12984. * @returns the updated Size.
  12985. */
  12986. set(width: number, height: number): Size;
  12987. /**
  12988. * Multiplies the width and height by numbers
  12989. * @param w factor to multiple the width by
  12990. * @param h factor to multiple the height by
  12991. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12992. */
  12993. multiplyByFloats(w: number, h: number): Size;
  12994. /**
  12995. * Clones the size
  12996. * @returns a new Size copied from the given one.
  12997. */
  12998. clone(): Size;
  12999. /**
  13000. * True if the current Size and the given one width and height are strictly equal.
  13001. * @param other the other size to compare against
  13002. * @returns True if the current Size and the given one width and height are strictly equal.
  13003. */
  13004. equals(other: Size): boolean;
  13005. /**
  13006. * The surface of the Size : width * height (float).
  13007. */
  13008. get surface(): number;
  13009. /**
  13010. * Create a new size of zero
  13011. * @returns a new Size set to (0.0, 0.0)
  13012. */
  13013. static Zero(): Size;
  13014. /**
  13015. * Sums the width and height of two sizes
  13016. * @param otherSize size to add to this size
  13017. * @returns a new Size set as the addition result of the current Size and the given one.
  13018. */
  13019. add(otherSize: Size): Size;
  13020. /**
  13021. * Subtracts the width and height of two
  13022. * @param otherSize size to subtract to this size
  13023. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13024. */
  13025. subtract(otherSize: Size): Size;
  13026. /**
  13027. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13028. * @param start starting size to lerp between
  13029. * @param end end size to lerp between
  13030. * @param amount amount to lerp between the start and end values
  13031. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13032. */
  13033. static Lerp(start: Size, end: Size, amount: number): Size;
  13034. }
  13035. }
  13036. declare module BABYLON {
  13037. /**
  13038. * Defines a runtime animation
  13039. */
  13040. export class RuntimeAnimation {
  13041. private _events;
  13042. /**
  13043. * The current frame of the runtime animation
  13044. */
  13045. private _currentFrame;
  13046. /**
  13047. * The animation used by the runtime animation
  13048. */
  13049. private _animation;
  13050. /**
  13051. * The target of the runtime animation
  13052. */
  13053. private _target;
  13054. /**
  13055. * The initiating animatable
  13056. */
  13057. private _host;
  13058. /**
  13059. * The original value of the runtime animation
  13060. */
  13061. private _originalValue;
  13062. /**
  13063. * The original blend value of the runtime animation
  13064. */
  13065. private _originalBlendValue;
  13066. /**
  13067. * The offsets cache of the runtime animation
  13068. */
  13069. private _offsetsCache;
  13070. /**
  13071. * The high limits cache of the runtime animation
  13072. */
  13073. private _highLimitsCache;
  13074. /**
  13075. * Specifies if the runtime animation has been stopped
  13076. */
  13077. private _stopped;
  13078. /**
  13079. * The blending factor of the runtime animation
  13080. */
  13081. private _blendingFactor;
  13082. /**
  13083. * The BabylonJS scene
  13084. */
  13085. private _scene;
  13086. /**
  13087. * The current value of the runtime animation
  13088. */
  13089. private _currentValue;
  13090. /** @hidden */
  13091. _animationState: _IAnimationState;
  13092. /**
  13093. * The active target of the runtime animation
  13094. */
  13095. private _activeTargets;
  13096. private _currentActiveTarget;
  13097. private _directTarget;
  13098. /**
  13099. * The target path of the runtime animation
  13100. */
  13101. private _targetPath;
  13102. /**
  13103. * The weight of the runtime animation
  13104. */
  13105. private _weight;
  13106. /**
  13107. * The ratio offset of the runtime animation
  13108. */
  13109. private _ratioOffset;
  13110. /**
  13111. * The previous delay of the runtime animation
  13112. */
  13113. private _previousDelay;
  13114. /**
  13115. * The previous ratio of the runtime animation
  13116. */
  13117. private _previousRatio;
  13118. private _enableBlending;
  13119. private _keys;
  13120. private _minFrame;
  13121. private _maxFrame;
  13122. private _minValue;
  13123. private _maxValue;
  13124. private _targetIsArray;
  13125. /**
  13126. * Gets the current frame of the runtime animation
  13127. */
  13128. get currentFrame(): number;
  13129. /**
  13130. * Gets the weight of the runtime animation
  13131. */
  13132. get weight(): number;
  13133. /**
  13134. * Gets the current value of the runtime animation
  13135. */
  13136. get currentValue(): any;
  13137. /**
  13138. * Gets the target path of the runtime animation
  13139. */
  13140. get targetPath(): string;
  13141. /**
  13142. * Gets the actual target of the runtime animation
  13143. */
  13144. get target(): any;
  13145. /** @hidden */
  13146. _onLoop: () => void;
  13147. /**
  13148. * Create a new RuntimeAnimation object
  13149. * @param target defines the target of the animation
  13150. * @param animation defines the source animation object
  13151. * @param scene defines the hosting scene
  13152. * @param host defines the initiating Animatable
  13153. */
  13154. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13155. private _preparePath;
  13156. /**
  13157. * Gets the animation from the runtime animation
  13158. */
  13159. get animation(): Animation;
  13160. /**
  13161. * Resets the runtime animation to the beginning
  13162. * @param restoreOriginal defines whether to restore the target property to the original value
  13163. */
  13164. reset(restoreOriginal?: boolean): void;
  13165. /**
  13166. * Specifies if the runtime animation is stopped
  13167. * @returns Boolean specifying if the runtime animation is stopped
  13168. */
  13169. isStopped(): boolean;
  13170. /**
  13171. * Disposes of the runtime animation
  13172. */
  13173. dispose(): void;
  13174. /**
  13175. * Apply the interpolated value to the target
  13176. * @param currentValue defines the value computed by the animation
  13177. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13178. */
  13179. setValue(currentValue: any, weight: number): void;
  13180. private _getOriginalValues;
  13181. private _setValue;
  13182. /**
  13183. * Gets the loop pmode of the runtime animation
  13184. * @returns Loop Mode
  13185. */
  13186. private _getCorrectLoopMode;
  13187. /**
  13188. * Move the current animation to a given frame
  13189. * @param frame defines the frame to move to
  13190. */
  13191. goToFrame(frame: number): void;
  13192. /**
  13193. * @hidden Internal use only
  13194. */
  13195. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13196. /**
  13197. * Execute the current animation
  13198. * @param delay defines the delay to add to the current frame
  13199. * @param from defines the lower bound of the animation range
  13200. * @param to defines the upper bound of the animation range
  13201. * @param loop defines if the current animation must loop
  13202. * @param speedRatio defines the current speed ratio
  13203. * @param weight defines the weight of the animation (default is -1 so no weight)
  13204. * @param onLoop optional callback called when animation loops
  13205. * @returns a boolean indicating if the animation is running
  13206. */
  13207. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13208. }
  13209. }
  13210. declare module BABYLON {
  13211. /**
  13212. * Class used to store an actual running animation
  13213. */
  13214. export class Animatable {
  13215. /** defines the target object */
  13216. target: any;
  13217. /** defines the starting frame number (default is 0) */
  13218. fromFrame: number;
  13219. /** defines the ending frame number (default is 100) */
  13220. toFrame: number;
  13221. /** defines if the animation must loop (default is false) */
  13222. loopAnimation: boolean;
  13223. /** defines a callback to call when animation ends if it is not looping */
  13224. onAnimationEnd?: (() => void) | null | undefined;
  13225. /** defines a callback to call when animation loops */
  13226. onAnimationLoop?: (() => void) | null | undefined;
  13227. private _localDelayOffset;
  13228. private _pausedDelay;
  13229. private _runtimeAnimations;
  13230. private _paused;
  13231. private _scene;
  13232. private _speedRatio;
  13233. private _weight;
  13234. private _syncRoot;
  13235. /**
  13236. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13237. * This will only apply for non looping animation (default is true)
  13238. */
  13239. disposeOnEnd: boolean;
  13240. /**
  13241. * Gets a boolean indicating if the animation has started
  13242. */
  13243. animationStarted: boolean;
  13244. /**
  13245. * Observer raised when the animation ends
  13246. */
  13247. onAnimationEndObservable: Observable<Animatable>;
  13248. /**
  13249. * Observer raised when the animation loops
  13250. */
  13251. onAnimationLoopObservable: Observable<Animatable>;
  13252. /**
  13253. * Gets the root Animatable used to synchronize and normalize animations
  13254. */
  13255. get syncRoot(): Nullable<Animatable>;
  13256. /**
  13257. * Gets the current frame of the first RuntimeAnimation
  13258. * Used to synchronize Animatables
  13259. */
  13260. get masterFrame(): number;
  13261. /**
  13262. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13263. */
  13264. get weight(): number;
  13265. set weight(value: number);
  13266. /**
  13267. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13268. */
  13269. get speedRatio(): number;
  13270. set speedRatio(value: number);
  13271. /**
  13272. * Creates a new Animatable
  13273. * @param scene defines the hosting scene
  13274. * @param target defines the target object
  13275. * @param fromFrame defines the starting frame number (default is 0)
  13276. * @param toFrame defines the ending frame number (default is 100)
  13277. * @param loopAnimation defines if the animation must loop (default is false)
  13278. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13279. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13280. * @param animations defines a group of animation to add to the new Animatable
  13281. * @param onAnimationLoop defines a callback to call when animation loops
  13282. */
  13283. constructor(scene: Scene,
  13284. /** defines the target object */
  13285. target: any,
  13286. /** defines the starting frame number (default is 0) */
  13287. fromFrame?: number,
  13288. /** defines the ending frame number (default is 100) */
  13289. toFrame?: number,
  13290. /** defines if the animation must loop (default is false) */
  13291. loopAnimation?: boolean, speedRatio?: number,
  13292. /** defines a callback to call when animation ends if it is not looping */
  13293. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13294. /** defines a callback to call when animation loops */
  13295. onAnimationLoop?: (() => void) | null | undefined);
  13296. /**
  13297. * Synchronize and normalize current Animatable with a source Animatable
  13298. * This is useful when using animation weights and when animations are not of the same length
  13299. * @param root defines the root Animatable to synchronize with
  13300. * @returns the current Animatable
  13301. */
  13302. syncWith(root: Animatable): Animatable;
  13303. /**
  13304. * Gets the list of runtime animations
  13305. * @returns an array of RuntimeAnimation
  13306. */
  13307. getAnimations(): RuntimeAnimation[];
  13308. /**
  13309. * Adds more animations to the current animatable
  13310. * @param target defines the target of the animations
  13311. * @param animations defines the new animations to add
  13312. */
  13313. appendAnimations(target: any, animations: Animation[]): void;
  13314. /**
  13315. * Gets the source animation for a specific property
  13316. * @param property defines the propertyu to look for
  13317. * @returns null or the source animation for the given property
  13318. */
  13319. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13320. /**
  13321. * Gets the runtime animation for a specific property
  13322. * @param property defines the propertyu to look for
  13323. * @returns null or the runtime animation for the given property
  13324. */
  13325. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13326. /**
  13327. * Resets the animatable to its original state
  13328. */
  13329. reset(): void;
  13330. /**
  13331. * Allows the animatable to blend with current running animations
  13332. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13333. * @param blendingSpeed defines the blending speed to use
  13334. */
  13335. enableBlending(blendingSpeed: number): void;
  13336. /**
  13337. * Disable animation blending
  13338. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13339. */
  13340. disableBlending(): void;
  13341. /**
  13342. * Jump directly to a given frame
  13343. * @param frame defines the frame to jump to
  13344. */
  13345. goToFrame(frame: number): void;
  13346. /**
  13347. * Pause the animation
  13348. */
  13349. pause(): void;
  13350. /**
  13351. * Restart the animation
  13352. */
  13353. restart(): void;
  13354. private _raiseOnAnimationEnd;
  13355. /**
  13356. * Stop and delete the current animation
  13357. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13358. * @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)
  13359. */
  13360. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13361. /**
  13362. * Wait asynchronously for the animation to end
  13363. * @returns a promise which will be fullfilled when the animation ends
  13364. */
  13365. waitAsync(): Promise<Animatable>;
  13366. /** @hidden */
  13367. _animate(delay: number): boolean;
  13368. }
  13369. interface Scene {
  13370. /** @hidden */
  13371. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13372. /** @hidden */
  13373. _processLateAnimationBindingsForMatrices(holder: {
  13374. totalWeight: number;
  13375. animations: RuntimeAnimation[];
  13376. originalValue: Matrix;
  13377. }): any;
  13378. /** @hidden */
  13379. _processLateAnimationBindingsForQuaternions(holder: {
  13380. totalWeight: number;
  13381. animations: RuntimeAnimation[];
  13382. originalValue: Quaternion;
  13383. }, refQuaternion: Quaternion): Quaternion;
  13384. /** @hidden */
  13385. _processLateAnimationBindings(): void;
  13386. /**
  13387. * Will start the animation sequence of a given target
  13388. * @param target defines the target
  13389. * @param from defines from which frame should animation start
  13390. * @param to defines until which frame should animation run.
  13391. * @param weight defines the weight to apply to the animation (1.0 by default)
  13392. * @param loop defines if the animation loops
  13393. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13394. * @param onAnimationEnd defines the function to be executed when the animation ends
  13395. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13396. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13397. * @param onAnimationLoop defines the callback to call when an animation loops
  13398. * @returns the animatable object created for this animation
  13399. */
  13400. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13401. /**
  13402. * Will start the animation sequence of a given target
  13403. * @param target defines the target
  13404. * @param from defines from which frame should animation start
  13405. * @param to defines until which frame should animation run.
  13406. * @param loop defines if the animation loops
  13407. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13408. * @param onAnimationEnd defines the function to be executed when the animation ends
  13409. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13410. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13411. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13412. * @param onAnimationLoop defines the callback to call when an animation loops
  13413. * @returns the animatable object created for this animation
  13414. */
  13415. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13416. /**
  13417. * Will start the animation sequence of a given target and its hierarchy
  13418. * @param target defines the target
  13419. * @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.
  13420. * @param from defines from which frame should animation start
  13421. * @param to defines until which frame should animation run.
  13422. * @param loop defines if the animation loops
  13423. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13424. * @param onAnimationEnd defines the function to be executed when the animation ends
  13425. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13426. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13427. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13428. * @param onAnimationLoop defines the callback to call when an animation loops
  13429. * @returns the list of created animatables
  13430. */
  13431. 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): Animatable[];
  13432. /**
  13433. * Begin a new animation on a given node
  13434. * @param target defines the target where the animation will take place
  13435. * @param animations defines the list of animations to start
  13436. * @param from defines the initial value
  13437. * @param to defines the final value
  13438. * @param loop defines if you want animation to loop (off by default)
  13439. * @param speedRatio defines the speed ratio to apply to all animations
  13440. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13441. * @param onAnimationLoop defines the callback to call when an animation loops
  13442. * @returns the list of created animatables
  13443. */
  13444. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13445. /**
  13446. * Begin a new animation on a given node and its hierarchy
  13447. * @param target defines the root node where the animation will take place
  13448. * @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.
  13449. * @param animations defines the list of animations to start
  13450. * @param from defines the initial value
  13451. * @param to defines the final value
  13452. * @param loop defines if you want animation to loop (off by default)
  13453. * @param speedRatio defines the speed ratio to apply to all animations
  13454. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13455. * @param onAnimationLoop defines the callback to call when an animation loops
  13456. * @returns the list of animatables created for all nodes
  13457. */
  13458. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13459. /**
  13460. * Gets the animatable associated with a specific target
  13461. * @param target defines the target of the animatable
  13462. * @returns the required animatable if found
  13463. */
  13464. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13465. /**
  13466. * Gets all animatables associated with a given target
  13467. * @param target defines the target to look animatables for
  13468. * @returns an array of Animatables
  13469. */
  13470. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13471. /**
  13472. * Stops and removes all animations that have been applied to the scene
  13473. */
  13474. stopAllAnimations(): void;
  13475. /**
  13476. * Gets the current delta time used by animation engine
  13477. */
  13478. deltaTime: number;
  13479. }
  13480. interface Bone {
  13481. /**
  13482. * Copy an animation range from another bone
  13483. * @param source defines the source bone
  13484. * @param rangeName defines the range name to copy
  13485. * @param frameOffset defines the frame offset
  13486. * @param rescaleAsRequired defines if rescaling must be applied if required
  13487. * @param skelDimensionsRatio defines the scaling ratio
  13488. * @returns true if operation was successful
  13489. */
  13490. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13491. }
  13492. }
  13493. declare module BABYLON {
  13494. /**
  13495. * Class used to override all child animations of a given target
  13496. */
  13497. export class AnimationPropertiesOverride {
  13498. /**
  13499. * Gets or sets a value indicating if animation blending must be used
  13500. */
  13501. enableBlending: boolean;
  13502. /**
  13503. * Gets or sets the blending speed to use when enableBlending is true
  13504. */
  13505. blendingSpeed: number;
  13506. /**
  13507. * Gets or sets the default loop mode to use
  13508. */
  13509. loopMode: number;
  13510. }
  13511. }
  13512. declare module BABYLON {
  13513. /**
  13514. * Class used to handle skinning animations
  13515. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13516. */
  13517. export class Skeleton implements IAnimatable {
  13518. /** defines the skeleton name */
  13519. name: string;
  13520. /** defines the skeleton Id */
  13521. id: string;
  13522. /**
  13523. * Defines the list of child bones
  13524. */
  13525. bones: Bone[];
  13526. /**
  13527. * Defines an estimate of the dimension of the skeleton at rest
  13528. */
  13529. dimensionsAtRest: Vector3;
  13530. /**
  13531. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13532. */
  13533. needInitialSkinMatrix: boolean;
  13534. /**
  13535. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13536. */
  13537. overrideMesh: Nullable<AbstractMesh>;
  13538. /**
  13539. * Gets the list of animations attached to this skeleton
  13540. */
  13541. animations: Array<Animation>;
  13542. private _scene;
  13543. private _isDirty;
  13544. private _transformMatrices;
  13545. private _transformMatrixTexture;
  13546. private _meshesWithPoseMatrix;
  13547. private _animatables;
  13548. private _identity;
  13549. private _synchronizedWithMesh;
  13550. private _ranges;
  13551. private _lastAbsoluteTransformsUpdateId;
  13552. private _canUseTextureForBones;
  13553. private _uniqueId;
  13554. /** @hidden */
  13555. _numBonesWithLinkedTransformNode: number;
  13556. /** @hidden */
  13557. _hasWaitingData: Nullable<boolean>;
  13558. /**
  13559. * Specifies if the skeleton should be serialized
  13560. */
  13561. doNotSerialize: boolean;
  13562. private _useTextureToStoreBoneMatrices;
  13563. /**
  13564. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13565. * Please note that this option is not available if the hardware does not support it
  13566. */
  13567. get useTextureToStoreBoneMatrices(): boolean;
  13568. set useTextureToStoreBoneMatrices(value: boolean);
  13569. private _animationPropertiesOverride;
  13570. /**
  13571. * Gets or sets the animation properties override
  13572. */
  13573. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13574. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13575. /**
  13576. * List of inspectable custom properties (used by the Inspector)
  13577. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13578. */
  13579. inspectableCustomProperties: IInspectable[];
  13580. /**
  13581. * An observable triggered before computing the skeleton's matrices
  13582. */
  13583. onBeforeComputeObservable: Observable<Skeleton>;
  13584. /**
  13585. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13586. */
  13587. get isUsingTextureForMatrices(): boolean;
  13588. /**
  13589. * Gets the unique ID of this skeleton
  13590. */
  13591. get uniqueId(): number;
  13592. /**
  13593. * Creates a new skeleton
  13594. * @param name defines the skeleton name
  13595. * @param id defines the skeleton Id
  13596. * @param scene defines the hosting scene
  13597. */
  13598. constructor(
  13599. /** defines the skeleton name */
  13600. name: string,
  13601. /** defines the skeleton Id */
  13602. id: string, scene: Scene);
  13603. /**
  13604. * Gets the current object class name.
  13605. * @return the class name
  13606. */
  13607. getClassName(): string;
  13608. /**
  13609. * Returns an array containing the root bones
  13610. * @returns an array containing the root bones
  13611. */
  13612. getChildren(): Array<Bone>;
  13613. /**
  13614. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13615. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13616. * @returns a Float32Array containing matrices data
  13617. */
  13618. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13619. /**
  13620. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13621. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13622. * @returns a raw texture containing the data
  13623. */
  13624. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13625. /**
  13626. * Gets the current hosting scene
  13627. * @returns a scene object
  13628. */
  13629. getScene(): Scene;
  13630. /**
  13631. * Gets a string representing the current skeleton data
  13632. * @param fullDetails defines a boolean indicating if we want a verbose version
  13633. * @returns a string representing the current skeleton data
  13634. */
  13635. toString(fullDetails?: boolean): string;
  13636. /**
  13637. * Get bone's index searching by name
  13638. * @param name defines bone's name to search for
  13639. * @return the indice of the bone. Returns -1 if not found
  13640. */
  13641. getBoneIndexByName(name: string): number;
  13642. /**
  13643. * Creater a new animation range
  13644. * @param name defines the name of the range
  13645. * @param from defines the start key
  13646. * @param to defines the end key
  13647. */
  13648. createAnimationRange(name: string, from: number, to: number): void;
  13649. /**
  13650. * Delete a specific animation range
  13651. * @param name defines the name of the range
  13652. * @param deleteFrames defines if frames must be removed as well
  13653. */
  13654. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13655. /**
  13656. * Gets a specific animation range
  13657. * @param name defines the name of the range to look for
  13658. * @returns the requested animation range or null if not found
  13659. */
  13660. getAnimationRange(name: string): Nullable<AnimationRange>;
  13661. /**
  13662. * Gets the list of all animation ranges defined on this skeleton
  13663. * @returns an array
  13664. */
  13665. getAnimationRanges(): Nullable<AnimationRange>[];
  13666. /**
  13667. * Copy animation range from a source skeleton.
  13668. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13669. * @param source defines the source skeleton
  13670. * @param name defines the name of the range to copy
  13671. * @param rescaleAsRequired defines if rescaling must be applied if required
  13672. * @returns true if operation was successful
  13673. */
  13674. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13675. /**
  13676. * Forces the skeleton to go to rest pose
  13677. */
  13678. returnToRest(): void;
  13679. private _getHighestAnimationFrame;
  13680. /**
  13681. * Begin a specific animation range
  13682. * @param name defines the name of the range to start
  13683. * @param loop defines if looping must be turned on (false by default)
  13684. * @param speedRatio defines the speed ratio to apply (1 by default)
  13685. * @param onAnimationEnd defines a callback which will be called when animation will end
  13686. * @returns a new animatable
  13687. */
  13688. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13689. /** @hidden */
  13690. _markAsDirty(): void;
  13691. /** @hidden */
  13692. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13693. /** @hidden */
  13694. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13695. private _computeTransformMatrices;
  13696. /**
  13697. * Build all resources required to render a skeleton
  13698. */
  13699. prepare(): void;
  13700. /**
  13701. * Gets the list of animatables currently running for this skeleton
  13702. * @returns an array of animatables
  13703. */
  13704. getAnimatables(): IAnimatable[];
  13705. /**
  13706. * Clone the current skeleton
  13707. * @param name defines the name of the new skeleton
  13708. * @param id defines the id of the new skeleton
  13709. * @returns the new skeleton
  13710. */
  13711. clone(name: string, id?: string): Skeleton;
  13712. /**
  13713. * Enable animation blending for this skeleton
  13714. * @param blendingSpeed defines the blending speed to apply
  13715. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13716. */
  13717. enableBlending(blendingSpeed?: number): void;
  13718. /**
  13719. * Releases all resources associated with the current skeleton
  13720. */
  13721. dispose(): void;
  13722. /**
  13723. * Serialize the skeleton in a JSON object
  13724. * @returns a JSON object
  13725. */
  13726. serialize(): any;
  13727. /**
  13728. * Creates a new skeleton from serialized data
  13729. * @param parsedSkeleton defines the serialized data
  13730. * @param scene defines the hosting scene
  13731. * @returns a new skeleton
  13732. */
  13733. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13734. /**
  13735. * Compute all node absolute transforms
  13736. * @param forceUpdate defines if computation must be done even if cache is up to date
  13737. */
  13738. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13739. /**
  13740. * Gets the root pose matrix
  13741. * @returns a matrix
  13742. */
  13743. getPoseMatrix(): Nullable<Matrix>;
  13744. /**
  13745. * Sorts bones per internal index
  13746. */
  13747. sortBones(): void;
  13748. private _sortBones;
  13749. }
  13750. }
  13751. declare module BABYLON {
  13752. /**
  13753. * Class used to store bone information
  13754. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13755. */
  13756. export class Bone extends Node {
  13757. /**
  13758. * defines the bone name
  13759. */
  13760. name: string;
  13761. private static _tmpVecs;
  13762. private static _tmpQuat;
  13763. private static _tmpMats;
  13764. /**
  13765. * Gets the list of child bones
  13766. */
  13767. children: Bone[];
  13768. /** Gets the animations associated with this bone */
  13769. animations: Animation[];
  13770. /**
  13771. * Gets or sets bone length
  13772. */
  13773. length: number;
  13774. /**
  13775. * @hidden Internal only
  13776. * Set this value to map this bone to a different index in the transform matrices
  13777. * Set this value to -1 to exclude the bone from the transform matrices
  13778. */
  13779. _index: Nullable<number>;
  13780. private _skeleton;
  13781. private _localMatrix;
  13782. private _restPose;
  13783. private _baseMatrix;
  13784. private _absoluteTransform;
  13785. private _invertedAbsoluteTransform;
  13786. private _parent;
  13787. private _scalingDeterminant;
  13788. private _worldTransform;
  13789. private _localScaling;
  13790. private _localRotation;
  13791. private _localPosition;
  13792. private _needToDecompose;
  13793. private _needToCompose;
  13794. /** @hidden */
  13795. _linkedTransformNode: Nullable<TransformNode>;
  13796. /** @hidden */
  13797. _waitingTransformNodeId: Nullable<string>;
  13798. /** @hidden */
  13799. get _matrix(): Matrix;
  13800. /** @hidden */
  13801. set _matrix(value: Matrix);
  13802. /**
  13803. * Create a new bone
  13804. * @param name defines the bone name
  13805. * @param skeleton defines the parent skeleton
  13806. * @param parentBone defines the parent (can be null if the bone is the root)
  13807. * @param localMatrix defines the local matrix
  13808. * @param restPose defines the rest pose matrix
  13809. * @param baseMatrix defines the base matrix
  13810. * @param index defines index of the bone in the hiearchy
  13811. */
  13812. constructor(
  13813. /**
  13814. * defines the bone name
  13815. */
  13816. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13817. /**
  13818. * Gets the current object class name.
  13819. * @return the class name
  13820. */
  13821. getClassName(): string;
  13822. /**
  13823. * Gets the parent skeleton
  13824. * @returns a skeleton
  13825. */
  13826. getSkeleton(): Skeleton;
  13827. /**
  13828. * Gets parent bone
  13829. * @returns a bone or null if the bone is the root of the bone hierarchy
  13830. */
  13831. getParent(): Nullable<Bone>;
  13832. /**
  13833. * Returns an array containing the root bones
  13834. * @returns an array containing the root bones
  13835. */
  13836. getChildren(): Array<Bone>;
  13837. /**
  13838. * Gets the node index in matrix array generated for rendering
  13839. * @returns the node index
  13840. */
  13841. getIndex(): number;
  13842. /**
  13843. * Sets the parent bone
  13844. * @param parent defines the parent (can be null if the bone is the root)
  13845. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13846. */
  13847. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13848. /**
  13849. * Gets the local matrix
  13850. * @returns a matrix
  13851. */
  13852. getLocalMatrix(): Matrix;
  13853. /**
  13854. * Gets the base matrix (initial matrix which remains unchanged)
  13855. * @returns a matrix
  13856. */
  13857. getBaseMatrix(): Matrix;
  13858. /**
  13859. * Gets the rest pose matrix
  13860. * @returns a matrix
  13861. */
  13862. getRestPose(): Matrix;
  13863. /**
  13864. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13865. */
  13866. getWorldMatrix(): Matrix;
  13867. /**
  13868. * Sets the local matrix to rest pose matrix
  13869. */
  13870. returnToRest(): void;
  13871. /**
  13872. * Gets the inverse of the absolute transform matrix.
  13873. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13874. * @returns a matrix
  13875. */
  13876. getInvertedAbsoluteTransform(): Matrix;
  13877. /**
  13878. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13879. * @returns a matrix
  13880. */
  13881. getAbsoluteTransform(): Matrix;
  13882. /**
  13883. * Links with the given transform node.
  13884. * The local matrix of this bone is copied from the transform node every frame.
  13885. * @param transformNode defines the transform node to link to
  13886. */
  13887. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13888. /**
  13889. * Gets the node used to drive the bone's transformation
  13890. * @returns a transform node or null
  13891. */
  13892. getTransformNode(): Nullable<TransformNode>;
  13893. /** Gets or sets current position (in local space) */
  13894. get position(): Vector3;
  13895. set position(newPosition: Vector3);
  13896. /** Gets or sets current rotation (in local space) */
  13897. get rotation(): Vector3;
  13898. set rotation(newRotation: Vector3);
  13899. /** Gets or sets current rotation quaternion (in local space) */
  13900. get rotationQuaternion(): Quaternion;
  13901. set rotationQuaternion(newRotation: Quaternion);
  13902. /** Gets or sets current scaling (in local space) */
  13903. get scaling(): Vector3;
  13904. set scaling(newScaling: Vector3);
  13905. /**
  13906. * Gets the animation properties override
  13907. */
  13908. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13909. private _decompose;
  13910. private _compose;
  13911. /**
  13912. * Update the base and local matrices
  13913. * @param matrix defines the new base or local matrix
  13914. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13915. * @param updateLocalMatrix defines if the local matrix should be updated
  13916. */
  13917. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13918. /** @hidden */
  13919. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13920. /**
  13921. * Flag the bone as dirty (Forcing it to update everything)
  13922. */
  13923. markAsDirty(): void;
  13924. /** @hidden */
  13925. _markAsDirtyAndCompose(): void;
  13926. private _markAsDirtyAndDecompose;
  13927. /**
  13928. * Translate the bone in local or world space
  13929. * @param vec The amount to translate the bone
  13930. * @param space The space that the translation is in
  13931. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13932. */
  13933. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13934. /**
  13935. * Set the postion of the bone in local or world space
  13936. * @param position The position to set the bone
  13937. * @param space The space that the position is in
  13938. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13939. */
  13940. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13941. /**
  13942. * Set the absolute position of the bone (world space)
  13943. * @param position The position to set the bone
  13944. * @param mesh The mesh that this bone is attached to
  13945. */
  13946. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13947. /**
  13948. * Scale the bone on the x, y and z axes (in local space)
  13949. * @param x The amount to scale the bone on the x axis
  13950. * @param y The amount to scale the bone on the y axis
  13951. * @param z The amount to scale the bone on the z axis
  13952. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13953. */
  13954. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13955. /**
  13956. * Set the bone scaling in local space
  13957. * @param scale defines the scaling vector
  13958. */
  13959. setScale(scale: Vector3): void;
  13960. /**
  13961. * Gets the current scaling in local space
  13962. * @returns the current scaling vector
  13963. */
  13964. getScale(): Vector3;
  13965. /**
  13966. * Gets the current scaling in local space and stores it in a target vector
  13967. * @param result defines the target vector
  13968. */
  13969. getScaleToRef(result: Vector3): void;
  13970. /**
  13971. * Set the yaw, pitch, and roll of the bone in local or world space
  13972. * @param yaw The rotation of the bone on the y axis
  13973. * @param pitch The rotation of the bone on the x axis
  13974. * @param roll The rotation of the bone on the z axis
  13975. * @param space The space that the axes of rotation are in
  13976. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13977. */
  13978. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13979. /**
  13980. * Add a rotation to the bone on an axis in local or world space
  13981. * @param axis The axis to rotate the bone on
  13982. * @param amount The amount to rotate the bone
  13983. * @param space The space that the axis is in
  13984. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13985. */
  13986. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13987. /**
  13988. * Set the rotation of the bone to a particular axis angle in local or world space
  13989. * @param axis The axis to rotate the bone on
  13990. * @param angle The angle that the bone should be rotated to
  13991. * @param space The space that the axis is in
  13992. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13993. */
  13994. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13995. /**
  13996. * Set the euler rotation of the bone in local of world space
  13997. * @param rotation The euler rotation that the bone should be set to
  13998. * @param space The space that the rotation is in
  13999. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14000. */
  14001. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14002. /**
  14003. * Set the quaternion rotation of the bone in local of world space
  14004. * @param quat The quaternion rotation that the bone should be set to
  14005. * @param space The space that the rotation is in
  14006. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14007. */
  14008. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14009. /**
  14010. * Set the rotation matrix of the bone in local of world space
  14011. * @param rotMat The rotation matrix that the bone should be set to
  14012. * @param space The space that the rotation is in
  14013. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14014. */
  14015. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14016. private _rotateWithMatrix;
  14017. private _getNegativeRotationToRef;
  14018. /**
  14019. * Get the position of the bone in local or world space
  14020. * @param space The space that the returned position is in
  14021. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14022. * @returns The position of the bone
  14023. */
  14024. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14025. /**
  14026. * Copy the position of the bone to a vector3 in local or world space
  14027. * @param space The space that the returned position is in
  14028. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14029. * @param result The vector3 to copy the position to
  14030. */
  14031. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14032. /**
  14033. * Get the absolute position of the bone (world space)
  14034. * @param mesh The mesh that this bone is attached to
  14035. * @returns The absolute position of the bone
  14036. */
  14037. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14038. /**
  14039. * Copy the absolute position of the bone (world space) to the result param
  14040. * @param mesh The mesh that this bone is attached to
  14041. * @param result The vector3 to copy the absolute position to
  14042. */
  14043. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14044. /**
  14045. * Compute the absolute transforms of this bone and its children
  14046. */
  14047. computeAbsoluteTransforms(): void;
  14048. /**
  14049. * Get the world direction from an axis that is in the local space of the bone
  14050. * @param localAxis The local direction that is used to compute the world direction
  14051. * @param mesh The mesh that this bone is attached to
  14052. * @returns The world direction
  14053. */
  14054. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14055. /**
  14056. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14057. * @param localAxis The local direction that is used to compute the world direction
  14058. * @param mesh The mesh that this bone is attached to
  14059. * @param result The vector3 that the world direction will be copied to
  14060. */
  14061. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14062. /**
  14063. * Get the euler rotation of the bone in local or world space
  14064. * @param space The space that the rotation should be in
  14065. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14066. * @returns The euler rotation
  14067. */
  14068. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14069. /**
  14070. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14071. * @param space The space that the rotation should be in
  14072. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14073. * @param result The vector3 that the rotation should be copied to
  14074. */
  14075. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14076. /**
  14077. * Get the quaternion rotation of the bone in either local or world space
  14078. * @param space The space that the rotation should be in
  14079. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14080. * @returns The quaternion rotation
  14081. */
  14082. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14083. /**
  14084. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14085. * @param space The space that the rotation should be in
  14086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14087. * @param result The quaternion that the rotation should be copied to
  14088. */
  14089. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14090. /**
  14091. * Get the rotation matrix of the bone in local or world space
  14092. * @param space The space that the rotation should be in
  14093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14094. * @returns The rotation matrix
  14095. */
  14096. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14097. /**
  14098. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14099. * @param space The space that the rotation should be in
  14100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14101. * @param result The quaternion that the rotation should be copied to
  14102. */
  14103. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14104. /**
  14105. * Get the world position of a point that is in the local space of the bone
  14106. * @param position The local position
  14107. * @param mesh The mesh that this bone is attached to
  14108. * @returns The world position
  14109. */
  14110. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14111. /**
  14112. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14113. * @param position The local position
  14114. * @param mesh The mesh that this bone is attached to
  14115. * @param result The vector3 that the world position should be copied to
  14116. */
  14117. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14118. /**
  14119. * Get the local position of a point that is in world space
  14120. * @param position The world position
  14121. * @param mesh The mesh that this bone is attached to
  14122. * @returns The local position
  14123. */
  14124. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14125. /**
  14126. * Get the local position of a point that is in world space and copy it to the result param
  14127. * @param position The world position
  14128. * @param mesh The mesh that this bone is attached to
  14129. * @param result The vector3 that the local position should be copied to
  14130. */
  14131. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14132. }
  14133. }
  14134. declare module BABYLON {
  14135. /**
  14136. * 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.
  14137. * @see https://doc.babylonjs.com/how_to/transformnode
  14138. */
  14139. export class TransformNode extends Node {
  14140. /**
  14141. * Object will not rotate to face the camera
  14142. */
  14143. static BILLBOARDMODE_NONE: number;
  14144. /**
  14145. * Object will rotate to face the camera but only on the x axis
  14146. */
  14147. static BILLBOARDMODE_X: number;
  14148. /**
  14149. * Object will rotate to face the camera but only on the y axis
  14150. */
  14151. static BILLBOARDMODE_Y: number;
  14152. /**
  14153. * Object will rotate to face the camera but only on the z axis
  14154. */
  14155. static BILLBOARDMODE_Z: number;
  14156. /**
  14157. * Object will rotate to face the camera
  14158. */
  14159. static BILLBOARDMODE_ALL: number;
  14160. /**
  14161. * Object will rotate to face the camera's position instead of orientation
  14162. */
  14163. static BILLBOARDMODE_USE_POSITION: number;
  14164. private _forward;
  14165. private _forwardInverted;
  14166. private _up;
  14167. private _right;
  14168. private _rightInverted;
  14169. private _position;
  14170. private _rotation;
  14171. private _rotationQuaternion;
  14172. protected _scaling: Vector3;
  14173. protected _isDirty: boolean;
  14174. private _transformToBoneReferal;
  14175. private _isAbsoluteSynced;
  14176. private _billboardMode;
  14177. /**
  14178. * Gets or sets the billboard mode. Default is 0.
  14179. *
  14180. * | Value | Type | Description |
  14181. * | --- | --- | --- |
  14182. * | 0 | BILLBOARDMODE_NONE | |
  14183. * | 1 | BILLBOARDMODE_X | |
  14184. * | 2 | BILLBOARDMODE_Y | |
  14185. * | 4 | BILLBOARDMODE_Z | |
  14186. * | 7 | BILLBOARDMODE_ALL | |
  14187. *
  14188. */
  14189. get billboardMode(): number;
  14190. set billboardMode(value: number);
  14191. private _preserveParentRotationForBillboard;
  14192. /**
  14193. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14194. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14195. */
  14196. get preserveParentRotationForBillboard(): boolean;
  14197. set preserveParentRotationForBillboard(value: boolean);
  14198. /**
  14199. * 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
  14200. */
  14201. scalingDeterminant: number;
  14202. private _infiniteDistance;
  14203. /**
  14204. * Gets or sets the distance of the object to max, often used by skybox
  14205. */
  14206. get infiniteDistance(): boolean;
  14207. set infiniteDistance(value: boolean);
  14208. /**
  14209. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14210. * By default the system will update normals to compensate
  14211. */
  14212. ignoreNonUniformScaling: boolean;
  14213. /**
  14214. * 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
  14215. */
  14216. reIntegrateRotationIntoRotationQuaternion: boolean;
  14217. /** @hidden */
  14218. _poseMatrix: Nullable<Matrix>;
  14219. /** @hidden */
  14220. _localMatrix: Matrix;
  14221. private _usePivotMatrix;
  14222. private _absolutePosition;
  14223. private _absoluteScaling;
  14224. private _absoluteRotationQuaternion;
  14225. private _pivotMatrix;
  14226. private _pivotMatrixInverse;
  14227. protected _postMultiplyPivotMatrix: boolean;
  14228. protected _isWorldMatrixFrozen: boolean;
  14229. /** @hidden */
  14230. _indexInSceneTransformNodesArray: number;
  14231. /**
  14232. * An event triggered after the world matrix is updated
  14233. */
  14234. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14235. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14236. /**
  14237. * Gets a string identifying the name of the class
  14238. * @returns "TransformNode" string
  14239. */
  14240. getClassName(): string;
  14241. /**
  14242. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14243. */
  14244. get position(): Vector3;
  14245. set position(newPosition: Vector3);
  14246. /**
  14247. * 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)).
  14248. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14249. */
  14250. get rotation(): Vector3;
  14251. set rotation(newRotation: Vector3);
  14252. /**
  14253. * 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)).
  14254. */
  14255. get scaling(): Vector3;
  14256. set scaling(newScaling: Vector3);
  14257. /**
  14258. * 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).
  14259. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14260. */
  14261. get rotationQuaternion(): Nullable<Quaternion>;
  14262. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14263. /**
  14264. * The forward direction of that transform in world space.
  14265. */
  14266. get forward(): Vector3;
  14267. /**
  14268. * The up direction of that transform in world space.
  14269. */
  14270. get up(): Vector3;
  14271. /**
  14272. * The right direction of that transform in world space.
  14273. */
  14274. get right(): Vector3;
  14275. /**
  14276. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14277. * @param matrix the matrix to copy the pose from
  14278. * @returns this TransformNode.
  14279. */
  14280. updatePoseMatrix(matrix: Matrix): TransformNode;
  14281. /**
  14282. * Returns the mesh Pose matrix.
  14283. * @returns the pose matrix
  14284. */
  14285. getPoseMatrix(): Matrix;
  14286. /** @hidden */
  14287. _isSynchronized(): boolean;
  14288. /** @hidden */
  14289. _initCache(): void;
  14290. /**
  14291. * Flag the transform node as dirty (Forcing it to update everything)
  14292. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14293. * @returns this transform node
  14294. */
  14295. markAsDirty(property: string): TransformNode;
  14296. /**
  14297. * Returns the current mesh absolute position.
  14298. * Returns a Vector3.
  14299. */
  14300. get absolutePosition(): Vector3;
  14301. /**
  14302. * Returns the current mesh absolute scaling.
  14303. * Returns a Vector3.
  14304. */
  14305. get absoluteScaling(): Vector3;
  14306. /**
  14307. * Returns the current mesh absolute rotation.
  14308. * Returns a Quaternion.
  14309. */
  14310. get absoluteRotationQuaternion(): Quaternion;
  14311. /**
  14312. * Sets a new matrix to apply before all other transformation
  14313. * @param matrix defines the transform matrix
  14314. * @returns the current TransformNode
  14315. */
  14316. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14317. /**
  14318. * Sets a new pivot matrix to the current node
  14319. * @param matrix defines the new pivot matrix to use
  14320. * @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
  14321. * @returns the current TransformNode
  14322. */
  14323. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14324. /**
  14325. * Returns the mesh pivot matrix.
  14326. * Default : Identity.
  14327. * @returns the matrix
  14328. */
  14329. getPivotMatrix(): Matrix;
  14330. /**
  14331. * Instantiate (when possible) or clone that node with its hierarchy
  14332. * @param newParent defines the new parent to use for the instance (or clone)
  14333. * @param options defines options to configure how copy is done
  14334. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14335. * @returns an instance (or a clone) of the current node with its hiearchy
  14336. */
  14337. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14338. doNotInstantiate: boolean;
  14339. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14340. /**
  14341. * Prevents the World matrix to be computed any longer
  14342. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14343. * @returns the TransformNode.
  14344. */
  14345. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14346. /**
  14347. * Allows back the World matrix computation.
  14348. * @returns the TransformNode.
  14349. */
  14350. unfreezeWorldMatrix(): this;
  14351. /**
  14352. * True if the World matrix has been frozen.
  14353. */
  14354. get isWorldMatrixFrozen(): boolean;
  14355. /**
  14356. * Retuns the mesh absolute position in the World.
  14357. * @returns a Vector3.
  14358. */
  14359. getAbsolutePosition(): Vector3;
  14360. /**
  14361. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14362. * @param absolutePosition the absolute position to set
  14363. * @returns the TransformNode.
  14364. */
  14365. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14366. /**
  14367. * Sets the mesh position in its local space.
  14368. * @param vector3 the position to set in localspace
  14369. * @returns the TransformNode.
  14370. */
  14371. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14372. /**
  14373. * Returns the mesh position in the local space from the current World matrix values.
  14374. * @returns a new Vector3.
  14375. */
  14376. getPositionExpressedInLocalSpace(): Vector3;
  14377. /**
  14378. * Translates the mesh along the passed Vector3 in its local space.
  14379. * @param vector3 the distance to translate in localspace
  14380. * @returns the TransformNode.
  14381. */
  14382. locallyTranslate(vector3: Vector3): TransformNode;
  14383. private static _lookAtVectorCache;
  14384. /**
  14385. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14386. * @param targetPoint the position (must be in same space as current mesh) to look at
  14387. * @param yawCor optional yaw (y-axis) correction in radians
  14388. * @param pitchCor optional pitch (x-axis) correction in radians
  14389. * @param rollCor optional roll (z-axis) correction in radians
  14390. * @param space the choosen space of the target
  14391. * @returns the TransformNode.
  14392. */
  14393. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14394. /**
  14395. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14396. * This Vector3 is expressed in the World space.
  14397. * @param localAxis axis to rotate
  14398. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14399. */
  14400. getDirection(localAxis: Vector3): Vector3;
  14401. /**
  14402. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14403. * localAxis is expressed in the mesh local space.
  14404. * result is computed in the Wordl space from the mesh World matrix.
  14405. * @param localAxis axis to rotate
  14406. * @param result the resulting transformnode
  14407. * @returns this TransformNode.
  14408. */
  14409. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14410. /**
  14411. * Sets this transform node rotation to the given local axis.
  14412. * @param localAxis the axis in local space
  14413. * @param yawCor optional yaw (y-axis) correction in radians
  14414. * @param pitchCor optional pitch (x-axis) correction in radians
  14415. * @param rollCor optional roll (z-axis) correction in radians
  14416. * @returns this TransformNode
  14417. */
  14418. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14419. /**
  14420. * Sets a new pivot point to the current node
  14421. * @param point defines the new pivot point to use
  14422. * @param space defines if the point is in world or local space (local by default)
  14423. * @returns the current TransformNode
  14424. */
  14425. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14426. /**
  14427. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14428. * @returns the pivot point
  14429. */
  14430. getPivotPoint(): Vector3;
  14431. /**
  14432. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14433. * @param result the vector3 to store the result
  14434. * @returns this TransformNode.
  14435. */
  14436. getPivotPointToRef(result: Vector3): TransformNode;
  14437. /**
  14438. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14439. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14440. */
  14441. getAbsolutePivotPoint(): Vector3;
  14442. /**
  14443. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14444. * @param result vector3 to store the result
  14445. * @returns this TransformNode.
  14446. */
  14447. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14448. /**
  14449. * Defines the passed node as the parent of the current node.
  14450. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14451. * @see https://doc.babylonjs.com/how_to/parenting
  14452. * @param node the node ot set as the parent
  14453. * @returns this TransformNode.
  14454. */
  14455. setParent(node: Nullable<Node>): TransformNode;
  14456. private _nonUniformScaling;
  14457. /**
  14458. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14459. */
  14460. get nonUniformScaling(): boolean;
  14461. /** @hidden */
  14462. _updateNonUniformScalingState(value: boolean): boolean;
  14463. /**
  14464. * Attach the current TransformNode to another TransformNode associated with a bone
  14465. * @param bone Bone affecting the TransformNode
  14466. * @param affectedTransformNode TransformNode associated with the bone
  14467. * @returns this object
  14468. */
  14469. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14470. /**
  14471. * Detach the transform node if its associated with a bone
  14472. * @returns this object
  14473. */
  14474. detachFromBone(): TransformNode;
  14475. private static _rotationAxisCache;
  14476. /**
  14477. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14478. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14479. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14480. * The passed axis is also normalized.
  14481. * @param axis the axis to rotate around
  14482. * @param amount the amount to rotate in radians
  14483. * @param space Space to rotate in (Default: local)
  14484. * @returns the TransformNode.
  14485. */
  14486. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14487. /**
  14488. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14489. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14490. * The passed axis is also normalized. .
  14491. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14492. * @param point the point to rotate around
  14493. * @param axis the axis to rotate around
  14494. * @param amount the amount to rotate in radians
  14495. * @returns the TransformNode
  14496. */
  14497. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14498. /**
  14499. * Translates the mesh along the axis vector for the passed distance in the given space.
  14500. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14501. * @param axis the axis to translate in
  14502. * @param distance the distance to translate
  14503. * @param space Space to rotate in (Default: local)
  14504. * @returns the TransformNode.
  14505. */
  14506. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14507. /**
  14508. * Adds a rotation step to the mesh current rotation.
  14509. * x, y, z are Euler angles expressed in radians.
  14510. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14511. * This means this rotation is made in the mesh local space only.
  14512. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14513. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14514. * ```javascript
  14515. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14516. * ```
  14517. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14518. * 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.
  14519. * @param x Rotation to add
  14520. * @param y Rotation to add
  14521. * @param z Rotation to add
  14522. * @returns the TransformNode.
  14523. */
  14524. addRotation(x: number, y: number, z: number): TransformNode;
  14525. /**
  14526. * @hidden
  14527. */
  14528. protected _getEffectiveParent(): Nullable<Node>;
  14529. /**
  14530. * Computes the world matrix of the node
  14531. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14532. * @returns the world matrix
  14533. */
  14534. computeWorldMatrix(force?: boolean): Matrix;
  14535. /**
  14536. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14537. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14538. */
  14539. resetLocalMatrix(independentOfChildren?: boolean): void;
  14540. protected _afterComputeWorldMatrix(): void;
  14541. /**
  14542. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14543. * @param func callback function to add
  14544. *
  14545. * @returns the TransformNode.
  14546. */
  14547. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14548. /**
  14549. * Removes a registered callback function.
  14550. * @param func callback function to remove
  14551. * @returns the TransformNode.
  14552. */
  14553. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14554. /**
  14555. * Gets the position of the current mesh in camera space
  14556. * @param camera defines the camera to use
  14557. * @returns a position
  14558. */
  14559. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14560. /**
  14561. * Returns the distance from the mesh to the active camera
  14562. * @param camera defines the camera to use
  14563. * @returns the distance
  14564. */
  14565. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14566. /**
  14567. * Clone the current transform node
  14568. * @param name Name of the new clone
  14569. * @param newParent New parent for the clone
  14570. * @param doNotCloneChildren Do not clone children hierarchy
  14571. * @returns the new transform node
  14572. */
  14573. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14574. /**
  14575. * Serializes the objects information.
  14576. * @param currentSerializationObject defines the object to serialize in
  14577. * @returns the serialized object
  14578. */
  14579. serialize(currentSerializationObject?: any): any;
  14580. /**
  14581. * Returns a new TransformNode object parsed from the source provided.
  14582. * @param parsedTransformNode is the source.
  14583. * @param scene the scne the object belongs to
  14584. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14585. * @returns a new TransformNode object parsed from the source provided.
  14586. */
  14587. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14588. /**
  14589. * Get all child-transformNodes of this node
  14590. * @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
  14591. * @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
  14592. * @returns an array of TransformNode
  14593. */
  14594. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14595. /**
  14596. * Releases resources associated with this transform node.
  14597. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14598. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14599. */
  14600. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14601. /**
  14602. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14603. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14604. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14605. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14606. * @returns the current mesh
  14607. */
  14608. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14609. private _syncAbsoluteScalingAndRotation;
  14610. }
  14611. }
  14612. declare module BABYLON {
  14613. /**
  14614. * Defines the types of pose enabled controllers that are supported
  14615. */
  14616. export enum PoseEnabledControllerType {
  14617. /**
  14618. * HTC Vive
  14619. */
  14620. VIVE = 0,
  14621. /**
  14622. * Oculus Rift
  14623. */
  14624. OCULUS = 1,
  14625. /**
  14626. * Windows mixed reality
  14627. */
  14628. WINDOWS = 2,
  14629. /**
  14630. * Samsung gear VR
  14631. */
  14632. GEAR_VR = 3,
  14633. /**
  14634. * Google Daydream
  14635. */
  14636. DAYDREAM = 4,
  14637. /**
  14638. * Generic
  14639. */
  14640. GENERIC = 5
  14641. }
  14642. /**
  14643. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14644. */
  14645. export interface MutableGamepadButton {
  14646. /**
  14647. * Value of the button/trigger
  14648. */
  14649. value: number;
  14650. /**
  14651. * If the button/trigger is currently touched
  14652. */
  14653. touched: boolean;
  14654. /**
  14655. * If the button/trigger is currently pressed
  14656. */
  14657. pressed: boolean;
  14658. }
  14659. /**
  14660. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14661. * @hidden
  14662. */
  14663. export interface ExtendedGamepadButton extends GamepadButton {
  14664. /**
  14665. * If the button/trigger is currently pressed
  14666. */
  14667. readonly pressed: boolean;
  14668. /**
  14669. * If the button/trigger is currently touched
  14670. */
  14671. readonly touched: boolean;
  14672. /**
  14673. * Value of the button/trigger
  14674. */
  14675. readonly value: number;
  14676. }
  14677. /** @hidden */
  14678. export interface _GamePadFactory {
  14679. /**
  14680. * Returns wether or not the current gamepad can be created for this type of controller.
  14681. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14682. * @returns true if it can be created, otherwise false
  14683. */
  14684. canCreate(gamepadInfo: any): boolean;
  14685. /**
  14686. * Creates a new instance of the Gamepad.
  14687. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14688. * @returns the new gamepad instance
  14689. */
  14690. create(gamepadInfo: any): Gamepad;
  14691. }
  14692. /**
  14693. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14694. */
  14695. export class PoseEnabledControllerHelper {
  14696. /** @hidden */
  14697. static _ControllerFactories: _GamePadFactory[];
  14698. /** @hidden */
  14699. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14700. /**
  14701. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14702. * @param vrGamepad the gamepad to initialized
  14703. * @returns a vr controller of the type the gamepad identified as
  14704. */
  14705. static InitiateController(vrGamepad: any): Gamepad;
  14706. }
  14707. /**
  14708. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14709. */
  14710. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14711. /**
  14712. * If the controller is used in a webXR session
  14713. */
  14714. isXR: boolean;
  14715. private _deviceRoomPosition;
  14716. private _deviceRoomRotationQuaternion;
  14717. /**
  14718. * The device position in babylon space
  14719. */
  14720. devicePosition: Vector3;
  14721. /**
  14722. * The device rotation in babylon space
  14723. */
  14724. deviceRotationQuaternion: Quaternion;
  14725. /**
  14726. * The scale factor of the device in babylon space
  14727. */
  14728. deviceScaleFactor: number;
  14729. /**
  14730. * (Likely devicePosition should be used instead) The device position in its room space
  14731. */
  14732. position: Vector3;
  14733. /**
  14734. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14735. */
  14736. rotationQuaternion: Quaternion;
  14737. /**
  14738. * The type of controller (Eg. Windows mixed reality)
  14739. */
  14740. controllerType: PoseEnabledControllerType;
  14741. protected _calculatedPosition: Vector3;
  14742. private _calculatedRotation;
  14743. /**
  14744. * The raw pose from the device
  14745. */
  14746. rawPose: DevicePose;
  14747. private _trackPosition;
  14748. private _maxRotationDistFromHeadset;
  14749. private _draggedRoomRotation;
  14750. /**
  14751. * @hidden
  14752. */
  14753. _disableTrackPosition(fixedPosition: Vector3): void;
  14754. /**
  14755. * Internal, the mesh attached to the controller
  14756. * @hidden
  14757. */
  14758. _mesh: Nullable<AbstractMesh>;
  14759. private _poseControlledCamera;
  14760. private _leftHandSystemQuaternion;
  14761. /**
  14762. * Internal, matrix used to convert room space to babylon space
  14763. * @hidden
  14764. */
  14765. _deviceToWorld: Matrix;
  14766. /**
  14767. * Node to be used when casting a ray from the controller
  14768. * @hidden
  14769. */
  14770. _pointingPoseNode: Nullable<TransformNode>;
  14771. /**
  14772. * Name of the child mesh that can be used to cast a ray from the controller
  14773. */
  14774. static readonly POINTING_POSE: string;
  14775. /**
  14776. * Creates a new PoseEnabledController from a gamepad
  14777. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14778. */
  14779. constructor(browserGamepad: any);
  14780. private _workingMatrix;
  14781. /**
  14782. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14783. */
  14784. update(): void;
  14785. /**
  14786. * Updates only the pose device and mesh without doing any button event checking
  14787. */
  14788. protected _updatePoseAndMesh(): void;
  14789. /**
  14790. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14791. * @param poseData raw pose fromthe device
  14792. */
  14793. updateFromDevice(poseData: DevicePose): void;
  14794. /**
  14795. * @hidden
  14796. */
  14797. _meshAttachedObservable: Observable<AbstractMesh>;
  14798. /**
  14799. * Attaches a mesh to the controller
  14800. * @param mesh the mesh to be attached
  14801. */
  14802. attachToMesh(mesh: AbstractMesh): void;
  14803. /**
  14804. * Attaches the controllers mesh to a camera
  14805. * @param camera the camera the mesh should be attached to
  14806. */
  14807. attachToPoseControlledCamera(camera: TargetCamera): void;
  14808. /**
  14809. * Disposes of the controller
  14810. */
  14811. dispose(): void;
  14812. /**
  14813. * The mesh that is attached to the controller
  14814. */
  14815. get mesh(): Nullable<AbstractMesh>;
  14816. /**
  14817. * Gets the ray of the controller in the direction the controller is pointing
  14818. * @param length the length the resulting ray should be
  14819. * @returns a ray in the direction the controller is pointing
  14820. */
  14821. getForwardRay(length?: number): Ray;
  14822. }
  14823. }
  14824. declare module BABYLON {
  14825. /**
  14826. * Defines the WebVRController object that represents controllers tracked in 3D space
  14827. */
  14828. export abstract class WebVRController extends PoseEnabledController {
  14829. /**
  14830. * Internal, the default controller model for the controller
  14831. */
  14832. protected _defaultModel: Nullable<AbstractMesh>;
  14833. /**
  14834. * Fired when the trigger state has changed
  14835. */
  14836. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14837. /**
  14838. * Fired when the main button state has changed
  14839. */
  14840. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14841. /**
  14842. * Fired when the secondary button state has changed
  14843. */
  14844. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14845. /**
  14846. * Fired when the pad state has changed
  14847. */
  14848. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14849. /**
  14850. * Fired when controllers stick values have changed
  14851. */
  14852. onPadValuesChangedObservable: Observable<StickValues>;
  14853. /**
  14854. * Array of button availible on the controller
  14855. */
  14856. protected _buttons: Array<MutableGamepadButton>;
  14857. private _onButtonStateChange;
  14858. /**
  14859. * Fired when a controller button's state has changed
  14860. * @param callback the callback containing the button that was modified
  14861. */
  14862. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14863. /**
  14864. * X and Y axis corresponding to the controllers joystick
  14865. */
  14866. pad: StickValues;
  14867. /**
  14868. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14869. */
  14870. hand: string;
  14871. /**
  14872. * The default controller model for the controller
  14873. */
  14874. get defaultModel(): Nullable<AbstractMesh>;
  14875. /**
  14876. * Creates a new WebVRController from a gamepad
  14877. * @param vrGamepad the gamepad that the WebVRController should be created from
  14878. */
  14879. constructor(vrGamepad: any);
  14880. /**
  14881. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14882. */
  14883. update(): void;
  14884. /**
  14885. * Function to be called when a button is modified
  14886. */
  14887. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14888. /**
  14889. * Loads a mesh and attaches it to the controller
  14890. * @param scene the scene the mesh should be added to
  14891. * @param meshLoaded callback for when the mesh has been loaded
  14892. */
  14893. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14894. private _setButtonValue;
  14895. private _changes;
  14896. private _checkChanges;
  14897. /**
  14898. * Disposes of th webVRCOntroller
  14899. */
  14900. dispose(): void;
  14901. }
  14902. }
  14903. declare module BABYLON {
  14904. /**
  14905. * The HemisphericLight simulates the ambient environment light,
  14906. * so the passed direction is the light reflection direction, not the incoming direction.
  14907. */
  14908. export class HemisphericLight extends Light {
  14909. /**
  14910. * The groundColor is the light in the opposite direction to the one specified during creation.
  14911. * 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.
  14912. */
  14913. groundColor: Color3;
  14914. /**
  14915. * The light reflection direction, not the incoming direction.
  14916. */
  14917. direction: Vector3;
  14918. /**
  14919. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14920. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14921. * The HemisphericLight can't cast shadows.
  14922. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14923. * @param name The friendly name of the light
  14924. * @param direction The direction of the light reflection
  14925. * @param scene The scene the light belongs to
  14926. */
  14927. constructor(name: string, direction: Vector3, scene: Scene);
  14928. protected _buildUniformLayout(): void;
  14929. /**
  14930. * Returns the string "HemisphericLight".
  14931. * @return The class name
  14932. */
  14933. getClassName(): string;
  14934. /**
  14935. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14936. * Returns the updated direction.
  14937. * @param target The target the direction should point to
  14938. * @return The computed direction
  14939. */
  14940. setDirectionToTarget(target: Vector3): Vector3;
  14941. /**
  14942. * Returns the shadow generator associated to the light.
  14943. * @returns Always null for hemispheric lights because it does not support shadows.
  14944. */
  14945. getShadowGenerator(): Nullable<IShadowGenerator>;
  14946. /**
  14947. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14948. * @param effect The effect to update
  14949. * @param lightIndex The index of the light in the effect to update
  14950. * @returns The hemispheric light
  14951. */
  14952. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14953. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14954. /**
  14955. * Computes the world matrix of the node
  14956. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14957. * @param useWasUpdatedFlag defines a reserved property
  14958. * @returns the world matrix
  14959. */
  14960. computeWorldMatrix(): Matrix;
  14961. /**
  14962. * Returns the integer 3.
  14963. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14964. */
  14965. getTypeID(): number;
  14966. /**
  14967. * Prepares the list of defines specific to the light type.
  14968. * @param defines the list of defines
  14969. * @param lightIndex defines the index of the light for the effect
  14970. */
  14971. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14972. }
  14973. }
  14974. declare module BABYLON {
  14975. /** @hidden */
  14976. export var vrMultiviewToSingleviewPixelShader: {
  14977. name: string;
  14978. shader: string;
  14979. };
  14980. }
  14981. declare module BABYLON {
  14982. /**
  14983. * Renders to multiple views with a single draw call
  14984. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14985. */
  14986. export class MultiviewRenderTarget extends RenderTargetTexture {
  14987. /**
  14988. * Creates a multiview render target
  14989. * @param scene scene used with the render target
  14990. * @param size the size of the render target (used for each view)
  14991. */
  14992. constructor(scene: Scene, size?: number | {
  14993. width: number;
  14994. height: number;
  14995. } | {
  14996. ratio: number;
  14997. });
  14998. /**
  14999. * @hidden
  15000. * @param faceIndex the face index, if its a cube texture
  15001. */
  15002. _bindFrameBuffer(faceIndex?: number): void;
  15003. /**
  15004. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15005. * @returns the view count
  15006. */
  15007. getViewCount(): number;
  15008. }
  15009. }
  15010. declare module BABYLON {
  15011. /**
  15012. * Represents a camera frustum
  15013. */
  15014. export class Frustum {
  15015. /**
  15016. * Gets the planes representing the frustum
  15017. * @param transform matrix to be applied to the returned planes
  15018. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15019. */
  15020. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15021. /**
  15022. * Gets the near frustum plane transformed by the transform matrix
  15023. * @param transform transformation matrix to be applied to the resulting frustum plane
  15024. * @param frustumPlane the resuling frustum plane
  15025. */
  15026. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15027. /**
  15028. * Gets the far frustum plane transformed by the transform matrix
  15029. * @param transform transformation matrix to be applied to the resulting frustum plane
  15030. * @param frustumPlane the resuling frustum plane
  15031. */
  15032. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15033. /**
  15034. * Gets the left frustum plane transformed by the transform matrix
  15035. * @param transform transformation matrix to be applied to the resulting frustum plane
  15036. * @param frustumPlane the resuling frustum plane
  15037. */
  15038. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15039. /**
  15040. * Gets the right frustum plane transformed by the transform matrix
  15041. * @param transform transformation matrix to be applied to the resulting frustum plane
  15042. * @param frustumPlane the resuling frustum plane
  15043. */
  15044. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15045. /**
  15046. * Gets the top frustum plane transformed by the transform matrix
  15047. * @param transform transformation matrix to be applied to the resulting frustum plane
  15048. * @param frustumPlane the resuling frustum plane
  15049. */
  15050. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15051. /**
  15052. * Gets the bottom frustum plane transformed by the transform matrix
  15053. * @param transform transformation matrix to be applied to the resulting frustum plane
  15054. * @param frustumPlane the resuling frustum plane
  15055. */
  15056. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15057. /**
  15058. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15059. * @param transform transformation matrix to be applied to the resulting frustum planes
  15060. * @param frustumPlanes the resuling frustum planes
  15061. */
  15062. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15063. }
  15064. }
  15065. declare module BABYLON {
  15066. interface Engine {
  15067. /**
  15068. * Creates a new multiview render target
  15069. * @param width defines the width of the texture
  15070. * @param height defines the height of the texture
  15071. * @returns the created multiview texture
  15072. */
  15073. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15074. /**
  15075. * Binds a multiview framebuffer to be drawn to
  15076. * @param multiviewTexture texture to bind
  15077. */
  15078. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15079. }
  15080. interface Camera {
  15081. /**
  15082. * @hidden
  15083. * 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)
  15084. */
  15085. _useMultiviewToSingleView: boolean;
  15086. /**
  15087. * @hidden
  15088. * 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)
  15089. */
  15090. _multiviewTexture: Nullable<RenderTargetTexture>;
  15091. /**
  15092. * @hidden
  15093. * ensures the multiview texture of the camera exists and has the specified width/height
  15094. * @param width height to set on the multiview texture
  15095. * @param height width to set on the multiview texture
  15096. */
  15097. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15098. }
  15099. interface Scene {
  15100. /** @hidden */
  15101. _transformMatrixR: Matrix;
  15102. /** @hidden */
  15103. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15104. /** @hidden */
  15105. _createMultiviewUbo(): void;
  15106. /** @hidden */
  15107. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15108. /** @hidden */
  15109. _renderMultiviewToSingleView(camera: Camera): void;
  15110. }
  15111. }
  15112. declare module BABYLON {
  15113. /**
  15114. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15115. * This will not be used for webXR as it supports displaying texture arrays directly
  15116. */
  15117. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15118. /**
  15119. * Initializes a VRMultiviewToSingleview
  15120. * @param name name of the post process
  15121. * @param camera camera to be applied to
  15122. * @param scaleFactor scaling factor to the size of the output texture
  15123. */
  15124. constructor(name: string, camera: Camera, scaleFactor: number);
  15125. }
  15126. }
  15127. declare module BABYLON {
  15128. /**
  15129. * Interface used to define additional presentation attributes
  15130. */
  15131. export interface IVRPresentationAttributes {
  15132. /**
  15133. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15134. */
  15135. highRefreshRate: boolean;
  15136. /**
  15137. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15138. */
  15139. foveationLevel: number;
  15140. }
  15141. interface Engine {
  15142. /** @hidden */
  15143. _vrDisplay: any;
  15144. /** @hidden */
  15145. _vrSupported: boolean;
  15146. /** @hidden */
  15147. _oldSize: Size;
  15148. /** @hidden */
  15149. _oldHardwareScaleFactor: number;
  15150. /** @hidden */
  15151. _vrExclusivePointerMode: boolean;
  15152. /** @hidden */
  15153. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15154. /** @hidden */
  15155. _onVRDisplayPointerRestricted: () => void;
  15156. /** @hidden */
  15157. _onVRDisplayPointerUnrestricted: () => void;
  15158. /** @hidden */
  15159. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15160. /** @hidden */
  15161. _onVrDisplayDisconnect: Nullable<() => void>;
  15162. /** @hidden */
  15163. _onVrDisplayPresentChange: Nullable<() => void>;
  15164. /**
  15165. * Observable signaled when VR display mode changes
  15166. */
  15167. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15168. /**
  15169. * Observable signaled when VR request present is complete
  15170. */
  15171. onVRRequestPresentComplete: Observable<boolean>;
  15172. /**
  15173. * Observable signaled when VR request present starts
  15174. */
  15175. onVRRequestPresentStart: Observable<Engine>;
  15176. /**
  15177. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15178. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15179. */
  15180. isInVRExclusivePointerMode: boolean;
  15181. /**
  15182. * Gets a boolean indicating if a webVR device was detected
  15183. * @returns true if a webVR device was detected
  15184. */
  15185. isVRDevicePresent(): boolean;
  15186. /**
  15187. * Gets the current webVR device
  15188. * @returns the current webVR device (or null)
  15189. */
  15190. getVRDevice(): any;
  15191. /**
  15192. * Initializes a webVR display and starts listening to display change events
  15193. * The onVRDisplayChangedObservable will be notified upon these changes
  15194. * @returns A promise containing a VRDisplay and if vr is supported
  15195. */
  15196. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15197. /** @hidden */
  15198. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15199. /**
  15200. * Gets or sets the presentation attributes used to configure VR rendering
  15201. */
  15202. vrPresentationAttributes?: IVRPresentationAttributes;
  15203. /**
  15204. * Call this function to switch to webVR mode
  15205. * Will do nothing if webVR is not supported or if there is no webVR device
  15206. * @param options the webvr options provided to the camera. mainly used for multiview
  15207. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15208. */
  15209. enableVR(options: WebVROptions): void;
  15210. /** @hidden */
  15211. _onVRFullScreenTriggered(): void;
  15212. }
  15213. }
  15214. declare module BABYLON {
  15215. /**
  15216. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15217. * IMPORTANT!! The data is right-hand data.
  15218. * @export
  15219. * @interface DevicePose
  15220. */
  15221. export interface DevicePose {
  15222. /**
  15223. * The position of the device, values in array are [x,y,z].
  15224. */
  15225. readonly position: Nullable<Float32Array>;
  15226. /**
  15227. * The linearVelocity of the device, values in array are [x,y,z].
  15228. */
  15229. readonly linearVelocity: Nullable<Float32Array>;
  15230. /**
  15231. * The linearAcceleration of the device, values in array are [x,y,z].
  15232. */
  15233. readonly linearAcceleration: Nullable<Float32Array>;
  15234. /**
  15235. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15236. */
  15237. readonly orientation: Nullable<Float32Array>;
  15238. /**
  15239. * The angularVelocity of the device, values in array are [x,y,z].
  15240. */
  15241. readonly angularVelocity: Nullable<Float32Array>;
  15242. /**
  15243. * The angularAcceleration of the device, values in array are [x,y,z].
  15244. */
  15245. readonly angularAcceleration: Nullable<Float32Array>;
  15246. }
  15247. /**
  15248. * Interface representing a pose controlled object in Babylon.
  15249. * A pose controlled object has both regular pose values as well as pose values
  15250. * from an external device such as a VR head mounted display
  15251. */
  15252. export interface PoseControlled {
  15253. /**
  15254. * The position of the object in babylon space.
  15255. */
  15256. position: Vector3;
  15257. /**
  15258. * The rotation quaternion of the object in babylon space.
  15259. */
  15260. rotationQuaternion: Quaternion;
  15261. /**
  15262. * The position of the device in babylon space.
  15263. */
  15264. devicePosition?: Vector3;
  15265. /**
  15266. * The rotation quaternion of the device in babylon space.
  15267. */
  15268. deviceRotationQuaternion: Quaternion;
  15269. /**
  15270. * The raw pose coming from the device.
  15271. */
  15272. rawPose: Nullable<DevicePose>;
  15273. /**
  15274. * The scale of the device to be used when translating from device space to babylon space.
  15275. */
  15276. deviceScaleFactor: number;
  15277. /**
  15278. * Updates the poseControlled values based on the input device pose.
  15279. * @param poseData the pose data to update the object with
  15280. */
  15281. updateFromDevice(poseData: DevicePose): void;
  15282. }
  15283. /**
  15284. * Set of options to customize the webVRCamera
  15285. */
  15286. export interface WebVROptions {
  15287. /**
  15288. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15289. */
  15290. trackPosition?: boolean;
  15291. /**
  15292. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15293. */
  15294. positionScale?: number;
  15295. /**
  15296. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15297. */
  15298. displayName?: string;
  15299. /**
  15300. * Should the native controller meshes be initialized. (default: true)
  15301. */
  15302. controllerMeshes?: boolean;
  15303. /**
  15304. * Creating a default HemiLight only on controllers. (default: true)
  15305. */
  15306. defaultLightingOnControllers?: boolean;
  15307. /**
  15308. * If you don't want to use the default VR button of the helper. (default: false)
  15309. */
  15310. useCustomVRButton?: boolean;
  15311. /**
  15312. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15313. */
  15314. customVRButton?: HTMLButtonElement;
  15315. /**
  15316. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15317. */
  15318. rayLength?: number;
  15319. /**
  15320. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15321. */
  15322. defaultHeight?: number;
  15323. /**
  15324. * If multiview should be used if availible (default: false)
  15325. */
  15326. useMultiview?: boolean;
  15327. }
  15328. /**
  15329. * This represents a WebVR camera.
  15330. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15331. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15332. */
  15333. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15334. private webVROptions;
  15335. /**
  15336. * @hidden
  15337. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15338. */
  15339. _vrDevice: any;
  15340. /**
  15341. * The rawPose of the vrDevice.
  15342. */
  15343. rawPose: Nullable<DevicePose>;
  15344. private _onVREnabled;
  15345. private _specsVersion;
  15346. private _attached;
  15347. private _frameData;
  15348. protected _descendants: Array<Node>;
  15349. private _deviceRoomPosition;
  15350. /** @hidden */
  15351. _deviceRoomRotationQuaternion: Quaternion;
  15352. private _standingMatrix;
  15353. /**
  15354. * Represents device position in babylon space.
  15355. */
  15356. devicePosition: Vector3;
  15357. /**
  15358. * Represents device rotation in babylon space.
  15359. */
  15360. deviceRotationQuaternion: Quaternion;
  15361. /**
  15362. * The scale of the device to be used when translating from device space to babylon space.
  15363. */
  15364. deviceScaleFactor: number;
  15365. private _deviceToWorld;
  15366. private _worldToDevice;
  15367. /**
  15368. * References to the webVR controllers for the vrDevice.
  15369. */
  15370. controllers: Array<WebVRController>;
  15371. /**
  15372. * Emits an event when a controller is attached.
  15373. */
  15374. onControllersAttachedObservable: Observable<WebVRController[]>;
  15375. /**
  15376. * Emits an event when a controller's mesh has been loaded;
  15377. */
  15378. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15379. /**
  15380. * Emits an event when the HMD's pose has been updated.
  15381. */
  15382. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15383. private _poseSet;
  15384. /**
  15385. * If the rig cameras be used as parent instead of this camera.
  15386. */
  15387. rigParenting: boolean;
  15388. private _lightOnControllers;
  15389. private _defaultHeight?;
  15390. /**
  15391. * Instantiates a WebVRFreeCamera.
  15392. * @param name The name of the WebVRFreeCamera
  15393. * @param position The starting anchor position for the camera
  15394. * @param scene The scene the camera belongs to
  15395. * @param webVROptions a set of customizable options for the webVRCamera
  15396. */
  15397. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15398. /**
  15399. * Gets the device distance from the ground in meters.
  15400. * @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.
  15401. */
  15402. deviceDistanceToRoomGround(): number;
  15403. /**
  15404. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15405. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15406. */
  15407. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15408. /**
  15409. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15410. * @returns A promise with a boolean set to if the standing matrix is supported.
  15411. */
  15412. useStandingMatrixAsync(): Promise<boolean>;
  15413. /**
  15414. * Disposes the camera
  15415. */
  15416. dispose(): void;
  15417. /**
  15418. * Gets a vrController by name.
  15419. * @param name The name of the controller to retreive
  15420. * @returns the controller matching the name specified or null if not found
  15421. */
  15422. getControllerByName(name: string): Nullable<WebVRController>;
  15423. private _leftController;
  15424. /**
  15425. * The controller corresponding to the users left hand.
  15426. */
  15427. get leftController(): Nullable<WebVRController>;
  15428. private _rightController;
  15429. /**
  15430. * The controller corresponding to the users right hand.
  15431. */
  15432. get rightController(): Nullable<WebVRController>;
  15433. /**
  15434. * Casts a ray forward from the vrCamera's gaze.
  15435. * @param length Length of the ray (default: 100)
  15436. * @returns the ray corresponding to the gaze
  15437. */
  15438. getForwardRay(length?: number): Ray;
  15439. /**
  15440. * @hidden
  15441. * Updates the camera based on device's frame data
  15442. */
  15443. _checkInputs(): void;
  15444. /**
  15445. * Updates the poseControlled values based on the input device pose.
  15446. * @param poseData Pose coming from the device
  15447. */
  15448. updateFromDevice(poseData: DevicePose): void;
  15449. private _htmlElementAttached;
  15450. private _detachIfAttached;
  15451. /**
  15452. * WebVR's attach control will start broadcasting frames to the device.
  15453. * Note that in certain browsers (chrome for example) this function must be called
  15454. * within a user-interaction callback. Example:
  15455. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15456. *
  15457. * @param element html element to attach the vrDevice to
  15458. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15459. */
  15460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15461. /**
  15462. * Detaches the camera from the html element and disables VR
  15463. *
  15464. * @param element html element to detach from
  15465. */
  15466. detachControl(element: HTMLElement): void;
  15467. /**
  15468. * @returns the name of this class
  15469. */
  15470. getClassName(): string;
  15471. /**
  15472. * Calls resetPose on the vrDisplay
  15473. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15474. */
  15475. resetToCurrentRotation(): void;
  15476. /**
  15477. * @hidden
  15478. * Updates the rig cameras (left and right eye)
  15479. */
  15480. _updateRigCameras(): void;
  15481. private _workingVector;
  15482. private _oneVector;
  15483. private _workingMatrix;
  15484. private updateCacheCalled;
  15485. private _correctPositionIfNotTrackPosition;
  15486. /**
  15487. * @hidden
  15488. * Updates the cached values of the camera
  15489. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15490. */
  15491. _updateCache(ignoreParentClass?: boolean): void;
  15492. /**
  15493. * @hidden
  15494. * Get current device position in babylon world
  15495. */
  15496. _computeDevicePosition(): void;
  15497. /**
  15498. * Updates the current device position and rotation in the babylon world
  15499. */
  15500. update(): void;
  15501. /**
  15502. * @hidden
  15503. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15504. * @returns an identity matrix
  15505. */
  15506. _getViewMatrix(): Matrix;
  15507. private _tmpMatrix;
  15508. /**
  15509. * This function is called by the two RIG cameras.
  15510. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15511. * @hidden
  15512. */
  15513. _getWebVRViewMatrix(): Matrix;
  15514. /** @hidden */
  15515. _getWebVRProjectionMatrix(): Matrix;
  15516. private _onGamepadConnectedObserver;
  15517. private _onGamepadDisconnectedObserver;
  15518. private _updateCacheWhenTrackingDisabledObserver;
  15519. /**
  15520. * Initializes the controllers and their meshes
  15521. */
  15522. initControllers(): void;
  15523. }
  15524. }
  15525. declare module BABYLON {
  15526. /**
  15527. * Size options for a post process
  15528. */
  15529. export type PostProcessOptions = {
  15530. width: number;
  15531. height: number;
  15532. };
  15533. /**
  15534. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15535. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15536. */
  15537. export class PostProcess {
  15538. /** Name of the PostProcess. */
  15539. name: string;
  15540. /**
  15541. * Gets or sets the unique id of the post process
  15542. */
  15543. uniqueId: number;
  15544. /**
  15545. * Width of the texture to apply the post process on
  15546. */
  15547. width: number;
  15548. /**
  15549. * Height of the texture to apply the post process on
  15550. */
  15551. height: number;
  15552. /**
  15553. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15554. * @hidden
  15555. */
  15556. _outputTexture: Nullable<InternalTexture>;
  15557. /**
  15558. * Sampling mode used by the shader
  15559. * See https://doc.babylonjs.com/classes/3.1/texture
  15560. */
  15561. renderTargetSamplingMode: number;
  15562. /**
  15563. * Clear color to use when screen clearing
  15564. */
  15565. clearColor: Color4;
  15566. /**
  15567. * If the buffer needs to be cleared before applying the post process. (default: true)
  15568. * Should be set to false if shader will overwrite all previous pixels.
  15569. */
  15570. autoClear: boolean;
  15571. /**
  15572. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15573. */
  15574. alphaMode: number;
  15575. /**
  15576. * Sets the setAlphaBlendConstants of the babylon engine
  15577. */
  15578. alphaConstants: Color4;
  15579. /**
  15580. * Animations to be used for the post processing
  15581. */
  15582. animations: Animation[];
  15583. /**
  15584. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15585. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15586. */
  15587. enablePixelPerfectMode: boolean;
  15588. /**
  15589. * Force the postprocess to be applied without taking in account viewport
  15590. */
  15591. forceFullscreenViewport: boolean;
  15592. /**
  15593. * List of inspectable custom properties (used by the Inspector)
  15594. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15595. */
  15596. inspectableCustomProperties: IInspectable[];
  15597. /**
  15598. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15599. *
  15600. * | Value | Type | Description |
  15601. * | ----- | ----------------------------------- | ----------- |
  15602. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15603. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15604. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15605. *
  15606. */
  15607. scaleMode: number;
  15608. /**
  15609. * Force textures to be a power of two (default: false)
  15610. */
  15611. alwaysForcePOT: boolean;
  15612. private _samples;
  15613. /**
  15614. * Number of sample textures (default: 1)
  15615. */
  15616. get samples(): number;
  15617. set samples(n: number);
  15618. /**
  15619. * Modify the scale of the post process to be the same as the viewport (default: false)
  15620. */
  15621. adaptScaleToCurrentViewport: boolean;
  15622. private _camera;
  15623. private _scene;
  15624. private _engine;
  15625. private _options;
  15626. private _reusable;
  15627. private _textureType;
  15628. private _textureFormat;
  15629. /**
  15630. * Smart array of input and output textures for the post process.
  15631. * @hidden
  15632. */
  15633. _textures: SmartArray<InternalTexture>;
  15634. /**
  15635. * The index in _textures that corresponds to the output texture.
  15636. * @hidden
  15637. */
  15638. _currentRenderTextureInd: number;
  15639. private _effect;
  15640. private _samplers;
  15641. private _fragmentUrl;
  15642. private _vertexUrl;
  15643. private _parameters;
  15644. private _scaleRatio;
  15645. protected _indexParameters: any;
  15646. private _shareOutputWithPostProcess;
  15647. private _texelSize;
  15648. private _forcedOutputTexture;
  15649. /**
  15650. * Returns the fragment url or shader name used in the post process.
  15651. * @returns the fragment url or name in the shader store.
  15652. */
  15653. getEffectName(): string;
  15654. /**
  15655. * An event triggered when the postprocess is activated.
  15656. */
  15657. onActivateObservable: Observable<Camera>;
  15658. private _onActivateObserver;
  15659. /**
  15660. * A function that is added to the onActivateObservable
  15661. */
  15662. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15663. /**
  15664. * An event triggered when the postprocess changes its size.
  15665. */
  15666. onSizeChangedObservable: Observable<PostProcess>;
  15667. private _onSizeChangedObserver;
  15668. /**
  15669. * A function that is added to the onSizeChangedObservable
  15670. */
  15671. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15672. /**
  15673. * An event triggered when the postprocess applies its effect.
  15674. */
  15675. onApplyObservable: Observable<Effect>;
  15676. private _onApplyObserver;
  15677. /**
  15678. * A function that is added to the onApplyObservable
  15679. */
  15680. set onApply(callback: (effect: Effect) => void);
  15681. /**
  15682. * An event triggered before rendering the postprocess
  15683. */
  15684. onBeforeRenderObservable: Observable<Effect>;
  15685. private _onBeforeRenderObserver;
  15686. /**
  15687. * A function that is added to the onBeforeRenderObservable
  15688. */
  15689. set onBeforeRender(callback: (effect: Effect) => void);
  15690. /**
  15691. * An event triggered after rendering the postprocess
  15692. */
  15693. onAfterRenderObservable: Observable<Effect>;
  15694. private _onAfterRenderObserver;
  15695. /**
  15696. * A function that is added to the onAfterRenderObservable
  15697. */
  15698. set onAfterRender(callback: (efect: Effect) => void);
  15699. /**
  15700. * 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
  15701. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15702. */
  15703. get inputTexture(): InternalTexture;
  15704. set inputTexture(value: InternalTexture);
  15705. /**
  15706. * Gets the camera which post process is applied to.
  15707. * @returns The camera the post process is applied to.
  15708. */
  15709. getCamera(): Camera;
  15710. /**
  15711. * Gets the texel size of the postprocess.
  15712. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15713. */
  15714. get texelSize(): Vector2;
  15715. /**
  15716. * Creates a new instance PostProcess
  15717. * @param name The name of the PostProcess.
  15718. * @param fragmentUrl The url of the fragment shader to be used.
  15719. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15720. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15721. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15722. * @param camera The camera to apply the render pass to.
  15723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15724. * @param engine The engine which the post process will be applied. (default: current engine)
  15725. * @param reusable If the post process can be reused on the same frame. (default: false)
  15726. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15727. * @param textureType Type of textures used when performing the post process. (default: 0)
  15728. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15729. * @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
  15730. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15731. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  15732. */
  15733. constructor(
  15734. /** Name of the PostProcess. */
  15735. 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);
  15736. /**
  15737. * Gets a string idenfifying the name of the class
  15738. * @returns "PostProcess" string
  15739. */
  15740. getClassName(): string;
  15741. /**
  15742. * Gets the engine which this post process belongs to.
  15743. * @returns The engine the post process was enabled with.
  15744. */
  15745. getEngine(): Engine;
  15746. /**
  15747. * The effect that is created when initializing the post process.
  15748. * @returns The created effect corresponding the the postprocess.
  15749. */
  15750. getEffect(): Effect;
  15751. /**
  15752. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15753. * @param postProcess The post process to share the output with.
  15754. * @returns This post process.
  15755. */
  15756. shareOutputWith(postProcess: PostProcess): PostProcess;
  15757. /**
  15758. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15759. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15760. */
  15761. useOwnOutput(): void;
  15762. /**
  15763. * Updates the effect with the current post process compile time values and recompiles the shader.
  15764. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15765. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15766. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15767. * @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
  15768. * @param onCompiled Called when the shader has been compiled.
  15769. * @param onError Called if there is an error when compiling a shader.
  15770. */
  15771. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15772. /**
  15773. * The post process is reusable if it can be used multiple times within one frame.
  15774. * @returns If the post process is reusable
  15775. */
  15776. isReusable(): boolean;
  15777. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15778. markTextureDirty(): void;
  15779. /**
  15780. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15781. * 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.
  15782. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15783. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15784. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15785. * @returns The target texture that was bound to be written to.
  15786. */
  15787. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15788. /**
  15789. * If the post process is supported.
  15790. */
  15791. get isSupported(): boolean;
  15792. /**
  15793. * The aspect ratio of the output texture.
  15794. */
  15795. get aspectRatio(): number;
  15796. /**
  15797. * Get a value indicating if the post-process is ready to be used
  15798. * @returns true if the post-process is ready (shader is compiled)
  15799. */
  15800. isReady(): boolean;
  15801. /**
  15802. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15803. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15804. */
  15805. apply(): Nullable<Effect>;
  15806. private _disposeTextures;
  15807. /**
  15808. * Disposes the post process.
  15809. * @param camera The camera to dispose the post process on.
  15810. */
  15811. dispose(camera?: Camera): void;
  15812. }
  15813. }
  15814. declare module BABYLON {
  15815. /** @hidden */
  15816. export var kernelBlurVaryingDeclaration: {
  15817. name: string;
  15818. shader: string;
  15819. };
  15820. }
  15821. declare module BABYLON {
  15822. /** @hidden */
  15823. export var kernelBlurFragment: {
  15824. name: string;
  15825. shader: string;
  15826. };
  15827. }
  15828. declare module BABYLON {
  15829. /** @hidden */
  15830. export var kernelBlurFragment2: {
  15831. name: string;
  15832. shader: string;
  15833. };
  15834. }
  15835. declare module BABYLON {
  15836. /** @hidden */
  15837. export var kernelBlurPixelShader: {
  15838. name: string;
  15839. shader: string;
  15840. };
  15841. }
  15842. declare module BABYLON {
  15843. /** @hidden */
  15844. export var kernelBlurVertex: {
  15845. name: string;
  15846. shader: string;
  15847. };
  15848. }
  15849. declare module BABYLON {
  15850. /** @hidden */
  15851. export var kernelBlurVertexShader: {
  15852. name: string;
  15853. shader: string;
  15854. };
  15855. }
  15856. declare module BABYLON {
  15857. /**
  15858. * The Blur Post Process which blurs an image based on a kernel and direction.
  15859. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15860. */
  15861. export class BlurPostProcess extends PostProcess {
  15862. /** The direction in which to blur the image. */
  15863. direction: Vector2;
  15864. private blockCompilation;
  15865. protected _kernel: number;
  15866. protected _idealKernel: number;
  15867. protected _packedFloat: boolean;
  15868. private _staticDefines;
  15869. /**
  15870. * Sets the length in pixels of the blur sample region
  15871. */
  15872. set kernel(v: number);
  15873. /**
  15874. * Gets the length in pixels of the blur sample region
  15875. */
  15876. get kernel(): number;
  15877. /**
  15878. * Sets wether or not the blur needs to unpack/repack floats
  15879. */
  15880. set packedFloat(v: boolean);
  15881. /**
  15882. * Gets wether or not the blur is unpacking/repacking floats
  15883. */
  15884. get packedFloat(): boolean;
  15885. /**
  15886. * Creates a new instance BlurPostProcess
  15887. * @param name The name of the effect.
  15888. * @param direction The direction in which to blur the image.
  15889. * @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.
  15890. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15891. * @param camera The camera to apply the render pass to.
  15892. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15893. * @param engine The engine which the post process will be applied. (default: current engine)
  15894. * @param reusable If the post process can be reused on the same frame. (default: false)
  15895. * @param textureType Type of textures used when performing the post process. (default: 0)
  15896. * @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)
  15897. */
  15898. constructor(name: string,
  15899. /** The direction in which to blur the image. */
  15900. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15901. /**
  15902. * Updates the effect with the current post process compile time values and recompiles the shader.
  15903. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15904. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15905. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15906. * @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
  15907. * @param onCompiled Called when the shader has been compiled.
  15908. * @param onError Called if there is an error when compiling a shader.
  15909. */
  15910. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15911. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15912. /**
  15913. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15914. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15915. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15916. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15917. * The gaps between physical kernels are compensated for in the weighting of the samples
  15918. * @param idealKernel Ideal blur kernel.
  15919. * @return Nearest best kernel.
  15920. */
  15921. protected _nearestBestKernel(idealKernel: number): number;
  15922. /**
  15923. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15924. * @param x The point on the Gaussian distribution to sample.
  15925. * @return the value of the Gaussian function at x.
  15926. */
  15927. protected _gaussianWeight(x: number): number;
  15928. /**
  15929. * Generates a string that can be used as a floating point number in GLSL.
  15930. * @param x Value to print.
  15931. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15932. * @return GLSL float string.
  15933. */
  15934. protected _glslFloat(x: number, decimalFigures?: number): string;
  15935. }
  15936. }
  15937. declare module BABYLON {
  15938. /**
  15939. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15940. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15941. * You can then easily use it as a reflectionTexture on a flat surface.
  15942. * In case the surface is not a plane, please consider relying on reflection probes.
  15943. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15944. */
  15945. export class MirrorTexture extends RenderTargetTexture {
  15946. private scene;
  15947. /**
  15948. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15949. * 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.
  15950. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15951. */
  15952. mirrorPlane: Plane;
  15953. /**
  15954. * Define the blur ratio used to blur the reflection if needed.
  15955. */
  15956. set blurRatio(value: number);
  15957. get blurRatio(): number;
  15958. /**
  15959. * Define the adaptive blur kernel used to blur the reflection if needed.
  15960. * This will autocompute the closest best match for the `blurKernel`
  15961. */
  15962. set adaptiveBlurKernel(value: number);
  15963. /**
  15964. * Define the blur kernel used to blur the reflection if needed.
  15965. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15966. */
  15967. set blurKernel(value: number);
  15968. /**
  15969. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15970. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15971. */
  15972. set blurKernelX(value: number);
  15973. get blurKernelX(): number;
  15974. /**
  15975. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15976. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15977. */
  15978. set blurKernelY(value: number);
  15979. get blurKernelY(): number;
  15980. private _autoComputeBlurKernel;
  15981. protected _onRatioRescale(): void;
  15982. private _updateGammaSpace;
  15983. private _imageProcessingConfigChangeObserver;
  15984. private _transformMatrix;
  15985. private _mirrorMatrix;
  15986. private _savedViewMatrix;
  15987. private _blurX;
  15988. private _blurY;
  15989. private _adaptiveBlurKernel;
  15990. private _blurKernelX;
  15991. private _blurKernelY;
  15992. private _blurRatio;
  15993. /**
  15994. * Instantiates a Mirror Texture.
  15995. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15996. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15997. * You can then easily use it as a reflectionTexture on a flat surface.
  15998. * In case the surface is not a plane, please consider relying on reflection probes.
  15999. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16000. * @param name
  16001. * @param size
  16002. * @param scene
  16003. * @param generateMipMaps
  16004. * @param type
  16005. * @param samplingMode
  16006. * @param generateDepthBuffer
  16007. */
  16008. constructor(name: string, size: number | {
  16009. width: number;
  16010. height: number;
  16011. } | {
  16012. ratio: number;
  16013. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16014. private _preparePostProcesses;
  16015. /**
  16016. * Clone the mirror texture.
  16017. * @returns the cloned texture
  16018. */
  16019. clone(): MirrorTexture;
  16020. /**
  16021. * Serialize the texture to a JSON representation you could use in Parse later on
  16022. * @returns the serialized JSON representation
  16023. */
  16024. serialize(): any;
  16025. /**
  16026. * Dispose the texture and release its associated resources.
  16027. */
  16028. dispose(): void;
  16029. }
  16030. }
  16031. declare module BABYLON {
  16032. /**
  16033. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16034. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16035. */
  16036. export class Texture extends BaseTexture {
  16037. /**
  16038. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16039. */
  16040. static SerializeBuffers: boolean;
  16041. /** @hidden */
  16042. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  16043. /** @hidden */
  16044. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  16045. /** @hidden */
  16046. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  16047. /** nearest is mag = nearest and min = nearest and mip = linear */
  16048. static readonly NEAREST_SAMPLINGMODE: number;
  16049. /** nearest is mag = nearest and min = nearest and mip = linear */
  16050. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16051. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16052. static readonly BILINEAR_SAMPLINGMODE: number;
  16053. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16054. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16055. /** Trilinear is mag = linear and min = linear and mip = linear */
  16056. static readonly TRILINEAR_SAMPLINGMODE: number;
  16057. /** Trilinear is mag = linear and min = linear and mip = linear */
  16058. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16059. /** mag = nearest and min = nearest and mip = nearest */
  16060. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16061. /** mag = nearest and min = linear and mip = nearest */
  16062. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16063. /** mag = nearest and min = linear and mip = linear */
  16064. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16065. /** mag = nearest and min = linear and mip = none */
  16066. static readonly NEAREST_LINEAR: number;
  16067. /** mag = nearest and min = nearest and mip = none */
  16068. static readonly NEAREST_NEAREST: number;
  16069. /** mag = linear and min = nearest and mip = nearest */
  16070. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16071. /** mag = linear and min = nearest and mip = linear */
  16072. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16073. /** mag = linear and min = linear and mip = none */
  16074. static readonly LINEAR_LINEAR: number;
  16075. /** mag = linear and min = nearest and mip = none */
  16076. static readonly LINEAR_NEAREST: number;
  16077. /** Explicit coordinates mode */
  16078. static readonly EXPLICIT_MODE: number;
  16079. /** Spherical coordinates mode */
  16080. static readonly SPHERICAL_MODE: number;
  16081. /** Planar coordinates mode */
  16082. static readonly PLANAR_MODE: number;
  16083. /** Cubic coordinates mode */
  16084. static readonly CUBIC_MODE: number;
  16085. /** Projection coordinates mode */
  16086. static readonly PROJECTION_MODE: number;
  16087. /** Inverse Cubic coordinates mode */
  16088. static readonly SKYBOX_MODE: number;
  16089. /** Inverse Cubic coordinates mode */
  16090. static readonly INVCUBIC_MODE: number;
  16091. /** Equirectangular coordinates mode */
  16092. static readonly EQUIRECTANGULAR_MODE: number;
  16093. /** Equirectangular Fixed coordinates mode */
  16094. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16095. /** Equirectangular Fixed Mirrored coordinates mode */
  16096. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16097. /** Texture is not repeating outside of 0..1 UVs */
  16098. static readonly CLAMP_ADDRESSMODE: number;
  16099. /** Texture is repeating outside of 0..1 UVs */
  16100. static readonly WRAP_ADDRESSMODE: number;
  16101. /** Texture is repeating and mirrored */
  16102. static readonly MIRROR_ADDRESSMODE: number;
  16103. /**
  16104. * 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
  16105. */
  16106. static UseSerializedUrlIfAny: boolean;
  16107. /**
  16108. * Define the url of the texture.
  16109. */
  16110. url: Nullable<string>;
  16111. /**
  16112. * Define an offset on the texture to offset the u coordinates of the UVs
  16113. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16114. */
  16115. uOffset: number;
  16116. /**
  16117. * Define an offset on the texture to offset the v coordinates of the UVs
  16118. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16119. */
  16120. vOffset: number;
  16121. /**
  16122. * Define an offset on the texture to scale the u coordinates of the UVs
  16123. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16124. */
  16125. uScale: number;
  16126. /**
  16127. * Define an offset on the texture to scale the v coordinates of the UVs
  16128. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16129. */
  16130. vScale: number;
  16131. /**
  16132. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16133. * @see http://doc.babylonjs.com/how_to/more_materials
  16134. */
  16135. uAng: number;
  16136. /**
  16137. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16138. * @see http://doc.babylonjs.com/how_to/more_materials
  16139. */
  16140. vAng: number;
  16141. /**
  16142. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16143. * @see http://doc.babylonjs.com/how_to/more_materials
  16144. */
  16145. wAng: number;
  16146. /**
  16147. * Defines the center of rotation (U)
  16148. */
  16149. uRotationCenter: number;
  16150. /**
  16151. * Defines the center of rotation (V)
  16152. */
  16153. vRotationCenter: number;
  16154. /**
  16155. * Defines the center of rotation (W)
  16156. */
  16157. wRotationCenter: number;
  16158. /**
  16159. * Are mip maps generated for this texture or not.
  16160. */
  16161. get noMipmap(): boolean;
  16162. /**
  16163. * List of inspectable custom properties (used by the Inspector)
  16164. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16165. */
  16166. inspectableCustomProperties: Nullable<IInspectable[]>;
  16167. private _noMipmap;
  16168. /** @hidden */
  16169. _invertY: boolean;
  16170. private _rowGenerationMatrix;
  16171. private _cachedTextureMatrix;
  16172. private _projectionModeMatrix;
  16173. private _t0;
  16174. private _t1;
  16175. private _t2;
  16176. private _cachedUOffset;
  16177. private _cachedVOffset;
  16178. private _cachedUScale;
  16179. private _cachedVScale;
  16180. private _cachedUAng;
  16181. private _cachedVAng;
  16182. private _cachedWAng;
  16183. private _cachedProjectionMatrixId;
  16184. private _cachedCoordinatesMode;
  16185. /** @hidden */
  16186. protected _initialSamplingMode: number;
  16187. /** @hidden */
  16188. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16189. private _deleteBuffer;
  16190. protected _format: Nullable<number>;
  16191. private _delayedOnLoad;
  16192. private _delayedOnError;
  16193. private _mimeType?;
  16194. /**
  16195. * Observable triggered once the texture has been loaded.
  16196. */
  16197. onLoadObservable: Observable<Texture>;
  16198. protected _isBlocking: boolean;
  16199. /**
  16200. * Is the texture preventing material to render while loading.
  16201. * If false, a default texture will be used instead of the loading one during the preparation step.
  16202. */
  16203. set isBlocking(value: boolean);
  16204. get isBlocking(): boolean;
  16205. /**
  16206. * Get the current sampling mode associated with the texture.
  16207. */
  16208. get samplingMode(): number;
  16209. /**
  16210. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16211. */
  16212. get invertY(): boolean;
  16213. /**
  16214. * Instantiates a new texture.
  16215. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16216. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16217. * @param url defines the url of the picture to load as a texture
  16218. * @param scene defines the scene or engine the texture will belong to
  16219. * @param noMipmap defines if the texture will require mip maps or not
  16220. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16221. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16222. * @param onLoad defines a callback triggered when the texture has been loaded
  16223. * @param onError defines a callback triggered when an error occurred during the loading session
  16224. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16225. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16226. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16227. * @param mimeType defines an optional mime type information
  16228. */
  16229. 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);
  16230. /**
  16231. * Update the url (and optional buffer) of this texture if url was null during construction.
  16232. * @param url the url of the texture
  16233. * @param buffer the buffer of the texture (defaults to null)
  16234. * @param onLoad callback called when the texture is loaded (defaults to null)
  16235. */
  16236. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16237. /**
  16238. * Finish the loading sequence of a texture flagged as delayed load.
  16239. * @hidden
  16240. */
  16241. delayLoad(): void;
  16242. private _prepareRowForTextureGeneration;
  16243. /**
  16244. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16245. * @returns the transform matrix of the texture.
  16246. */
  16247. getTextureMatrix(uBase?: number): Matrix;
  16248. /**
  16249. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16250. * @returns The reflection texture transform
  16251. */
  16252. getReflectionTextureMatrix(): Matrix;
  16253. /**
  16254. * Clones the texture.
  16255. * @returns the cloned texture
  16256. */
  16257. clone(): Texture;
  16258. /**
  16259. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16260. * @returns The JSON representation of the texture
  16261. */
  16262. serialize(): any;
  16263. /**
  16264. * Get the current class name of the texture useful for serialization or dynamic coding.
  16265. * @returns "Texture"
  16266. */
  16267. getClassName(): string;
  16268. /**
  16269. * Dispose the texture and release its associated resources.
  16270. */
  16271. dispose(): void;
  16272. /**
  16273. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16274. * @param parsedTexture Define the JSON representation of the texture
  16275. * @param scene Define the scene the parsed texture should be instantiated in
  16276. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16277. * @returns The parsed texture if successful
  16278. */
  16279. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16280. /**
  16281. * Creates a texture from its base 64 representation.
  16282. * @param data Define the base64 payload without the data: prefix
  16283. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16284. * @param scene Define the scene the texture should belong to
  16285. * @param noMipmap Forces the texture to not create mip map information if true
  16286. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16287. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16288. * @param onLoad define a callback triggered when the texture has been loaded
  16289. * @param onError define a callback triggered when an error occurred during the loading session
  16290. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16291. * @returns the created texture
  16292. */
  16293. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16294. /**
  16295. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16296. * @param data Define the base64 payload without the data: prefix
  16297. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16298. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16299. * @param scene Define the scene the texture should belong to
  16300. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16301. * @param noMipmap Forces the texture to not create mip map information if true
  16302. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16303. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16304. * @param onLoad define a callback triggered when the texture has been loaded
  16305. * @param onError define a callback triggered when an error occurred during the loading session
  16306. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16307. * @returns the created texture
  16308. */
  16309. 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;
  16310. }
  16311. }
  16312. declare module BABYLON {
  16313. /**
  16314. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16315. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16316. */
  16317. export class PostProcessManager {
  16318. private _scene;
  16319. private _indexBuffer;
  16320. private _vertexBuffers;
  16321. /**
  16322. * Creates a new instance PostProcess
  16323. * @param scene The scene that the post process is associated with.
  16324. */
  16325. constructor(scene: Scene);
  16326. private _prepareBuffers;
  16327. private _buildIndexBuffer;
  16328. /**
  16329. * Rebuilds the vertex buffers of the manager.
  16330. * @hidden
  16331. */
  16332. _rebuild(): void;
  16333. /**
  16334. * Prepares a frame to be run through a post process.
  16335. * @param sourceTexture The input texture to the post procesess. (default: null)
  16336. * @param postProcesses An array of post processes to be run. (default: null)
  16337. * @returns True if the post processes were able to be run.
  16338. * @hidden
  16339. */
  16340. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16341. /**
  16342. * Manually render a set of post processes to a texture.
  16343. * @param postProcesses An array of post processes to be run.
  16344. * @param targetTexture The target texture to render to.
  16345. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16346. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16347. * @param lodLevel defines which lod of the texture to render to
  16348. */
  16349. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16350. /**
  16351. * Finalize the result of the output of the postprocesses.
  16352. * @param doNotPresent If true the result will not be displayed to the screen.
  16353. * @param targetTexture The target texture to render to.
  16354. * @param faceIndex The index of the face to bind the target texture to.
  16355. * @param postProcesses The array of post processes to render.
  16356. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16357. * @hidden
  16358. */
  16359. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16360. /**
  16361. * Disposes of the post process manager.
  16362. */
  16363. dispose(): void;
  16364. }
  16365. }
  16366. declare module BABYLON {
  16367. /** Interface used by value gradients (color, factor, ...) */
  16368. export interface IValueGradient {
  16369. /**
  16370. * Gets or sets the gradient value (between 0 and 1)
  16371. */
  16372. gradient: number;
  16373. }
  16374. /** Class used to store color4 gradient */
  16375. export class ColorGradient implements IValueGradient {
  16376. /**
  16377. * Gets or sets the gradient value (between 0 and 1)
  16378. */
  16379. gradient: number;
  16380. /**
  16381. * Gets or sets first associated color
  16382. */
  16383. color1: Color4;
  16384. /**
  16385. * Gets or sets second associated color
  16386. */
  16387. color2?: Color4;
  16388. /**
  16389. * Will get a color picked randomly between color1 and color2.
  16390. * If color2 is undefined then color1 will be used
  16391. * @param result defines the target Color4 to store the result in
  16392. */
  16393. getColorToRef(result: Color4): void;
  16394. }
  16395. /** Class used to store color 3 gradient */
  16396. export class Color3Gradient implements IValueGradient {
  16397. /**
  16398. * Gets or sets the gradient value (between 0 and 1)
  16399. */
  16400. gradient: number;
  16401. /**
  16402. * Gets or sets the associated color
  16403. */
  16404. color: Color3;
  16405. }
  16406. /** Class used to store factor gradient */
  16407. export class FactorGradient implements IValueGradient {
  16408. /**
  16409. * Gets or sets the gradient value (between 0 and 1)
  16410. */
  16411. gradient: number;
  16412. /**
  16413. * Gets or sets first associated factor
  16414. */
  16415. factor1: number;
  16416. /**
  16417. * Gets or sets second associated factor
  16418. */
  16419. factor2?: number;
  16420. /**
  16421. * Will get a number picked randomly between factor1 and factor2.
  16422. * If factor2 is undefined then factor1 will be used
  16423. * @returns the picked number
  16424. */
  16425. getFactor(): number;
  16426. }
  16427. /**
  16428. * Helper used to simplify some generic gradient tasks
  16429. */
  16430. export class GradientHelper {
  16431. /**
  16432. * Gets the current gradient from an array of IValueGradient
  16433. * @param ratio defines the current ratio to get
  16434. * @param gradients defines the array of IValueGradient
  16435. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16436. */
  16437. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16438. }
  16439. }
  16440. declare module BABYLON {
  16441. interface ThinEngine {
  16442. /**
  16443. * Creates a dynamic texture
  16444. * @param width defines the width of the texture
  16445. * @param height defines the height of the texture
  16446. * @param generateMipMaps defines if the engine should generate the mip levels
  16447. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16448. * @returns the dynamic texture inside an InternalTexture
  16449. */
  16450. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16451. /**
  16452. * Update the content of a dynamic texture
  16453. * @param texture defines the texture to update
  16454. * @param canvas defines the canvas containing the source
  16455. * @param invertY defines if data must be stored with Y axis inverted
  16456. * @param premulAlpha defines if alpha is stored as premultiplied
  16457. * @param format defines the format of the data
  16458. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16459. */
  16460. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16461. }
  16462. }
  16463. declare module BABYLON {
  16464. /**
  16465. * Helper class used to generate a canvas to manipulate images
  16466. */
  16467. export class CanvasGenerator {
  16468. /**
  16469. * Create a new canvas (or offscreen canvas depending on the context)
  16470. * @param width defines the expected width
  16471. * @param height defines the expected height
  16472. * @return a new canvas or offscreen canvas
  16473. */
  16474. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16475. }
  16476. }
  16477. declare module BABYLON {
  16478. /**
  16479. * A class extending Texture allowing drawing on a texture
  16480. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16481. */
  16482. export class DynamicTexture extends Texture {
  16483. private _generateMipMaps;
  16484. private _canvas;
  16485. private _context;
  16486. private _engine;
  16487. /**
  16488. * Creates a DynamicTexture
  16489. * @param name defines the name of the texture
  16490. * @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
  16491. * @param scene defines the scene where you want the texture
  16492. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16493. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16494. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16495. */
  16496. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16497. /**
  16498. * Get the current class name of the texture useful for serialization or dynamic coding.
  16499. * @returns "DynamicTexture"
  16500. */
  16501. getClassName(): string;
  16502. /**
  16503. * Gets the current state of canRescale
  16504. */
  16505. get canRescale(): boolean;
  16506. private _recreate;
  16507. /**
  16508. * Scales the texture
  16509. * @param ratio the scale factor to apply to both width and height
  16510. */
  16511. scale(ratio: number): void;
  16512. /**
  16513. * Resizes the texture
  16514. * @param width the new width
  16515. * @param height the new height
  16516. */
  16517. scaleTo(width: number, height: number): void;
  16518. /**
  16519. * Gets the context of the canvas used by the texture
  16520. * @returns the canvas context of the dynamic texture
  16521. */
  16522. getContext(): CanvasRenderingContext2D;
  16523. /**
  16524. * Clears the texture
  16525. */
  16526. clear(): void;
  16527. /**
  16528. * Updates the texture
  16529. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16530. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16531. */
  16532. update(invertY?: boolean, premulAlpha?: boolean): void;
  16533. /**
  16534. * Draws text onto the texture
  16535. * @param text defines the text to be drawn
  16536. * @param x defines the placement of the text from the left
  16537. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16538. * @param font defines the font to be used with font-style, font-size, font-name
  16539. * @param color defines the color used for the text
  16540. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16541. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16542. * @param update defines whether texture is immediately update (default is true)
  16543. */
  16544. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16545. /**
  16546. * Clones the texture
  16547. * @returns the clone of the texture.
  16548. */
  16549. clone(): DynamicTexture;
  16550. /**
  16551. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16552. * @returns a serialized dynamic texture object
  16553. */
  16554. serialize(): any;
  16555. /** @hidden */
  16556. _rebuild(): void;
  16557. }
  16558. }
  16559. declare module BABYLON {
  16560. interface AbstractScene {
  16561. /**
  16562. * The list of procedural textures added to the scene
  16563. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16564. */
  16565. proceduralTextures: Array<ProceduralTexture>;
  16566. }
  16567. /**
  16568. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16569. * in a given scene.
  16570. */
  16571. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16572. /**
  16573. * The component name helpfull to identify the component in the list of scene components.
  16574. */
  16575. readonly name: string;
  16576. /**
  16577. * The scene the component belongs to.
  16578. */
  16579. scene: Scene;
  16580. /**
  16581. * Creates a new instance of the component for the given scene
  16582. * @param scene Defines the scene to register the component in
  16583. */
  16584. constructor(scene: Scene);
  16585. /**
  16586. * Registers the component in a given scene
  16587. */
  16588. register(): void;
  16589. /**
  16590. * Rebuilds the elements related to this component in case of
  16591. * context lost for instance.
  16592. */
  16593. rebuild(): void;
  16594. /**
  16595. * Disposes the component and the associated ressources.
  16596. */
  16597. dispose(): void;
  16598. private _beforeClear;
  16599. }
  16600. }
  16601. declare module BABYLON {
  16602. interface ThinEngine {
  16603. /**
  16604. * Creates a new render target cube texture
  16605. * @param size defines the size of the texture
  16606. * @param options defines the options used to create the texture
  16607. * @returns a new render target cube texture stored in an InternalTexture
  16608. */
  16609. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16610. }
  16611. }
  16612. declare module BABYLON {
  16613. /** @hidden */
  16614. export var proceduralVertexShader: {
  16615. name: string;
  16616. shader: string;
  16617. };
  16618. }
  16619. declare module BABYLON {
  16620. /**
  16621. * 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.
  16622. * This is the base class of any Procedural texture and contains most of the shareable code.
  16623. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16624. */
  16625. export class ProceduralTexture extends Texture {
  16626. isCube: boolean;
  16627. /**
  16628. * Define if the texture is enabled or not (disabled texture will not render)
  16629. */
  16630. isEnabled: boolean;
  16631. /**
  16632. * Define if the texture must be cleared before rendering (default is true)
  16633. */
  16634. autoClear: boolean;
  16635. /**
  16636. * Callback called when the texture is generated
  16637. */
  16638. onGenerated: () => void;
  16639. /**
  16640. * Event raised when the texture is generated
  16641. */
  16642. onGeneratedObservable: Observable<ProceduralTexture>;
  16643. /** @hidden */
  16644. _generateMipMaps: boolean;
  16645. /** @hidden **/
  16646. _effect: Effect;
  16647. /** @hidden */
  16648. _textures: {
  16649. [key: string]: Texture;
  16650. };
  16651. private _size;
  16652. private _currentRefreshId;
  16653. private _frameId;
  16654. private _refreshRate;
  16655. private _vertexBuffers;
  16656. private _indexBuffer;
  16657. private _uniforms;
  16658. private _samplers;
  16659. private _fragment;
  16660. private _floats;
  16661. private _ints;
  16662. private _floatsArrays;
  16663. private _colors3;
  16664. private _colors4;
  16665. private _vectors2;
  16666. private _vectors3;
  16667. private _matrices;
  16668. private _fallbackTexture;
  16669. private _fallbackTextureUsed;
  16670. private _engine;
  16671. private _cachedDefines;
  16672. private _contentUpdateId;
  16673. private _contentData;
  16674. /**
  16675. * Instantiates a new procedural texture.
  16676. * 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.
  16677. * This is the base class of any Procedural texture and contains most of the shareable code.
  16678. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16679. * @param name Define the name of the texture
  16680. * @param size Define the size of the texture to create
  16681. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16682. * @param scene Define the scene the texture belongs to
  16683. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16684. * @param generateMipMaps Define if the texture should creates mip maps or not
  16685. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16686. */
  16687. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16688. /**
  16689. * The effect that is created when initializing the post process.
  16690. * @returns The created effect corresponding the the postprocess.
  16691. */
  16692. getEffect(): Effect;
  16693. /**
  16694. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16695. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16696. */
  16697. getContent(): Nullable<ArrayBufferView>;
  16698. private _createIndexBuffer;
  16699. /** @hidden */
  16700. _rebuild(): void;
  16701. /**
  16702. * Resets the texture in order to recreate its associated resources.
  16703. * This can be called in case of context loss
  16704. */
  16705. reset(): void;
  16706. protected _getDefines(): string;
  16707. /**
  16708. * Is the texture ready to be used ? (rendered at least once)
  16709. * @returns true if ready, otherwise, false.
  16710. */
  16711. isReady(): boolean;
  16712. /**
  16713. * Resets the refresh counter of the texture and start bak from scratch.
  16714. * Could be useful to regenerate the texture if it is setup to render only once.
  16715. */
  16716. resetRefreshCounter(): void;
  16717. /**
  16718. * Set the fragment shader to use in order to render the texture.
  16719. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16720. */
  16721. setFragment(fragment: any): void;
  16722. /**
  16723. * Define the refresh rate of the texture or the rendering frequency.
  16724. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16725. */
  16726. get refreshRate(): number;
  16727. set refreshRate(value: number);
  16728. /** @hidden */
  16729. _shouldRender(): boolean;
  16730. /**
  16731. * Get the size the texture is rendering at.
  16732. * @returns the size (texture is always squared)
  16733. */
  16734. getRenderSize(): number;
  16735. /**
  16736. * Resize the texture to new value.
  16737. * @param size Define the new size the texture should have
  16738. * @param generateMipMaps Define whether the new texture should create mip maps
  16739. */
  16740. resize(size: number, generateMipMaps: boolean): void;
  16741. private _checkUniform;
  16742. /**
  16743. * Set a texture in the shader program used to render.
  16744. * @param name Define the name of the uniform samplers as defined in the shader
  16745. * @param texture Define the texture to bind to this sampler
  16746. * @return the texture itself allowing "fluent" like uniform updates
  16747. */
  16748. setTexture(name: string, texture: Texture): ProceduralTexture;
  16749. /**
  16750. * Set a float in the shader.
  16751. * @param name Define the name of the uniform as defined in the shader
  16752. * @param value Define the value to give to the uniform
  16753. * @return the texture itself allowing "fluent" like uniform updates
  16754. */
  16755. setFloat(name: string, value: number): ProceduralTexture;
  16756. /**
  16757. * Set a int in the shader.
  16758. * @param name Define the name of the uniform as defined in the shader
  16759. * @param value Define the value to give to the uniform
  16760. * @return the texture itself allowing "fluent" like uniform updates
  16761. */
  16762. setInt(name: string, value: number): ProceduralTexture;
  16763. /**
  16764. * Set an array of floats in the shader.
  16765. * @param name Define the name of the uniform as defined in the shader
  16766. * @param value Define the value to give to the uniform
  16767. * @return the texture itself allowing "fluent" like uniform updates
  16768. */
  16769. setFloats(name: string, value: number[]): ProceduralTexture;
  16770. /**
  16771. * Set a vec3 in the shader from a Color3.
  16772. * @param name Define the name of the uniform as defined in the shader
  16773. * @param value Define the value to give to the uniform
  16774. * @return the texture itself allowing "fluent" like uniform updates
  16775. */
  16776. setColor3(name: string, value: Color3): ProceduralTexture;
  16777. /**
  16778. * Set a vec4 in the shader from a Color4.
  16779. * @param name Define the name of the uniform as defined in the shader
  16780. * @param value Define the value to give to the uniform
  16781. * @return the texture itself allowing "fluent" like uniform updates
  16782. */
  16783. setColor4(name: string, value: Color4): ProceduralTexture;
  16784. /**
  16785. * Set a vec2 in the shader from a Vector2.
  16786. * @param name Define the name of the uniform as defined in the shader
  16787. * @param value Define the value to give to the uniform
  16788. * @return the texture itself allowing "fluent" like uniform updates
  16789. */
  16790. setVector2(name: string, value: Vector2): ProceduralTexture;
  16791. /**
  16792. * Set a vec3 in the shader from a Vector3.
  16793. * @param name Define the name of the uniform as defined in the shader
  16794. * @param value Define the value to give to the uniform
  16795. * @return the texture itself allowing "fluent" like uniform updates
  16796. */
  16797. setVector3(name: string, value: Vector3): ProceduralTexture;
  16798. /**
  16799. * Set a mat4 in the shader from a MAtrix.
  16800. * @param name Define the name of the uniform as defined in the shader
  16801. * @param value Define the value to give to the uniform
  16802. * @return the texture itself allowing "fluent" like uniform updates
  16803. */
  16804. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16805. /**
  16806. * Render the texture to its associated render target.
  16807. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16808. */
  16809. render(useCameraPostProcess?: boolean): void;
  16810. /**
  16811. * Clone the texture.
  16812. * @returns the cloned texture
  16813. */
  16814. clone(): ProceduralTexture;
  16815. /**
  16816. * Dispose the texture and release its asoociated resources.
  16817. */
  16818. dispose(): void;
  16819. }
  16820. }
  16821. declare module BABYLON {
  16822. /**
  16823. * This represents the base class for particle system in Babylon.
  16824. * 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.
  16825. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16826. * @example https://doc.babylonjs.com/babylon101/particles
  16827. */
  16828. export class BaseParticleSystem {
  16829. /**
  16830. * Source color is added to the destination color without alpha affecting the result
  16831. */
  16832. static BLENDMODE_ONEONE: number;
  16833. /**
  16834. * Blend current color and particle color using particle’s alpha
  16835. */
  16836. static BLENDMODE_STANDARD: number;
  16837. /**
  16838. * Add current color and particle color multiplied by particle’s alpha
  16839. */
  16840. static BLENDMODE_ADD: number;
  16841. /**
  16842. * Multiply current color with particle color
  16843. */
  16844. static BLENDMODE_MULTIPLY: number;
  16845. /**
  16846. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16847. */
  16848. static BLENDMODE_MULTIPLYADD: number;
  16849. /**
  16850. * List of animations used by the particle system.
  16851. */
  16852. animations: Animation[];
  16853. /**
  16854. * The id of the Particle system.
  16855. */
  16856. id: string;
  16857. /**
  16858. * The friendly name of the Particle system.
  16859. */
  16860. name: string;
  16861. /**
  16862. * The rendering group used by the Particle system to chose when to render.
  16863. */
  16864. renderingGroupId: number;
  16865. /**
  16866. * The emitter represents the Mesh or position we are attaching the particle system to.
  16867. */
  16868. emitter: Nullable<AbstractMesh | Vector3>;
  16869. /**
  16870. * The maximum number of particles to emit per frame
  16871. */
  16872. emitRate: number;
  16873. /**
  16874. * If you want to launch only a few particles at once, that can be done, as well.
  16875. */
  16876. manualEmitCount: number;
  16877. /**
  16878. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16879. */
  16880. updateSpeed: number;
  16881. /**
  16882. * The amount of time the particle system is running (depends of the overall update speed).
  16883. */
  16884. targetStopDuration: number;
  16885. /**
  16886. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16887. */
  16888. disposeOnStop: boolean;
  16889. /**
  16890. * Minimum power of emitting particles.
  16891. */
  16892. minEmitPower: number;
  16893. /**
  16894. * Maximum power of emitting particles.
  16895. */
  16896. maxEmitPower: number;
  16897. /**
  16898. * Minimum life time of emitting particles.
  16899. */
  16900. minLifeTime: number;
  16901. /**
  16902. * Maximum life time of emitting particles.
  16903. */
  16904. maxLifeTime: number;
  16905. /**
  16906. * Minimum Size of emitting particles.
  16907. */
  16908. minSize: number;
  16909. /**
  16910. * Maximum Size of emitting particles.
  16911. */
  16912. maxSize: number;
  16913. /**
  16914. * Minimum scale of emitting particles on X axis.
  16915. */
  16916. minScaleX: number;
  16917. /**
  16918. * Maximum scale of emitting particles on X axis.
  16919. */
  16920. maxScaleX: number;
  16921. /**
  16922. * Minimum scale of emitting particles on Y axis.
  16923. */
  16924. minScaleY: number;
  16925. /**
  16926. * Maximum scale of emitting particles on Y axis.
  16927. */
  16928. maxScaleY: number;
  16929. /**
  16930. * Gets or sets the minimal initial rotation in radians.
  16931. */
  16932. minInitialRotation: number;
  16933. /**
  16934. * Gets or sets the maximal initial rotation in radians.
  16935. */
  16936. maxInitialRotation: number;
  16937. /**
  16938. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16939. */
  16940. minAngularSpeed: number;
  16941. /**
  16942. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16943. */
  16944. maxAngularSpeed: number;
  16945. /**
  16946. * The texture used to render each particle. (this can be a spritesheet)
  16947. */
  16948. particleTexture: Nullable<Texture>;
  16949. /**
  16950. * The layer mask we are rendering the particles through.
  16951. */
  16952. layerMask: number;
  16953. /**
  16954. * This can help using your own shader to render the particle system.
  16955. * The according effect will be created
  16956. */
  16957. customShader: any;
  16958. /**
  16959. * By default particle system starts as soon as they are created. This prevents the
  16960. * automatic start to happen and let you decide when to start emitting particles.
  16961. */
  16962. preventAutoStart: boolean;
  16963. private _noiseTexture;
  16964. /**
  16965. * Gets or sets a texture used to add random noise to particle positions
  16966. */
  16967. get noiseTexture(): Nullable<ProceduralTexture>;
  16968. set noiseTexture(value: Nullable<ProceduralTexture>);
  16969. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16970. noiseStrength: Vector3;
  16971. /**
  16972. * Callback triggered when the particle animation is ending.
  16973. */
  16974. onAnimationEnd: Nullable<() => void>;
  16975. /**
  16976. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16977. */
  16978. blendMode: number;
  16979. /**
  16980. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16981. * to override the particles.
  16982. */
  16983. forceDepthWrite: boolean;
  16984. /** 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 */
  16985. preWarmCycles: number;
  16986. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16987. preWarmStepOffset: number;
  16988. /**
  16989. * 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)
  16990. */
  16991. spriteCellChangeSpeed: number;
  16992. /**
  16993. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16994. */
  16995. startSpriteCellID: number;
  16996. /**
  16997. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16998. */
  16999. endSpriteCellID: number;
  17000. /**
  17001. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17002. */
  17003. spriteCellWidth: number;
  17004. /**
  17005. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17006. */
  17007. spriteCellHeight: number;
  17008. /**
  17009. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17010. */
  17011. spriteRandomStartCell: boolean;
  17012. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17013. translationPivot: Vector2;
  17014. /** @hidden */
  17015. protected _isAnimationSheetEnabled: boolean;
  17016. /**
  17017. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17018. */
  17019. beginAnimationOnStart: boolean;
  17020. /**
  17021. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17022. */
  17023. beginAnimationFrom: number;
  17024. /**
  17025. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17026. */
  17027. beginAnimationTo: number;
  17028. /**
  17029. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17030. */
  17031. beginAnimationLoop: boolean;
  17032. /**
  17033. * Gets or sets a world offset applied to all particles
  17034. */
  17035. worldOffset: Vector3;
  17036. /**
  17037. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17038. */
  17039. get isAnimationSheetEnabled(): boolean;
  17040. set isAnimationSheetEnabled(value: boolean);
  17041. /**
  17042. * Get hosting scene
  17043. * @returns the scene
  17044. */
  17045. getScene(): Scene;
  17046. /**
  17047. * You can use gravity if you want to give an orientation to your particles.
  17048. */
  17049. gravity: Vector3;
  17050. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17051. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17052. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17053. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17054. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17055. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17056. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17057. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17058. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17059. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17060. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17061. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17062. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17063. /**
  17064. * Defines the delay in milliseconds before starting the system (0 by default)
  17065. */
  17066. startDelay: number;
  17067. /**
  17068. * Gets the current list of drag gradients.
  17069. * You must use addDragGradient and removeDragGradient to udpate this list
  17070. * @returns the list of drag gradients
  17071. */
  17072. getDragGradients(): Nullable<Array<FactorGradient>>;
  17073. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17074. limitVelocityDamping: number;
  17075. /**
  17076. * Gets the current list of limit velocity gradients.
  17077. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17078. * @returns the list of limit velocity gradients
  17079. */
  17080. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17081. /**
  17082. * Gets the current list of color gradients.
  17083. * You must use addColorGradient and removeColorGradient to udpate this list
  17084. * @returns the list of color gradients
  17085. */
  17086. getColorGradients(): Nullable<Array<ColorGradient>>;
  17087. /**
  17088. * Gets the current list of size gradients.
  17089. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17090. * @returns the list of size gradients
  17091. */
  17092. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17093. /**
  17094. * Gets the current list of color remap gradients.
  17095. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17096. * @returns the list of color remap gradients
  17097. */
  17098. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17099. /**
  17100. * Gets the current list of alpha remap gradients.
  17101. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17102. * @returns the list of alpha remap gradients
  17103. */
  17104. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17105. /**
  17106. * Gets the current list of life time gradients.
  17107. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17108. * @returns the list of life time gradients
  17109. */
  17110. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17111. /**
  17112. * Gets the current list of angular speed gradients.
  17113. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17114. * @returns the list of angular speed gradients
  17115. */
  17116. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17117. /**
  17118. * Gets the current list of velocity gradients.
  17119. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17120. * @returns the list of velocity gradients
  17121. */
  17122. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17123. /**
  17124. * Gets the current list of start size gradients.
  17125. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17126. * @returns the list of start size gradients
  17127. */
  17128. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17129. /**
  17130. * Gets the current list of emit rate gradients.
  17131. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17132. * @returns the list of emit rate gradients
  17133. */
  17134. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17135. /**
  17136. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17137. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17138. */
  17139. get direction1(): Vector3;
  17140. set direction1(value: Vector3);
  17141. /**
  17142. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17143. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17144. */
  17145. get direction2(): Vector3;
  17146. set direction2(value: Vector3);
  17147. /**
  17148. * 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.
  17149. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17150. */
  17151. get minEmitBox(): Vector3;
  17152. set minEmitBox(value: Vector3);
  17153. /**
  17154. * 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.
  17155. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17156. */
  17157. get maxEmitBox(): Vector3;
  17158. set maxEmitBox(value: Vector3);
  17159. /**
  17160. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17161. */
  17162. color1: Color4;
  17163. /**
  17164. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17165. */
  17166. color2: Color4;
  17167. /**
  17168. * Color the particle will have at the end of its lifetime
  17169. */
  17170. colorDead: Color4;
  17171. /**
  17172. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17173. */
  17174. textureMask: Color4;
  17175. /**
  17176. * The particle emitter type defines the emitter used by the particle system.
  17177. * It can be for example box, sphere, or cone...
  17178. */
  17179. particleEmitterType: IParticleEmitterType;
  17180. /** @hidden */
  17181. _isSubEmitter: boolean;
  17182. /**
  17183. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17184. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17185. */
  17186. billboardMode: number;
  17187. protected _isBillboardBased: boolean;
  17188. /**
  17189. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17190. */
  17191. get isBillboardBased(): boolean;
  17192. set isBillboardBased(value: boolean);
  17193. /**
  17194. * The scene the particle system belongs to.
  17195. */
  17196. protected _scene: Scene;
  17197. /**
  17198. * Local cache of defines for image processing.
  17199. */
  17200. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17201. /**
  17202. * Default configuration related to image processing available in the standard Material.
  17203. */
  17204. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17205. /**
  17206. * Gets the image processing configuration used either in this material.
  17207. */
  17208. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17209. /**
  17210. * Sets the Default image processing configuration used either in the this material.
  17211. *
  17212. * If sets to null, the scene one is in use.
  17213. */
  17214. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17215. /**
  17216. * Attaches a new image processing configuration to the Standard Material.
  17217. * @param configuration
  17218. */
  17219. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17220. /** @hidden */
  17221. protected _reset(): void;
  17222. /** @hidden */
  17223. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17224. /**
  17225. * Instantiates a particle system.
  17226. * 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.
  17227. * @param name The name of the particle system
  17228. */
  17229. constructor(name: string);
  17230. /**
  17231. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17232. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17233. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17234. * @returns the emitter
  17235. */
  17236. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17237. /**
  17238. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17239. * @param radius The radius of the hemisphere to emit from
  17240. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17241. * @returns the emitter
  17242. */
  17243. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17244. /**
  17245. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17246. * @param radius The radius of the sphere to emit from
  17247. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17248. * @returns the emitter
  17249. */
  17250. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17251. /**
  17252. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17253. * @param radius The radius of the sphere to emit from
  17254. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17255. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17256. * @returns the emitter
  17257. */
  17258. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17259. /**
  17260. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17261. * @param radius The radius of the emission cylinder
  17262. * @param height The height of the emission cylinder
  17263. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17264. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17265. * @returns the emitter
  17266. */
  17267. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17268. /**
  17269. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17270. * @param radius The radius of the cylinder to emit from
  17271. * @param height The height of the emission cylinder
  17272. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17273. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17274. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17275. * @returns the emitter
  17276. */
  17277. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17278. /**
  17279. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17280. * @param radius The radius of the cone to emit from
  17281. * @param angle The base angle of the cone
  17282. * @returns the emitter
  17283. */
  17284. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17285. /**
  17286. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17287. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17288. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17289. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17290. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17291. * @returns the emitter
  17292. */
  17293. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17294. }
  17295. }
  17296. declare module BABYLON {
  17297. /**
  17298. * Type of sub emitter
  17299. */
  17300. export enum SubEmitterType {
  17301. /**
  17302. * Attached to the particle over it's lifetime
  17303. */
  17304. ATTACHED = 0,
  17305. /**
  17306. * Created when the particle dies
  17307. */
  17308. END = 1
  17309. }
  17310. /**
  17311. * Sub emitter class used to emit particles from an existing particle
  17312. */
  17313. export class SubEmitter {
  17314. /**
  17315. * the particle system to be used by the sub emitter
  17316. */
  17317. particleSystem: ParticleSystem;
  17318. /**
  17319. * Type of the submitter (Default: END)
  17320. */
  17321. type: SubEmitterType;
  17322. /**
  17323. * 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)
  17324. * Note: This only is supported when using an emitter of type Mesh
  17325. */
  17326. inheritDirection: boolean;
  17327. /**
  17328. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17329. */
  17330. inheritedVelocityAmount: number;
  17331. /**
  17332. * Creates a sub emitter
  17333. * @param particleSystem the particle system to be used by the sub emitter
  17334. */
  17335. constructor(
  17336. /**
  17337. * the particle system to be used by the sub emitter
  17338. */
  17339. particleSystem: ParticleSystem);
  17340. /**
  17341. * Clones the sub emitter
  17342. * @returns the cloned sub emitter
  17343. */
  17344. clone(): SubEmitter;
  17345. /**
  17346. * Serialize current object to a JSON object
  17347. * @returns the serialized object
  17348. */
  17349. serialize(): any;
  17350. /** @hidden */
  17351. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17352. /**
  17353. * Creates a new SubEmitter from a serialized JSON version
  17354. * @param serializationObject defines the JSON object to read from
  17355. * @param scene defines the hosting scene
  17356. * @param rootUrl defines the rootUrl for data loading
  17357. * @returns a new SubEmitter
  17358. */
  17359. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17360. /** Release associated resources */
  17361. dispose(): void;
  17362. }
  17363. }
  17364. declare module BABYLON {
  17365. /** @hidden */
  17366. export var imageProcessingDeclaration: {
  17367. name: string;
  17368. shader: string;
  17369. };
  17370. }
  17371. declare module BABYLON {
  17372. /** @hidden */
  17373. export var imageProcessingFunctions: {
  17374. name: string;
  17375. shader: string;
  17376. };
  17377. }
  17378. declare module BABYLON {
  17379. /** @hidden */
  17380. export var particlesPixelShader: {
  17381. name: string;
  17382. shader: string;
  17383. };
  17384. }
  17385. declare module BABYLON {
  17386. /** @hidden */
  17387. export var particlesVertexShader: {
  17388. name: string;
  17389. shader: string;
  17390. };
  17391. }
  17392. declare module BABYLON {
  17393. /**
  17394. * This represents a particle system in Babylon.
  17395. * 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.
  17396. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17397. * @example https://doc.babylonjs.com/babylon101/particles
  17398. */
  17399. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17400. /**
  17401. * Billboard mode will only apply to Y axis
  17402. */
  17403. static readonly BILLBOARDMODE_Y: number;
  17404. /**
  17405. * Billboard mode will apply to all axes
  17406. */
  17407. static readonly BILLBOARDMODE_ALL: number;
  17408. /**
  17409. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17410. */
  17411. static readonly BILLBOARDMODE_STRETCHED: number;
  17412. /**
  17413. * This function can be defined to provide custom update for active particles.
  17414. * This function will be called instead of regular update (age, position, color, etc.).
  17415. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17416. */
  17417. updateFunction: (particles: Particle[]) => void;
  17418. private _emitterWorldMatrix;
  17419. /**
  17420. * This function can be defined to specify initial direction for every new particle.
  17421. * It by default use the emitterType defined function
  17422. */
  17423. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17424. /**
  17425. * This function can be defined to specify initial position for every new particle.
  17426. * It by default use the emitterType defined function
  17427. */
  17428. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17429. /**
  17430. * @hidden
  17431. */
  17432. _inheritedVelocityOffset: Vector3;
  17433. /**
  17434. * An event triggered when the system is disposed
  17435. */
  17436. onDisposeObservable: Observable<ParticleSystem>;
  17437. private _onDisposeObserver;
  17438. /**
  17439. * Sets a callback that will be triggered when the system is disposed
  17440. */
  17441. set onDispose(callback: () => void);
  17442. private _particles;
  17443. private _epsilon;
  17444. private _capacity;
  17445. private _stockParticles;
  17446. private _newPartsExcess;
  17447. private _vertexData;
  17448. private _vertexBuffer;
  17449. private _vertexBuffers;
  17450. private _spriteBuffer;
  17451. private _indexBuffer;
  17452. private _effect;
  17453. private _customEffect;
  17454. private _cachedDefines;
  17455. private _scaledColorStep;
  17456. private _colorDiff;
  17457. private _scaledDirection;
  17458. private _scaledGravity;
  17459. private _currentRenderId;
  17460. private _alive;
  17461. private _useInstancing;
  17462. private _started;
  17463. private _stopped;
  17464. private _actualFrame;
  17465. private _scaledUpdateSpeed;
  17466. private _vertexBufferSize;
  17467. /** @hidden */
  17468. _currentEmitRateGradient: Nullable<FactorGradient>;
  17469. /** @hidden */
  17470. _currentEmitRate1: number;
  17471. /** @hidden */
  17472. _currentEmitRate2: number;
  17473. /** @hidden */
  17474. _currentStartSizeGradient: Nullable<FactorGradient>;
  17475. /** @hidden */
  17476. _currentStartSize1: number;
  17477. /** @hidden */
  17478. _currentStartSize2: number;
  17479. private readonly _rawTextureWidth;
  17480. private _rampGradientsTexture;
  17481. private _useRampGradients;
  17482. /** Gets or sets a boolean indicating that ramp gradients must be used
  17483. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17484. */
  17485. get useRampGradients(): boolean;
  17486. set useRampGradients(value: boolean);
  17487. /**
  17488. * 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.
  17489. * 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: [])
  17490. */
  17491. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17492. private _subEmitters;
  17493. /**
  17494. * @hidden
  17495. * If the particle systems emitter should be disposed when the particle system is disposed
  17496. */
  17497. _disposeEmitterOnDispose: boolean;
  17498. /**
  17499. * The current active Sub-systems, this property is used by the root particle system only.
  17500. */
  17501. activeSubSystems: Array<ParticleSystem>;
  17502. private _rootParticleSystem;
  17503. /**
  17504. * Gets the current list of active particles
  17505. */
  17506. get particles(): Particle[];
  17507. /**
  17508. * Returns the string "ParticleSystem"
  17509. * @returns a string containing the class name
  17510. */
  17511. getClassName(): string;
  17512. /**
  17513. * Instantiates a particle system.
  17514. * 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.
  17515. * @param name The name of the particle system
  17516. * @param capacity The max number of particles alive at the same time
  17517. * @param scene The scene the particle system belongs to
  17518. * @param customEffect a custom effect used to change the way particles are rendered by default
  17519. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17520. * @param epsilon Offset used to render the particles
  17521. */
  17522. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17523. private _addFactorGradient;
  17524. private _removeFactorGradient;
  17525. /**
  17526. * Adds a new life time gradient
  17527. * @param gradient defines the gradient to use (between 0 and 1)
  17528. * @param factor defines the life time factor to affect to the specified gradient
  17529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17530. * @returns the current particle system
  17531. */
  17532. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17533. /**
  17534. * Remove a specific life time gradient
  17535. * @param gradient defines the gradient to remove
  17536. * @returns the current particle system
  17537. */
  17538. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17539. /**
  17540. * Adds a new size gradient
  17541. * @param gradient defines the gradient to use (between 0 and 1)
  17542. * @param factor defines the size factor to affect to the specified gradient
  17543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17544. * @returns the current particle system
  17545. */
  17546. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17547. /**
  17548. * Remove a specific size gradient
  17549. * @param gradient defines the gradient to remove
  17550. * @returns the current particle system
  17551. */
  17552. removeSizeGradient(gradient: number): IParticleSystem;
  17553. /**
  17554. * Adds a new color remap gradient
  17555. * @param gradient defines the gradient to use (between 0 and 1)
  17556. * @param min defines the color remap minimal range
  17557. * @param max defines the color remap maximal range
  17558. * @returns the current particle system
  17559. */
  17560. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17561. /**
  17562. * Remove a specific color remap gradient
  17563. * @param gradient defines the gradient to remove
  17564. * @returns the current particle system
  17565. */
  17566. removeColorRemapGradient(gradient: number): IParticleSystem;
  17567. /**
  17568. * Adds a new alpha remap gradient
  17569. * @param gradient defines the gradient to use (between 0 and 1)
  17570. * @param min defines the alpha remap minimal range
  17571. * @param max defines the alpha remap maximal range
  17572. * @returns the current particle system
  17573. */
  17574. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17575. /**
  17576. * Remove a specific alpha remap gradient
  17577. * @param gradient defines the gradient to remove
  17578. * @returns the current particle system
  17579. */
  17580. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17581. /**
  17582. * Adds a new angular speed gradient
  17583. * @param gradient defines the gradient to use (between 0 and 1)
  17584. * @param factor defines the angular speed to affect to the specified gradient
  17585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17586. * @returns the current particle system
  17587. */
  17588. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17589. /**
  17590. * Remove a specific angular speed gradient
  17591. * @param gradient defines the gradient to remove
  17592. * @returns the current particle system
  17593. */
  17594. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17595. /**
  17596. * Adds a new velocity gradient
  17597. * @param gradient defines the gradient to use (between 0 and 1)
  17598. * @param factor defines the velocity to affect to the specified gradient
  17599. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17600. * @returns the current particle system
  17601. */
  17602. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17603. /**
  17604. * Remove a specific velocity gradient
  17605. * @param gradient defines the gradient to remove
  17606. * @returns the current particle system
  17607. */
  17608. removeVelocityGradient(gradient: number): IParticleSystem;
  17609. /**
  17610. * Adds a new limit velocity gradient
  17611. * @param gradient defines the gradient to use (between 0 and 1)
  17612. * @param factor defines the limit velocity value to affect to the specified gradient
  17613. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17614. * @returns the current particle system
  17615. */
  17616. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17617. /**
  17618. * Remove a specific limit velocity gradient
  17619. * @param gradient defines the gradient to remove
  17620. * @returns the current particle system
  17621. */
  17622. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17623. /**
  17624. * Adds a new drag gradient
  17625. * @param gradient defines the gradient to use (between 0 and 1)
  17626. * @param factor defines the drag value to affect to the specified gradient
  17627. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17628. * @returns the current particle system
  17629. */
  17630. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17631. /**
  17632. * Remove a specific drag gradient
  17633. * @param gradient defines the gradient to remove
  17634. * @returns the current particle system
  17635. */
  17636. removeDragGradient(gradient: number): IParticleSystem;
  17637. /**
  17638. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17639. * @param gradient defines the gradient to use (between 0 and 1)
  17640. * @param factor defines the emit rate value to affect to the specified gradient
  17641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17642. * @returns the current particle system
  17643. */
  17644. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17645. /**
  17646. * Remove a specific emit rate gradient
  17647. * @param gradient defines the gradient to remove
  17648. * @returns the current particle system
  17649. */
  17650. removeEmitRateGradient(gradient: number): IParticleSystem;
  17651. /**
  17652. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17653. * @param gradient defines the gradient to use (between 0 and 1)
  17654. * @param factor defines the start size value to affect to the specified gradient
  17655. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17656. * @returns the current particle system
  17657. */
  17658. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17659. /**
  17660. * Remove a specific start size gradient
  17661. * @param gradient defines the gradient to remove
  17662. * @returns the current particle system
  17663. */
  17664. removeStartSizeGradient(gradient: number): IParticleSystem;
  17665. private _createRampGradientTexture;
  17666. /**
  17667. * Gets the current list of ramp gradients.
  17668. * You must use addRampGradient and removeRampGradient to udpate this list
  17669. * @returns the list of ramp gradients
  17670. */
  17671. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17672. /**
  17673. * Adds a new ramp gradient used to remap particle colors
  17674. * @param gradient defines the gradient to use (between 0 and 1)
  17675. * @param color defines the color to affect to the specified gradient
  17676. * @returns the current particle system
  17677. */
  17678. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17679. /**
  17680. * Remove a specific ramp gradient
  17681. * @param gradient defines the gradient to remove
  17682. * @returns the current particle system
  17683. */
  17684. removeRampGradient(gradient: number): ParticleSystem;
  17685. /**
  17686. * Adds a new color gradient
  17687. * @param gradient defines the gradient to use (between 0 and 1)
  17688. * @param color1 defines the color to affect to the specified gradient
  17689. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17690. * @returns this particle system
  17691. */
  17692. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17693. /**
  17694. * Remove a specific color gradient
  17695. * @param gradient defines the gradient to remove
  17696. * @returns this particle system
  17697. */
  17698. removeColorGradient(gradient: number): IParticleSystem;
  17699. private _fetchR;
  17700. protected _reset(): void;
  17701. private _resetEffect;
  17702. private _createVertexBuffers;
  17703. private _createIndexBuffer;
  17704. /**
  17705. * Gets the maximum number of particles active at the same time.
  17706. * @returns The max number of active particles.
  17707. */
  17708. getCapacity(): number;
  17709. /**
  17710. * Gets whether there are still active particles in the system.
  17711. * @returns True if it is alive, otherwise false.
  17712. */
  17713. isAlive(): boolean;
  17714. /**
  17715. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17716. * @returns True if it has been started, otherwise false.
  17717. */
  17718. isStarted(): boolean;
  17719. private _prepareSubEmitterInternalArray;
  17720. /**
  17721. * Starts the particle system and begins to emit
  17722. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17723. */
  17724. start(delay?: number): void;
  17725. /**
  17726. * Stops the particle system.
  17727. * @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.
  17728. */
  17729. stop(stopSubEmitters?: boolean): void;
  17730. /**
  17731. * Remove all active particles
  17732. */
  17733. reset(): void;
  17734. /**
  17735. * @hidden (for internal use only)
  17736. */
  17737. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17738. /**
  17739. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17740. * Its lifetime will start back at 0.
  17741. */
  17742. recycleParticle: (particle: Particle) => void;
  17743. private _stopSubEmitters;
  17744. private _createParticle;
  17745. private _removeFromRoot;
  17746. private _emitFromParticle;
  17747. private _update;
  17748. /** @hidden */
  17749. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17750. /** @hidden */
  17751. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17752. /** @hidden */
  17753. private _getEffect;
  17754. /**
  17755. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17756. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17757. */
  17758. animate(preWarmOnly?: boolean): void;
  17759. private _appendParticleVertices;
  17760. /**
  17761. * Rebuilds the particle system.
  17762. */
  17763. rebuild(): void;
  17764. /**
  17765. * Is this system ready to be used/rendered
  17766. * @return true if the system is ready
  17767. */
  17768. isReady(): boolean;
  17769. private _render;
  17770. /**
  17771. * Renders the particle system in its current state.
  17772. * @returns the current number of particles
  17773. */
  17774. render(): number;
  17775. /**
  17776. * Disposes the particle system and free the associated resources
  17777. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17778. */
  17779. dispose(disposeTexture?: boolean): void;
  17780. /**
  17781. * Clones the particle system.
  17782. * @param name The name of the cloned object
  17783. * @param newEmitter The new emitter to use
  17784. * @returns the cloned particle system
  17785. */
  17786. clone(name: string, newEmitter: any): ParticleSystem;
  17787. /**
  17788. * Serializes the particle system to a JSON object.
  17789. * @returns the JSON object
  17790. */
  17791. serialize(): any;
  17792. /** @hidden */
  17793. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17794. /** @hidden */
  17795. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17796. /**
  17797. * Parses a JSON object to create a particle system.
  17798. * @param parsedParticleSystem The JSON object to parse
  17799. * @param scene The scene to create the particle system in
  17800. * @param rootUrl The root url to use to load external dependencies like texture
  17801. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17802. * @returns the Parsed particle system
  17803. */
  17804. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17805. }
  17806. }
  17807. declare module BABYLON {
  17808. /**
  17809. * A particle represents one of the element emitted by a particle system.
  17810. * This is mainly define by its coordinates, direction, velocity and age.
  17811. */
  17812. export class Particle {
  17813. /**
  17814. * The particle system the particle belongs to.
  17815. */
  17816. particleSystem: ParticleSystem;
  17817. private static _Count;
  17818. /**
  17819. * Unique ID of the particle
  17820. */
  17821. id: number;
  17822. /**
  17823. * The world position of the particle in the scene.
  17824. */
  17825. position: Vector3;
  17826. /**
  17827. * The world direction of the particle in the scene.
  17828. */
  17829. direction: Vector3;
  17830. /**
  17831. * The color of the particle.
  17832. */
  17833. color: Color4;
  17834. /**
  17835. * The color change of the particle per step.
  17836. */
  17837. colorStep: Color4;
  17838. /**
  17839. * Defines how long will the life of the particle be.
  17840. */
  17841. lifeTime: number;
  17842. /**
  17843. * The current age of the particle.
  17844. */
  17845. age: number;
  17846. /**
  17847. * The current size of the particle.
  17848. */
  17849. size: number;
  17850. /**
  17851. * The current scale of the particle.
  17852. */
  17853. scale: Vector2;
  17854. /**
  17855. * The current angle of the particle.
  17856. */
  17857. angle: number;
  17858. /**
  17859. * Defines how fast is the angle changing.
  17860. */
  17861. angularSpeed: number;
  17862. /**
  17863. * Defines the cell index used by the particle to be rendered from a sprite.
  17864. */
  17865. cellIndex: number;
  17866. /**
  17867. * The information required to support color remapping
  17868. */
  17869. remapData: Vector4;
  17870. /** @hidden */
  17871. _randomCellOffset?: number;
  17872. /** @hidden */
  17873. _initialDirection: Nullable<Vector3>;
  17874. /** @hidden */
  17875. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17876. /** @hidden */
  17877. _initialStartSpriteCellID: number;
  17878. /** @hidden */
  17879. _initialEndSpriteCellID: number;
  17880. /** @hidden */
  17881. _currentColorGradient: Nullable<ColorGradient>;
  17882. /** @hidden */
  17883. _currentColor1: Color4;
  17884. /** @hidden */
  17885. _currentColor2: Color4;
  17886. /** @hidden */
  17887. _currentSizeGradient: Nullable<FactorGradient>;
  17888. /** @hidden */
  17889. _currentSize1: number;
  17890. /** @hidden */
  17891. _currentSize2: number;
  17892. /** @hidden */
  17893. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17894. /** @hidden */
  17895. _currentAngularSpeed1: number;
  17896. /** @hidden */
  17897. _currentAngularSpeed2: number;
  17898. /** @hidden */
  17899. _currentVelocityGradient: Nullable<FactorGradient>;
  17900. /** @hidden */
  17901. _currentVelocity1: number;
  17902. /** @hidden */
  17903. _currentVelocity2: number;
  17904. /** @hidden */
  17905. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17906. /** @hidden */
  17907. _currentLimitVelocity1: number;
  17908. /** @hidden */
  17909. _currentLimitVelocity2: number;
  17910. /** @hidden */
  17911. _currentDragGradient: Nullable<FactorGradient>;
  17912. /** @hidden */
  17913. _currentDrag1: number;
  17914. /** @hidden */
  17915. _currentDrag2: number;
  17916. /** @hidden */
  17917. _randomNoiseCoordinates1: Vector3;
  17918. /** @hidden */
  17919. _randomNoiseCoordinates2: Vector3;
  17920. /**
  17921. * Creates a new instance Particle
  17922. * @param particleSystem the particle system the particle belongs to
  17923. */
  17924. constructor(
  17925. /**
  17926. * The particle system the particle belongs to.
  17927. */
  17928. particleSystem: ParticleSystem);
  17929. private updateCellInfoFromSystem;
  17930. /**
  17931. * Defines how the sprite cell index is updated for the particle
  17932. */
  17933. updateCellIndex(): void;
  17934. /** @hidden */
  17935. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17936. /** @hidden */
  17937. _inheritParticleInfoToSubEmitters(): void;
  17938. /** @hidden */
  17939. _reset(): void;
  17940. /**
  17941. * Copy the properties of particle to another one.
  17942. * @param other the particle to copy the information to.
  17943. */
  17944. copyTo(other: Particle): void;
  17945. }
  17946. }
  17947. declare module BABYLON {
  17948. /**
  17949. * Particle emitter represents a volume emitting particles.
  17950. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17951. */
  17952. export interface IParticleEmitterType {
  17953. /**
  17954. * Called by the particle System when the direction is computed for the created particle.
  17955. * @param worldMatrix is the world matrix of the particle system
  17956. * @param directionToUpdate is the direction vector to update with the result
  17957. * @param particle is the particle we are computed the direction for
  17958. */
  17959. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17960. /**
  17961. * Called by the particle System when the position is computed for the created particle.
  17962. * @param worldMatrix is the world matrix of the particle system
  17963. * @param positionToUpdate is the position vector to update with the result
  17964. * @param particle is the particle we are computed the position for
  17965. */
  17966. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17967. /**
  17968. * Clones the current emitter and returns a copy of it
  17969. * @returns the new emitter
  17970. */
  17971. clone(): IParticleEmitterType;
  17972. /**
  17973. * Called by the GPUParticleSystem to setup the update shader
  17974. * @param effect defines the update shader
  17975. */
  17976. applyToShader(effect: Effect): void;
  17977. /**
  17978. * Returns a string to use to update the GPU particles update shader
  17979. * @returns the effect defines string
  17980. */
  17981. getEffectDefines(): string;
  17982. /**
  17983. * Returns a string representing the class name
  17984. * @returns a string containing the class name
  17985. */
  17986. getClassName(): string;
  17987. /**
  17988. * Serializes the particle system to a JSON object.
  17989. * @returns the JSON object
  17990. */
  17991. serialize(): any;
  17992. /**
  17993. * Parse properties from a JSON object
  17994. * @param serializationObject defines the JSON object
  17995. */
  17996. parse(serializationObject: any): void;
  17997. }
  17998. }
  17999. declare module BABYLON {
  18000. /**
  18001. * Particle emitter emitting particles from the inside of a box.
  18002. * It emits the particles randomly between 2 given directions.
  18003. */
  18004. export class BoxParticleEmitter implements IParticleEmitterType {
  18005. /**
  18006. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18007. */
  18008. direction1: Vector3;
  18009. /**
  18010. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18011. */
  18012. direction2: Vector3;
  18013. /**
  18014. * 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.
  18015. */
  18016. minEmitBox: Vector3;
  18017. /**
  18018. * 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.
  18019. */
  18020. maxEmitBox: Vector3;
  18021. /**
  18022. * Creates a new instance BoxParticleEmitter
  18023. */
  18024. constructor();
  18025. /**
  18026. * Called by the particle System when the direction is computed for the created particle.
  18027. * @param worldMatrix is the world matrix of the particle system
  18028. * @param directionToUpdate is the direction vector to update with the result
  18029. * @param particle is the particle we are computed the direction for
  18030. */
  18031. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18032. /**
  18033. * Called by the particle System when the position is computed for the created particle.
  18034. * @param worldMatrix is the world matrix of the particle system
  18035. * @param positionToUpdate is the position vector to update with the result
  18036. * @param particle is the particle we are computed the position for
  18037. */
  18038. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18039. /**
  18040. * Clones the current emitter and returns a copy of it
  18041. * @returns the new emitter
  18042. */
  18043. clone(): BoxParticleEmitter;
  18044. /**
  18045. * Called by the GPUParticleSystem to setup the update shader
  18046. * @param effect defines the update shader
  18047. */
  18048. applyToShader(effect: Effect): void;
  18049. /**
  18050. * Returns a string to use to update the GPU particles update shader
  18051. * @returns a string containng the defines string
  18052. */
  18053. getEffectDefines(): string;
  18054. /**
  18055. * Returns the string "BoxParticleEmitter"
  18056. * @returns a string containing the class name
  18057. */
  18058. getClassName(): string;
  18059. /**
  18060. * Serializes the particle system to a JSON object.
  18061. * @returns the JSON object
  18062. */
  18063. serialize(): any;
  18064. /**
  18065. * Parse properties from a JSON object
  18066. * @param serializationObject defines the JSON object
  18067. */
  18068. parse(serializationObject: any): void;
  18069. }
  18070. }
  18071. declare module BABYLON {
  18072. /**
  18073. * Particle emitter emitting particles from the inside of a cone.
  18074. * It emits the particles alongside the cone volume from the base to the particle.
  18075. * The emission direction might be randomized.
  18076. */
  18077. export class ConeParticleEmitter implements IParticleEmitterType {
  18078. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18079. directionRandomizer: number;
  18080. private _radius;
  18081. private _angle;
  18082. private _height;
  18083. /**
  18084. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18085. */
  18086. radiusRange: number;
  18087. /**
  18088. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18089. */
  18090. heightRange: number;
  18091. /**
  18092. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18093. */
  18094. emitFromSpawnPointOnly: boolean;
  18095. /**
  18096. * Gets or sets the radius of the emission cone
  18097. */
  18098. get radius(): number;
  18099. set radius(value: number);
  18100. /**
  18101. * Gets or sets the angle of the emission cone
  18102. */
  18103. get angle(): number;
  18104. set angle(value: number);
  18105. private _buildHeight;
  18106. /**
  18107. * Creates a new instance ConeParticleEmitter
  18108. * @param radius the radius of the emission cone (1 by default)
  18109. * @param angle the cone base angle (PI by default)
  18110. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18111. */
  18112. constructor(radius?: number, angle?: number,
  18113. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18114. directionRandomizer?: number);
  18115. /**
  18116. * Called by the particle System when the direction is computed for the created particle.
  18117. * @param worldMatrix is the world matrix of the particle system
  18118. * @param directionToUpdate is the direction vector to update with the result
  18119. * @param particle is the particle we are computed the direction for
  18120. */
  18121. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18122. /**
  18123. * Called by the particle System when the position is computed for the created particle.
  18124. * @param worldMatrix is the world matrix of the particle system
  18125. * @param positionToUpdate is the position vector to update with the result
  18126. * @param particle is the particle we are computed the position for
  18127. */
  18128. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18129. /**
  18130. * Clones the current emitter and returns a copy of it
  18131. * @returns the new emitter
  18132. */
  18133. clone(): ConeParticleEmitter;
  18134. /**
  18135. * Called by the GPUParticleSystem to setup the update shader
  18136. * @param effect defines the update shader
  18137. */
  18138. applyToShader(effect: Effect): void;
  18139. /**
  18140. * Returns a string to use to update the GPU particles update shader
  18141. * @returns a string containng the defines string
  18142. */
  18143. getEffectDefines(): string;
  18144. /**
  18145. * Returns the string "ConeParticleEmitter"
  18146. * @returns a string containing the class name
  18147. */
  18148. getClassName(): string;
  18149. /**
  18150. * Serializes the particle system to a JSON object.
  18151. * @returns the JSON object
  18152. */
  18153. serialize(): any;
  18154. /**
  18155. * Parse properties from a JSON object
  18156. * @param serializationObject defines the JSON object
  18157. */
  18158. parse(serializationObject: any): void;
  18159. }
  18160. }
  18161. declare module BABYLON {
  18162. /**
  18163. * Particle emitter emitting particles from the inside of a cylinder.
  18164. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18165. */
  18166. export class CylinderParticleEmitter implements IParticleEmitterType {
  18167. /**
  18168. * The radius of the emission cylinder.
  18169. */
  18170. radius: number;
  18171. /**
  18172. * The height of the emission cylinder.
  18173. */
  18174. height: number;
  18175. /**
  18176. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18177. */
  18178. radiusRange: number;
  18179. /**
  18180. * How much to randomize the particle direction [0-1].
  18181. */
  18182. directionRandomizer: number;
  18183. /**
  18184. * Creates a new instance CylinderParticleEmitter
  18185. * @param radius the radius of the emission cylinder (1 by default)
  18186. * @param height the height of the emission cylinder (1 by default)
  18187. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18188. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18189. */
  18190. constructor(
  18191. /**
  18192. * The radius of the emission cylinder.
  18193. */
  18194. radius?: number,
  18195. /**
  18196. * The height of the emission cylinder.
  18197. */
  18198. height?: number,
  18199. /**
  18200. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18201. */
  18202. radiusRange?: number,
  18203. /**
  18204. * How much to randomize the particle direction [0-1].
  18205. */
  18206. directionRandomizer?: number);
  18207. /**
  18208. * Called by the particle System when the direction is computed for the created particle.
  18209. * @param worldMatrix is the world matrix of the particle system
  18210. * @param directionToUpdate is the direction vector to update with the result
  18211. * @param particle is the particle we are computed the direction for
  18212. */
  18213. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18214. /**
  18215. * Called by the particle System when the position is computed for the created particle.
  18216. * @param worldMatrix is the world matrix of the particle system
  18217. * @param positionToUpdate is the position vector to update with the result
  18218. * @param particle is the particle we are computed the position for
  18219. */
  18220. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18221. /**
  18222. * Clones the current emitter and returns a copy of it
  18223. * @returns the new emitter
  18224. */
  18225. clone(): CylinderParticleEmitter;
  18226. /**
  18227. * Called by the GPUParticleSystem to setup the update shader
  18228. * @param effect defines the update shader
  18229. */
  18230. applyToShader(effect: Effect): void;
  18231. /**
  18232. * Returns a string to use to update the GPU particles update shader
  18233. * @returns a string containng the defines string
  18234. */
  18235. getEffectDefines(): string;
  18236. /**
  18237. * Returns the string "CylinderParticleEmitter"
  18238. * @returns a string containing the class name
  18239. */
  18240. getClassName(): string;
  18241. /**
  18242. * Serializes the particle system to a JSON object.
  18243. * @returns the JSON object
  18244. */
  18245. serialize(): any;
  18246. /**
  18247. * Parse properties from a JSON object
  18248. * @param serializationObject defines the JSON object
  18249. */
  18250. parse(serializationObject: any): void;
  18251. }
  18252. /**
  18253. * Particle emitter emitting particles from the inside of a cylinder.
  18254. * It emits the particles randomly between two vectors.
  18255. */
  18256. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18257. /**
  18258. * The min limit of the emission direction.
  18259. */
  18260. direction1: Vector3;
  18261. /**
  18262. * The max limit of the emission direction.
  18263. */
  18264. direction2: Vector3;
  18265. /**
  18266. * Creates a new instance CylinderDirectedParticleEmitter
  18267. * @param radius the radius of the emission cylinder (1 by default)
  18268. * @param height the height of the emission cylinder (1 by default)
  18269. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18270. * @param direction1 the min limit of the emission direction (up vector by default)
  18271. * @param direction2 the max limit of the emission direction (up vector by default)
  18272. */
  18273. constructor(radius?: number, height?: number, radiusRange?: number,
  18274. /**
  18275. * The min limit of the emission direction.
  18276. */
  18277. direction1?: Vector3,
  18278. /**
  18279. * The max limit of the emission direction.
  18280. */
  18281. direction2?: Vector3);
  18282. /**
  18283. * Called by the particle System when the direction is computed for the created particle.
  18284. * @param worldMatrix is the world matrix of the particle system
  18285. * @param directionToUpdate is the direction vector to update with the result
  18286. * @param particle is the particle we are computed the direction for
  18287. */
  18288. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18289. /**
  18290. * Clones the current emitter and returns a copy of it
  18291. * @returns the new emitter
  18292. */
  18293. clone(): CylinderDirectedParticleEmitter;
  18294. /**
  18295. * Called by the GPUParticleSystem to setup the update shader
  18296. * @param effect defines the update shader
  18297. */
  18298. applyToShader(effect: Effect): void;
  18299. /**
  18300. * Returns a string to use to update the GPU particles update shader
  18301. * @returns a string containng the defines string
  18302. */
  18303. getEffectDefines(): string;
  18304. /**
  18305. * Returns the string "CylinderDirectedParticleEmitter"
  18306. * @returns a string containing the class name
  18307. */
  18308. getClassName(): string;
  18309. /**
  18310. * Serializes the particle system to a JSON object.
  18311. * @returns the JSON object
  18312. */
  18313. serialize(): any;
  18314. /**
  18315. * Parse properties from a JSON object
  18316. * @param serializationObject defines the JSON object
  18317. */
  18318. parse(serializationObject: any): void;
  18319. }
  18320. }
  18321. declare module BABYLON {
  18322. /**
  18323. * Particle emitter emitting particles from the inside of a hemisphere.
  18324. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18325. */
  18326. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18327. /**
  18328. * The radius of the emission hemisphere.
  18329. */
  18330. radius: number;
  18331. /**
  18332. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18333. */
  18334. radiusRange: number;
  18335. /**
  18336. * How much to randomize the particle direction [0-1].
  18337. */
  18338. directionRandomizer: number;
  18339. /**
  18340. * Creates a new instance HemisphericParticleEmitter
  18341. * @param radius the radius of the emission hemisphere (1 by default)
  18342. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18343. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18344. */
  18345. constructor(
  18346. /**
  18347. * The radius of the emission hemisphere.
  18348. */
  18349. radius?: number,
  18350. /**
  18351. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18352. */
  18353. radiusRange?: number,
  18354. /**
  18355. * How much to randomize the particle direction [0-1].
  18356. */
  18357. directionRandomizer?: number);
  18358. /**
  18359. * Called by the particle System when the direction is computed for the created particle.
  18360. * @param worldMatrix is the world matrix of the particle system
  18361. * @param directionToUpdate is the direction vector to update with the result
  18362. * @param particle is the particle we are computed the direction for
  18363. */
  18364. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18365. /**
  18366. * Called by the particle System when the position is computed for the created particle.
  18367. * @param worldMatrix is the world matrix of the particle system
  18368. * @param positionToUpdate is the position vector to update with the result
  18369. * @param particle is the particle we are computed the position for
  18370. */
  18371. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18372. /**
  18373. * Clones the current emitter and returns a copy of it
  18374. * @returns the new emitter
  18375. */
  18376. clone(): HemisphericParticleEmitter;
  18377. /**
  18378. * Called by the GPUParticleSystem to setup the update shader
  18379. * @param effect defines the update shader
  18380. */
  18381. applyToShader(effect: Effect): void;
  18382. /**
  18383. * Returns a string to use to update the GPU particles update shader
  18384. * @returns a string containng the defines string
  18385. */
  18386. getEffectDefines(): string;
  18387. /**
  18388. * Returns the string "HemisphericParticleEmitter"
  18389. * @returns a string containing the class name
  18390. */
  18391. getClassName(): string;
  18392. /**
  18393. * Serializes the particle system to a JSON object.
  18394. * @returns the JSON object
  18395. */
  18396. serialize(): any;
  18397. /**
  18398. * Parse properties from a JSON object
  18399. * @param serializationObject defines the JSON object
  18400. */
  18401. parse(serializationObject: any): void;
  18402. }
  18403. }
  18404. declare module BABYLON {
  18405. /**
  18406. * Particle emitter emitting particles from a point.
  18407. * It emits the particles randomly between 2 given directions.
  18408. */
  18409. export class PointParticleEmitter implements IParticleEmitterType {
  18410. /**
  18411. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18412. */
  18413. direction1: Vector3;
  18414. /**
  18415. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18416. */
  18417. direction2: Vector3;
  18418. /**
  18419. * Creates a new instance PointParticleEmitter
  18420. */
  18421. constructor();
  18422. /**
  18423. * Called by the particle System when the direction is computed for the created particle.
  18424. * @param worldMatrix is the world matrix of the particle system
  18425. * @param directionToUpdate is the direction vector to update with the result
  18426. * @param particle is the particle we are computed the direction for
  18427. */
  18428. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18429. /**
  18430. * Called by the particle System when the position is computed for the created particle.
  18431. * @param worldMatrix is the world matrix of the particle system
  18432. * @param positionToUpdate is the position vector to update with the result
  18433. * @param particle is the particle we are computed the position for
  18434. */
  18435. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18436. /**
  18437. * Clones the current emitter and returns a copy of it
  18438. * @returns the new emitter
  18439. */
  18440. clone(): PointParticleEmitter;
  18441. /**
  18442. * Called by the GPUParticleSystem to setup the update shader
  18443. * @param effect defines the update shader
  18444. */
  18445. applyToShader(effect: Effect): void;
  18446. /**
  18447. * Returns a string to use to update the GPU particles update shader
  18448. * @returns a string containng the defines string
  18449. */
  18450. getEffectDefines(): string;
  18451. /**
  18452. * Returns the string "PointParticleEmitter"
  18453. * @returns a string containing the class name
  18454. */
  18455. getClassName(): string;
  18456. /**
  18457. * Serializes the particle system to a JSON object.
  18458. * @returns the JSON object
  18459. */
  18460. serialize(): any;
  18461. /**
  18462. * Parse properties from a JSON object
  18463. * @param serializationObject defines the JSON object
  18464. */
  18465. parse(serializationObject: any): void;
  18466. }
  18467. }
  18468. declare module BABYLON {
  18469. /**
  18470. * Particle emitter emitting particles from the inside of a sphere.
  18471. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18472. */
  18473. export class SphereParticleEmitter implements IParticleEmitterType {
  18474. /**
  18475. * The radius of the emission sphere.
  18476. */
  18477. radius: number;
  18478. /**
  18479. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18480. */
  18481. radiusRange: number;
  18482. /**
  18483. * How much to randomize the particle direction [0-1].
  18484. */
  18485. directionRandomizer: number;
  18486. /**
  18487. * Creates a new instance SphereParticleEmitter
  18488. * @param radius the radius of the emission sphere (1 by default)
  18489. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18490. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18491. */
  18492. constructor(
  18493. /**
  18494. * The radius of the emission sphere.
  18495. */
  18496. radius?: number,
  18497. /**
  18498. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18499. */
  18500. radiusRange?: number,
  18501. /**
  18502. * How much to randomize the particle direction [0-1].
  18503. */
  18504. directionRandomizer?: number);
  18505. /**
  18506. * Called by the particle System when the direction is computed for the created particle.
  18507. * @param worldMatrix is the world matrix of the particle system
  18508. * @param directionToUpdate is the direction vector to update with the result
  18509. * @param particle is the particle we are computed the direction for
  18510. */
  18511. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18512. /**
  18513. * Called by the particle System when the position is computed for the created particle.
  18514. * @param worldMatrix is the world matrix of the particle system
  18515. * @param positionToUpdate is the position vector to update with the result
  18516. * @param particle is the particle we are computed the position for
  18517. */
  18518. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18519. /**
  18520. * Clones the current emitter and returns a copy of it
  18521. * @returns the new emitter
  18522. */
  18523. clone(): SphereParticleEmitter;
  18524. /**
  18525. * Called by the GPUParticleSystem to setup the update shader
  18526. * @param effect defines the update shader
  18527. */
  18528. applyToShader(effect: Effect): void;
  18529. /**
  18530. * Returns a string to use to update the GPU particles update shader
  18531. * @returns a string containng the defines string
  18532. */
  18533. getEffectDefines(): string;
  18534. /**
  18535. * Returns the string "SphereParticleEmitter"
  18536. * @returns a string containing the class name
  18537. */
  18538. getClassName(): string;
  18539. /**
  18540. * Serializes the particle system to a JSON object.
  18541. * @returns the JSON object
  18542. */
  18543. serialize(): any;
  18544. /**
  18545. * Parse properties from a JSON object
  18546. * @param serializationObject defines the JSON object
  18547. */
  18548. parse(serializationObject: any): void;
  18549. }
  18550. /**
  18551. * Particle emitter emitting particles from the inside of a sphere.
  18552. * It emits the particles randomly between two vectors.
  18553. */
  18554. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18555. /**
  18556. * The min limit of the emission direction.
  18557. */
  18558. direction1: Vector3;
  18559. /**
  18560. * The max limit of the emission direction.
  18561. */
  18562. direction2: Vector3;
  18563. /**
  18564. * Creates a new instance SphereDirectedParticleEmitter
  18565. * @param radius the radius of the emission sphere (1 by default)
  18566. * @param direction1 the min limit of the emission direction (up vector by default)
  18567. * @param direction2 the max limit of the emission direction (up vector by default)
  18568. */
  18569. constructor(radius?: number,
  18570. /**
  18571. * The min limit of the emission direction.
  18572. */
  18573. direction1?: Vector3,
  18574. /**
  18575. * The max limit of the emission direction.
  18576. */
  18577. direction2?: Vector3);
  18578. /**
  18579. * Called by the particle System when the direction is computed for the created particle.
  18580. * @param worldMatrix is the world matrix of the particle system
  18581. * @param directionToUpdate is the direction vector to update with the result
  18582. * @param particle is the particle we are computed the direction for
  18583. */
  18584. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18585. /**
  18586. * Clones the current emitter and returns a copy of it
  18587. * @returns the new emitter
  18588. */
  18589. clone(): SphereDirectedParticleEmitter;
  18590. /**
  18591. * Called by the GPUParticleSystem to setup the update shader
  18592. * @param effect defines the update shader
  18593. */
  18594. applyToShader(effect: Effect): void;
  18595. /**
  18596. * Returns a string to use to update the GPU particles update shader
  18597. * @returns a string containng the defines string
  18598. */
  18599. getEffectDefines(): string;
  18600. /**
  18601. * Returns the string "SphereDirectedParticleEmitter"
  18602. * @returns a string containing the class name
  18603. */
  18604. getClassName(): string;
  18605. /**
  18606. * Serializes the particle system to a JSON object.
  18607. * @returns the JSON object
  18608. */
  18609. serialize(): any;
  18610. /**
  18611. * Parse properties from a JSON object
  18612. * @param serializationObject defines the JSON object
  18613. */
  18614. parse(serializationObject: any): void;
  18615. }
  18616. }
  18617. declare module BABYLON {
  18618. /**
  18619. * Particle emitter emitting particles from a custom list of positions.
  18620. */
  18621. export class CustomParticleEmitter implements IParticleEmitterType {
  18622. /**
  18623. * Gets or sets the position generator that will create the inital position of each particle.
  18624. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  18625. */
  18626. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  18627. /**
  18628. * Gets or sets the destination generator that will create the final destination of each particle.
  18629. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  18630. */
  18631. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  18632. /**
  18633. * Creates a new instance CustomParticleEmitter
  18634. */
  18635. constructor();
  18636. /**
  18637. * Called by the particle System when the direction is computed for the created particle.
  18638. * @param worldMatrix is the world matrix of the particle system
  18639. * @param directionToUpdate is the direction vector to update with the result
  18640. * @param particle is the particle we are computed the direction for
  18641. */
  18642. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18643. /**
  18644. * Called by the particle System when the position is computed for the created particle.
  18645. * @param worldMatrix is the world matrix of the particle system
  18646. * @param positionToUpdate is the position vector to update with the result
  18647. * @param particle is the particle we are computed the position for
  18648. */
  18649. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18650. /**
  18651. * Clones the current emitter and returns a copy of it
  18652. * @returns the new emitter
  18653. */
  18654. clone(): CustomParticleEmitter;
  18655. /**
  18656. * Called by the GPUParticleSystem to setup the update shader
  18657. * @param effect defines the update shader
  18658. */
  18659. applyToShader(effect: Effect): void;
  18660. /**
  18661. * Returns a string to use to update the GPU particles update shader
  18662. * @returns a string containng the defines string
  18663. */
  18664. getEffectDefines(): string;
  18665. /**
  18666. * Returns the string "PointParticleEmitter"
  18667. * @returns a string containing the class name
  18668. */
  18669. getClassName(): string;
  18670. /**
  18671. * Serializes the particle system to a JSON object.
  18672. * @returns the JSON object
  18673. */
  18674. serialize(): any;
  18675. /**
  18676. * Parse properties from a JSON object
  18677. * @param serializationObject defines the JSON object
  18678. */
  18679. parse(serializationObject: any): void;
  18680. }
  18681. }
  18682. declare module BABYLON {
  18683. /**
  18684. * Interface representing a particle system in Babylon.js.
  18685. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18686. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18687. */
  18688. export interface IParticleSystem {
  18689. /**
  18690. * List of animations used by the particle system.
  18691. */
  18692. animations: Animation[];
  18693. /**
  18694. * The id of the Particle system.
  18695. */
  18696. id: string;
  18697. /**
  18698. * The name of the Particle system.
  18699. */
  18700. name: string;
  18701. /**
  18702. * The emitter represents the Mesh or position we are attaching the particle system to.
  18703. */
  18704. emitter: Nullable<AbstractMesh | Vector3>;
  18705. /**
  18706. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18707. */
  18708. isBillboardBased: boolean;
  18709. /**
  18710. * The rendering group used by the Particle system to chose when to render.
  18711. */
  18712. renderingGroupId: number;
  18713. /**
  18714. * The layer mask we are rendering the particles through.
  18715. */
  18716. layerMask: number;
  18717. /**
  18718. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18719. */
  18720. updateSpeed: number;
  18721. /**
  18722. * The amount of time the particle system is running (depends of the overall update speed).
  18723. */
  18724. targetStopDuration: number;
  18725. /**
  18726. * The texture used to render each particle. (this can be a spritesheet)
  18727. */
  18728. particleTexture: Nullable<Texture>;
  18729. /**
  18730. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18731. */
  18732. blendMode: number;
  18733. /**
  18734. * Minimum life time of emitting particles.
  18735. */
  18736. minLifeTime: number;
  18737. /**
  18738. * Maximum life time of emitting particles.
  18739. */
  18740. maxLifeTime: number;
  18741. /**
  18742. * Minimum Size of emitting particles.
  18743. */
  18744. minSize: number;
  18745. /**
  18746. * Maximum Size of emitting particles.
  18747. */
  18748. maxSize: number;
  18749. /**
  18750. * Minimum scale of emitting particles on X axis.
  18751. */
  18752. minScaleX: number;
  18753. /**
  18754. * Maximum scale of emitting particles on X axis.
  18755. */
  18756. maxScaleX: number;
  18757. /**
  18758. * Minimum scale of emitting particles on Y axis.
  18759. */
  18760. minScaleY: number;
  18761. /**
  18762. * Maximum scale of emitting particles on Y axis.
  18763. */
  18764. maxScaleY: number;
  18765. /**
  18766. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18767. */
  18768. color1: Color4;
  18769. /**
  18770. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18771. */
  18772. color2: Color4;
  18773. /**
  18774. * Color the particle will have at the end of its lifetime.
  18775. */
  18776. colorDead: Color4;
  18777. /**
  18778. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18779. */
  18780. emitRate: number;
  18781. /**
  18782. * You can use gravity if you want to give an orientation to your particles.
  18783. */
  18784. gravity: Vector3;
  18785. /**
  18786. * Minimum power of emitting particles.
  18787. */
  18788. minEmitPower: number;
  18789. /**
  18790. * Maximum power of emitting particles.
  18791. */
  18792. maxEmitPower: number;
  18793. /**
  18794. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18795. */
  18796. minAngularSpeed: number;
  18797. /**
  18798. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18799. */
  18800. maxAngularSpeed: number;
  18801. /**
  18802. * Gets or sets the minimal initial rotation in radians.
  18803. */
  18804. minInitialRotation: number;
  18805. /**
  18806. * Gets or sets the maximal initial rotation in radians.
  18807. */
  18808. maxInitialRotation: number;
  18809. /**
  18810. * The particle emitter type defines the emitter used by the particle system.
  18811. * It can be for example box, sphere, or cone...
  18812. */
  18813. particleEmitterType: Nullable<IParticleEmitterType>;
  18814. /**
  18815. * Defines the delay in milliseconds before starting the system (0 by default)
  18816. */
  18817. startDelay: number;
  18818. /**
  18819. * 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
  18820. */
  18821. preWarmCycles: number;
  18822. /**
  18823. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18824. */
  18825. preWarmStepOffset: number;
  18826. /**
  18827. * 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)
  18828. */
  18829. spriteCellChangeSpeed: number;
  18830. /**
  18831. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18832. */
  18833. startSpriteCellID: number;
  18834. /**
  18835. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18836. */
  18837. endSpriteCellID: number;
  18838. /**
  18839. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18840. */
  18841. spriteCellWidth: number;
  18842. /**
  18843. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18844. */
  18845. spriteCellHeight: number;
  18846. /**
  18847. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18848. */
  18849. spriteRandomStartCell: boolean;
  18850. /**
  18851. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18852. */
  18853. isAnimationSheetEnabled: boolean;
  18854. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18855. translationPivot: Vector2;
  18856. /**
  18857. * Gets or sets a texture used to add random noise to particle positions
  18858. */
  18859. noiseTexture: Nullable<BaseTexture>;
  18860. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18861. noiseStrength: Vector3;
  18862. /**
  18863. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18864. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18865. */
  18866. billboardMode: number;
  18867. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18868. limitVelocityDamping: number;
  18869. /**
  18870. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18871. */
  18872. beginAnimationOnStart: boolean;
  18873. /**
  18874. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18875. */
  18876. beginAnimationFrom: number;
  18877. /**
  18878. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18879. */
  18880. beginAnimationTo: number;
  18881. /**
  18882. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18883. */
  18884. beginAnimationLoop: boolean;
  18885. /**
  18886. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18887. */
  18888. disposeOnStop: boolean;
  18889. /**
  18890. * Gets the maximum number of particles active at the same time.
  18891. * @returns The max number of active particles.
  18892. */
  18893. getCapacity(): number;
  18894. /**
  18895. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18896. * @returns True if it has been started, otherwise false.
  18897. */
  18898. isStarted(): boolean;
  18899. /**
  18900. * Animates the particle system for this frame.
  18901. */
  18902. animate(): void;
  18903. /**
  18904. * Renders the particle system in its current state.
  18905. * @returns the current number of particles
  18906. */
  18907. render(): number;
  18908. /**
  18909. * Dispose the particle system and frees its associated resources.
  18910. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18911. */
  18912. dispose(disposeTexture?: boolean): void;
  18913. /**
  18914. * Clones the particle system.
  18915. * @param name The name of the cloned object
  18916. * @param newEmitter The new emitter to use
  18917. * @returns the cloned particle system
  18918. */
  18919. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18920. /**
  18921. * Serializes the particle system to a JSON object.
  18922. * @returns the JSON object
  18923. */
  18924. serialize(): any;
  18925. /**
  18926. * Rebuild the particle system
  18927. */
  18928. rebuild(): void;
  18929. /**
  18930. * Starts the particle system and begins to emit
  18931. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18932. */
  18933. start(delay?: number): void;
  18934. /**
  18935. * Stops the particle system.
  18936. */
  18937. stop(): void;
  18938. /**
  18939. * Remove all active particles
  18940. */
  18941. reset(): void;
  18942. /**
  18943. * Is this system ready to be used/rendered
  18944. * @return true if the system is ready
  18945. */
  18946. isReady(): boolean;
  18947. /**
  18948. * Adds a new color gradient
  18949. * @param gradient defines the gradient to use (between 0 and 1)
  18950. * @param color1 defines the color to affect to the specified gradient
  18951. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18952. * @returns the current particle system
  18953. */
  18954. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18955. /**
  18956. * Remove a specific color gradient
  18957. * @param gradient defines the gradient to remove
  18958. * @returns the current particle system
  18959. */
  18960. removeColorGradient(gradient: number): IParticleSystem;
  18961. /**
  18962. * Adds a new size gradient
  18963. * @param gradient defines the gradient to use (between 0 and 1)
  18964. * @param factor defines the size factor to affect to the specified gradient
  18965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18966. * @returns the current particle system
  18967. */
  18968. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18969. /**
  18970. * Remove a specific size gradient
  18971. * @param gradient defines the gradient to remove
  18972. * @returns the current particle system
  18973. */
  18974. removeSizeGradient(gradient: number): IParticleSystem;
  18975. /**
  18976. * Gets the current list of color gradients.
  18977. * You must use addColorGradient and removeColorGradient to udpate this list
  18978. * @returns the list of color gradients
  18979. */
  18980. getColorGradients(): Nullable<Array<ColorGradient>>;
  18981. /**
  18982. * Gets the current list of size gradients.
  18983. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18984. * @returns the list of size gradients
  18985. */
  18986. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18987. /**
  18988. * Gets the current list of angular speed gradients.
  18989. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18990. * @returns the list of angular speed gradients
  18991. */
  18992. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18993. /**
  18994. * Adds a new angular speed gradient
  18995. * @param gradient defines the gradient to use (between 0 and 1)
  18996. * @param factor defines the angular speed to affect to the specified gradient
  18997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18998. * @returns the current particle system
  18999. */
  19000. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19001. /**
  19002. * Remove a specific angular speed gradient
  19003. * @param gradient defines the gradient to remove
  19004. * @returns the current particle system
  19005. */
  19006. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19007. /**
  19008. * Gets the current list of velocity gradients.
  19009. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19010. * @returns the list of velocity gradients
  19011. */
  19012. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19013. /**
  19014. * Adds a new velocity gradient
  19015. * @param gradient defines the gradient to use (between 0 and 1)
  19016. * @param factor defines the velocity to affect to the specified gradient
  19017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19018. * @returns the current particle system
  19019. */
  19020. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19021. /**
  19022. * Remove a specific velocity gradient
  19023. * @param gradient defines the gradient to remove
  19024. * @returns the current particle system
  19025. */
  19026. removeVelocityGradient(gradient: number): IParticleSystem;
  19027. /**
  19028. * Gets the current list of limit velocity gradients.
  19029. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19030. * @returns the list of limit velocity gradients
  19031. */
  19032. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19033. /**
  19034. * Adds a new limit velocity gradient
  19035. * @param gradient defines the gradient to use (between 0 and 1)
  19036. * @param factor defines the limit velocity to affect to the specified gradient
  19037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19038. * @returns the current particle system
  19039. */
  19040. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19041. /**
  19042. * Remove a specific limit velocity gradient
  19043. * @param gradient defines the gradient to remove
  19044. * @returns the current particle system
  19045. */
  19046. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19047. /**
  19048. * Adds a new drag gradient
  19049. * @param gradient defines the gradient to use (between 0 and 1)
  19050. * @param factor defines the drag to affect to the specified gradient
  19051. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19052. * @returns the current particle system
  19053. */
  19054. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19055. /**
  19056. * Remove a specific drag gradient
  19057. * @param gradient defines the gradient to remove
  19058. * @returns the current particle system
  19059. */
  19060. removeDragGradient(gradient: number): IParticleSystem;
  19061. /**
  19062. * Gets the current list of drag gradients.
  19063. * You must use addDragGradient and removeDragGradient to udpate this list
  19064. * @returns the list of drag gradients
  19065. */
  19066. getDragGradients(): Nullable<Array<FactorGradient>>;
  19067. /**
  19068. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19069. * @param gradient defines the gradient to use (between 0 and 1)
  19070. * @param factor defines the emit rate to affect to the specified gradient
  19071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19072. * @returns the current particle system
  19073. */
  19074. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19075. /**
  19076. * Remove a specific emit rate gradient
  19077. * @param gradient defines the gradient to remove
  19078. * @returns the current particle system
  19079. */
  19080. removeEmitRateGradient(gradient: number): IParticleSystem;
  19081. /**
  19082. * Gets the current list of emit rate gradients.
  19083. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19084. * @returns the list of emit rate gradients
  19085. */
  19086. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19087. /**
  19088. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19089. * @param gradient defines the gradient to use (between 0 and 1)
  19090. * @param factor defines the start size to affect to the specified gradient
  19091. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19092. * @returns the current particle system
  19093. */
  19094. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19095. /**
  19096. * Remove a specific start size gradient
  19097. * @param gradient defines the gradient to remove
  19098. * @returns the current particle system
  19099. */
  19100. removeStartSizeGradient(gradient: number): IParticleSystem;
  19101. /**
  19102. * Gets the current list of start size gradients.
  19103. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19104. * @returns the list of start size gradients
  19105. */
  19106. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19107. /**
  19108. * Adds a new life time gradient
  19109. * @param gradient defines the gradient to use (between 0 and 1)
  19110. * @param factor defines the life time factor to affect to the specified gradient
  19111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19112. * @returns the current particle system
  19113. */
  19114. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19115. /**
  19116. * Remove a specific life time gradient
  19117. * @param gradient defines the gradient to remove
  19118. * @returns the current particle system
  19119. */
  19120. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19121. /**
  19122. * Gets the current list of life time gradients.
  19123. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19124. * @returns the list of life time gradients
  19125. */
  19126. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19127. /**
  19128. * Gets the current list of color gradients.
  19129. * You must use addColorGradient and removeColorGradient to udpate this list
  19130. * @returns the list of color gradients
  19131. */
  19132. getColorGradients(): Nullable<Array<ColorGradient>>;
  19133. /**
  19134. * Adds a new ramp gradient used to remap particle colors
  19135. * @param gradient defines the gradient to use (between 0 and 1)
  19136. * @param color defines the color to affect to the specified gradient
  19137. * @returns the current particle system
  19138. */
  19139. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19140. /**
  19141. * Gets the current list of ramp gradients.
  19142. * You must use addRampGradient and removeRampGradient to udpate this list
  19143. * @returns the list of ramp gradients
  19144. */
  19145. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19146. /** Gets or sets a boolean indicating that ramp gradients must be used
  19147. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19148. */
  19149. useRampGradients: boolean;
  19150. /**
  19151. * Adds a new color remap gradient
  19152. * @param gradient defines the gradient to use (between 0 and 1)
  19153. * @param min defines the color remap minimal range
  19154. * @param max defines the color remap maximal range
  19155. * @returns the current particle system
  19156. */
  19157. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19158. /**
  19159. * Gets the current list of color remap gradients.
  19160. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19161. * @returns the list of color remap gradients
  19162. */
  19163. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19164. /**
  19165. * Adds a new alpha remap gradient
  19166. * @param gradient defines the gradient to use (between 0 and 1)
  19167. * @param min defines the alpha remap minimal range
  19168. * @param max defines the alpha remap maximal range
  19169. * @returns the current particle system
  19170. */
  19171. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19172. /**
  19173. * Gets the current list of alpha remap gradients.
  19174. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19175. * @returns the list of alpha remap gradients
  19176. */
  19177. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19178. /**
  19179. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19180. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19181. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19182. * @returns the emitter
  19183. */
  19184. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19185. /**
  19186. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19187. * @param radius The radius of the hemisphere to emit from
  19188. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19189. * @returns the emitter
  19190. */
  19191. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19192. /**
  19193. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19194. * @param radius The radius of the sphere to emit from
  19195. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19196. * @returns the emitter
  19197. */
  19198. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19199. /**
  19200. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19201. * @param radius The radius of the sphere to emit from
  19202. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19203. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19204. * @returns the emitter
  19205. */
  19206. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19207. /**
  19208. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19209. * @param radius The radius of the emission cylinder
  19210. * @param height The height of the emission cylinder
  19211. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19212. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19213. * @returns the emitter
  19214. */
  19215. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19216. /**
  19217. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19218. * @param radius The radius of the cylinder to emit from
  19219. * @param height The height of the emission cylinder
  19220. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19221. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19222. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19223. * @returns the emitter
  19224. */
  19225. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19226. /**
  19227. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19228. * @param radius The radius of the cone to emit from
  19229. * @param angle The base angle of the cone
  19230. * @returns the emitter
  19231. */
  19232. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19233. /**
  19234. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19235. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19236. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19237. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19238. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19239. * @returns the emitter
  19240. */
  19241. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19242. /**
  19243. * Get hosting scene
  19244. * @returns the scene
  19245. */
  19246. getScene(): Scene;
  19247. }
  19248. }
  19249. declare module BABYLON {
  19250. /**
  19251. * Creates an instance based on a source mesh.
  19252. */
  19253. export class InstancedMesh extends AbstractMesh {
  19254. private _sourceMesh;
  19255. private _currentLOD;
  19256. /** @hidden */
  19257. _indexInSourceMeshInstanceArray: number;
  19258. constructor(name: string, source: Mesh);
  19259. /**
  19260. * Returns the string "InstancedMesh".
  19261. */
  19262. getClassName(): string;
  19263. /** Gets the list of lights affecting that mesh */
  19264. get lightSources(): Light[];
  19265. _resyncLightSources(): void;
  19266. _resyncLightSource(light: Light): void;
  19267. _removeLightSource(light: Light, dispose: boolean): void;
  19268. /**
  19269. * If the source mesh receives shadows
  19270. */
  19271. get receiveShadows(): boolean;
  19272. /**
  19273. * The material of the source mesh
  19274. */
  19275. get material(): Nullable<Material>;
  19276. /**
  19277. * Visibility of the source mesh
  19278. */
  19279. get visibility(): number;
  19280. /**
  19281. * Skeleton of the source mesh
  19282. */
  19283. get skeleton(): Nullable<Skeleton>;
  19284. /**
  19285. * Rendering ground id of the source mesh
  19286. */
  19287. get renderingGroupId(): number;
  19288. set renderingGroupId(value: number);
  19289. /**
  19290. * Returns the total number of vertices (integer).
  19291. */
  19292. getTotalVertices(): number;
  19293. /**
  19294. * Returns a positive integer : the total number of indices in this mesh geometry.
  19295. * @returns the numner of indices or zero if the mesh has no geometry.
  19296. */
  19297. getTotalIndices(): number;
  19298. /**
  19299. * The source mesh of the instance
  19300. */
  19301. get sourceMesh(): Mesh;
  19302. /**
  19303. * Is this node ready to be used/rendered
  19304. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19305. * @return {boolean} is it ready
  19306. */
  19307. isReady(completeCheck?: boolean): boolean;
  19308. /**
  19309. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19310. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19311. * @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.
  19312. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19313. */
  19314. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19315. /**
  19316. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19317. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19318. * The `data` are either a numeric array either a Float32Array.
  19319. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19320. * 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).
  19321. * Note that a new underlying VertexBuffer object is created each call.
  19322. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19323. *
  19324. * Possible `kind` values :
  19325. * - VertexBuffer.PositionKind
  19326. * - VertexBuffer.UVKind
  19327. * - VertexBuffer.UV2Kind
  19328. * - VertexBuffer.UV3Kind
  19329. * - VertexBuffer.UV4Kind
  19330. * - VertexBuffer.UV5Kind
  19331. * - VertexBuffer.UV6Kind
  19332. * - VertexBuffer.ColorKind
  19333. * - VertexBuffer.MatricesIndicesKind
  19334. * - VertexBuffer.MatricesIndicesExtraKind
  19335. * - VertexBuffer.MatricesWeightsKind
  19336. * - VertexBuffer.MatricesWeightsExtraKind
  19337. *
  19338. * Returns the Mesh.
  19339. */
  19340. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19341. /**
  19342. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19343. * If the mesh has no geometry, it is simply returned as it is.
  19344. * The `data` are either a numeric array either a Float32Array.
  19345. * No new underlying VertexBuffer object is created.
  19346. * 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.
  19347. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19348. *
  19349. * Possible `kind` values :
  19350. * - VertexBuffer.PositionKind
  19351. * - VertexBuffer.UVKind
  19352. * - VertexBuffer.UV2Kind
  19353. * - VertexBuffer.UV3Kind
  19354. * - VertexBuffer.UV4Kind
  19355. * - VertexBuffer.UV5Kind
  19356. * - VertexBuffer.UV6Kind
  19357. * - VertexBuffer.ColorKind
  19358. * - VertexBuffer.MatricesIndicesKind
  19359. * - VertexBuffer.MatricesIndicesExtraKind
  19360. * - VertexBuffer.MatricesWeightsKind
  19361. * - VertexBuffer.MatricesWeightsExtraKind
  19362. *
  19363. * Returns the Mesh.
  19364. */
  19365. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19366. /**
  19367. * Sets the mesh indices.
  19368. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19369. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19370. * This method creates a new index buffer each call.
  19371. * Returns the Mesh.
  19372. */
  19373. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19374. /**
  19375. * Boolean : True if the mesh owns the requested kind of data.
  19376. */
  19377. isVerticesDataPresent(kind: string): boolean;
  19378. /**
  19379. * Returns an array of indices (IndicesArray).
  19380. */
  19381. getIndices(): Nullable<IndicesArray>;
  19382. get _positions(): Nullable<Vector3[]>;
  19383. /**
  19384. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19385. * This means the mesh underlying bounding box and sphere are recomputed.
  19386. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19387. * @returns the current mesh
  19388. */
  19389. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19390. /** @hidden */
  19391. _preActivate(): InstancedMesh;
  19392. /** @hidden */
  19393. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19394. /** @hidden */
  19395. _postActivate(): void;
  19396. getWorldMatrix(): Matrix;
  19397. get isAnInstance(): boolean;
  19398. /**
  19399. * Returns the current associated LOD AbstractMesh.
  19400. */
  19401. getLOD(camera: Camera): AbstractMesh;
  19402. /** @hidden */
  19403. _syncSubMeshes(): InstancedMesh;
  19404. /** @hidden */
  19405. _generatePointsArray(): boolean;
  19406. /**
  19407. * Creates a new InstancedMesh from the current mesh.
  19408. * - name (string) : the cloned mesh name
  19409. * - newParent (optional Node) : the optional Node to parent the clone to.
  19410. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19411. *
  19412. * Returns the clone.
  19413. */
  19414. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  19415. /**
  19416. * Disposes the InstancedMesh.
  19417. * Returns nothing.
  19418. */
  19419. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19420. }
  19421. interface Mesh {
  19422. /**
  19423. * Register a custom buffer that will be instanced
  19424. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19425. * @param kind defines the buffer kind
  19426. * @param stride defines the stride in floats
  19427. */
  19428. registerInstancedBuffer(kind: string, stride: number): void;
  19429. /** @hidden */
  19430. _userInstancedBuffersStorage: {
  19431. data: {
  19432. [key: string]: Float32Array;
  19433. };
  19434. sizes: {
  19435. [key: string]: number;
  19436. };
  19437. vertexBuffers: {
  19438. [key: string]: Nullable<VertexBuffer>;
  19439. };
  19440. strides: {
  19441. [key: string]: number;
  19442. };
  19443. };
  19444. }
  19445. interface AbstractMesh {
  19446. /**
  19447. * Object used to store instanced buffers defined by user
  19448. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19449. */
  19450. instancedBuffers: {
  19451. [key: string]: any;
  19452. };
  19453. }
  19454. }
  19455. declare module BABYLON {
  19456. /**
  19457. * Defines the options associated with the creation of a shader material.
  19458. */
  19459. export interface IShaderMaterialOptions {
  19460. /**
  19461. * Does the material work in alpha blend mode
  19462. */
  19463. needAlphaBlending: boolean;
  19464. /**
  19465. * Does the material work in alpha test mode
  19466. */
  19467. needAlphaTesting: boolean;
  19468. /**
  19469. * The list of attribute names used in the shader
  19470. */
  19471. attributes: string[];
  19472. /**
  19473. * The list of unifrom names used in the shader
  19474. */
  19475. uniforms: string[];
  19476. /**
  19477. * The list of UBO names used in the shader
  19478. */
  19479. uniformBuffers: string[];
  19480. /**
  19481. * The list of sampler names used in the shader
  19482. */
  19483. samplers: string[];
  19484. /**
  19485. * The list of defines used in the shader
  19486. */
  19487. defines: string[];
  19488. }
  19489. /**
  19490. * 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.
  19491. *
  19492. * This returned material effects how the mesh will look based on the code in the shaders.
  19493. *
  19494. * @see http://doc.babylonjs.com/how_to/shader_material
  19495. */
  19496. export class ShaderMaterial extends Material {
  19497. private _shaderPath;
  19498. private _options;
  19499. private _textures;
  19500. private _textureArrays;
  19501. private _floats;
  19502. private _ints;
  19503. private _floatsArrays;
  19504. private _colors3;
  19505. private _colors3Arrays;
  19506. private _colors4;
  19507. private _colors4Arrays;
  19508. private _vectors2;
  19509. private _vectors3;
  19510. private _vectors4;
  19511. private _matrices;
  19512. private _matrixArrays;
  19513. private _matrices3x3;
  19514. private _matrices2x2;
  19515. private _vectors2Arrays;
  19516. private _vectors3Arrays;
  19517. private _vectors4Arrays;
  19518. private _cachedWorldViewMatrix;
  19519. private _cachedWorldViewProjectionMatrix;
  19520. private _renderId;
  19521. private _multiview;
  19522. /**
  19523. * Instantiate a new shader material.
  19524. * 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.
  19525. * This returned material effects how the mesh will look based on the code in the shaders.
  19526. * @see http://doc.babylonjs.com/how_to/shader_material
  19527. * @param name Define the name of the material in the scene
  19528. * @param scene Define the scene the material belongs to
  19529. * @param shaderPath Defines the route to the shader code in one of three ways:
  19530. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19531. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19532. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19533. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19534. * @param options Define the options used to create the shader
  19535. */
  19536. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19537. /**
  19538. * Gets the shader path used to define the shader code
  19539. * It can be modified to trigger a new compilation
  19540. */
  19541. get shaderPath(): any;
  19542. /**
  19543. * Sets the shader path used to define the shader code
  19544. * It can be modified to trigger a new compilation
  19545. */
  19546. set shaderPath(shaderPath: any);
  19547. /**
  19548. * Gets the options used to compile the shader.
  19549. * They can be modified to trigger a new compilation
  19550. */
  19551. get options(): IShaderMaterialOptions;
  19552. /**
  19553. * Gets the current class name of the material e.g. "ShaderMaterial"
  19554. * Mainly use in serialization.
  19555. * @returns the class name
  19556. */
  19557. getClassName(): string;
  19558. /**
  19559. * Specifies if the material will require alpha blending
  19560. * @returns a boolean specifying if alpha blending is needed
  19561. */
  19562. needAlphaBlending(): boolean;
  19563. /**
  19564. * Specifies if this material should be rendered in alpha test mode
  19565. * @returns a boolean specifying if an alpha test is needed.
  19566. */
  19567. needAlphaTesting(): boolean;
  19568. private _checkUniform;
  19569. /**
  19570. * Set a texture in the shader.
  19571. * @param name Define the name of the uniform samplers as defined in the shader
  19572. * @param texture Define the texture to bind to this sampler
  19573. * @return the material itself allowing "fluent" like uniform updates
  19574. */
  19575. setTexture(name: string, texture: Texture): ShaderMaterial;
  19576. /**
  19577. * Set a texture array in the shader.
  19578. * @param name Define the name of the uniform sampler array as defined in the shader
  19579. * @param textures Define the list of textures to bind to this sampler
  19580. * @return the material itself allowing "fluent" like uniform updates
  19581. */
  19582. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19583. /**
  19584. * Set a float in the shader.
  19585. * @param name Define the name of the uniform as defined in the shader
  19586. * @param value Define the value to give to the uniform
  19587. * @return the material itself allowing "fluent" like uniform updates
  19588. */
  19589. setFloat(name: string, value: number): ShaderMaterial;
  19590. /**
  19591. * Set a int in the shader.
  19592. * @param name Define the name of the uniform as defined in the shader
  19593. * @param value Define the value to give to the uniform
  19594. * @return the material itself allowing "fluent" like uniform updates
  19595. */
  19596. setInt(name: string, value: number): ShaderMaterial;
  19597. /**
  19598. * Set an array of floats in the shader.
  19599. * @param name Define the name of the uniform as defined in the shader
  19600. * @param value Define the value to give to the uniform
  19601. * @return the material itself allowing "fluent" like uniform updates
  19602. */
  19603. setFloats(name: string, value: number[]): ShaderMaterial;
  19604. /**
  19605. * Set a vec3 in the shader from a Color3.
  19606. * @param name Define the name of the uniform as defined in the shader
  19607. * @param value Define the value to give to the uniform
  19608. * @return the material itself allowing "fluent" like uniform updates
  19609. */
  19610. setColor3(name: string, value: Color3): ShaderMaterial;
  19611. /**
  19612. * Set a vec3 array in the shader from a Color3 array.
  19613. * @param name Define the name of the uniform as defined in the shader
  19614. * @param value Define the value to give to the uniform
  19615. * @return the material itself allowing "fluent" like uniform updates
  19616. */
  19617. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19618. /**
  19619. * Set a vec4 in the shader from a Color4.
  19620. * @param name Define the name of the uniform as defined in the shader
  19621. * @param value Define the value to give to the uniform
  19622. * @return the material itself allowing "fluent" like uniform updates
  19623. */
  19624. setColor4(name: string, value: Color4): ShaderMaterial;
  19625. /**
  19626. * Set a vec4 array in the shader from a Color4 array.
  19627. * @param name Define the name of the uniform as defined in the shader
  19628. * @param value Define the value to give to the uniform
  19629. * @return the material itself allowing "fluent" like uniform updates
  19630. */
  19631. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19632. /**
  19633. * Set a vec2 in the shader from a Vector2.
  19634. * @param name Define the name of the uniform as defined in the shader
  19635. * @param value Define the value to give to the uniform
  19636. * @return the material itself allowing "fluent" like uniform updates
  19637. */
  19638. setVector2(name: string, value: Vector2): ShaderMaterial;
  19639. /**
  19640. * Set a vec3 in the shader from a Vector3.
  19641. * @param name Define the name of the uniform as defined in the shader
  19642. * @param value Define the value to give to the uniform
  19643. * @return the material itself allowing "fluent" like uniform updates
  19644. */
  19645. setVector3(name: string, value: Vector3): ShaderMaterial;
  19646. /**
  19647. * Set a vec4 in the shader from a Vector4.
  19648. * @param name Define the name of the uniform as defined in the shader
  19649. * @param value Define the value to give to the uniform
  19650. * @return the material itself allowing "fluent" like uniform updates
  19651. */
  19652. setVector4(name: string, value: Vector4): ShaderMaterial;
  19653. /**
  19654. * Set a mat4 in the shader from a Matrix.
  19655. * @param name Define the name of the uniform as defined in the shader
  19656. * @param value Define the value to give to the uniform
  19657. * @return the material itself allowing "fluent" like uniform updates
  19658. */
  19659. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19660. /**
  19661. * Set a float32Array in the shader from a matrix array.
  19662. * @param name Define the name of the uniform as defined in the shader
  19663. * @param value Define the value to give to the uniform
  19664. * @return the material itself allowing "fluent" like uniform updates
  19665. */
  19666. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19667. /**
  19668. * Set a mat3 in the shader from a Float32Array.
  19669. * @param name Define the name of the uniform as defined in the shader
  19670. * @param value Define the value to give to the uniform
  19671. * @return the material itself allowing "fluent" like uniform updates
  19672. */
  19673. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19674. /**
  19675. * Set a mat2 in the shader from a Float32Array.
  19676. * @param name Define the name of the uniform as defined in the shader
  19677. * @param value Define the value to give to the uniform
  19678. * @return the material itself allowing "fluent" like uniform updates
  19679. */
  19680. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19681. /**
  19682. * Set a vec2 array in the shader from a number array.
  19683. * @param name Define the name of the uniform as defined in the shader
  19684. * @param value Define the value to give to the uniform
  19685. * @return the material itself allowing "fluent" like uniform updates
  19686. */
  19687. setArray2(name: string, value: number[]): ShaderMaterial;
  19688. /**
  19689. * Set a vec3 array in the shader from a number array.
  19690. * @param name Define the name of the uniform as defined in the shader
  19691. * @param value Define the value to give to the uniform
  19692. * @return the material itself allowing "fluent" like uniform updates
  19693. */
  19694. setArray3(name: string, value: number[]): ShaderMaterial;
  19695. /**
  19696. * Set a vec4 array in the shader from a number array.
  19697. * @param name Define the name of the uniform as defined in the shader
  19698. * @param value Define the value to give to the uniform
  19699. * @return the material itself allowing "fluent" like uniform updates
  19700. */
  19701. setArray4(name: string, value: number[]): ShaderMaterial;
  19702. private _checkCache;
  19703. /**
  19704. * Specifies that the submesh is ready to be used
  19705. * @param mesh defines the mesh to check
  19706. * @param subMesh defines which submesh to check
  19707. * @param useInstances specifies that instances should be used
  19708. * @returns a boolean indicating that the submesh is ready or not
  19709. */
  19710. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19711. /**
  19712. * Checks if the material is ready to render the requested mesh
  19713. * @param mesh Define the mesh to render
  19714. * @param useInstances Define whether or not the material is used with instances
  19715. * @returns true if ready, otherwise false
  19716. */
  19717. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19718. /**
  19719. * Binds the world matrix to the material
  19720. * @param world defines the world transformation matrix
  19721. */
  19722. bindOnlyWorldMatrix(world: Matrix): void;
  19723. /**
  19724. * Binds the material to the mesh
  19725. * @param world defines the world transformation matrix
  19726. * @param mesh defines the mesh to bind the material to
  19727. */
  19728. bind(world: Matrix, mesh?: Mesh): void;
  19729. /**
  19730. * Gets the active textures from the material
  19731. * @returns an array of textures
  19732. */
  19733. getActiveTextures(): BaseTexture[];
  19734. /**
  19735. * Specifies if the material uses a texture
  19736. * @param texture defines the texture to check against the material
  19737. * @returns a boolean specifying if the material uses the texture
  19738. */
  19739. hasTexture(texture: BaseTexture): boolean;
  19740. /**
  19741. * Makes a duplicate of the material, and gives it a new name
  19742. * @param name defines the new name for the duplicated material
  19743. * @returns the cloned material
  19744. */
  19745. clone(name: string): ShaderMaterial;
  19746. /**
  19747. * Disposes the material
  19748. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19749. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19750. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19751. */
  19752. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19753. /**
  19754. * Serializes this material in a JSON representation
  19755. * @returns the serialized material object
  19756. */
  19757. serialize(): any;
  19758. /**
  19759. * Creates a shader material from parsed shader material data
  19760. * @param source defines the JSON represnetation of the material
  19761. * @param scene defines the hosting scene
  19762. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19763. * @returns a new material
  19764. */
  19765. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19766. }
  19767. }
  19768. declare module BABYLON {
  19769. /** @hidden */
  19770. export var colorPixelShader: {
  19771. name: string;
  19772. shader: string;
  19773. };
  19774. }
  19775. declare module BABYLON {
  19776. /** @hidden */
  19777. export var colorVertexShader: {
  19778. name: string;
  19779. shader: string;
  19780. };
  19781. }
  19782. declare module BABYLON {
  19783. /**
  19784. * Line mesh
  19785. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19786. */
  19787. export class LinesMesh extends Mesh {
  19788. /**
  19789. * If vertex color should be applied to the mesh
  19790. */
  19791. readonly useVertexColor?: boolean | undefined;
  19792. /**
  19793. * If vertex alpha should be applied to the mesh
  19794. */
  19795. readonly useVertexAlpha?: boolean | undefined;
  19796. /**
  19797. * Color of the line (Default: White)
  19798. */
  19799. color: Color3;
  19800. /**
  19801. * Alpha of the line (Default: 1)
  19802. */
  19803. alpha: number;
  19804. /**
  19805. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19806. * This margin is expressed in world space coordinates, so its value may vary.
  19807. * Default value is 0.1
  19808. */
  19809. intersectionThreshold: number;
  19810. private _colorShader;
  19811. private color4;
  19812. /**
  19813. * Creates a new LinesMesh
  19814. * @param name defines the name
  19815. * @param scene defines the hosting scene
  19816. * @param parent defines the parent mesh if any
  19817. * @param source defines the optional source LinesMesh used to clone data from
  19818. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19819. * When false, achieved by calling a clone(), also passing False.
  19820. * This will make creation of children, recursive.
  19821. * @param useVertexColor defines if this LinesMesh supports vertex color
  19822. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19823. */
  19824. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19825. /**
  19826. * If vertex color should be applied to the mesh
  19827. */
  19828. useVertexColor?: boolean | undefined,
  19829. /**
  19830. * If vertex alpha should be applied to the mesh
  19831. */
  19832. useVertexAlpha?: boolean | undefined);
  19833. private _addClipPlaneDefine;
  19834. private _removeClipPlaneDefine;
  19835. isReady(): boolean;
  19836. /**
  19837. * Returns the string "LineMesh"
  19838. */
  19839. getClassName(): string;
  19840. /**
  19841. * @hidden
  19842. */
  19843. get material(): Material;
  19844. /**
  19845. * @hidden
  19846. */
  19847. set material(value: Material);
  19848. /**
  19849. * @hidden
  19850. */
  19851. get checkCollisions(): boolean;
  19852. /** @hidden */
  19853. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19854. /** @hidden */
  19855. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19856. /**
  19857. * Disposes of the line mesh
  19858. * @param doNotRecurse If children should be disposed
  19859. */
  19860. dispose(doNotRecurse?: boolean): void;
  19861. /**
  19862. * Returns a new LineMesh object cloned from the current one.
  19863. */
  19864. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  19865. /**
  19866. * Creates a new InstancedLinesMesh object from the mesh model.
  19867. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19868. * @param name defines the name of the new instance
  19869. * @returns a new InstancedLinesMesh
  19870. */
  19871. createInstance(name: string): InstancedLinesMesh;
  19872. }
  19873. /**
  19874. * Creates an instance based on a source LinesMesh
  19875. */
  19876. export class InstancedLinesMesh extends InstancedMesh {
  19877. /**
  19878. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19879. * This margin is expressed in world space coordinates, so its value may vary.
  19880. * Initilized with the intersectionThreshold value of the source LinesMesh
  19881. */
  19882. intersectionThreshold: number;
  19883. constructor(name: string, source: LinesMesh);
  19884. /**
  19885. * Returns the string "InstancedLinesMesh".
  19886. */
  19887. getClassName(): string;
  19888. }
  19889. }
  19890. declare module BABYLON {
  19891. /** @hidden */
  19892. export var linePixelShader: {
  19893. name: string;
  19894. shader: string;
  19895. };
  19896. }
  19897. declare module BABYLON {
  19898. /** @hidden */
  19899. export var lineVertexShader: {
  19900. name: string;
  19901. shader: string;
  19902. };
  19903. }
  19904. declare module BABYLON {
  19905. interface AbstractMesh {
  19906. /**
  19907. * Gets the edgesRenderer associated with the mesh
  19908. */
  19909. edgesRenderer: Nullable<EdgesRenderer>;
  19910. }
  19911. interface LinesMesh {
  19912. /**
  19913. * Enables the edge rendering mode on the mesh.
  19914. * This mode makes the mesh edges visible
  19915. * @param epsilon defines the maximal distance between two angles to detect a face
  19916. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19917. * @returns the currentAbstractMesh
  19918. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19919. */
  19920. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19921. }
  19922. interface InstancedLinesMesh {
  19923. /**
  19924. * Enables the edge rendering mode on the mesh.
  19925. * This mode makes the mesh edges visible
  19926. * @param epsilon defines the maximal distance between two angles to detect a face
  19927. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19928. * @returns the current InstancedLinesMesh
  19929. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19930. */
  19931. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19932. }
  19933. /**
  19934. * Defines the minimum contract an Edges renderer should follow.
  19935. */
  19936. export interface IEdgesRenderer extends IDisposable {
  19937. /**
  19938. * Gets or sets a boolean indicating if the edgesRenderer is active
  19939. */
  19940. isEnabled: boolean;
  19941. /**
  19942. * Renders the edges of the attached mesh,
  19943. */
  19944. render(): void;
  19945. /**
  19946. * Checks wether or not the edges renderer is ready to render.
  19947. * @return true if ready, otherwise false.
  19948. */
  19949. isReady(): boolean;
  19950. }
  19951. /**
  19952. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19953. */
  19954. export class EdgesRenderer implements IEdgesRenderer {
  19955. /**
  19956. * Define the size of the edges with an orthographic camera
  19957. */
  19958. edgesWidthScalerForOrthographic: number;
  19959. /**
  19960. * Define the size of the edges with a perspective camera
  19961. */
  19962. edgesWidthScalerForPerspective: number;
  19963. protected _source: AbstractMesh;
  19964. protected _linesPositions: number[];
  19965. protected _linesNormals: number[];
  19966. protected _linesIndices: number[];
  19967. protected _epsilon: number;
  19968. protected _indicesCount: number;
  19969. protected _lineShader: ShaderMaterial;
  19970. protected _ib: DataBuffer;
  19971. protected _buffers: {
  19972. [key: string]: Nullable<VertexBuffer>;
  19973. };
  19974. protected _checkVerticesInsteadOfIndices: boolean;
  19975. private _meshRebuildObserver;
  19976. private _meshDisposeObserver;
  19977. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19978. isEnabled: boolean;
  19979. /**
  19980. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19981. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19982. * @param source Mesh used to create edges
  19983. * @param epsilon sum of angles in adjacency to check for edge
  19984. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19985. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19986. */
  19987. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19988. protected _prepareRessources(): void;
  19989. /** @hidden */
  19990. _rebuild(): void;
  19991. /**
  19992. * Releases the required resources for the edges renderer
  19993. */
  19994. dispose(): void;
  19995. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19996. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19997. /**
  19998. * Checks if the pair of p0 and p1 is en edge
  19999. * @param faceIndex
  20000. * @param edge
  20001. * @param faceNormals
  20002. * @param p0
  20003. * @param p1
  20004. * @private
  20005. */
  20006. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20007. /**
  20008. * push line into the position, normal and index buffer
  20009. * @protected
  20010. */
  20011. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20012. /**
  20013. * Generates lines edges from adjacencjes
  20014. * @private
  20015. */
  20016. _generateEdgesLines(): void;
  20017. /**
  20018. * Checks wether or not the edges renderer is ready to render.
  20019. * @return true if ready, otherwise false.
  20020. */
  20021. isReady(): boolean;
  20022. /**
  20023. * Renders the edges of the attached mesh,
  20024. */
  20025. render(): void;
  20026. }
  20027. /**
  20028. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20029. */
  20030. export class LineEdgesRenderer extends EdgesRenderer {
  20031. /**
  20032. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20033. * @param source LineMesh used to generate edges
  20034. * @param epsilon not important (specified angle for edge detection)
  20035. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20036. */
  20037. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20038. /**
  20039. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20040. */
  20041. _generateEdgesLines(): void;
  20042. }
  20043. }
  20044. declare module BABYLON {
  20045. /**
  20046. * This represents the object necessary to create a rendering group.
  20047. * This is exclusively used and created by the rendering manager.
  20048. * To modify the behavior, you use the available helpers in your scene or meshes.
  20049. * @hidden
  20050. */
  20051. export class RenderingGroup {
  20052. index: number;
  20053. private static _zeroVector;
  20054. private _scene;
  20055. private _opaqueSubMeshes;
  20056. private _transparentSubMeshes;
  20057. private _alphaTestSubMeshes;
  20058. private _depthOnlySubMeshes;
  20059. private _particleSystems;
  20060. private _spriteManagers;
  20061. private _opaqueSortCompareFn;
  20062. private _alphaTestSortCompareFn;
  20063. private _transparentSortCompareFn;
  20064. private _renderOpaque;
  20065. private _renderAlphaTest;
  20066. private _renderTransparent;
  20067. /** @hidden */
  20068. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20069. onBeforeTransparentRendering: () => void;
  20070. /**
  20071. * Set the opaque sort comparison function.
  20072. * If null the sub meshes will be render in the order they were created
  20073. */
  20074. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20075. /**
  20076. * Set the alpha test sort comparison function.
  20077. * If null the sub meshes will be render in the order they were created
  20078. */
  20079. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20080. /**
  20081. * Set the transparent sort comparison function.
  20082. * If null the sub meshes will be render in the order they were created
  20083. */
  20084. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20085. /**
  20086. * Creates a new rendering group.
  20087. * @param index The rendering group index
  20088. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20089. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20090. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20091. */
  20092. 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>);
  20093. /**
  20094. * Render all the sub meshes contained in the group.
  20095. * @param customRenderFunction Used to override the default render behaviour of the group.
  20096. * @returns true if rendered some submeshes.
  20097. */
  20098. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20099. /**
  20100. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20101. * @param subMeshes The submeshes to render
  20102. */
  20103. private renderOpaqueSorted;
  20104. /**
  20105. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20106. * @param subMeshes The submeshes to render
  20107. */
  20108. private renderAlphaTestSorted;
  20109. /**
  20110. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20111. * @param subMeshes The submeshes to render
  20112. */
  20113. private renderTransparentSorted;
  20114. /**
  20115. * Renders the submeshes in a specified order.
  20116. * @param subMeshes The submeshes to sort before render
  20117. * @param sortCompareFn The comparison function use to sort
  20118. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20119. * @param transparent Specifies to activate blending if true
  20120. */
  20121. private static renderSorted;
  20122. /**
  20123. * Renders the submeshes in the order they were dispatched (no sort applied).
  20124. * @param subMeshes The submeshes to render
  20125. */
  20126. private static renderUnsorted;
  20127. /**
  20128. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20129. * are rendered back to front if in the same alpha index.
  20130. *
  20131. * @param a The first submesh
  20132. * @param b The second submesh
  20133. * @returns The result of the comparison
  20134. */
  20135. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20136. /**
  20137. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20138. * are rendered back to front.
  20139. *
  20140. * @param a The first submesh
  20141. * @param b The second submesh
  20142. * @returns The result of the comparison
  20143. */
  20144. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20145. /**
  20146. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20147. * are rendered front to back (prevent overdraw).
  20148. *
  20149. * @param a The first submesh
  20150. * @param b The second submesh
  20151. * @returns The result of the comparison
  20152. */
  20153. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20154. /**
  20155. * Resets the different lists of submeshes to prepare a new frame.
  20156. */
  20157. prepare(): void;
  20158. dispose(): void;
  20159. /**
  20160. * Inserts the submesh in its correct queue depending on its material.
  20161. * @param subMesh The submesh to dispatch
  20162. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20163. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20164. */
  20165. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20166. dispatchSprites(spriteManager: ISpriteManager): void;
  20167. dispatchParticles(particleSystem: IParticleSystem): void;
  20168. private _renderParticles;
  20169. private _renderSprites;
  20170. }
  20171. }
  20172. declare module BABYLON {
  20173. /**
  20174. * Interface describing the different options available in the rendering manager
  20175. * regarding Auto Clear between groups.
  20176. */
  20177. export interface IRenderingManagerAutoClearSetup {
  20178. /**
  20179. * Defines whether or not autoclear is enable.
  20180. */
  20181. autoClear: boolean;
  20182. /**
  20183. * Defines whether or not to autoclear the depth buffer.
  20184. */
  20185. depth: boolean;
  20186. /**
  20187. * Defines whether or not to autoclear the stencil buffer.
  20188. */
  20189. stencil: boolean;
  20190. }
  20191. /**
  20192. * This class is used by the onRenderingGroupObservable
  20193. */
  20194. export class RenderingGroupInfo {
  20195. /**
  20196. * The Scene that being rendered
  20197. */
  20198. scene: Scene;
  20199. /**
  20200. * The camera currently used for the rendering pass
  20201. */
  20202. camera: Nullable<Camera>;
  20203. /**
  20204. * The ID of the renderingGroup being processed
  20205. */
  20206. renderingGroupId: number;
  20207. }
  20208. /**
  20209. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20210. * It is enable to manage the different groups as well as the different necessary sort functions.
  20211. * This should not be used directly aside of the few static configurations
  20212. */
  20213. export class RenderingManager {
  20214. /**
  20215. * The max id used for rendering groups (not included)
  20216. */
  20217. static MAX_RENDERINGGROUPS: number;
  20218. /**
  20219. * The min id used for rendering groups (included)
  20220. */
  20221. static MIN_RENDERINGGROUPS: number;
  20222. /**
  20223. * Used to globally prevent autoclearing scenes.
  20224. */
  20225. static AUTOCLEAR: boolean;
  20226. /**
  20227. * @hidden
  20228. */
  20229. _useSceneAutoClearSetup: boolean;
  20230. private _scene;
  20231. private _renderingGroups;
  20232. private _depthStencilBufferAlreadyCleaned;
  20233. private _autoClearDepthStencil;
  20234. private _customOpaqueSortCompareFn;
  20235. private _customAlphaTestSortCompareFn;
  20236. private _customTransparentSortCompareFn;
  20237. private _renderingGroupInfo;
  20238. /**
  20239. * Instantiates a new rendering group for a particular scene
  20240. * @param scene Defines the scene the groups belongs to
  20241. */
  20242. constructor(scene: Scene);
  20243. private _clearDepthStencilBuffer;
  20244. /**
  20245. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20246. * @hidden
  20247. */
  20248. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20249. /**
  20250. * Resets the different information of the group to prepare a new frame
  20251. * @hidden
  20252. */
  20253. reset(): void;
  20254. /**
  20255. * Dispose and release the group and its associated resources.
  20256. * @hidden
  20257. */
  20258. dispose(): void;
  20259. /**
  20260. * Clear the info related to rendering groups preventing retention points during dispose.
  20261. */
  20262. freeRenderingGroups(): void;
  20263. private _prepareRenderingGroup;
  20264. /**
  20265. * Add a sprite manager to the rendering manager in order to render it this frame.
  20266. * @param spriteManager Define the sprite manager to render
  20267. */
  20268. dispatchSprites(spriteManager: ISpriteManager): void;
  20269. /**
  20270. * Add a particle system to the rendering manager in order to render it this frame.
  20271. * @param particleSystem Define the particle system to render
  20272. */
  20273. dispatchParticles(particleSystem: IParticleSystem): void;
  20274. /**
  20275. * Add a submesh to the manager in order to render it this frame
  20276. * @param subMesh The submesh to dispatch
  20277. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20278. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20279. */
  20280. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20281. /**
  20282. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20283. * This allowed control for front to back rendering or reversly depending of the special needs.
  20284. *
  20285. * @param renderingGroupId The rendering group id corresponding to its index
  20286. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20287. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20288. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20289. */
  20290. 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;
  20291. /**
  20292. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20293. *
  20294. * @param renderingGroupId The rendering group id corresponding to its index
  20295. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20296. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20297. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20298. */
  20299. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20300. /**
  20301. * Gets the current auto clear configuration for one rendering group of the rendering
  20302. * manager.
  20303. * @param index the rendering group index to get the information for
  20304. * @returns The auto clear setup for the requested rendering group
  20305. */
  20306. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20307. }
  20308. }
  20309. declare module BABYLON {
  20310. /**
  20311. * This Helps creating a texture that will be created from a camera in your scene.
  20312. * It is basically a dynamic texture that could be used to create special effects for instance.
  20313. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20314. */
  20315. export class RenderTargetTexture extends Texture {
  20316. isCube: boolean;
  20317. /**
  20318. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20319. */
  20320. static readonly REFRESHRATE_RENDER_ONCE: number;
  20321. /**
  20322. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20323. */
  20324. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20325. /**
  20326. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20327. * the central point of your effect and can save a lot of performances.
  20328. */
  20329. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20330. /**
  20331. * Use this predicate to dynamically define the list of mesh you want to render.
  20332. * If set, the renderList property will be overwritten.
  20333. */
  20334. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20335. private _renderList;
  20336. /**
  20337. * Use this list to define the list of mesh you want to render.
  20338. */
  20339. get renderList(): Nullable<Array<AbstractMesh>>;
  20340. set renderList(value: Nullable<Array<AbstractMesh>>);
  20341. /**
  20342. * Use this function to overload the renderList array at rendering time.
  20343. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20344. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20345. * the cube (if the RTT is a cube, else layerOrFace=0).
  20346. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  20347. */
  20348. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  20349. private _hookArray;
  20350. /**
  20351. * Define if particles should be rendered in your texture.
  20352. */
  20353. renderParticles: boolean;
  20354. /**
  20355. * Define if sprites should be rendered in your texture.
  20356. */
  20357. renderSprites: boolean;
  20358. /**
  20359. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20360. */
  20361. coordinatesMode: number;
  20362. /**
  20363. * Define the camera used to render the texture.
  20364. */
  20365. activeCamera: Nullable<Camera>;
  20366. /**
  20367. * Override the render function of the texture with your own one.
  20368. */
  20369. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20370. /**
  20371. * Define if camera post processes should be use while rendering the texture.
  20372. */
  20373. useCameraPostProcesses: boolean;
  20374. /**
  20375. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20376. */
  20377. ignoreCameraViewport: boolean;
  20378. private _postProcessManager;
  20379. private _postProcesses;
  20380. private _resizeObserver;
  20381. /**
  20382. * An event triggered when the texture is unbind.
  20383. */
  20384. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20385. /**
  20386. * An event triggered when the texture is unbind.
  20387. */
  20388. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20389. private _onAfterUnbindObserver;
  20390. /**
  20391. * Set a after unbind callback in the texture.
  20392. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20393. */
  20394. set onAfterUnbind(callback: () => void);
  20395. /**
  20396. * An event triggered before rendering the texture
  20397. */
  20398. onBeforeRenderObservable: Observable<number>;
  20399. private _onBeforeRenderObserver;
  20400. /**
  20401. * Set a before render callback in the texture.
  20402. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20403. */
  20404. set onBeforeRender(callback: (faceIndex: number) => void);
  20405. /**
  20406. * An event triggered after rendering the texture
  20407. */
  20408. onAfterRenderObservable: Observable<number>;
  20409. private _onAfterRenderObserver;
  20410. /**
  20411. * Set a after render callback in the texture.
  20412. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20413. */
  20414. set onAfterRender(callback: (faceIndex: number) => void);
  20415. /**
  20416. * An event triggered after the texture clear
  20417. */
  20418. onClearObservable: Observable<Engine>;
  20419. private _onClearObserver;
  20420. /**
  20421. * Set a clear callback in the texture.
  20422. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20423. */
  20424. set onClear(callback: (Engine: Engine) => void);
  20425. /**
  20426. * An event triggered when the texture is resized.
  20427. */
  20428. onResizeObservable: Observable<RenderTargetTexture>;
  20429. /**
  20430. * Define the clear color of the Render Target if it should be different from the scene.
  20431. */
  20432. clearColor: Color4;
  20433. protected _size: number | {
  20434. width: number;
  20435. height: number;
  20436. layers?: number;
  20437. };
  20438. protected _initialSizeParameter: number | {
  20439. width: number;
  20440. height: number;
  20441. } | {
  20442. ratio: number;
  20443. };
  20444. protected _sizeRatio: Nullable<number>;
  20445. /** @hidden */
  20446. _generateMipMaps: boolean;
  20447. protected _renderingManager: RenderingManager;
  20448. /** @hidden */
  20449. _waitingRenderList: string[];
  20450. protected _doNotChangeAspectRatio: boolean;
  20451. protected _currentRefreshId: number;
  20452. protected _refreshRate: number;
  20453. protected _textureMatrix: Matrix;
  20454. protected _samples: number;
  20455. protected _renderTargetOptions: RenderTargetCreationOptions;
  20456. /**
  20457. * Gets render target creation options that were used.
  20458. */
  20459. get renderTargetOptions(): RenderTargetCreationOptions;
  20460. protected _engine: Engine;
  20461. protected _onRatioRescale(): void;
  20462. /**
  20463. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20464. * It must define where the camera used to render the texture is set
  20465. */
  20466. boundingBoxPosition: Vector3;
  20467. private _boundingBoxSize;
  20468. /**
  20469. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20470. * When defined, the cubemap will switch to local mode
  20471. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20472. * @example https://www.babylonjs-playground.com/#RNASML
  20473. */
  20474. set boundingBoxSize(value: Vector3);
  20475. get boundingBoxSize(): Vector3;
  20476. /**
  20477. * In case the RTT has been created with a depth texture, get the associated
  20478. * depth texture.
  20479. * Otherwise, return null.
  20480. */
  20481. get depthStencilTexture(): Nullable<InternalTexture>;
  20482. /**
  20483. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20484. * or used a shadow, depth texture...
  20485. * @param name The friendly name of the texture
  20486. * @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)
  20487. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20488. * @param generateMipMaps True if mip maps need to be generated after render.
  20489. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20490. * @param type The type of the buffer in the RTT (int, half float, float...)
  20491. * @param isCube True if a cube texture needs to be created
  20492. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20493. * @param generateDepthBuffer True to generate a depth buffer
  20494. * @param generateStencilBuffer True to generate a stencil buffer
  20495. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20496. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20497. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20498. */
  20499. constructor(name: string, size: number | {
  20500. width: number;
  20501. height: number;
  20502. layers?: number;
  20503. } | {
  20504. ratio: number;
  20505. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20506. /**
  20507. * Creates a depth stencil texture.
  20508. * This is only available in WebGL 2 or with the depth texture extension available.
  20509. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20510. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20511. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20512. */
  20513. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20514. private _processSizeParameter;
  20515. /**
  20516. * Define the number of samples to use in case of MSAA.
  20517. * It defaults to one meaning no MSAA has been enabled.
  20518. */
  20519. get samples(): number;
  20520. set samples(value: number);
  20521. /**
  20522. * Resets the refresh counter of the texture and start bak from scratch.
  20523. * Could be useful to regenerate the texture if it is setup to render only once.
  20524. */
  20525. resetRefreshCounter(): void;
  20526. /**
  20527. * Define the refresh rate of the texture or the rendering frequency.
  20528. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20529. */
  20530. get refreshRate(): number;
  20531. set refreshRate(value: number);
  20532. /**
  20533. * Adds a post process to the render target rendering passes.
  20534. * @param postProcess define the post process to add
  20535. */
  20536. addPostProcess(postProcess: PostProcess): void;
  20537. /**
  20538. * Clear all the post processes attached to the render target
  20539. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20540. */
  20541. clearPostProcesses(dispose?: boolean): void;
  20542. /**
  20543. * Remove one of the post process from the list of attached post processes to the texture
  20544. * @param postProcess define the post process to remove from the list
  20545. */
  20546. removePostProcess(postProcess: PostProcess): void;
  20547. /** @hidden */
  20548. _shouldRender(): boolean;
  20549. /**
  20550. * Gets the actual render size of the texture.
  20551. * @returns the width of the render size
  20552. */
  20553. getRenderSize(): number;
  20554. /**
  20555. * Gets the actual render width of the texture.
  20556. * @returns the width of the render size
  20557. */
  20558. getRenderWidth(): number;
  20559. /**
  20560. * Gets the actual render height of the texture.
  20561. * @returns the height of the render size
  20562. */
  20563. getRenderHeight(): number;
  20564. /**
  20565. * Gets the actual number of layers of the texture.
  20566. * @returns the number of layers
  20567. */
  20568. getRenderLayers(): number;
  20569. /**
  20570. * Get if the texture can be rescaled or not.
  20571. */
  20572. get canRescale(): boolean;
  20573. /**
  20574. * Resize the texture using a ratio.
  20575. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20576. */
  20577. scale(ratio: number): void;
  20578. /**
  20579. * Get the texture reflection matrix used to rotate/transform the reflection.
  20580. * @returns the reflection matrix
  20581. */
  20582. getReflectionTextureMatrix(): Matrix;
  20583. /**
  20584. * Resize the texture to a new desired size.
  20585. * Be carrefull as it will recreate all the data in the new texture.
  20586. * @param size Define the new size. It can be:
  20587. * - a number for squared texture,
  20588. * - an object containing { width: number, height: number }
  20589. * - or an object containing a ratio { ratio: number }
  20590. */
  20591. resize(size: number | {
  20592. width: number;
  20593. height: number;
  20594. } | {
  20595. ratio: number;
  20596. }): void;
  20597. private _defaultRenderListPrepared;
  20598. /**
  20599. * Renders all the objects from the render list into the texture.
  20600. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20601. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20602. */
  20603. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20604. private _bestReflectionRenderTargetDimension;
  20605. private _prepareRenderingManager;
  20606. /**
  20607. * @hidden
  20608. * @param faceIndex face index to bind to if this is a cubetexture
  20609. * @param layer defines the index of the texture to bind in the array
  20610. */
  20611. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20612. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20613. private renderToTarget;
  20614. /**
  20615. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20616. * This allowed control for front to back rendering or reversly depending of the special needs.
  20617. *
  20618. * @param renderingGroupId The rendering group id corresponding to its index
  20619. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20620. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20621. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20622. */
  20623. 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;
  20624. /**
  20625. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20626. *
  20627. * @param renderingGroupId The rendering group id corresponding to its index
  20628. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20629. */
  20630. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20631. /**
  20632. * Clones the texture.
  20633. * @returns the cloned texture
  20634. */
  20635. clone(): RenderTargetTexture;
  20636. /**
  20637. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20638. * @returns The JSON representation of the texture
  20639. */
  20640. serialize(): any;
  20641. /**
  20642. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20643. */
  20644. disposeFramebufferObjects(): void;
  20645. /**
  20646. * Dispose the texture and release its associated resources.
  20647. */
  20648. dispose(): void;
  20649. /** @hidden */
  20650. _rebuild(): void;
  20651. /**
  20652. * Clear the info related to rendering groups preventing retention point in material dispose.
  20653. */
  20654. freeRenderingGroups(): void;
  20655. /**
  20656. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20657. * @returns the view count
  20658. */
  20659. getViewCount(): number;
  20660. }
  20661. }
  20662. declare module BABYLON {
  20663. /**
  20664. * Options for compiling materials.
  20665. */
  20666. export interface IMaterialCompilationOptions {
  20667. /**
  20668. * Defines whether clip planes are enabled.
  20669. */
  20670. clipPlane: boolean;
  20671. /**
  20672. * Defines whether instances are enabled.
  20673. */
  20674. useInstances: boolean;
  20675. }
  20676. /**
  20677. * Base class for the main features of a material in Babylon.js
  20678. */
  20679. export class Material implements IAnimatable {
  20680. /**
  20681. * Returns the triangle fill mode
  20682. */
  20683. static readonly TriangleFillMode: number;
  20684. /**
  20685. * Returns the wireframe mode
  20686. */
  20687. static readonly WireFrameFillMode: number;
  20688. /**
  20689. * Returns the point fill mode
  20690. */
  20691. static readonly PointFillMode: number;
  20692. /**
  20693. * Returns the point list draw mode
  20694. */
  20695. static readonly PointListDrawMode: number;
  20696. /**
  20697. * Returns the line list draw mode
  20698. */
  20699. static readonly LineListDrawMode: number;
  20700. /**
  20701. * Returns the line loop draw mode
  20702. */
  20703. static readonly LineLoopDrawMode: number;
  20704. /**
  20705. * Returns the line strip draw mode
  20706. */
  20707. static readonly LineStripDrawMode: number;
  20708. /**
  20709. * Returns the triangle strip draw mode
  20710. */
  20711. static readonly TriangleStripDrawMode: number;
  20712. /**
  20713. * Returns the triangle fan draw mode
  20714. */
  20715. static readonly TriangleFanDrawMode: number;
  20716. /**
  20717. * Stores the clock-wise side orientation
  20718. */
  20719. static readonly ClockWiseSideOrientation: number;
  20720. /**
  20721. * Stores the counter clock-wise side orientation
  20722. */
  20723. static readonly CounterClockWiseSideOrientation: number;
  20724. /**
  20725. * The dirty texture flag value
  20726. */
  20727. static readonly TextureDirtyFlag: number;
  20728. /**
  20729. * The dirty light flag value
  20730. */
  20731. static readonly LightDirtyFlag: number;
  20732. /**
  20733. * The dirty fresnel flag value
  20734. */
  20735. static readonly FresnelDirtyFlag: number;
  20736. /**
  20737. * The dirty attribute flag value
  20738. */
  20739. static readonly AttributesDirtyFlag: number;
  20740. /**
  20741. * The dirty misc flag value
  20742. */
  20743. static readonly MiscDirtyFlag: number;
  20744. /**
  20745. * The all dirty flag value
  20746. */
  20747. static readonly AllDirtyFlag: number;
  20748. /**
  20749. * The ID of the material
  20750. */
  20751. id: string;
  20752. /**
  20753. * Gets or sets the unique id of the material
  20754. */
  20755. uniqueId: number;
  20756. /**
  20757. * The name of the material
  20758. */
  20759. name: string;
  20760. /**
  20761. * Gets or sets user defined metadata
  20762. */
  20763. metadata: any;
  20764. /**
  20765. * For internal use only. Please do not use.
  20766. */
  20767. reservedDataStore: any;
  20768. /**
  20769. * Specifies if the ready state should be checked on each call
  20770. */
  20771. checkReadyOnEveryCall: boolean;
  20772. /**
  20773. * Specifies if the ready state should be checked once
  20774. */
  20775. checkReadyOnlyOnce: boolean;
  20776. /**
  20777. * The state of the material
  20778. */
  20779. state: string;
  20780. /**
  20781. * The alpha value of the material
  20782. */
  20783. protected _alpha: number;
  20784. /**
  20785. * List of inspectable custom properties (used by the Inspector)
  20786. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20787. */
  20788. inspectableCustomProperties: IInspectable[];
  20789. /**
  20790. * Sets the alpha value of the material
  20791. */
  20792. set alpha(value: number);
  20793. /**
  20794. * Gets the alpha value of the material
  20795. */
  20796. get alpha(): number;
  20797. /**
  20798. * Specifies if back face culling is enabled
  20799. */
  20800. protected _backFaceCulling: boolean;
  20801. /**
  20802. * Sets the back-face culling state
  20803. */
  20804. set backFaceCulling(value: boolean);
  20805. /**
  20806. * Gets the back-face culling state
  20807. */
  20808. get backFaceCulling(): boolean;
  20809. /**
  20810. * Stores the value for side orientation
  20811. */
  20812. sideOrientation: number;
  20813. /**
  20814. * Callback triggered when the material is compiled
  20815. */
  20816. onCompiled: Nullable<(effect: Effect) => void>;
  20817. /**
  20818. * Callback triggered when an error occurs
  20819. */
  20820. onError: Nullable<(effect: Effect, errors: string) => void>;
  20821. /**
  20822. * Callback triggered to get the render target textures
  20823. */
  20824. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20825. /**
  20826. * Gets a boolean indicating that current material needs to register RTT
  20827. */
  20828. get hasRenderTargetTextures(): boolean;
  20829. /**
  20830. * Specifies if the material should be serialized
  20831. */
  20832. doNotSerialize: boolean;
  20833. /**
  20834. * @hidden
  20835. */
  20836. _storeEffectOnSubMeshes: boolean;
  20837. /**
  20838. * Stores the animations for the material
  20839. */
  20840. animations: Nullable<Array<Animation>>;
  20841. /**
  20842. * An event triggered when the material is disposed
  20843. */
  20844. onDisposeObservable: Observable<Material>;
  20845. /**
  20846. * An observer which watches for dispose events
  20847. */
  20848. private _onDisposeObserver;
  20849. private _onUnBindObservable;
  20850. /**
  20851. * Called during a dispose event
  20852. */
  20853. set onDispose(callback: () => void);
  20854. private _onBindObservable;
  20855. /**
  20856. * An event triggered when the material is bound
  20857. */
  20858. get onBindObservable(): Observable<AbstractMesh>;
  20859. /**
  20860. * An observer which watches for bind events
  20861. */
  20862. private _onBindObserver;
  20863. /**
  20864. * Called during a bind event
  20865. */
  20866. set onBind(callback: (Mesh: AbstractMesh) => void);
  20867. /**
  20868. * An event triggered when the material is unbound
  20869. */
  20870. get onUnBindObservable(): Observable<Material>;
  20871. /**
  20872. * Stores the value of the alpha mode
  20873. */
  20874. private _alphaMode;
  20875. /**
  20876. * Sets the value of the alpha mode.
  20877. *
  20878. * | Value | Type | Description |
  20879. * | --- | --- | --- |
  20880. * | 0 | ALPHA_DISABLE | |
  20881. * | 1 | ALPHA_ADD | |
  20882. * | 2 | ALPHA_COMBINE | |
  20883. * | 3 | ALPHA_SUBTRACT | |
  20884. * | 4 | ALPHA_MULTIPLY | |
  20885. * | 5 | ALPHA_MAXIMIZED | |
  20886. * | 6 | ALPHA_ONEONE | |
  20887. * | 7 | ALPHA_PREMULTIPLIED | |
  20888. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20889. * | 9 | ALPHA_INTERPOLATE | |
  20890. * | 10 | ALPHA_SCREENMODE | |
  20891. *
  20892. */
  20893. set alphaMode(value: number);
  20894. /**
  20895. * Gets the value of the alpha mode
  20896. */
  20897. get alphaMode(): number;
  20898. /**
  20899. * Stores the state of the need depth pre-pass value
  20900. */
  20901. private _needDepthPrePass;
  20902. /**
  20903. * Sets the need depth pre-pass value
  20904. */
  20905. set needDepthPrePass(value: boolean);
  20906. /**
  20907. * Gets the depth pre-pass value
  20908. */
  20909. get needDepthPrePass(): boolean;
  20910. /**
  20911. * Specifies if depth writing should be disabled
  20912. */
  20913. disableDepthWrite: boolean;
  20914. /**
  20915. * Specifies if depth writing should be forced
  20916. */
  20917. forceDepthWrite: boolean;
  20918. /**
  20919. * Specifies the depth function that should be used. 0 means the default engine function
  20920. */
  20921. depthFunction: number;
  20922. /**
  20923. * Specifies if there should be a separate pass for culling
  20924. */
  20925. separateCullingPass: boolean;
  20926. /**
  20927. * Stores the state specifing if fog should be enabled
  20928. */
  20929. private _fogEnabled;
  20930. /**
  20931. * Sets the state for enabling fog
  20932. */
  20933. set fogEnabled(value: boolean);
  20934. /**
  20935. * Gets the value of the fog enabled state
  20936. */
  20937. get fogEnabled(): boolean;
  20938. /**
  20939. * Stores the size of points
  20940. */
  20941. pointSize: number;
  20942. /**
  20943. * Stores the z offset value
  20944. */
  20945. zOffset: number;
  20946. /**
  20947. * Gets a value specifying if wireframe mode is enabled
  20948. */
  20949. get wireframe(): boolean;
  20950. /**
  20951. * Sets the state of wireframe mode
  20952. */
  20953. set wireframe(value: boolean);
  20954. /**
  20955. * Gets the value specifying if point clouds are enabled
  20956. */
  20957. get pointsCloud(): boolean;
  20958. /**
  20959. * Sets the state of point cloud mode
  20960. */
  20961. set pointsCloud(value: boolean);
  20962. /**
  20963. * Gets the material fill mode
  20964. */
  20965. get fillMode(): number;
  20966. /**
  20967. * Sets the material fill mode
  20968. */
  20969. set fillMode(value: number);
  20970. /**
  20971. * @hidden
  20972. * Stores the effects for the material
  20973. */
  20974. _effect: Nullable<Effect>;
  20975. /**
  20976. * Specifies if uniform buffers should be used
  20977. */
  20978. private _useUBO;
  20979. /**
  20980. * Stores a reference to the scene
  20981. */
  20982. private _scene;
  20983. /**
  20984. * Stores the fill mode state
  20985. */
  20986. private _fillMode;
  20987. /**
  20988. * Specifies if the depth write state should be cached
  20989. */
  20990. private _cachedDepthWriteState;
  20991. /**
  20992. * Specifies if the depth function state should be cached
  20993. */
  20994. private _cachedDepthFunctionState;
  20995. /**
  20996. * Stores the uniform buffer
  20997. */
  20998. protected _uniformBuffer: UniformBuffer;
  20999. /** @hidden */
  21000. _indexInSceneMaterialArray: number;
  21001. /** @hidden */
  21002. meshMap: Nullable<{
  21003. [id: string]: AbstractMesh | undefined;
  21004. }>;
  21005. /**
  21006. * Creates a material instance
  21007. * @param name defines the name of the material
  21008. * @param scene defines the scene to reference
  21009. * @param doNotAdd specifies if the material should be added to the scene
  21010. */
  21011. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21012. /**
  21013. * Returns a string representation of the current material
  21014. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21015. * @returns a string with material information
  21016. */
  21017. toString(fullDetails?: boolean): string;
  21018. /**
  21019. * Gets the class name of the material
  21020. * @returns a string with the class name of the material
  21021. */
  21022. getClassName(): string;
  21023. /**
  21024. * Specifies if updates for the material been locked
  21025. */
  21026. get isFrozen(): boolean;
  21027. /**
  21028. * Locks updates for the material
  21029. */
  21030. freeze(): void;
  21031. /**
  21032. * Unlocks updates for the material
  21033. */
  21034. unfreeze(): void;
  21035. /**
  21036. * Specifies if the material is ready to be used
  21037. * @param mesh defines the mesh to check
  21038. * @param useInstances specifies if instances should be used
  21039. * @returns a boolean indicating if the material is ready to be used
  21040. */
  21041. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21042. /**
  21043. * Specifies that the submesh is ready to be used
  21044. * @param mesh defines the mesh to check
  21045. * @param subMesh defines which submesh to check
  21046. * @param useInstances specifies that instances should be used
  21047. * @returns a boolean indicating that the submesh is ready or not
  21048. */
  21049. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21050. /**
  21051. * Returns the material effect
  21052. * @returns the effect associated with the material
  21053. */
  21054. getEffect(): Nullable<Effect>;
  21055. /**
  21056. * Returns the current scene
  21057. * @returns a Scene
  21058. */
  21059. getScene(): Scene;
  21060. /**
  21061. * Specifies if the material will require alpha blending
  21062. * @returns a boolean specifying if alpha blending is needed
  21063. */
  21064. needAlphaBlending(): boolean;
  21065. /**
  21066. * Specifies if the mesh will require alpha blending
  21067. * @param mesh defines the mesh to check
  21068. * @returns a boolean specifying if alpha blending is needed for the mesh
  21069. */
  21070. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21071. /**
  21072. * Specifies if this material should be rendered in alpha test mode
  21073. * @returns a boolean specifying if an alpha test is needed.
  21074. */
  21075. needAlphaTesting(): boolean;
  21076. /**
  21077. * Gets the texture used for the alpha test
  21078. * @returns the texture to use for alpha testing
  21079. */
  21080. getAlphaTestTexture(): Nullable<BaseTexture>;
  21081. /**
  21082. * Marks the material to indicate that it needs to be re-calculated
  21083. */
  21084. markDirty(): void;
  21085. /** @hidden */
  21086. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21087. /**
  21088. * Binds the material to the mesh
  21089. * @param world defines the world transformation matrix
  21090. * @param mesh defines the mesh to bind the material to
  21091. */
  21092. bind(world: Matrix, mesh?: Mesh): void;
  21093. /**
  21094. * Binds the submesh to the material
  21095. * @param world defines the world transformation matrix
  21096. * @param mesh defines the mesh containing the submesh
  21097. * @param subMesh defines the submesh to bind the material to
  21098. */
  21099. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21100. /**
  21101. * Binds the world matrix to the material
  21102. * @param world defines the world transformation matrix
  21103. */
  21104. bindOnlyWorldMatrix(world: Matrix): void;
  21105. /**
  21106. * Binds the scene's uniform buffer to the effect.
  21107. * @param effect defines the effect to bind to the scene uniform buffer
  21108. * @param sceneUbo defines the uniform buffer storing scene data
  21109. */
  21110. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21111. /**
  21112. * Binds the view matrix to the effect
  21113. * @param effect defines the effect to bind the view matrix to
  21114. */
  21115. bindView(effect: Effect): void;
  21116. /**
  21117. * Binds the view projection matrix to the effect
  21118. * @param effect defines the effect to bind the view projection matrix to
  21119. */
  21120. bindViewProjection(effect: Effect): void;
  21121. /**
  21122. * Specifies if material alpha testing should be turned on for the mesh
  21123. * @param mesh defines the mesh to check
  21124. */
  21125. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21126. /**
  21127. * Processes to execute after binding the material to a mesh
  21128. * @param mesh defines the rendered mesh
  21129. */
  21130. protected _afterBind(mesh?: Mesh): void;
  21131. /**
  21132. * Unbinds the material from the mesh
  21133. */
  21134. unbind(): void;
  21135. /**
  21136. * Gets the active textures from the material
  21137. * @returns an array of textures
  21138. */
  21139. getActiveTextures(): BaseTexture[];
  21140. /**
  21141. * Specifies if the material uses a texture
  21142. * @param texture defines the texture to check against the material
  21143. * @returns a boolean specifying if the material uses the texture
  21144. */
  21145. hasTexture(texture: BaseTexture): boolean;
  21146. /**
  21147. * Makes a duplicate of the material, and gives it a new name
  21148. * @param name defines the new name for the duplicated material
  21149. * @returns the cloned material
  21150. */
  21151. clone(name: string): Nullable<Material>;
  21152. /**
  21153. * Gets the meshes bound to the material
  21154. * @returns an array of meshes bound to the material
  21155. */
  21156. getBindedMeshes(): AbstractMesh[];
  21157. /**
  21158. * Force shader compilation
  21159. * @param mesh defines the mesh associated with this material
  21160. * @param onCompiled defines a function to execute once the material is compiled
  21161. * @param options defines the options to configure the compilation
  21162. * @param onError defines a function to execute if the material fails compiling
  21163. */
  21164. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21165. /**
  21166. * Force shader compilation
  21167. * @param mesh defines the mesh that will use this material
  21168. * @param options defines additional options for compiling the shaders
  21169. * @returns a promise that resolves when the compilation completes
  21170. */
  21171. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21172. private static readonly _AllDirtyCallBack;
  21173. private static readonly _ImageProcessingDirtyCallBack;
  21174. private static readonly _TextureDirtyCallBack;
  21175. private static readonly _FresnelDirtyCallBack;
  21176. private static readonly _MiscDirtyCallBack;
  21177. private static readonly _LightsDirtyCallBack;
  21178. private static readonly _AttributeDirtyCallBack;
  21179. private static _FresnelAndMiscDirtyCallBack;
  21180. private static _TextureAndMiscDirtyCallBack;
  21181. private static readonly _DirtyCallbackArray;
  21182. private static readonly _RunDirtyCallBacks;
  21183. /**
  21184. * Marks a define in the material to indicate that it needs to be re-computed
  21185. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21186. */
  21187. markAsDirty(flag: number): void;
  21188. /**
  21189. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21190. * @param func defines a function which checks material defines against the submeshes
  21191. */
  21192. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21193. /**
  21194. * Indicates that we need to re-calculated for all submeshes
  21195. */
  21196. protected _markAllSubMeshesAsAllDirty(): void;
  21197. /**
  21198. * Indicates that image processing needs to be re-calculated for all submeshes
  21199. */
  21200. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21201. /**
  21202. * Indicates that textures need to be re-calculated for all submeshes
  21203. */
  21204. protected _markAllSubMeshesAsTexturesDirty(): void;
  21205. /**
  21206. * Indicates that fresnel needs to be re-calculated for all submeshes
  21207. */
  21208. protected _markAllSubMeshesAsFresnelDirty(): void;
  21209. /**
  21210. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21211. */
  21212. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21213. /**
  21214. * Indicates that lights need to be re-calculated for all submeshes
  21215. */
  21216. protected _markAllSubMeshesAsLightsDirty(): void;
  21217. /**
  21218. * Indicates that attributes need to be re-calculated for all submeshes
  21219. */
  21220. protected _markAllSubMeshesAsAttributesDirty(): void;
  21221. /**
  21222. * Indicates that misc needs to be re-calculated for all submeshes
  21223. */
  21224. protected _markAllSubMeshesAsMiscDirty(): void;
  21225. /**
  21226. * Indicates that textures and misc need to be re-calculated for all submeshes
  21227. */
  21228. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21229. /**
  21230. * Disposes the material
  21231. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21232. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21233. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21234. */
  21235. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21236. /** @hidden */
  21237. private releaseVertexArrayObject;
  21238. /**
  21239. * Serializes this material
  21240. * @returns the serialized material object
  21241. */
  21242. serialize(): any;
  21243. /**
  21244. * Creates a material from parsed material data
  21245. * @param parsedMaterial defines parsed material data
  21246. * @param scene defines the hosting scene
  21247. * @param rootUrl defines the root URL to use to load textures
  21248. * @returns a new material
  21249. */
  21250. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21251. }
  21252. }
  21253. declare module BABYLON {
  21254. /**
  21255. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21256. * separate meshes. This can be use to improve performances.
  21257. * @see http://doc.babylonjs.com/how_to/multi_materials
  21258. */
  21259. export class MultiMaterial extends Material {
  21260. private _subMaterials;
  21261. /**
  21262. * Gets or Sets the list of Materials used within the multi material.
  21263. * They need to be ordered according to the submeshes order in the associated mesh
  21264. */
  21265. get subMaterials(): Nullable<Material>[];
  21266. set subMaterials(value: Nullable<Material>[]);
  21267. /**
  21268. * Function used to align with Node.getChildren()
  21269. * @returns the list of Materials used within the multi material
  21270. */
  21271. getChildren(): Nullable<Material>[];
  21272. /**
  21273. * Instantiates a new Multi Material
  21274. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21275. * separate meshes. This can be use to improve performances.
  21276. * @see http://doc.babylonjs.com/how_to/multi_materials
  21277. * @param name Define the name in the scene
  21278. * @param scene Define the scene the material belongs to
  21279. */
  21280. constructor(name: string, scene: Scene);
  21281. private _hookArray;
  21282. /**
  21283. * Get one of the submaterial by its index in the submaterials array
  21284. * @param index The index to look the sub material at
  21285. * @returns The Material if the index has been defined
  21286. */
  21287. getSubMaterial(index: number): Nullable<Material>;
  21288. /**
  21289. * Get the list of active textures for the whole sub materials list.
  21290. * @returns All the textures that will be used during the rendering
  21291. */
  21292. getActiveTextures(): BaseTexture[];
  21293. /**
  21294. * Gets the current class name of the material e.g. "MultiMaterial"
  21295. * Mainly use in serialization.
  21296. * @returns the class name
  21297. */
  21298. getClassName(): string;
  21299. /**
  21300. * Checks if the material is ready to render the requested sub mesh
  21301. * @param mesh Define the mesh the submesh belongs to
  21302. * @param subMesh Define the sub mesh to look readyness for
  21303. * @param useInstances Define whether or not the material is used with instances
  21304. * @returns true if ready, otherwise false
  21305. */
  21306. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21307. /**
  21308. * Clones the current material and its related sub materials
  21309. * @param name Define the name of the newly cloned material
  21310. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21311. * @returns the cloned material
  21312. */
  21313. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21314. /**
  21315. * Serializes the materials into a JSON representation.
  21316. * @returns the JSON representation
  21317. */
  21318. serialize(): any;
  21319. /**
  21320. * Dispose the material and release its associated resources
  21321. * @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)
  21322. * @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)
  21323. * @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)
  21324. */
  21325. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21326. /**
  21327. * Creates a MultiMaterial from parsed MultiMaterial data.
  21328. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21329. * @param scene defines the hosting scene
  21330. * @returns a new MultiMaterial
  21331. */
  21332. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21333. }
  21334. }
  21335. declare module BABYLON {
  21336. /**
  21337. * Base class for submeshes
  21338. */
  21339. export class BaseSubMesh {
  21340. /** @hidden */
  21341. _materialDefines: Nullable<MaterialDefines>;
  21342. /** @hidden */
  21343. _materialEffect: Nullable<Effect>;
  21344. /**
  21345. * Gets material defines used by the effect associated to the sub mesh
  21346. */
  21347. get materialDefines(): Nullable<MaterialDefines>;
  21348. /**
  21349. * Sets material defines used by the effect associated to the sub mesh
  21350. */
  21351. set materialDefines(defines: Nullable<MaterialDefines>);
  21352. /**
  21353. * Gets associated effect
  21354. */
  21355. get effect(): Nullable<Effect>;
  21356. /**
  21357. * Sets associated effect (effect used to render this submesh)
  21358. * @param effect defines the effect to associate with
  21359. * @param defines defines the set of defines used to compile this effect
  21360. */
  21361. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21362. }
  21363. /**
  21364. * Defines a subdivision inside a mesh
  21365. */
  21366. export class SubMesh extends BaseSubMesh implements ICullable {
  21367. /** the material index to use */
  21368. materialIndex: number;
  21369. /** vertex index start */
  21370. verticesStart: number;
  21371. /** vertices count */
  21372. verticesCount: number;
  21373. /** index start */
  21374. indexStart: number;
  21375. /** indices count */
  21376. indexCount: number;
  21377. /** @hidden */
  21378. _linesIndexCount: number;
  21379. private _mesh;
  21380. private _renderingMesh;
  21381. private _boundingInfo;
  21382. private _linesIndexBuffer;
  21383. /** @hidden */
  21384. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21385. /** @hidden */
  21386. _trianglePlanes: Plane[];
  21387. /** @hidden */
  21388. _lastColliderTransformMatrix: Nullable<Matrix>;
  21389. /** @hidden */
  21390. _renderId: number;
  21391. /** @hidden */
  21392. _alphaIndex: number;
  21393. /** @hidden */
  21394. _distanceToCamera: number;
  21395. /** @hidden */
  21396. _id: number;
  21397. private _currentMaterial;
  21398. /**
  21399. * Add a new submesh to a mesh
  21400. * @param materialIndex defines the material index to use
  21401. * @param verticesStart defines vertex index start
  21402. * @param verticesCount defines vertices count
  21403. * @param indexStart defines index start
  21404. * @param indexCount defines indices count
  21405. * @param mesh defines the parent mesh
  21406. * @param renderingMesh defines an optional rendering mesh
  21407. * @param createBoundingBox defines if bounding box should be created for this submesh
  21408. * @returns the new submesh
  21409. */
  21410. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21411. /**
  21412. * Creates a new submesh
  21413. * @param materialIndex defines the material index to use
  21414. * @param verticesStart defines vertex index start
  21415. * @param verticesCount defines vertices count
  21416. * @param indexStart defines index start
  21417. * @param indexCount defines indices count
  21418. * @param mesh defines the parent mesh
  21419. * @param renderingMesh defines an optional rendering mesh
  21420. * @param createBoundingBox defines if bounding box should be created for this submesh
  21421. */
  21422. constructor(
  21423. /** the material index to use */
  21424. materialIndex: number,
  21425. /** vertex index start */
  21426. verticesStart: number,
  21427. /** vertices count */
  21428. verticesCount: number,
  21429. /** index start */
  21430. indexStart: number,
  21431. /** indices count */
  21432. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21433. /**
  21434. * Returns true if this submesh covers the entire parent mesh
  21435. * @ignorenaming
  21436. */
  21437. get IsGlobal(): boolean;
  21438. /**
  21439. * Returns the submesh BoudingInfo object
  21440. * @returns current bounding info (or mesh's one if the submesh is global)
  21441. */
  21442. getBoundingInfo(): BoundingInfo;
  21443. /**
  21444. * Sets the submesh BoundingInfo
  21445. * @param boundingInfo defines the new bounding info to use
  21446. * @returns the SubMesh
  21447. */
  21448. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21449. /**
  21450. * Returns the mesh of the current submesh
  21451. * @return the parent mesh
  21452. */
  21453. getMesh(): AbstractMesh;
  21454. /**
  21455. * Returns the rendering mesh of the submesh
  21456. * @returns the rendering mesh (could be different from parent mesh)
  21457. */
  21458. getRenderingMesh(): Mesh;
  21459. /**
  21460. * Returns the submesh material
  21461. * @returns null or the current material
  21462. */
  21463. getMaterial(): Nullable<Material>;
  21464. /**
  21465. * Sets a new updated BoundingInfo object to the submesh
  21466. * @param data defines an optional position array to use to determine the bounding info
  21467. * @returns the SubMesh
  21468. */
  21469. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21470. /** @hidden */
  21471. _checkCollision(collider: Collider): boolean;
  21472. /**
  21473. * Updates the submesh BoundingInfo
  21474. * @param world defines the world matrix to use to update the bounding info
  21475. * @returns the submesh
  21476. */
  21477. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21478. /**
  21479. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21480. * @param frustumPlanes defines the frustum planes
  21481. * @returns true if the submesh is intersecting with the frustum
  21482. */
  21483. isInFrustum(frustumPlanes: Plane[]): boolean;
  21484. /**
  21485. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21486. * @param frustumPlanes defines the frustum planes
  21487. * @returns true if the submesh is inside the frustum
  21488. */
  21489. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21490. /**
  21491. * Renders the submesh
  21492. * @param enableAlphaMode defines if alpha needs to be used
  21493. * @returns the submesh
  21494. */
  21495. render(enableAlphaMode: boolean): SubMesh;
  21496. /**
  21497. * @hidden
  21498. */
  21499. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21500. /**
  21501. * Checks if the submesh intersects with a ray
  21502. * @param ray defines the ray to test
  21503. * @returns true is the passed ray intersects the submesh bounding box
  21504. */
  21505. canIntersects(ray: Ray): boolean;
  21506. /**
  21507. * Intersects current submesh with a ray
  21508. * @param ray defines the ray to test
  21509. * @param positions defines mesh's positions array
  21510. * @param indices defines mesh's indices array
  21511. * @param fastCheck defines if only bounding info should be used
  21512. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21513. * @returns intersection info or null if no intersection
  21514. */
  21515. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21516. /** @hidden */
  21517. private _intersectLines;
  21518. /** @hidden */
  21519. private _intersectUnIndexedLines;
  21520. /** @hidden */
  21521. private _intersectTriangles;
  21522. /** @hidden */
  21523. private _intersectUnIndexedTriangles;
  21524. /** @hidden */
  21525. _rebuild(): void;
  21526. /**
  21527. * Creates a new submesh from the passed mesh
  21528. * @param newMesh defines the new hosting mesh
  21529. * @param newRenderingMesh defines an optional rendering mesh
  21530. * @returns the new submesh
  21531. */
  21532. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21533. /**
  21534. * Release associated resources
  21535. */
  21536. dispose(): void;
  21537. /**
  21538. * Gets the class name
  21539. * @returns the string "SubMesh".
  21540. */
  21541. getClassName(): string;
  21542. /**
  21543. * Creates a new submesh from indices data
  21544. * @param materialIndex the index of the main mesh material
  21545. * @param startIndex the index where to start the copy in the mesh indices array
  21546. * @param indexCount the number of indices to copy then from the startIndex
  21547. * @param mesh the main mesh to create the submesh from
  21548. * @param renderingMesh the optional rendering mesh
  21549. * @returns a new submesh
  21550. */
  21551. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21552. }
  21553. }
  21554. declare module BABYLON {
  21555. /**
  21556. * Class used to represent data loading progression
  21557. */
  21558. export class SceneLoaderFlags {
  21559. private static _ForceFullSceneLoadingForIncremental;
  21560. private static _ShowLoadingScreen;
  21561. private static _CleanBoneMatrixWeights;
  21562. private static _loggingLevel;
  21563. /**
  21564. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21565. */
  21566. static get ForceFullSceneLoadingForIncremental(): boolean;
  21567. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21568. /**
  21569. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21570. */
  21571. static get ShowLoadingScreen(): boolean;
  21572. static set ShowLoadingScreen(value: boolean);
  21573. /**
  21574. * Defines the current logging level (while loading the scene)
  21575. * @ignorenaming
  21576. */
  21577. static get loggingLevel(): number;
  21578. static set loggingLevel(value: number);
  21579. /**
  21580. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21581. */
  21582. static get CleanBoneMatrixWeights(): boolean;
  21583. static set CleanBoneMatrixWeights(value: boolean);
  21584. }
  21585. }
  21586. declare module BABYLON {
  21587. /**
  21588. * Class used to store geometry data (vertex buffers + index buffer)
  21589. */
  21590. export class Geometry implements IGetSetVerticesData {
  21591. /**
  21592. * Gets or sets the ID of the geometry
  21593. */
  21594. id: string;
  21595. /**
  21596. * Gets or sets the unique ID of the geometry
  21597. */
  21598. uniqueId: number;
  21599. /**
  21600. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21601. */
  21602. delayLoadState: number;
  21603. /**
  21604. * Gets the file containing the data to load when running in delay load state
  21605. */
  21606. delayLoadingFile: Nullable<string>;
  21607. /**
  21608. * Callback called when the geometry is updated
  21609. */
  21610. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21611. private _scene;
  21612. private _engine;
  21613. private _meshes;
  21614. private _totalVertices;
  21615. /** @hidden */
  21616. _indices: IndicesArray;
  21617. /** @hidden */
  21618. _vertexBuffers: {
  21619. [key: string]: VertexBuffer;
  21620. };
  21621. private _isDisposed;
  21622. private _extend;
  21623. private _boundingBias;
  21624. /** @hidden */
  21625. _delayInfo: Array<string>;
  21626. private _indexBuffer;
  21627. private _indexBufferIsUpdatable;
  21628. /** @hidden */
  21629. _boundingInfo: Nullable<BoundingInfo>;
  21630. /** @hidden */
  21631. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21632. /** @hidden */
  21633. _softwareSkinningFrameId: number;
  21634. private _vertexArrayObjects;
  21635. private _updatable;
  21636. /** @hidden */
  21637. _positions: Nullable<Vector3[]>;
  21638. /**
  21639. * 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
  21640. */
  21641. get boundingBias(): Vector2;
  21642. /**
  21643. * 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
  21644. */
  21645. set boundingBias(value: Vector2);
  21646. /**
  21647. * Static function used to attach a new empty geometry to a mesh
  21648. * @param mesh defines the mesh to attach the geometry to
  21649. * @returns the new Geometry
  21650. */
  21651. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21652. /**
  21653. * Creates a new geometry
  21654. * @param id defines the unique ID
  21655. * @param scene defines the hosting scene
  21656. * @param vertexData defines the VertexData used to get geometry data
  21657. * @param updatable defines if geometry must be updatable (false by default)
  21658. * @param mesh defines the mesh that will be associated with the geometry
  21659. */
  21660. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21661. /**
  21662. * Gets the current extend of the geometry
  21663. */
  21664. get extend(): {
  21665. minimum: Vector3;
  21666. maximum: Vector3;
  21667. };
  21668. /**
  21669. * Gets the hosting scene
  21670. * @returns the hosting Scene
  21671. */
  21672. getScene(): Scene;
  21673. /**
  21674. * Gets the hosting engine
  21675. * @returns the hosting Engine
  21676. */
  21677. getEngine(): Engine;
  21678. /**
  21679. * Defines if the geometry is ready to use
  21680. * @returns true if the geometry is ready to be used
  21681. */
  21682. isReady(): boolean;
  21683. /**
  21684. * Gets a value indicating that the geometry should not be serialized
  21685. */
  21686. get doNotSerialize(): boolean;
  21687. /** @hidden */
  21688. _rebuild(): void;
  21689. /**
  21690. * Affects all geometry data in one call
  21691. * @param vertexData defines the geometry data
  21692. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21693. */
  21694. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21695. /**
  21696. * Set specific vertex data
  21697. * @param kind defines the data kind (Position, normal, etc...)
  21698. * @param data defines the vertex data to use
  21699. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21700. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21701. */
  21702. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21703. /**
  21704. * Removes a specific vertex data
  21705. * @param kind defines the data kind (Position, normal, etc...)
  21706. */
  21707. removeVerticesData(kind: string): void;
  21708. /**
  21709. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21710. * @param buffer defines the vertex buffer to use
  21711. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21712. */
  21713. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21714. /**
  21715. * Update a specific vertex buffer
  21716. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21717. * It will do nothing if the buffer is not updatable
  21718. * @param kind defines the data kind (Position, normal, etc...)
  21719. * @param data defines the data to use
  21720. * @param offset defines the offset in the target buffer where to store the data
  21721. * @param useBytes set to true if the offset is in bytes
  21722. */
  21723. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21724. /**
  21725. * Update a specific vertex buffer
  21726. * This function will create a new buffer if the current one is not updatable
  21727. * @param kind defines the data kind (Position, normal, etc...)
  21728. * @param data defines the data to use
  21729. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21730. */
  21731. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21732. private _updateBoundingInfo;
  21733. /** @hidden */
  21734. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21735. /**
  21736. * Gets total number of vertices
  21737. * @returns the total number of vertices
  21738. */
  21739. getTotalVertices(): number;
  21740. /**
  21741. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21742. * @param kind defines the data kind (Position, normal, etc...)
  21743. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21744. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21745. * @returns a float array containing vertex data
  21746. */
  21747. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21748. /**
  21749. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21750. * @param kind defines the data kind (Position, normal, etc...)
  21751. * @returns true if the vertex buffer with the specified kind is updatable
  21752. */
  21753. isVertexBufferUpdatable(kind: string): boolean;
  21754. /**
  21755. * Gets a specific vertex buffer
  21756. * @param kind defines the data kind (Position, normal, etc...)
  21757. * @returns a VertexBuffer
  21758. */
  21759. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21760. /**
  21761. * Returns all vertex buffers
  21762. * @return an object holding all vertex buffers indexed by kind
  21763. */
  21764. getVertexBuffers(): Nullable<{
  21765. [key: string]: VertexBuffer;
  21766. }>;
  21767. /**
  21768. * Gets a boolean indicating if specific vertex buffer is present
  21769. * @param kind defines the data kind (Position, normal, etc...)
  21770. * @returns true if data is present
  21771. */
  21772. isVerticesDataPresent(kind: string): boolean;
  21773. /**
  21774. * Gets a list of all attached data kinds (Position, normal, etc...)
  21775. * @returns a list of string containing all kinds
  21776. */
  21777. getVerticesDataKinds(): string[];
  21778. /**
  21779. * Update index buffer
  21780. * @param indices defines the indices to store in the index buffer
  21781. * @param offset defines the offset in the target buffer where to store the data
  21782. * @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)
  21783. */
  21784. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21785. /**
  21786. * Creates a new index buffer
  21787. * @param indices defines the indices to store in the index buffer
  21788. * @param totalVertices defines the total number of vertices (could be null)
  21789. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21790. */
  21791. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21792. /**
  21793. * Return the total number of indices
  21794. * @returns the total number of indices
  21795. */
  21796. getTotalIndices(): number;
  21797. /**
  21798. * Gets the index buffer array
  21799. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21800. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21801. * @returns the index buffer array
  21802. */
  21803. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21804. /**
  21805. * Gets the index buffer
  21806. * @return the index buffer
  21807. */
  21808. getIndexBuffer(): Nullable<DataBuffer>;
  21809. /** @hidden */
  21810. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21811. /**
  21812. * Release the associated resources for a specific mesh
  21813. * @param mesh defines the source mesh
  21814. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21815. */
  21816. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21817. /**
  21818. * Apply current geometry to a given mesh
  21819. * @param mesh defines the mesh to apply geometry to
  21820. */
  21821. applyToMesh(mesh: Mesh): void;
  21822. private _updateExtend;
  21823. private _applyToMesh;
  21824. private notifyUpdate;
  21825. /**
  21826. * Load the geometry if it was flagged as delay loaded
  21827. * @param scene defines the hosting scene
  21828. * @param onLoaded defines a callback called when the geometry is loaded
  21829. */
  21830. load(scene: Scene, onLoaded?: () => void): void;
  21831. private _queueLoad;
  21832. /**
  21833. * Invert the geometry to move from a right handed system to a left handed one.
  21834. */
  21835. toLeftHanded(): void;
  21836. /** @hidden */
  21837. _resetPointsArrayCache(): void;
  21838. /** @hidden */
  21839. _generatePointsArray(): boolean;
  21840. /**
  21841. * Gets a value indicating if the geometry is disposed
  21842. * @returns true if the geometry was disposed
  21843. */
  21844. isDisposed(): boolean;
  21845. private _disposeVertexArrayObjects;
  21846. /**
  21847. * Free all associated resources
  21848. */
  21849. dispose(): void;
  21850. /**
  21851. * Clone the current geometry into a new geometry
  21852. * @param id defines the unique ID of the new geometry
  21853. * @returns a new geometry object
  21854. */
  21855. copy(id: string): Geometry;
  21856. /**
  21857. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21858. * @return a JSON representation of the current geometry data (without the vertices data)
  21859. */
  21860. serialize(): any;
  21861. private toNumberArray;
  21862. /**
  21863. * Serialize all vertices data into a JSON oject
  21864. * @returns a JSON representation of the current geometry data
  21865. */
  21866. serializeVerticeData(): any;
  21867. /**
  21868. * Extracts a clone of a mesh geometry
  21869. * @param mesh defines the source mesh
  21870. * @param id defines the unique ID of the new geometry object
  21871. * @returns the new geometry object
  21872. */
  21873. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21874. /**
  21875. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21876. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21877. * Be aware Math.random() could cause collisions, but:
  21878. * "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"
  21879. * @returns a string containing a new GUID
  21880. */
  21881. static RandomId(): string;
  21882. /** @hidden */
  21883. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21884. private static _CleanMatricesWeights;
  21885. /**
  21886. * Create a new geometry from persisted data (Using .babylon file format)
  21887. * @param parsedVertexData defines the persisted data
  21888. * @param scene defines the hosting scene
  21889. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21890. * @returns the new geometry object
  21891. */
  21892. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21893. }
  21894. }
  21895. declare module BABYLON {
  21896. /**
  21897. * Define an interface for all classes that will get and set the data on vertices
  21898. */
  21899. export interface IGetSetVerticesData {
  21900. /**
  21901. * Gets a boolean indicating if specific vertex data is present
  21902. * @param kind defines the vertex data kind to use
  21903. * @returns true is data kind is present
  21904. */
  21905. isVerticesDataPresent(kind: string): boolean;
  21906. /**
  21907. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21908. * @param kind defines the data kind (Position, normal, etc...)
  21909. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21910. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21911. * @returns a float array containing vertex data
  21912. */
  21913. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21914. /**
  21915. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21916. * @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.
  21917. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21918. * @returns the indices array or an empty array if the mesh has no geometry
  21919. */
  21920. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21921. /**
  21922. * Set specific vertex data
  21923. * @param kind defines the data kind (Position, normal, etc...)
  21924. * @param data defines the vertex data to use
  21925. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21926. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21927. */
  21928. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21929. /**
  21930. * Update a specific associated vertex buffer
  21931. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21932. * - VertexBuffer.PositionKind
  21933. * - VertexBuffer.UVKind
  21934. * - VertexBuffer.UV2Kind
  21935. * - VertexBuffer.UV3Kind
  21936. * - VertexBuffer.UV4Kind
  21937. * - VertexBuffer.UV5Kind
  21938. * - VertexBuffer.UV6Kind
  21939. * - VertexBuffer.ColorKind
  21940. * - VertexBuffer.MatricesIndicesKind
  21941. * - VertexBuffer.MatricesIndicesExtraKind
  21942. * - VertexBuffer.MatricesWeightsKind
  21943. * - VertexBuffer.MatricesWeightsExtraKind
  21944. * @param data defines the data source
  21945. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21946. * @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)
  21947. */
  21948. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21949. /**
  21950. * Creates a new index buffer
  21951. * @param indices defines the indices to store in the index buffer
  21952. * @param totalVertices defines the total number of vertices (could be null)
  21953. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21954. */
  21955. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21956. }
  21957. /**
  21958. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21959. */
  21960. export class VertexData {
  21961. /**
  21962. * Mesh side orientation : usually the external or front surface
  21963. */
  21964. static readonly FRONTSIDE: number;
  21965. /**
  21966. * Mesh side orientation : usually the internal or back surface
  21967. */
  21968. static readonly BACKSIDE: number;
  21969. /**
  21970. * Mesh side orientation : both internal and external or front and back surfaces
  21971. */
  21972. static readonly DOUBLESIDE: number;
  21973. /**
  21974. * Mesh side orientation : by default, `FRONTSIDE`
  21975. */
  21976. static readonly DEFAULTSIDE: number;
  21977. /**
  21978. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21979. */
  21980. positions: Nullable<FloatArray>;
  21981. /**
  21982. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21983. */
  21984. normals: Nullable<FloatArray>;
  21985. /**
  21986. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21987. */
  21988. tangents: Nullable<FloatArray>;
  21989. /**
  21990. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21991. */
  21992. uvs: Nullable<FloatArray>;
  21993. /**
  21994. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21995. */
  21996. uvs2: Nullable<FloatArray>;
  21997. /**
  21998. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21999. */
  22000. uvs3: Nullable<FloatArray>;
  22001. /**
  22002. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22003. */
  22004. uvs4: Nullable<FloatArray>;
  22005. /**
  22006. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22007. */
  22008. uvs5: Nullable<FloatArray>;
  22009. /**
  22010. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22011. */
  22012. uvs6: Nullable<FloatArray>;
  22013. /**
  22014. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22015. */
  22016. colors: Nullable<FloatArray>;
  22017. /**
  22018. * 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).
  22019. */
  22020. matricesIndices: Nullable<FloatArray>;
  22021. /**
  22022. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22023. */
  22024. matricesWeights: Nullable<FloatArray>;
  22025. /**
  22026. * An array extending the number of possible indices
  22027. */
  22028. matricesIndicesExtra: Nullable<FloatArray>;
  22029. /**
  22030. * An array extending the number of possible weights when the number of indices is extended
  22031. */
  22032. matricesWeightsExtra: Nullable<FloatArray>;
  22033. /**
  22034. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22035. */
  22036. indices: Nullable<IndicesArray>;
  22037. /**
  22038. * Uses the passed data array to set the set the values for the specified kind of data
  22039. * @param data a linear array of floating numbers
  22040. * @param kind the type of data that is being set, eg positions, colors etc
  22041. */
  22042. set(data: FloatArray, kind: string): void;
  22043. /**
  22044. * Associates the vertexData to the passed Mesh.
  22045. * Sets it as updatable or not (default `false`)
  22046. * @param mesh the mesh the vertexData is applied to
  22047. * @param updatable when used and having the value true allows new data to update the vertexData
  22048. * @returns the VertexData
  22049. */
  22050. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22051. /**
  22052. * Associates the vertexData to the passed Geometry.
  22053. * Sets it as updatable or not (default `false`)
  22054. * @param geometry the geometry the vertexData is applied to
  22055. * @param updatable when used and having the value true allows new data to update the vertexData
  22056. * @returns VertexData
  22057. */
  22058. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22059. /**
  22060. * Updates the associated mesh
  22061. * @param mesh the mesh to be updated
  22062. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22063. * @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
  22064. * @returns VertexData
  22065. */
  22066. updateMesh(mesh: Mesh): VertexData;
  22067. /**
  22068. * Updates the associated geometry
  22069. * @param geometry the geometry to be updated
  22070. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22071. * @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
  22072. * @returns VertexData.
  22073. */
  22074. updateGeometry(geometry: Geometry): VertexData;
  22075. private _applyTo;
  22076. private _update;
  22077. /**
  22078. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22079. * @param matrix the transforming matrix
  22080. * @returns the VertexData
  22081. */
  22082. transform(matrix: Matrix): VertexData;
  22083. /**
  22084. * Merges the passed VertexData into the current one
  22085. * @param other the VertexData to be merged into the current one
  22086. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22087. * @returns the modified VertexData
  22088. */
  22089. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22090. private _mergeElement;
  22091. private _validate;
  22092. /**
  22093. * Serializes the VertexData
  22094. * @returns a serialized object
  22095. */
  22096. serialize(): any;
  22097. /**
  22098. * Extracts the vertexData from a mesh
  22099. * @param mesh the mesh from which to extract the VertexData
  22100. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22101. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22102. * @returns the object VertexData associated to the passed mesh
  22103. */
  22104. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22105. /**
  22106. * Extracts the vertexData from the geometry
  22107. * @param geometry the geometry from which to extract the VertexData
  22108. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22109. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22110. * @returns the object VertexData associated to the passed mesh
  22111. */
  22112. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22113. private static _ExtractFrom;
  22114. /**
  22115. * Creates the VertexData for a Ribbon
  22116. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22117. * * pathArray array of paths, each of which an array of successive Vector3
  22118. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22119. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22120. * * 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
  22121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22122. * * 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)
  22123. * * 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)
  22124. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22125. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22126. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22127. * @returns the VertexData of the ribbon
  22128. */
  22129. static CreateRibbon(options: {
  22130. pathArray: Vector3[][];
  22131. closeArray?: boolean;
  22132. closePath?: boolean;
  22133. offset?: number;
  22134. sideOrientation?: number;
  22135. frontUVs?: Vector4;
  22136. backUVs?: Vector4;
  22137. invertUV?: boolean;
  22138. uvs?: Vector2[];
  22139. colors?: Color4[];
  22140. }): VertexData;
  22141. /**
  22142. * Creates the VertexData for a box
  22143. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22144. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22145. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22146. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22147. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22148. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22149. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22151. * * 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)
  22152. * * 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)
  22153. * @returns the VertexData of the box
  22154. */
  22155. static CreateBox(options: {
  22156. size?: number;
  22157. width?: number;
  22158. height?: number;
  22159. depth?: number;
  22160. faceUV?: Vector4[];
  22161. faceColors?: Color4[];
  22162. sideOrientation?: number;
  22163. frontUVs?: Vector4;
  22164. backUVs?: Vector4;
  22165. }): VertexData;
  22166. /**
  22167. * Creates the VertexData for a tiled box
  22168. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22169. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22170. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22171. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22172. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22173. * @returns the VertexData of the box
  22174. */
  22175. static CreateTiledBox(options: {
  22176. pattern?: number;
  22177. width?: number;
  22178. height?: number;
  22179. depth?: number;
  22180. tileSize?: number;
  22181. tileWidth?: number;
  22182. tileHeight?: number;
  22183. alignHorizontal?: number;
  22184. alignVertical?: number;
  22185. faceUV?: Vector4[];
  22186. faceColors?: Color4[];
  22187. sideOrientation?: number;
  22188. }): VertexData;
  22189. /**
  22190. * Creates the VertexData for a tiled plane
  22191. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22192. * * pattern a limited pattern arrangement depending on the number
  22193. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22194. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22195. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22196. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22197. * * 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)
  22198. * * 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)
  22199. * @returns the VertexData of the tiled plane
  22200. */
  22201. static CreateTiledPlane(options: {
  22202. pattern?: number;
  22203. tileSize?: number;
  22204. tileWidth?: number;
  22205. tileHeight?: number;
  22206. size?: number;
  22207. width?: number;
  22208. height?: number;
  22209. alignHorizontal?: number;
  22210. alignVertical?: number;
  22211. sideOrientation?: number;
  22212. frontUVs?: Vector4;
  22213. backUVs?: Vector4;
  22214. }): VertexData;
  22215. /**
  22216. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22217. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22218. * * segments sets the number of horizontal strips optional, default 32
  22219. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22220. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22221. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22222. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22223. * * 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
  22224. * * 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
  22225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22226. * * 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)
  22227. * * 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)
  22228. * @returns the VertexData of the ellipsoid
  22229. */
  22230. static CreateSphere(options: {
  22231. segments?: number;
  22232. diameter?: number;
  22233. diameterX?: number;
  22234. diameterY?: number;
  22235. diameterZ?: number;
  22236. arc?: number;
  22237. slice?: number;
  22238. sideOrientation?: number;
  22239. frontUVs?: Vector4;
  22240. backUVs?: Vector4;
  22241. }): VertexData;
  22242. /**
  22243. * Creates the VertexData for a cylinder, cone or prism
  22244. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22245. * * height sets the height (y direction) of the cylinder, optional, default 2
  22246. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22247. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22248. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22249. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22250. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22251. * * 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
  22252. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22253. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22254. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22255. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22256. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22257. * * 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)
  22258. * * 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)
  22259. * @returns the VertexData of the cylinder, cone or prism
  22260. */
  22261. static CreateCylinder(options: {
  22262. height?: number;
  22263. diameterTop?: number;
  22264. diameterBottom?: number;
  22265. diameter?: number;
  22266. tessellation?: number;
  22267. subdivisions?: number;
  22268. arc?: number;
  22269. faceColors?: Color4[];
  22270. faceUV?: Vector4[];
  22271. hasRings?: boolean;
  22272. enclose?: boolean;
  22273. sideOrientation?: number;
  22274. frontUVs?: Vector4;
  22275. backUVs?: Vector4;
  22276. }): VertexData;
  22277. /**
  22278. * Creates the VertexData for a torus
  22279. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22280. * * diameter the diameter of the torus, optional default 1
  22281. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22282. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22283. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22284. * * 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)
  22285. * * 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)
  22286. * @returns the VertexData of the torus
  22287. */
  22288. static CreateTorus(options: {
  22289. diameter?: number;
  22290. thickness?: number;
  22291. tessellation?: number;
  22292. sideOrientation?: number;
  22293. frontUVs?: Vector4;
  22294. backUVs?: Vector4;
  22295. }): VertexData;
  22296. /**
  22297. * Creates the VertexData of the LineSystem
  22298. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22299. * - lines an array of lines, each line being an array of successive Vector3
  22300. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22301. * @returns the VertexData of the LineSystem
  22302. */
  22303. static CreateLineSystem(options: {
  22304. lines: Vector3[][];
  22305. colors?: Nullable<Color4[][]>;
  22306. }): VertexData;
  22307. /**
  22308. * Create the VertexData for a DashedLines
  22309. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22310. * - points an array successive Vector3
  22311. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22312. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22313. * - dashNb the intended total number of dashes, optional, default 200
  22314. * @returns the VertexData for the DashedLines
  22315. */
  22316. static CreateDashedLines(options: {
  22317. points: Vector3[];
  22318. dashSize?: number;
  22319. gapSize?: number;
  22320. dashNb?: number;
  22321. }): VertexData;
  22322. /**
  22323. * Creates the VertexData for a Ground
  22324. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22325. * - width the width (x direction) of the ground, optional, default 1
  22326. * - height the height (z direction) of the ground, optional, default 1
  22327. * - subdivisions the number of subdivisions per side, optional, default 1
  22328. * @returns the VertexData of the Ground
  22329. */
  22330. static CreateGround(options: {
  22331. width?: number;
  22332. height?: number;
  22333. subdivisions?: number;
  22334. subdivisionsX?: number;
  22335. subdivisionsY?: number;
  22336. }): VertexData;
  22337. /**
  22338. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22339. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22340. * * xmin the ground minimum X coordinate, optional, default -1
  22341. * * zmin the ground minimum Z coordinate, optional, default -1
  22342. * * xmax the ground maximum X coordinate, optional, default 1
  22343. * * zmax the ground maximum Z coordinate, optional, default 1
  22344. * * 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}
  22345. * * 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}
  22346. * @returns the VertexData of the TiledGround
  22347. */
  22348. static CreateTiledGround(options: {
  22349. xmin: number;
  22350. zmin: number;
  22351. xmax: number;
  22352. zmax: number;
  22353. subdivisions?: {
  22354. w: number;
  22355. h: number;
  22356. };
  22357. precision?: {
  22358. w: number;
  22359. h: number;
  22360. };
  22361. }): VertexData;
  22362. /**
  22363. * Creates the VertexData of the Ground designed from a heightmap
  22364. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22365. * * width the width (x direction) of the ground
  22366. * * height the height (z direction) of the ground
  22367. * * subdivisions the number of subdivisions per side
  22368. * * minHeight the minimum altitude on the ground, optional, default 0
  22369. * * maxHeight the maximum altitude on the ground, optional default 1
  22370. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22371. * * buffer the array holding the image color data
  22372. * * bufferWidth the width of image
  22373. * * bufferHeight the height of image
  22374. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22375. * @returns the VertexData of the Ground designed from a heightmap
  22376. */
  22377. static CreateGroundFromHeightMap(options: {
  22378. width: number;
  22379. height: number;
  22380. subdivisions: number;
  22381. minHeight: number;
  22382. maxHeight: number;
  22383. colorFilter: Color3;
  22384. buffer: Uint8Array;
  22385. bufferWidth: number;
  22386. bufferHeight: number;
  22387. alphaFilter: number;
  22388. }): VertexData;
  22389. /**
  22390. * Creates the VertexData for a Plane
  22391. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22392. * * size sets the width and height of the plane to the value of size, optional default 1
  22393. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22394. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22395. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22396. * * 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)
  22397. * * 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)
  22398. * @returns the VertexData of the box
  22399. */
  22400. static CreatePlane(options: {
  22401. size?: number;
  22402. width?: number;
  22403. height?: number;
  22404. sideOrientation?: number;
  22405. frontUVs?: Vector4;
  22406. backUVs?: Vector4;
  22407. }): VertexData;
  22408. /**
  22409. * Creates the VertexData of the Disc or regular Polygon
  22410. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22411. * * radius the radius of the disc, optional default 0.5
  22412. * * tessellation the number of polygon sides, optional, default 64
  22413. * * 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
  22414. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22415. * * 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)
  22416. * * 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)
  22417. * @returns the VertexData of the box
  22418. */
  22419. static CreateDisc(options: {
  22420. radius?: number;
  22421. tessellation?: number;
  22422. arc?: number;
  22423. sideOrientation?: number;
  22424. frontUVs?: Vector4;
  22425. backUVs?: Vector4;
  22426. }): VertexData;
  22427. /**
  22428. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22429. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22430. * @param polygon a mesh built from polygonTriangulation.build()
  22431. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22432. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22433. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22434. * @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)
  22435. * @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)
  22436. * @returns the VertexData of the Polygon
  22437. */
  22438. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22439. /**
  22440. * Creates the VertexData of the IcoSphere
  22441. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22442. * * radius the radius of the IcoSphere, optional default 1
  22443. * * radiusX allows stretching in the x direction, optional, default radius
  22444. * * radiusY allows stretching in the y direction, optional, default radius
  22445. * * radiusZ allows stretching in the z direction, optional, default radius
  22446. * * flat when true creates a flat shaded mesh, optional, default true
  22447. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22448. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22449. * * 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)
  22450. * * 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)
  22451. * @returns the VertexData of the IcoSphere
  22452. */
  22453. static CreateIcoSphere(options: {
  22454. radius?: number;
  22455. radiusX?: number;
  22456. radiusY?: number;
  22457. radiusZ?: number;
  22458. flat?: boolean;
  22459. subdivisions?: number;
  22460. sideOrientation?: number;
  22461. frontUVs?: Vector4;
  22462. backUVs?: Vector4;
  22463. }): VertexData;
  22464. /**
  22465. * Creates the VertexData for a Polyhedron
  22466. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22467. * * type provided types are:
  22468. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22469. * * 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)
  22470. * * size the size of the IcoSphere, optional default 1
  22471. * * sizeX allows stretching in the x direction, optional, default size
  22472. * * sizeY allows stretching in the y direction, optional, default size
  22473. * * sizeZ allows stretching in the z direction, optional, default size
  22474. * * 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
  22475. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22476. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22477. * * flat when true creates a flat shaded mesh, optional, default true
  22478. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22479. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22480. * * 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)
  22481. * * 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)
  22482. * @returns the VertexData of the Polyhedron
  22483. */
  22484. static CreatePolyhedron(options: {
  22485. type?: number;
  22486. size?: number;
  22487. sizeX?: number;
  22488. sizeY?: number;
  22489. sizeZ?: number;
  22490. custom?: any;
  22491. faceUV?: Vector4[];
  22492. faceColors?: Color4[];
  22493. flat?: boolean;
  22494. sideOrientation?: number;
  22495. frontUVs?: Vector4;
  22496. backUVs?: Vector4;
  22497. }): VertexData;
  22498. /**
  22499. * Creates the VertexData for a TorusKnot
  22500. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22501. * * radius the radius of the torus knot, optional, default 2
  22502. * * tube the thickness of the tube, optional, default 0.5
  22503. * * radialSegments the number of sides on each tube segments, optional, default 32
  22504. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22505. * * p the number of windings around the z axis, optional, default 2
  22506. * * q the number of windings around the x axis, optional, default 3
  22507. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22508. * * 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)
  22509. * * 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)
  22510. * @returns the VertexData of the Torus Knot
  22511. */
  22512. static CreateTorusKnot(options: {
  22513. radius?: number;
  22514. tube?: number;
  22515. radialSegments?: number;
  22516. tubularSegments?: number;
  22517. p?: number;
  22518. q?: number;
  22519. sideOrientation?: number;
  22520. frontUVs?: Vector4;
  22521. backUVs?: Vector4;
  22522. }): VertexData;
  22523. /**
  22524. * Compute normals for given positions and indices
  22525. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22526. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22527. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22528. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22529. * * facetNormals : optional array of facet normals (vector3)
  22530. * * facetPositions : optional array of facet positions (vector3)
  22531. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22532. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22533. * * bInfo : optional bounding info, required for facetPartitioning computation
  22534. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22535. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22536. * * useRightHandedSystem: optional boolean to for right handed system computation
  22537. * * depthSort : optional boolean to enable the facet depth sort computation
  22538. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22539. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22540. */
  22541. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22542. facetNormals?: any;
  22543. facetPositions?: any;
  22544. facetPartitioning?: any;
  22545. ratio?: number;
  22546. bInfo?: any;
  22547. bbSize?: Vector3;
  22548. subDiv?: any;
  22549. useRightHandedSystem?: boolean;
  22550. depthSort?: boolean;
  22551. distanceTo?: Vector3;
  22552. depthSortedFacets?: any;
  22553. }): void;
  22554. /** @hidden */
  22555. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22556. /**
  22557. * Applies VertexData created from the imported parameters to the geometry
  22558. * @param parsedVertexData the parsed data from an imported file
  22559. * @param geometry the geometry to apply the VertexData to
  22560. */
  22561. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22562. }
  22563. }
  22564. declare module BABYLON {
  22565. /**
  22566. * Defines a target to use with MorphTargetManager
  22567. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22568. */
  22569. export class MorphTarget implements IAnimatable {
  22570. /** defines the name of the target */
  22571. name: string;
  22572. /**
  22573. * Gets or sets the list of animations
  22574. */
  22575. animations: Animation[];
  22576. private _scene;
  22577. private _positions;
  22578. private _normals;
  22579. private _tangents;
  22580. private _uvs;
  22581. private _influence;
  22582. private _uniqueId;
  22583. /**
  22584. * Observable raised when the influence changes
  22585. */
  22586. onInfluenceChanged: Observable<boolean>;
  22587. /** @hidden */
  22588. _onDataLayoutChanged: Observable<void>;
  22589. /**
  22590. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22591. */
  22592. get influence(): number;
  22593. set influence(influence: number);
  22594. /**
  22595. * Gets or sets the id of the morph Target
  22596. */
  22597. id: string;
  22598. private _animationPropertiesOverride;
  22599. /**
  22600. * Gets or sets the animation properties override
  22601. */
  22602. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22603. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22604. /**
  22605. * Creates a new MorphTarget
  22606. * @param name defines the name of the target
  22607. * @param influence defines the influence to use
  22608. * @param scene defines the scene the morphtarget belongs to
  22609. */
  22610. constructor(
  22611. /** defines the name of the target */
  22612. name: string, influence?: number, scene?: Nullable<Scene>);
  22613. /**
  22614. * Gets the unique ID of this manager
  22615. */
  22616. get uniqueId(): number;
  22617. /**
  22618. * Gets a boolean defining if the target contains position data
  22619. */
  22620. get hasPositions(): boolean;
  22621. /**
  22622. * Gets a boolean defining if the target contains normal data
  22623. */
  22624. get hasNormals(): boolean;
  22625. /**
  22626. * Gets a boolean defining if the target contains tangent data
  22627. */
  22628. get hasTangents(): boolean;
  22629. /**
  22630. * Gets a boolean defining if the target contains texture coordinates data
  22631. */
  22632. get hasUVs(): boolean;
  22633. /**
  22634. * Affects position data to this target
  22635. * @param data defines the position data to use
  22636. */
  22637. setPositions(data: Nullable<FloatArray>): void;
  22638. /**
  22639. * Gets the position data stored in this target
  22640. * @returns a FloatArray containing the position data (or null if not present)
  22641. */
  22642. getPositions(): Nullable<FloatArray>;
  22643. /**
  22644. * Affects normal data to this target
  22645. * @param data defines the normal data to use
  22646. */
  22647. setNormals(data: Nullable<FloatArray>): void;
  22648. /**
  22649. * Gets the normal data stored in this target
  22650. * @returns a FloatArray containing the normal data (or null if not present)
  22651. */
  22652. getNormals(): Nullable<FloatArray>;
  22653. /**
  22654. * Affects tangent data to this target
  22655. * @param data defines the tangent data to use
  22656. */
  22657. setTangents(data: Nullable<FloatArray>): void;
  22658. /**
  22659. * Gets the tangent data stored in this target
  22660. * @returns a FloatArray containing the tangent data (or null if not present)
  22661. */
  22662. getTangents(): Nullable<FloatArray>;
  22663. /**
  22664. * Affects texture coordinates data to this target
  22665. * @param data defines the texture coordinates data to use
  22666. */
  22667. setUVs(data: Nullable<FloatArray>): void;
  22668. /**
  22669. * Gets the texture coordinates data stored in this target
  22670. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22671. */
  22672. getUVs(): Nullable<FloatArray>;
  22673. /**
  22674. * Clone the current target
  22675. * @returns a new MorphTarget
  22676. */
  22677. clone(): MorphTarget;
  22678. /**
  22679. * Serializes the current target into a Serialization object
  22680. * @returns the serialized object
  22681. */
  22682. serialize(): any;
  22683. /**
  22684. * Returns the string "MorphTarget"
  22685. * @returns "MorphTarget"
  22686. */
  22687. getClassName(): string;
  22688. /**
  22689. * Creates a new target from serialized data
  22690. * @param serializationObject defines the serialized data to use
  22691. * @returns a new MorphTarget
  22692. */
  22693. static Parse(serializationObject: any): MorphTarget;
  22694. /**
  22695. * Creates a MorphTarget from mesh data
  22696. * @param mesh defines the source mesh
  22697. * @param name defines the name to use for the new target
  22698. * @param influence defines the influence to attach to the target
  22699. * @returns a new MorphTarget
  22700. */
  22701. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22702. }
  22703. }
  22704. declare module BABYLON {
  22705. /**
  22706. * This class is used to deform meshes using morphing between different targets
  22707. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22708. */
  22709. export class MorphTargetManager {
  22710. private _targets;
  22711. private _targetInfluenceChangedObservers;
  22712. private _targetDataLayoutChangedObservers;
  22713. private _activeTargets;
  22714. private _scene;
  22715. private _influences;
  22716. private _supportsNormals;
  22717. private _supportsTangents;
  22718. private _supportsUVs;
  22719. private _vertexCount;
  22720. private _uniqueId;
  22721. private _tempInfluences;
  22722. /**
  22723. * Gets or sets a boolean indicating if normals must be morphed
  22724. */
  22725. enableNormalMorphing: boolean;
  22726. /**
  22727. * Gets or sets a boolean indicating if tangents must be morphed
  22728. */
  22729. enableTangentMorphing: boolean;
  22730. /**
  22731. * Gets or sets a boolean indicating if UV must be morphed
  22732. */
  22733. enableUVMorphing: boolean;
  22734. /**
  22735. * Creates a new MorphTargetManager
  22736. * @param scene defines the current scene
  22737. */
  22738. constructor(scene?: Nullable<Scene>);
  22739. /**
  22740. * Gets the unique ID of this manager
  22741. */
  22742. get uniqueId(): number;
  22743. /**
  22744. * Gets the number of vertices handled by this manager
  22745. */
  22746. get vertexCount(): number;
  22747. /**
  22748. * Gets a boolean indicating if this manager supports morphing of normals
  22749. */
  22750. get supportsNormals(): boolean;
  22751. /**
  22752. * Gets a boolean indicating if this manager supports morphing of tangents
  22753. */
  22754. get supportsTangents(): boolean;
  22755. /**
  22756. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22757. */
  22758. get supportsUVs(): boolean;
  22759. /**
  22760. * Gets the number of targets stored in this manager
  22761. */
  22762. get numTargets(): number;
  22763. /**
  22764. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22765. */
  22766. get numInfluencers(): number;
  22767. /**
  22768. * Gets the list of influences (one per target)
  22769. */
  22770. get influences(): Float32Array;
  22771. /**
  22772. * Gets the active target at specified index. An active target is a target with an influence > 0
  22773. * @param index defines the index to check
  22774. * @returns the requested target
  22775. */
  22776. getActiveTarget(index: number): MorphTarget;
  22777. /**
  22778. * Gets the target at specified index
  22779. * @param index defines the index to check
  22780. * @returns the requested target
  22781. */
  22782. getTarget(index: number): MorphTarget;
  22783. /**
  22784. * Add a new target to this manager
  22785. * @param target defines the target to add
  22786. */
  22787. addTarget(target: MorphTarget): void;
  22788. /**
  22789. * Removes a target from the manager
  22790. * @param target defines the target to remove
  22791. */
  22792. removeTarget(target: MorphTarget): void;
  22793. /**
  22794. * Clone the current manager
  22795. * @returns a new MorphTargetManager
  22796. */
  22797. clone(): MorphTargetManager;
  22798. /**
  22799. * Serializes the current manager into a Serialization object
  22800. * @returns the serialized object
  22801. */
  22802. serialize(): any;
  22803. private _syncActiveTargets;
  22804. /**
  22805. * Syncrhonize the targets with all the meshes using this morph target manager
  22806. */
  22807. synchronize(): void;
  22808. /**
  22809. * Creates a new MorphTargetManager from serialized data
  22810. * @param serializationObject defines the serialized data
  22811. * @param scene defines the hosting scene
  22812. * @returns the new MorphTargetManager
  22813. */
  22814. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22815. }
  22816. }
  22817. declare module BABYLON {
  22818. /**
  22819. * Class used to represent a specific level of detail of a mesh
  22820. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22821. */
  22822. export class MeshLODLevel {
  22823. /** Defines the distance where this level should start being displayed */
  22824. distance: number;
  22825. /** Defines the mesh to use to render this level */
  22826. mesh: Nullable<Mesh>;
  22827. /**
  22828. * Creates a new LOD level
  22829. * @param distance defines the distance where this level should star being displayed
  22830. * @param mesh defines the mesh to use to render this level
  22831. */
  22832. constructor(
  22833. /** Defines the distance where this level should start being displayed */
  22834. distance: number,
  22835. /** Defines the mesh to use to render this level */
  22836. mesh: Nullable<Mesh>);
  22837. }
  22838. }
  22839. declare module BABYLON {
  22840. /**
  22841. * Mesh representing the gorund
  22842. */
  22843. export class GroundMesh extends Mesh {
  22844. /** If octree should be generated */
  22845. generateOctree: boolean;
  22846. private _heightQuads;
  22847. /** @hidden */
  22848. _subdivisionsX: number;
  22849. /** @hidden */
  22850. _subdivisionsY: number;
  22851. /** @hidden */
  22852. _width: number;
  22853. /** @hidden */
  22854. _height: number;
  22855. /** @hidden */
  22856. _minX: number;
  22857. /** @hidden */
  22858. _maxX: number;
  22859. /** @hidden */
  22860. _minZ: number;
  22861. /** @hidden */
  22862. _maxZ: number;
  22863. constructor(name: string, scene: Scene);
  22864. /**
  22865. * "GroundMesh"
  22866. * @returns "GroundMesh"
  22867. */
  22868. getClassName(): string;
  22869. /**
  22870. * The minimum of x and y subdivisions
  22871. */
  22872. get subdivisions(): number;
  22873. /**
  22874. * X subdivisions
  22875. */
  22876. get subdivisionsX(): number;
  22877. /**
  22878. * Y subdivisions
  22879. */
  22880. get subdivisionsY(): number;
  22881. /**
  22882. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22883. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22884. * @param chunksCount the number of subdivisions for x and y
  22885. * @param octreeBlocksSize (Default: 32)
  22886. */
  22887. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22888. /**
  22889. * Returns a height (y) value in the Worl system :
  22890. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22891. * @param x x coordinate
  22892. * @param z z coordinate
  22893. * @returns the ground y position if (x, z) are outside the ground surface.
  22894. */
  22895. getHeightAtCoordinates(x: number, z: number): number;
  22896. /**
  22897. * Returns a normalized vector (Vector3) orthogonal to the ground
  22898. * at the ground coordinates (x, z) expressed in the World system.
  22899. * @param x x coordinate
  22900. * @param z z coordinate
  22901. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22902. */
  22903. getNormalAtCoordinates(x: number, z: number): Vector3;
  22904. /**
  22905. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22906. * at the ground coordinates (x, z) expressed in the World system.
  22907. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22908. * @param x x coordinate
  22909. * @param z z coordinate
  22910. * @param ref vector to store the result
  22911. * @returns the GroundMesh.
  22912. */
  22913. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22914. /**
  22915. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22916. * if the ground has been updated.
  22917. * This can be used in the render loop.
  22918. * @returns the GroundMesh.
  22919. */
  22920. updateCoordinateHeights(): GroundMesh;
  22921. private _getFacetAt;
  22922. private _initHeightQuads;
  22923. private _computeHeightQuads;
  22924. /**
  22925. * Serializes this ground mesh
  22926. * @param serializationObject object to write serialization to
  22927. */
  22928. serialize(serializationObject: any): void;
  22929. /**
  22930. * Parses a serialized ground mesh
  22931. * @param parsedMesh the serialized mesh
  22932. * @param scene the scene to create the ground mesh in
  22933. * @returns the created ground mesh
  22934. */
  22935. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22936. }
  22937. }
  22938. declare module BABYLON {
  22939. /**
  22940. * Interface for Physics-Joint data
  22941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22942. */
  22943. export interface PhysicsJointData {
  22944. /**
  22945. * The main pivot of the joint
  22946. */
  22947. mainPivot?: Vector3;
  22948. /**
  22949. * The connected pivot of the joint
  22950. */
  22951. connectedPivot?: Vector3;
  22952. /**
  22953. * The main axis of the joint
  22954. */
  22955. mainAxis?: Vector3;
  22956. /**
  22957. * The connected axis of the joint
  22958. */
  22959. connectedAxis?: Vector3;
  22960. /**
  22961. * The collision of the joint
  22962. */
  22963. collision?: boolean;
  22964. /**
  22965. * Native Oimo/Cannon/Energy data
  22966. */
  22967. nativeParams?: any;
  22968. }
  22969. /**
  22970. * This is a holder class for the physics joint created by the physics plugin
  22971. * It holds a set of functions to control the underlying joint
  22972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22973. */
  22974. export class PhysicsJoint {
  22975. /**
  22976. * The type of the physics joint
  22977. */
  22978. type: number;
  22979. /**
  22980. * The data for the physics joint
  22981. */
  22982. jointData: PhysicsJointData;
  22983. private _physicsJoint;
  22984. protected _physicsPlugin: IPhysicsEnginePlugin;
  22985. /**
  22986. * Initializes the physics joint
  22987. * @param type The type of the physics joint
  22988. * @param jointData The data for the physics joint
  22989. */
  22990. constructor(
  22991. /**
  22992. * The type of the physics joint
  22993. */
  22994. type: number,
  22995. /**
  22996. * The data for the physics joint
  22997. */
  22998. jointData: PhysicsJointData);
  22999. /**
  23000. * Gets the physics joint
  23001. */
  23002. get physicsJoint(): any;
  23003. /**
  23004. * Sets the physics joint
  23005. */
  23006. set physicsJoint(newJoint: any);
  23007. /**
  23008. * Sets the physics plugin
  23009. */
  23010. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23011. /**
  23012. * Execute a function that is physics-plugin specific.
  23013. * @param {Function} func the function that will be executed.
  23014. * It accepts two parameters: the physics world and the physics joint
  23015. */
  23016. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23017. /**
  23018. * Distance-Joint type
  23019. */
  23020. static DistanceJoint: number;
  23021. /**
  23022. * Hinge-Joint type
  23023. */
  23024. static HingeJoint: number;
  23025. /**
  23026. * Ball-and-Socket joint type
  23027. */
  23028. static BallAndSocketJoint: number;
  23029. /**
  23030. * Wheel-Joint type
  23031. */
  23032. static WheelJoint: number;
  23033. /**
  23034. * Slider-Joint type
  23035. */
  23036. static SliderJoint: number;
  23037. /**
  23038. * Prismatic-Joint type
  23039. */
  23040. static PrismaticJoint: number;
  23041. /**
  23042. * Universal-Joint type
  23043. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23044. */
  23045. static UniversalJoint: number;
  23046. /**
  23047. * Hinge-Joint 2 type
  23048. */
  23049. static Hinge2Joint: number;
  23050. /**
  23051. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23052. */
  23053. static PointToPointJoint: number;
  23054. /**
  23055. * Spring-Joint type
  23056. */
  23057. static SpringJoint: number;
  23058. /**
  23059. * Lock-Joint type
  23060. */
  23061. static LockJoint: number;
  23062. }
  23063. /**
  23064. * A class representing a physics distance joint
  23065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23066. */
  23067. export class DistanceJoint extends PhysicsJoint {
  23068. /**
  23069. *
  23070. * @param jointData The data for the Distance-Joint
  23071. */
  23072. constructor(jointData: DistanceJointData);
  23073. /**
  23074. * Update the predefined distance.
  23075. * @param maxDistance The maximum preferred distance
  23076. * @param minDistance The minimum preferred distance
  23077. */
  23078. updateDistance(maxDistance: number, minDistance?: number): void;
  23079. }
  23080. /**
  23081. * Represents a Motor-Enabled Joint
  23082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23083. */
  23084. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23085. /**
  23086. * Initializes the Motor-Enabled Joint
  23087. * @param type The type of the joint
  23088. * @param jointData The physica joint data for the joint
  23089. */
  23090. constructor(type: number, jointData: PhysicsJointData);
  23091. /**
  23092. * Set the motor values.
  23093. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23094. * @param force the force to apply
  23095. * @param maxForce max force for this motor.
  23096. */
  23097. setMotor(force?: number, maxForce?: number): void;
  23098. /**
  23099. * Set the motor's limits.
  23100. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23101. * @param upperLimit The upper limit of the motor
  23102. * @param lowerLimit The lower limit of the motor
  23103. */
  23104. setLimit(upperLimit: number, lowerLimit?: number): void;
  23105. }
  23106. /**
  23107. * This class represents a single physics Hinge-Joint
  23108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23109. */
  23110. export class HingeJoint extends MotorEnabledJoint {
  23111. /**
  23112. * Initializes the Hinge-Joint
  23113. * @param jointData The joint data for the Hinge-Joint
  23114. */
  23115. constructor(jointData: PhysicsJointData);
  23116. /**
  23117. * Set the motor values.
  23118. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23119. * @param {number} force the force to apply
  23120. * @param {number} maxForce max force for this motor.
  23121. */
  23122. setMotor(force?: number, maxForce?: number): void;
  23123. /**
  23124. * Set the motor's limits.
  23125. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23126. * @param upperLimit The upper limit of the motor
  23127. * @param lowerLimit The lower limit of the motor
  23128. */
  23129. setLimit(upperLimit: number, lowerLimit?: number): void;
  23130. }
  23131. /**
  23132. * This class represents a dual hinge physics joint (same as wheel joint)
  23133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23134. */
  23135. export class Hinge2Joint extends MotorEnabledJoint {
  23136. /**
  23137. * Initializes the Hinge2-Joint
  23138. * @param jointData The joint data for the Hinge2-Joint
  23139. */
  23140. constructor(jointData: PhysicsJointData);
  23141. /**
  23142. * Set the motor values.
  23143. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23144. * @param {number} targetSpeed the speed the motor is to reach
  23145. * @param {number} maxForce max force for this motor.
  23146. * @param {motorIndex} the motor's index, 0 or 1.
  23147. */
  23148. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23149. /**
  23150. * Set the motor limits.
  23151. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23152. * @param {number} upperLimit the upper limit
  23153. * @param {number} lowerLimit lower limit
  23154. * @param {motorIndex} the motor's index, 0 or 1.
  23155. */
  23156. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23157. }
  23158. /**
  23159. * Interface for a motor enabled joint
  23160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23161. */
  23162. export interface IMotorEnabledJoint {
  23163. /**
  23164. * Physics joint
  23165. */
  23166. physicsJoint: any;
  23167. /**
  23168. * Sets the motor of the motor-enabled joint
  23169. * @param force The force of the motor
  23170. * @param maxForce The maximum force of the motor
  23171. * @param motorIndex The index of the motor
  23172. */
  23173. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23174. /**
  23175. * Sets the limit of the motor
  23176. * @param upperLimit The upper limit of the motor
  23177. * @param lowerLimit The lower limit of the motor
  23178. * @param motorIndex The index of the motor
  23179. */
  23180. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23181. }
  23182. /**
  23183. * Joint data for a Distance-Joint
  23184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23185. */
  23186. export interface DistanceJointData extends PhysicsJointData {
  23187. /**
  23188. * Max distance the 2 joint objects can be apart
  23189. */
  23190. maxDistance: number;
  23191. }
  23192. /**
  23193. * Joint data from a spring joint
  23194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23195. */
  23196. export interface SpringJointData extends PhysicsJointData {
  23197. /**
  23198. * Length of the spring
  23199. */
  23200. length: number;
  23201. /**
  23202. * Stiffness of the spring
  23203. */
  23204. stiffness: number;
  23205. /**
  23206. * Damping of the spring
  23207. */
  23208. damping: number;
  23209. /** this callback will be called when applying the force to the impostors. */
  23210. forceApplicationCallback: () => void;
  23211. }
  23212. }
  23213. declare module BABYLON {
  23214. /**
  23215. * Holds the data for the raycast result
  23216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23217. */
  23218. export class PhysicsRaycastResult {
  23219. private _hasHit;
  23220. private _hitDistance;
  23221. private _hitNormalWorld;
  23222. private _hitPointWorld;
  23223. private _rayFromWorld;
  23224. private _rayToWorld;
  23225. /**
  23226. * Gets if there was a hit
  23227. */
  23228. get hasHit(): boolean;
  23229. /**
  23230. * Gets the distance from the hit
  23231. */
  23232. get hitDistance(): number;
  23233. /**
  23234. * Gets the hit normal/direction in the world
  23235. */
  23236. get hitNormalWorld(): Vector3;
  23237. /**
  23238. * Gets the hit point in the world
  23239. */
  23240. get hitPointWorld(): Vector3;
  23241. /**
  23242. * Gets the ray "start point" of the ray in the world
  23243. */
  23244. get rayFromWorld(): Vector3;
  23245. /**
  23246. * Gets the ray "end point" of the ray in the world
  23247. */
  23248. get rayToWorld(): Vector3;
  23249. /**
  23250. * Sets the hit data (normal & point in world space)
  23251. * @param hitNormalWorld defines the normal in world space
  23252. * @param hitPointWorld defines the point in world space
  23253. */
  23254. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23255. /**
  23256. * Sets the distance from the start point to the hit point
  23257. * @param distance
  23258. */
  23259. setHitDistance(distance: number): void;
  23260. /**
  23261. * Calculates the distance manually
  23262. */
  23263. calculateHitDistance(): void;
  23264. /**
  23265. * Resets all the values to default
  23266. * @param from The from point on world space
  23267. * @param to The to point on world space
  23268. */
  23269. reset(from?: Vector3, to?: Vector3): void;
  23270. }
  23271. /**
  23272. * Interface for the size containing width and height
  23273. */
  23274. interface IXYZ {
  23275. /**
  23276. * X
  23277. */
  23278. x: number;
  23279. /**
  23280. * Y
  23281. */
  23282. y: number;
  23283. /**
  23284. * Z
  23285. */
  23286. z: number;
  23287. }
  23288. }
  23289. declare module BABYLON {
  23290. /**
  23291. * Interface used to describe a physics joint
  23292. */
  23293. export interface PhysicsImpostorJoint {
  23294. /** Defines the main impostor to which the joint is linked */
  23295. mainImpostor: PhysicsImpostor;
  23296. /** Defines the impostor that is connected to the main impostor using this joint */
  23297. connectedImpostor: PhysicsImpostor;
  23298. /** Defines the joint itself */
  23299. joint: PhysicsJoint;
  23300. }
  23301. /** @hidden */
  23302. export interface IPhysicsEnginePlugin {
  23303. world: any;
  23304. name: string;
  23305. setGravity(gravity: Vector3): void;
  23306. setTimeStep(timeStep: number): void;
  23307. getTimeStep(): number;
  23308. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23309. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23310. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23311. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23312. removePhysicsBody(impostor: PhysicsImpostor): void;
  23313. generateJoint(joint: PhysicsImpostorJoint): void;
  23314. removeJoint(joint: PhysicsImpostorJoint): void;
  23315. isSupported(): boolean;
  23316. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23317. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23318. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23319. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23320. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23321. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23322. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23323. getBodyMass(impostor: PhysicsImpostor): number;
  23324. getBodyFriction(impostor: PhysicsImpostor): number;
  23325. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23326. getBodyRestitution(impostor: PhysicsImpostor): number;
  23327. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23328. getBodyPressure?(impostor: PhysicsImpostor): number;
  23329. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23330. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23331. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23332. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23333. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23334. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23335. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23336. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23337. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23338. sleepBody(impostor: PhysicsImpostor): void;
  23339. wakeUpBody(impostor: PhysicsImpostor): void;
  23340. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23341. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23342. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23343. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23344. getRadius(impostor: PhysicsImpostor): number;
  23345. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23346. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23347. dispose(): void;
  23348. }
  23349. /**
  23350. * Interface used to define a physics engine
  23351. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23352. */
  23353. export interface IPhysicsEngine {
  23354. /**
  23355. * Gets the gravity vector used by the simulation
  23356. */
  23357. gravity: Vector3;
  23358. /**
  23359. * Sets the gravity vector used by the simulation
  23360. * @param gravity defines the gravity vector to use
  23361. */
  23362. setGravity(gravity: Vector3): void;
  23363. /**
  23364. * Set the time step of the physics engine.
  23365. * Default is 1/60.
  23366. * To slow it down, enter 1/600 for example.
  23367. * To speed it up, 1/30
  23368. * @param newTimeStep the new timestep to apply to this world.
  23369. */
  23370. setTimeStep(newTimeStep: number): void;
  23371. /**
  23372. * Get the time step of the physics engine.
  23373. * @returns the current time step
  23374. */
  23375. getTimeStep(): number;
  23376. /**
  23377. * Set the sub time step of the physics engine.
  23378. * Default is 0 meaning there is no sub steps
  23379. * To increase physics resolution precision, set a small value (like 1 ms)
  23380. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23381. */
  23382. setSubTimeStep(subTimeStep: number): void;
  23383. /**
  23384. * Get the sub time step of the physics engine.
  23385. * @returns the current sub time step
  23386. */
  23387. getSubTimeStep(): number;
  23388. /**
  23389. * Release all resources
  23390. */
  23391. dispose(): void;
  23392. /**
  23393. * Gets the name of the current physics plugin
  23394. * @returns the name of the plugin
  23395. */
  23396. getPhysicsPluginName(): string;
  23397. /**
  23398. * Adding a new impostor for the impostor tracking.
  23399. * This will be done by the impostor itself.
  23400. * @param impostor the impostor to add
  23401. */
  23402. addImpostor(impostor: PhysicsImpostor): void;
  23403. /**
  23404. * Remove an impostor from the engine.
  23405. * This impostor and its mesh will not longer be updated by the physics engine.
  23406. * @param impostor the impostor to remove
  23407. */
  23408. removeImpostor(impostor: PhysicsImpostor): void;
  23409. /**
  23410. * Add a joint to the physics engine
  23411. * @param mainImpostor defines the main impostor to which the joint is added.
  23412. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23413. * @param joint defines the joint that will connect both impostors.
  23414. */
  23415. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23416. /**
  23417. * Removes a joint from the simulation
  23418. * @param mainImpostor defines the impostor used with the joint
  23419. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23420. * @param joint defines the joint to remove
  23421. */
  23422. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23423. /**
  23424. * Gets the current plugin used to run the simulation
  23425. * @returns current plugin
  23426. */
  23427. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23428. /**
  23429. * Gets the list of physic impostors
  23430. * @returns an array of PhysicsImpostor
  23431. */
  23432. getImpostors(): Array<PhysicsImpostor>;
  23433. /**
  23434. * Gets the impostor for a physics enabled object
  23435. * @param object defines the object impersonated by the impostor
  23436. * @returns the PhysicsImpostor or null if not found
  23437. */
  23438. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23439. /**
  23440. * Gets the impostor for a physics body object
  23441. * @param body defines physics body used by the impostor
  23442. * @returns the PhysicsImpostor or null if not found
  23443. */
  23444. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23445. /**
  23446. * Does a raycast in the physics world
  23447. * @param from when should the ray start?
  23448. * @param to when should the ray end?
  23449. * @returns PhysicsRaycastResult
  23450. */
  23451. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23452. /**
  23453. * Called by the scene. No need to call it.
  23454. * @param delta defines the timespam between frames
  23455. */
  23456. _step(delta: number): void;
  23457. }
  23458. }
  23459. declare module BABYLON {
  23460. /**
  23461. * The interface for the physics imposter parameters
  23462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23463. */
  23464. export interface PhysicsImpostorParameters {
  23465. /**
  23466. * The mass of the physics imposter
  23467. */
  23468. mass: number;
  23469. /**
  23470. * The friction of the physics imposter
  23471. */
  23472. friction?: number;
  23473. /**
  23474. * The coefficient of restitution of the physics imposter
  23475. */
  23476. restitution?: number;
  23477. /**
  23478. * The native options of the physics imposter
  23479. */
  23480. nativeOptions?: any;
  23481. /**
  23482. * Specifies if the parent should be ignored
  23483. */
  23484. ignoreParent?: boolean;
  23485. /**
  23486. * Specifies if bi-directional transformations should be disabled
  23487. */
  23488. disableBidirectionalTransformation?: boolean;
  23489. /**
  23490. * The pressure inside the physics imposter, soft object only
  23491. */
  23492. pressure?: number;
  23493. /**
  23494. * The stiffness the physics imposter, soft object only
  23495. */
  23496. stiffness?: number;
  23497. /**
  23498. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23499. */
  23500. velocityIterations?: number;
  23501. /**
  23502. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23503. */
  23504. positionIterations?: number;
  23505. /**
  23506. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23507. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23508. * Add to fix multiple points
  23509. */
  23510. fixedPoints?: number;
  23511. /**
  23512. * The collision margin around a soft object
  23513. */
  23514. margin?: number;
  23515. /**
  23516. * The collision margin around a soft object
  23517. */
  23518. damping?: number;
  23519. /**
  23520. * The path for a rope based on an extrusion
  23521. */
  23522. path?: any;
  23523. /**
  23524. * The shape of an extrusion used for a rope based on an extrusion
  23525. */
  23526. shape?: any;
  23527. }
  23528. /**
  23529. * Interface for a physics-enabled object
  23530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23531. */
  23532. export interface IPhysicsEnabledObject {
  23533. /**
  23534. * The position of the physics-enabled object
  23535. */
  23536. position: Vector3;
  23537. /**
  23538. * The rotation of the physics-enabled object
  23539. */
  23540. rotationQuaternion: Nullable<Quaternion>;
  23541. /**
  23542. * The scale of the physics-enabled object
  23543. */
  23544. scaling: Vector3;
  23545. /**
  23546. * The rotation of the physics-enabled object
  23547. */
  23548. rotation?: Vector3;
  23549. /**
  23550. * The parent of the physics-enabled object
  23551. */
  23552. parent?: any;
  23553. /**
  23554. * The bounding info of the physics-enabled object
  23555. * @returns The bounding info of the physics-enabled object
  23556. */
  23557. getBoundingInfo(): BoundingInfo;
  23558. /**
  23559. * Computes the world matrix
  23560. * @param force Specifies if the world matrix should be computed by force
  23561. * @returns A world matrix
  23562. */
  23563. computeWorldMatrix(force: boolean): Matrix;
  23564. /**
  23565. * Gets the world matrix
  23566. * @returns A world matrix
  23567. */
  23568. getWorldMatrix?(): Matrix;
  23569. /**
  23570. * Gets the child meshes
  23571. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23572. * @returns An array of abstract meshes
  23573. */
  23574. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23575. /**
  23576. * Gets the vertex data
  23577. * @param kind The type of vertex data
  23578. * @returns A nullable array of numbers, or a float32 array
  23579. */
  23580. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23581. /**
  23582. * Gets the indices from the mesh
  23583. * @returns A nullable array of index arrays
  23584. */
  23585. getIndices?(): Nullable<IndicesArray>;
  23586. /**
  23587. * Gets the scene from the mesh
  23588. * @returns the indices array or null
  23589. */
  23590. getScene?(): Scene;
  23591. /**
  23592. * Gets the absolute position from the mesh
  23593. * @returns the absolute position
  23594. */
  23595. getAbsolutePosition(): Vector3;
  23596. /**
  23597. * Gets the absolute pivot point from the mesh
  23598. * @returns the absolute pivot point
  23599. */
  23600. getAbsolutePivotPoint(): Vector3;
  23601. /**
  23602. * Rotates the mesh
  23603. * @param axis The axis of rotation
  23604. * @param amount The amount of rotation
  23605. * @param space The space of the rotation
  23606. * @returns The rotation transform node
  23607. */
  23608. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23609. /**
  23610. * Translates the mesh
  23611. * @param axis The axis of translation
  23612. * @param distance The distance of translation
  23613. * @param space The space of the translation
  23614. * @returns The transform node
  23615. */
  23616. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23617. /**
  23618. * Sets the absolute position of the mesh
  23619. * @param absolutePosition The absolute position of the mesh
  23620. * @returns The transform node
  23621. */
  23622. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23623. /**
  23624. * Gets the class name of the mesh
  23625. * @returns The class name
  23626. */
  23627. getClassName(): string;
  23628. }
  23629. /**
  23630. * Represents a physics imposter
  23631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23632. */
  23633. export class PhysicsImpostor {
  23634. /**
  23635. * The physics-enabled object used as the physics imposter
  23636. */
  23637. object: IPhysicsEnabledObject;
  23638. /**
  23639. * The type of the physics imposter
  23640. */
  23641. type: number;
  23642. private _options;
  23643. private _scene?;
  23644. /**
  23645. * The default object size of the imposter
  23646. */
  23647. static DEFAULT_OBJECT_SIZE: Vector3;
  23648. /**
  23649. * The identity quaternion of the imposter
  23650. */
  23651. static IDENTITY_QUATERNION: Quaternion;
  23652. /** @hidden */
  23653. _pluginData: any;
  23654. private _physicsEngine;
  23655. private _physicsBody;
  23656. private _bodyUpdateRequired;
  23657. private _onBeforePhysicsStepCallbacks;
  23658. private _onAfterPhysicsStepCallbacks;
  23659. /** @hidden */
  23660. _onPhysicsCollideCallbacks: Array<{
  23661. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23662. otherImpostors: Array<PhysicsImpostor>;
  23663. }>;
  23664. private _deltaPosition;
  23665. private _deltaRotation;
  23666. private _deltaRotationConjugated;
  23667. /** @hidden */
  23668. _isFromLine: boolean;
  23669. private _parent;
  23670. private _isDisposed;
  23671. private static _tmpVecs;
  23672. private static _tmpQuat;
  23673. /**
  23674. * Specifies if the physics imposter is disposed
  23675. */
  23676. get isDisposed(): boolean;
  23677. /**
  23678. * Gets the mass of the physics imposter
  23679. */
  23680. get mass(): number;
  23681. set mass(value: number);
  23682. /**
  23683. * Gets the coefficient of friction
  23684. */
  23685. get friction(): number;
  23686. /**
  23687. * Sets the coefficient of friction
  23688. */
  23689. set friction(value: number);
  23690. /**
  23691. * Gets the coefficient of restitution
  23692. */
  23693. get restitution(): number;
  23694. /**
  23695. * Sets the coefficient of restitution
  23696. */
  23697. set restitution(value: number);
  23698. /**
  23699. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23700. */
  23701. get pressure(): number;
  23702. /**
  23703. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23704. */
  23705. set pressure(value: number);
  23706. /**
  23707. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23708. */
  23709. get stiffness(): number;
  23710. /**
  23711. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23712. */
  23713. set stiffness(value: number);
  23714. /**
  23715. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23716. */
  23717. get velocityIterations(): number;
  23718. /**
  23719. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23720. */
  23721. set velocityIterations(value: number);
  23722. /**
  23723. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23724. */
  23725. get positionIterations(): number;
  23726. /**
  23727. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23728. */
  23729. set positionIterations(value: number);
  23730. /**
  23731. * The unique id of the physics imposter
  23732. * set by the physics engine when adding this impostor to the array
  23733. */
  23734. uniqueId: number;
  23735. /**
  23736. * @hidden
  23737. */
  23738. soft: boolean;
  23739. /**
  23740. * @hidden
  23741. */
  23742. segments: number;
  23743. private _joints;
  23744. /**
  23745. * Initializes the physics imposter
  23746. * @param object The physics-enabled object used as the physics imposter
  23747. * @param type The type of the physics imposter
  23748. * @param _options The options for the physics imposter
  23749. * @param _scene The Babylon scene
  23750. */
  23751. constructor(
  23752. /**
  23753. * The physics-enabled object used as the physics imposter
  23754. */
  23755. object: IPhysicsEnabledObject,
  23756. /**
  23757. * The type of the physics imposter
  23758. */
  23759. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23760. /**
  23761. * This function will completly initialize this impostor.
  23762. * It will create a new body - but only if this mesh has no parent.
  23763. * If it has, this impostor will not be used other than to define the impostor
  23764. * of the child mesh.
  23765. * @hidden
  23766. */
  23767. _init(): void;
  23768. private _getPhysicsParent;
  23769. /**
  23770. * Should a new body be generated.
  23771. * @returns boolean specifying if body initialization is required
  23772. */
  23773. isBodyInitRequired(): boolean;
  23774. /**
  23775. * Sets the updated scaling
  23776. * @param updated Specifies if the scaling is updated
  23777. */
  23778. setScalingUpdated(): void;
  23779. /**
  23780. * Force a regeneration of this or the parent's impostor's body.
  23781. * Use under cautious - This will remove all joints already implemented.
  23782. */
  23783. forceUpdate(): void;
  23784. /**
  23785. * Gets the body that holds this impostor. Either its own, or its parent.
  23786. */
  23787. get physicsBody(): any;
  23788. /**
  23789. * Get the parent of the physics imposter
  23790. * @returns Physics imposter or null
  23791. */
  23792. get parent(): Nullable<PhysicsImpostor>;
  23793. /**
  23794. * Sets the parent of the physics imposter
  23795. */
  23796. set parent(value: Nullable<PhysicsImpostor>);
  23797. /**
  23798. * Set the physics body. Used mainly by the physics engine/plugin
  23799. */
  23800. set physicsBody(physicsBody: any);
  23801. /**
  23802. * Resets the update flags
  23803. */
  23804. resetUpdateFlags(): void;
  23805. /**
  23806. * Gets the object extend size
  23807. * @returns the object extend size
  23808. */
  23809. getObjectExtendSize(): Vector3;
  23810. /**
  23811. * Gets the object center
  23812. * @returns The object center
  23813. */
  23814. getObjectCenter(): Vector3;
  23815. /**
  23816. * Get a specific parameter from the options parameters
  23817. * @param paramName The object parameter name
  23818. * @returns The object parameter
  23819. */
  23820. getParam(paramName: string): any;
  23821. /**
  23822. * Sets a specific parameter in the options given to the physics plugin
  23823. * @param paramName The parameter name
  23824. * @param value The value of the parameter
  23825. */
  23826. setParam(paramName: string, value: number): void;
  23827. /**
  23828. * Specifically change the body's mass option. Won't recreate the physics body object
  23829. * @param mass The mass of the physics imposter
  23830. */
  23831. setMass(mass: number): void;
  23832. /**
  23833. * Gets the linear velocity
  23834. * @returns linear velocity or null
  23835. */
  23836. getLinearVelocity(): Nullable<Vector3>;
  23837. /**
  23838. * Sets the linear velocity
  23839. * @param velocity linear velocity or null
  23840. */
  23841. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23842. /**
  23843. * Gets the angular velocity
  23844. * @returns angular velocity or null
  23845. */
  23846. getAngularVelocity(): Nullable<Vector3>;
  23847. /**
  23848. * Sets the angular velocity
  23849. * @param velocity The velocity or null
  23850. */
  23851. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23852. /**
  23853. * Execute a function with the physics plugin native code
  23854. * Provide a function the will have two variables - the world object and the physics body object
  23855. * @param func The function to execute with the physics plugin native code
  23856. */
  23857. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23858. /**
  23859. * Register a function that will be executed before the physics world is stepping forward
  23860. * @param func The function to execute before the physics world is stepped forward
  23861. */
  23862. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23863. /**
  23864. * Unregister a function that will be executed before the physics world is stepping forward
  23865. * @param func The function to execute before the physics world is stepped forward
  23866. */
  23867. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23868. /**
  23869. * Register a function that will be executed after the physics step
  23870. * @param func The function to execute after physics step
  23871. */
  23872. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23873. /**
  23874. * Unregisters a function that will be executed after the physics step
  23875. * @param func The function to execute after physics step
  23876. */
  23877. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23878. /**
  23879. * register a function that will be executed when this impostor collides against a different body
  23880. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23881. * @param func Callback that is executed on collision
  23882. */
  23883. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23884. /**
  23885. * Unregisters the physics imposter on contact
  23886. * @param collideAgainst The physics object to collide against
  23887. * @param func Callback to execute on collision
  23888. */
  23889. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23890. private _tmpQuat;
  23891. private _tmpQuat2;
  23892. /**
  23893. * Get the parent rotation
  23894. * @returns The parent rotation
  23895. */
  23896. getParentsRotation(): Quaternion;
  23897. /**
  23898. * this function is executed by the physics engine.
  23899. */
  23900. beforeStep: () => void;
  23901. /**
  23902. * this function is executed by the physics engine
  23903. */
  23904. afterStep: () => void;
  23905. /**
  23906. * Legacy collision detection event support
  23907. */
  23908. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23909. /**
  23910. * event and body object due to cannon's event-based architecture.
  23911. */
  23912. onCollide: (e: {
  23913. body: any;
  23914. }) => void;
  23915. /**
  23916. * Apply a force
  23917. * @param force The force to apply
  23918. * @param contactPoint The contact point for the force
  23919. * @returns The physics imposter
  23920. */
  23921. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23922. /**
  23923. * Apply an impulse
  23924. * @param force The impulse force
  23925. * @param contactPoint The contact point for the impulse force
  23926. * @returns The physics imposter
  23927. */
  23928. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23929. /**
  23930. * A help function to create a joint
  23931. * @param otherImpostor A physics imposter used to create a joint
  23932. * @param jointType The type of joint
  23933. * @param jointData The data for the joint
  23934. * @returns The physics imposter
  23935. */
  23936. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23937. /**
  23938. * Add a joint to this impostor with a different impostor
  23939. * @param otherImpostor A physics imposter used to add a joint
  23940. * @param joint The joint to add
  23941. * @returns The physics imposter
  23942. */
  23943. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23944. /**
  23945. * Add an anchor to a cloth impostor
  23946. * @param otherImpostor rigid impostor to anchor to
  23947. * @param width ratio across width from 0 to 1
  23948. * @param height ratio up height from 0 to 1
  23949. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23950. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23951. * @returns impostor the soft imposter
  23952. */
  23953. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23954. /**
  23955. * Add a hook to a rope impostor
  23956. * @param otherImpostor rigid impostor to anchor to
  23957. * @param length ratio across rope from 0 to 1
  23958. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23959. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23960. * @returns impostor the rope imposter
  23961. */
  23962. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23963. /**
  23964. * Will keep this body still, in a sleep mode.
  23965. * @returns the physics imposter
  23966. */
  23967. sleep(): PhysicsImpostor;
  23968. /**
  23969. * Wake the body up.
  23970. * @returns The physics imposter
  23971. */
  23972. wakeUp(): PhysicsImpostor;
  23973. /**
  23974. * Clones the physics imposter
  23975. * @param newObject The physics imposter clones to this physics-enabled object
  23976. * @returns A nullable physics imposter
  23977. */
  23978. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23979. /**
  23980. * Disposes the physics imposter
  23981. */
  23982. dispose(): void;
  23983. /**
  23984. * Sets the delta position
  23985. * @param position The delta position amount
  23986. */
  23987. setDeltaPosition(position: Vector3): void;
  23988. /**
  23989. * Sets the delta rotation
  23990. * @param rotation The delta rotation amount
  23991. */
  23992. setDeltaRotation(rotation: Quaternion): void;
  23993. /**
  23994. * Gets the box size of the physics imposter and stores the result in the input parameter
  23995. * @param result Stores the box size
  23996. * @returns The physics imposter
  23997. */
  23998. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23999. /**
  24000. * Gets the radius of the physics imposter
  24001. * @returns Radius of the physics imposter
  24002. */
  24003. getRadius(): number;
  24004. /**
  24005. * Sync a bone with this impostor
  24006. * @param bone The bone to sync to the impostor.
  24007. * @param boneMesh The mesh that the bone is influencing.
  24008. * @param jointPivot The pivot of the joint / bone in local space.
  24009. * @param distToJoint Optional distance from the impostor to the joint.
  24010. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24011. */
  24012. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24013. /**
  24014. * Sync impostor to a bone
  24015. * @param bone The bone that the impostor will be synced to.
  24016. * @param boneMesh The mesh that the bone is influencing.
  24017. * @param jointPivot The pivot of the joint / bone in local space.
  24018. * @param distToJoint Optional distance from the impostor to the joint.
  24019. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24020. * @param boneAxis Optional vector3 axis the bone is aligned with
  24021. */
  24022. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24023. /**
  24024. * No-Imposter type
  24025. */
  24026. static NoImpostor: number;
  24027. /**
  24028. * Sphere-Imposter type
  24029. */
  24030. static SphereImpostor: number;
  24031. /**
  24032. * Box-Imposter type
  24033. */
  24034. static BoxImpostor: number;
  24035. /**
  24036. * Plane-Imposter type
  24037. */
  24038. static PlaneImpostor: number;
  24039. /**
  24040. * Mesh-imposter type
  24041. */
  24042. static MeshImpostor: number;
  24043. /**
  24044. * Capsule-Impostor type (Ammo.js plugin only)
  24045. */
  24046. static CapsuleImpostor: number;
  24047. /**
  24048. * Cylinder-Imposter type
  24049. */
  24050. static CylinderImpostor: number;
  24051. /**
  24052. * Particle-Imposter type
  24053. */
  24054. static ParticleImpostor: number;
  24055. /**
  24056. * Heightmap-Imposter type
  24057. */
  24058. static HeightmapImpostor: number;
  24059. /**
  24060. * ConvexHull-Impostor type (Ammo.js plugin only)
  24061. */
  24062. static ConvexHullImpostor: number;
  24063. /**
  24064. * Custom-Imposter type (Ammo.js plugin only)
  24065. */
  24066. static CustomImpostor: number;
  24067. /**
  24068. * Rope-Imposter type
  24069. */
  24070. static RopeImpostor: number;
  24071. /**
  24072. * Cloth-Imposter type
  24073. */
  24074. static ClothImpostor: number;
  24075. /**
  24076. * Softbody-Imposter type
  24077. */
  24078. static SoftbodyImpostor: number;
  24079. }
  24080. }
  24081. declare module BABYLON {
  24082. /**
  24083. * @hidden
  24084. **/
  24085. export class _CreationDataStorage {
  24086. closePath?: boolean;
  24087. closeArray?: boolean;
  24088. idx: number[];
  24089. dashSize: number;
  24090. gapSize: number;
  24091. path3D: Path3D;
  24092. pathArray: Vector3[][];
  24093. arc: number;
  24094. radius: number;
  24095. cap: number;
  24096. tessellation: number;
  24097. }
  24098. /**
  24099. * @hidden
  24100. **/
  24101. class _InstanceDataStorage {
  24102. visibleInstances: any;
  24103. batchCache: _InstancesBatch;
  24104. instancesBufferSize: number;
  24105. instancesBuffer: Nullable<Buffer>;
  24106. instancesData: Float32Array;
  24107. overridenInstanceCount: number;
  24108. isFrozen: boolean;
  24109. previousBatch: Nullable<_InstancesBatch>;
  24110. hardwareInstancedRendering: boolean;
  24111. sideOrientation: number;
  24112. manualUpdate: boolean;
  24113. }
  24114. /**
  24115. * @hidden
  24116. **/
  24117. export class _InstancesBatch {
  24118. mustReturn: boolean;
  24119. visibleInstances: Nullable<InstancedMesh[]>[];
  24120. renderSelf: boolean[];
  24121. hardwareInstancedRendering: boolean[];
  24122. }
  24123. /**
  24124. * Class used to represent renderable models
  24125. */
  24126. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24127. /**
  24128. * Mesh side orientation : usually the external or front surface
  24129. */
  24130. static readonly FRONTSIDE: number;
  24131. /**
  24132. * Mesh side orientation : usually the internal or back surface
  24133. */
  24134. static readonly BACKSIDE: number;
  24135. /**
  24136. * Mesh side orientation : both internal and external or front and back surfaces
  24137. */
  24138. static readonly DOUBLESIDE: number;
  24139. /**
  24140. * Mesh side orientation : by default, `FRONTSIDE`
  24141. */
  24142. static readonly DEFAULTSIDE: number;
  24143. /**
  24144. * Mesh cap setting : no cap
  24145. */
  24146. static readonly NO_CAP: number;
  24147. /**
  24148. * Mesh cap setting : one cap at the beginning of the mesh
  24149. */
  24150. static readonly CAP_START: number;
  24151. /**
  24152. * Mesh cap setting : one cap at the end of the mesh
  24153. */
  24154. static readonly CAP_END: number;
  24155. /**
  24156. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24157. */
  24158. static readonly CAP_ALL: number;
  24159. /**
  24160. * Mesh pattern setting : no flip or rotate
  24161. */
  24162. static readonly NO_FLIP: number;
  24163. /**
  24164. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24165. */
  24166. static readonly FLIP_TILE: number;
  24167. /**
  24168. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24169. */
  24170. static readonly ROTATE_TILE: number;
  24171. /**
  24172. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24173. */
  24174. static readonly FLIP_ROW: number;
  24175. /**
  24176. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24177. */
  24178. static readonly ROTATE_ROW: number;
  24179. /**
  24180. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24181. */
  24182. static readonly FLIP_N_ROTATE_TILE: number;
  24183. /**
  24184. * Mesh pattern setting : rotate pattern and rotate
  24185. */
  24186. static readonly FLIP_N_ROTATE_ROW: number;
  24187. /**
  24188. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24189. */
  24190. static readonly CENTER: number;
  24191. /**
  24192. * Mesh tile positioning : part tiles on left
  24193. */
  24194. static readonly LEFT: number;
  24195. /**
  24196. * Mesh tile positioning : part tiles on right
  24197. */
  24198. static readonly RIGHT: number;
  24199. /**
  24200. * Mesh tile positioning : part tiles on top
  24201. */
  24202. static readonly TOP: number;
  24203. /**
  24204. * Mesh tile positioning : part tiles on bottom
  24205. */
  24206. static readonly BOTTOM: number;
  24207. /**
  24208. * Gets the default side orientation.
  24209. * @param orientation the orientation to value to attempt to get
  24210. * @returns the default orientation
  24211. * @hidden
  24212. */
  24213. static _GetDefaultSideOrientation(orientation?: number): number;
  24214. private _internalMeshDataInfo;
  24215. /**
  24216. * An event triggered before rendering the mesh
  24217. */
  24218. get onBeforeRenderObservable(): Observable<Mesh>;
  24219. /**
  24220. * An event triggered before binding the mesh
  24221. */
  24222. get onBeforeBindObservable(): Observable<Mesh>;
  24223. /**
  24224. * An event triggered after rendering the mesh
  24225. */
  24226. get onAfterRenderObservable(): Observable<Mesh>;
  24227. /**
  24228. * An event triggered before drawing the mesh
  24229. */
  24230. get onBeforeDrawObservable(): Observable<Mesh>;
  24231. private _onBeforeDrawObserver;
  24232. /**
  24233. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24234. */
  24235. set onBeforeDraw(callback: () => void);
  24236. get hasInstances(): boolean;
  24237. /**
  24238. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24239. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24240. */
  24241. delayLoadState: number;
  24242. /**
  24243. * Gets the list of instances created from this mesh
  24244. * it is not supposed to be modified manually.
  24245. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24246. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24247. */
  24248. instances: InstancedMesh[];
  24249. /**
  24250. * Gets the file containing delay loading data for this mesh
  24251. */
  24252. delayLoadingFile: string;
  24253. /** @hidden */
  24254. _binaryInfo: any;
  24255. /**
  24256. * User defined function used to change how LOD level selection is done
  24257. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24258. */
  24259. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24260. /**
  24261. * Gets or sets the morph target manager
  24262. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24263. */
  24264. get morphTargetManager(): Nullable<MorphTargetManager>;
  24265. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24266. /** @hidden */
  24267. _creationDataStorage: Nullable<_CreationDataStorage>;
  24268. /** @hidden */
  24269. _geometry: Nullable<Geometry>;
  24270. /** @hidden */
  24271. _delayInfo: Array<string>;
  24272. /** @hidden */
  24273. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24274. /** @hidden */
  24275. _instanceDataStorage: _InstanceDataStorage;
  24276. private _effectiveMaterial;
  24277. /** @hidden */
  24278. _shouldGenerateFlatShading: boolean;
  24279. /** @hidden */
  24280. _originalBuilderSideOrientation: number;
  24281. /**
  24282. * Use this property to change the original side orientation defined at construction time
  24283. */
  24284. overrideMaterialSideOrientation: Nullable<number>;
  24285. /**
  24286. * Gets the source mesh (the one used to clone this one from)
  24287. */
  24288. get source(): Nullable<Mesh>;
  24289. /**
  24290. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24291. */
  24292. get isUnIndexed(): boolean;
  24293. set isUnIndexed(value: boolean);
  24294. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24295. get worldMatrixInstancedBuffer(): Float32Array;
  24296. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24297. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24298. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24299. /**
  24300. * @constructor
  24301. * @param name The value used by scene.getMeshByName() to do a lookup.
  24302. * @param scene The scene to add this mesh to.
  24303. * @param parent The parent of this mesh, if it has one
  24304. * @param source An optional Mesh from which geometry is shared, cloned.
  24305. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24306. * When false, achieved by calling a clone(), also passing False.
  24307. * This will make creation of children, recursive.
  24308. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24309. */
  24310. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24311. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24312. doNotInstantiate: boolean;
  24313. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24314. /**
  24315. * Gets the class name
  24316. * @returns the string "Mesh".
  24317. */
  24318. getClassName(): string;
  24319. /** @hidden */
  24320. get _isMesh(): boolean;
  24321. /**
  24322. * Returns a description of this mesh
  24323. * @param fullDetails define if full details about this mesh must be used
  24324. * @returns a descriptive string representing this mesh
  24325. */
  24326. toString(fullDetails?: boolean): string;
  24327. /** @hidden */
  24328. _unBindEffect(): void;
  24329. /**
  24330. * Gets a boolean indicating if this mesh has LOD
  24331. */
  24332. get hasLODLevels(): boolean;
  24333. /**
  24334. * Gets the list of MeshLODLevel associated with the current mesh
  24335. * @returns an array of MeshLODLevel
  24336. */
  24337. getLODLevels(): MeshLODLevel[];
  24338. private _sortLODLevels;
  24339. /**
  24340. * Add a mesh as LOD level triggered at the given distance.
  24341. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24342. * @param distance The distance from the center of the object to show this level
  24343. * @param mesh The mesh to be added as LOD level (can be null)
  24344. * @return This mesh (for chaining)
  24345. */
  24346. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24347. /**
  24348. * Returns the LOD level mesh at the passed distance or null if not found.
  24349. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24350. * @param distance The distance from the center of the object to show this level
  24351. * @returns a Mesh or `null`
  24352. */
  24353. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24354. /**
  24355. * Remove a mesh from the LOD array
  24356. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24357. * @param mesh defines the mesh to be removed
  24358. * @return This mesh (for chaining)
  24359. */
  24360. removeLODLevel(mesh: Mesh): Mesh;
  24361. /**
  24362. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24363. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24364. * @param camera defines the camera to use to compute distance
  24365. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24366. * @return This mesh (for chaining)
  24367. */
  24368. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24369. /**
  24370. * Gets the mesh internal Geometry object
  24371. */
  24372. get geometry(): Nullable<Geometry>;
  24373. /**
  24374. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24375. * @returns the total number of vertices
  24376. */
  24377. getTotalVertices(): number;
  24378. /**
  24379. * Returns the content of an associated vertex buffer
  24380. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24381. * - VertexBuffer.PositionKind
  24382. * - VertexBuffer.UVKind
  24383. * - VertexBuffer.UV2Kind
  24384. * - VertexBuffer.UV3Kind
  24385. * - VertexBuffer.UV4Kind
  24386. * - VertexBuffer.UV5Kind
  24387. * - VertexBuffer.UV6Kind
  24388. * - VertexBuffer.ColorKind
  24389. * - VertexBuffer.MatricesIndicesKind
  24390. * - VertexBuffer.MatricesIndicesExtraKind
  24391. * - VertexBuffer.MatricesWeightsKind
  24392. * - VertexBuffer.MatricesWeightsExtraKind
  24393. * @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
  24394. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24395. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24396. */
  24397. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24398. /**
  24399. * Returns the mesh VertexBuffer object from the requested `kind`
  24400. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24401. * - VertexBuffer.PositionKind
  24402. * - VertexBuffer.NormalKind
  24403. * - VertexBuffer.UVKind
  24404. * - VertexBuffer.UV2Kind
  24405. * - VertexBuffer.UV3Kind
  24406. * - VertexBuffer.UV4Kind
  24407. * - VertexBuffer.UV5Kind
  24408. * - VertexBuffer.UV6Kind
  24409. * - VertexBuffer.ColorKind
  24410. * - VertexBuffer.MatricesIndicesKind
  24411. * - VertexBuffer.MatricesIndicesExtraKind
  24412. * - VertexBuffer.MatricesWeightsKind
  24413. * - VertexBuffer.MatricesWeightsExtraKind
  24414. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24415. */
  24416. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24417. /**
  24418. * Tests if a specific vertex buffer is associated with this mesh
  24419. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24420. * - VertexBuffer.PositionKind
  24421. * - VertexBuffer.NormalKind
  24422. * - VertexBuffer.UVKind
  24423. * - VertexBuffer.UV2Kind
  24424. * - VertexBuffer.UV3Kind
  24425. * - VertexBuffer.UV4Kind
  24426. * - VertexBuffer.UV5Kind
  24427. * - VertexBuffer.UV6Kind
  24428. * - VertexBuffer.ColorKind
  24429. * - VertexBuffer.MatricesIndicesKind
  24430. * - VertexBuffer.MatricesIndicesExtraKind
  24431. * - VertexBuffer.MatricesWeightsKind
  24432. * - VertexBuffer.MatricesWeightsExtraKind
  24433. * @returns a boolean
  24434. */
  24435. isVerticesDataPresent(kind: string): boolean;
  24436. /**
  24437. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24438. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24439. * - VertexBuffer.PositionKind
  24440. * - VertexBuffer.UVKind
  24441. * - VertexBuffer.UV2Kind
  24442. * - VertexBuffer.UV3Kind
  24443. * - VertexBuffer.UV4Kind
  24444. * - VertexBuffer.UV5Kind
  24445. * - VertexBuffer.UV6Kind
  24446. * - VertexBuffer.ColorKind
  24447. * - VertexBuffer.MatricesIndicesKind
  24448. * - VertexBuffer.MatricesIndicesExtraKind
  24449. * - VertexBuffer.MatricesWeightsKind
  24450. * - VertexBuffer.MatricesWeightsExtraKind
  24451. * @returns a boolean
  24452. */
  24453. isVertexBufferUpdatable(kind: string): boolean;
  24454. /**
  24455. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24456. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24457. * - VertexBuffer.PositionKind
  24458. * - VertexBuffer.NormalKind
  24459. * - VertexBuffer.UVKind
  24460. * - VertexBuffer.UV2Kind
  24461. * - VertexBuffer.UV3Kind
  24462. * - VertexBuffer.UV4Kind
  24463. * - VertexBuffer.UV5Kind
  24464. * - VertexBuffer.UV6Kind
  24465. * - VertexBuffer.ColorKind
  24466. * - VertexBuffer.MatricesIndicesKind
  24467. * - VertexBuffer.MatricesIndicesExtraKind
  24468. * - VertexBuffer.MatricesWeightsKind
  24469. * - VertexBuffer.MatricesWeightsExtraKind
  24470. * @returns an array of strings
  24471. */
  24472. getVerticesDataKinds(): string[];
  24473. /**
  24474. * Returns a positive integer : the total number of indices in this mesh geometry.
  24475. * @returns the numner of indices or zero if the mesh has no geometry.
  24476. */
  24477. getTotalIndices(): number;
  24478. /**
  24479. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24480. * @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.
  24481. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24482. * @returns the indices array or an empty array if the mesh has no geometry
  24483. */
  24484. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24485. get isBlocked(): boolean;
  24486. /**
  24487. * Determine if the current mesh is ready to be rendered
  24488. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24489. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24490. * @returns true if all associated assets are ready (material, textures, shaders)
  24491. */
  24492. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24493. /**
  24494. * 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.
  24495. */
  24496. get areNormalsFrozen(): boolean;
  24497. /**
  24498. * 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.
  24499. * @returns the current mesh
  24500. */
  24501. freezeNormals(): Mesh;
  24502. /**
  24503. * 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
  24504. * @returns the current mesh
  24505. */
  24506. unfreezeNormals(): Mesh;
  24507. /**
  24508. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24509. */
  24510. set overridenInstanceCount(count: number);
  24511. /** @hidden */
  24512. _preActivate(): Mesh;
  24513. /** @hidden */
  24514. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24515. /** @hidden */
  24516. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24517. /**
  24518. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24519. * This means the mesh underlying bounding box and sphere are recomputed.
  24520. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24521. * @returns the current mesh
  24522. */
  24523. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24524. /** @hidden */
  24525. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24526. /**
  24527. * This function will subdivide the mesh into multiple submeshes
  24528. * @param count defines the expected number of submeshes
  24529. */
  24530. subdivide(count: number): void;
  24531. /**
  24532. * Copy a FloatArray into a specific associated vertex buffer
  24533. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24534. * - VertexBuffer.PositionKind
  24535. * - VertexBuffer.UVKind
  24536. * - VertexBuffer.UV2Kind
  24537. * - VertexBuffer.UV3Kind
  24538. * - VertexBuffer.UV4Kind
  24539. * - VertexBuffer.UV5Kind
  24540. * - VertexBuffer.UV6Kind
  24541. * - VertexBuffer.ColorKind
  24542. * - VertexBuffer.MatricesIndicesKind
  24543. * - VertexBuffer.MatricesIndicesExtraKind
  24544. * - VertexBuffer.MatricesWeightsKind
  24545. * - VertexBuffer.MatricesWeightsExtraKind
  24546. * @param data defines the data source
  24547. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24548. * @param stride defines the data stride size (can be null)
  24549. * @returns the current mesh
  24550. */
  24551. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24552. /**
  24553. * Delete a vertex buffer associated with this mesh
  24554. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24555. * - VertexBuffer.PositionKind
  24556. * - VertexBuffer.UVKind
  24557. * - VertexBuffer.UV2Kind
  24558. * - VertexBuffer.UV3Kind
  24559. * - VertexBuffer.UV4Kind
  24560. * - VertexBuffer.UV5Kind
  24561. * - VertexBuffer.UV6Kind
  24562. * - VertexBuffer.ColorKind
  24563. * - VertexBuffer.MatricesIndicesKind
  24564. * - VertexBuffer.MatricesIndicesExtraKind
  24565. * - VertexBuffer.MatricesWeightsKind
  24566. * - VertexBuffer.MatricesWeightsExtraKind
  24567. */
  24568. removeVerticesData(kind: string): void;
  24569. /**
  24570. * Flags an associated vertex buffer as updatable
  24571. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24572. * - VertexBuffer.PositionKind
  24573. * - VertexBuffer.UVKind
  24574. * - VertexBuffer.UV2Kind
  24575. * - VertexBuffer.UV3Kind
  24576. * - VertexBuffer.UV4Kind
  24577. * - VertexBuffer.UV5Kind
  24578. * - VertexBuffer.UV6Kind
  24579. * - VertexBuffer.ColorKind
  24580. * - VertexBuffer.MatricesIndicesKind
  24581. * - VertexBuffer.MatricesIndicesExtraKind
  24582. * - VertexBuffer.MatricesWeightsKind
  24583. * - VertexBuffer.MatricesWeightsExtraKind
  24584. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24585. */
  24586. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24587. /**
  24588. * Sets the mesh global Vertex Buffer
  24589. * @param buffer defines the buffer to use
  24590. * @returns the current mesh
  24591. */
  24592. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24593. /**
  24594. * Update a specific associated vertex buffer
  24595. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24596. * - VertexBuffer.PositionKind
  24597. * - VertexBuffer.UVKind
  24598. * - VertexBuffer.UV2Kind
  24599. * - VertexBuffer.UV3Kind
  24600. * - VertexBuffer.UV4Kind
  24601. * - VertexBuffer.UV5Kind
  24602. * - VertexBuffer.UV6Kind
  24603. * - VertexBuffer.ColorKind
  24604. * - VertexBuffer.MatricesIndicesKind
  24605. * - VertexBuffer.MatricesIndicesExtraKind
  24606. * - VertexBuffer.MatricesWeightsKind
  24607. * - VertexBuffer.MatricesWeightsExtraKind
  24608. * @param data defines the data source
  24609. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24610. * @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)
  24611. * @returns the current mesh
  24612. */
  24613. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24614. /**
  24615. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24616. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24617. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24618. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24619. * @returns the current mesh
  24620. */
  24621. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24622. /**
  24623. * Creates a un-shared specific occurence of the geometry for the mesh.
  24624. * @returns the current mesh
  24625. */
  24626. makeGeometryUnique(): Mesh;
  24627. /**
  24628. * Set the index buffer of this mesh
  24629. * @param indices defines the source data
  24630. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24631. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24632. * @returns the current mesh
  24633. */
  24634. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24635. /**
  24636. * Update the current index buffer
  24637. * @param indices defines the source data
  24638. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24639. * @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)
  24640. * @returns the current mesh
  24641. */
  24642. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24643. /**
  24644. * Invert the geometry to move from a right handed system to a left handed one.
  24645. * @returns the current mesh
  24646. */
  24647. toLeftHanded(): Mesh;
  24648. /** @hidden */
  24649. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24650. /** @hidden */
  24651. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24652. /**
  24653. * Registers for this mesh a javascript function called just before the rendering process
  24654. * @param func defines the function to call before rendering this mesh
  24655. * @returns the current mesh
  24656. */
  24657. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24658. /**
  24659. * Disposes a previously registered javascript function called before the rendering
  24660. * @param func defines the function to remove
  24661. * @returns the current mesh
  24662. */
  24663. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24664. /**
  24665. * Registers for this mesh a javascript function called just after the rendering is complete
  24666. * @param func defines the function to call after rendering this mesh
  24667. * @returns the current mesh
  24668. */
  24669. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24670. /**
  24671. * Disposes a previously registered javascript function called after the rendering.
  24672. * @param func defines the function to remove
  24673. * @returns the current mesh
  24674. */
  24675. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24676. /** @hidden */
  24677. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24678. /** @hidden */
  24679. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24680. /** @hidden */
  24681. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24682. /** @hidden */
  24683. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24684. /** @hidden */
  24685. _rebuild(): void;
  24686. /** @hidden */
  24687. _freeze(): void;
  24688. /** @hidden */
  24689. _unFreeze(): void;
  24690. /**
  24691. * 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
  24692. * @param subMesh defines the subMesh to render
  24693. * @param enableAlphaMode defines if alpha mode can be changed
  24694. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24695. * @returns the current mesh
  24696. */
  24697. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24698. private _onBeforeDraw;
  24699. /**
  24700. * Renormalize the mesh and patch it up if there are no weights
  24701. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24702. * However in the case of zero weights then we set just a single influence to 1.
  24703. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24704. */
  24705. cleanMatrixWeights(): void;
  24706. private normalizeSkinFourWeights;
  24707. private normalizeSkinWeightsAndExtra;
  24708. /**
  24709. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24710. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24711. * the user know there was an issue with importing the mesh
  24712. * @returns a validation object with skinned, valid and report string
  24713. */
  24714. validateSkinning(): {
  24715. skinned: boolean;
  24716. valid: boolean;
  24717. report: string;
  24718. };
  24719. /** @hidden */
  24720. _checkDelayState(): Mesh;
  24721. private _queueLoad;
  24722. /**
  24723. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24724. * A mesh is in the frustum if its bounding box intersects the frustum
  24725. * @param frustumPlanes defines the frustum to test
  24726. * @returns true if the mesh is in the frustum planes
  24727. */
  24728. isInFrustum(frustumPlanes: Plane[]): boolean;
  24729. /**
  24730. * Sets the mesh material by the material or multiMaterial `id` property
  24731. * @param id is a string identifying the material or the multiMaterial
  24732. * @returns the current mesh
  24733. */
  24734. setMaterialByID(id: string): Mesh;
  24735. /**
  24736. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24737. * @returns an array of IAnimatable
  24738. */
  24739. getAnimatables(): IAnimatable[];
  24740. /**
  24741. * Modifies the mesh geometry according to the passed transformation matrix.
  24742. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24743. * The mesh normals are modified using the same transformation.
  24744. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24745. * @param transform defines the transform matrix to use
  24746. * @see http://doc.babylonjs.com/resources/baking_transformations
  24747. * @returns the current mesh
  24748. */
  24749. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24750. /**
  24751. * Modifies the mesh geometry according to its own current World Matrix.
  24752. * The mesh World Matrix is then reset.
  24753. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24754. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24755. * @see http://doc.babylonjs.com/resources/baking_transformations
  24756. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24757. * @returns the current mesh
  24758. */
  24759. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24760. /** @hidden */
  24761. get _positions(): Nullable<Vector3[]>;
  24762. /** @hidden */
  24763. _resetPointsArrayCache(): Mesh;
  24764. /** @hidden */
  24765. _generatePointsArray(): boolean;
  24766. /**
  24767. * Returns a new Mesh object generated from the current mesh properties.
  24768. * This method must not get confused with createInstance()
  24769. * @param name is a string, the name given to the new mesh
  24770. * @param newParent can be any Node object (default `null`)
  24771. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24772. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24773. * @returns a new mesh
  24774. */
  24775. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24776. /**
  24777. * Releases resources associated with this mesh.
  24778. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24779. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24780. */
  24781. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24782. /** @hidden */
  24783. _disposeInstanceSpecificData(): void;
  24784. /**
  24785. * Modifies the mesh geometry according to a displacement map.
  24786. * 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.
  24787. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24788. * @param url is a string, the URL from the image file is to be downloaded.
  24789. * @param minHeight is the lower limit of the displacement.
  24790. * @param maxHeight is the upper limit of the displacement.
  24791. * @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.
  24792. * @param uvOffset is an optional vector2 used to offset UV.
  24793. * @param uvScale is an optional vector2 used to scale UV.
  24794. * @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.
  24795. * @returns the Mesh.
  24796. */
  24797. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24798. /**
  24799. * Modifies the mesh geometry according to a displacementMap buffer.
  24800. * 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.
  24801. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24802. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24803. * @param heightMapWidth is the width of the buffer image.
  24804. * @param heightMapHeight is the height of the buffer image.
  24805. * @param minHeight is the lower limit of the displacement.
  24806. * @param maxHeight is the upper limit of the displacement.
  24807. * @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.
  24808. * @param uvOffset is an optional vector2 used to offset UV.
  24809. * @param uvScale is an optional vector2 used to scale UV.
  24810. * @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.
  24811. * @returns the Mesh.
  24812. */
  24813. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24814. /**
  24815. * Modify the mesh to get a flat shading rendering.
  24816. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24817. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24818. * @returns current mesh
  24819. */
  24820. convertToFlatShadedMesh(): Mesh;
  24821. /**
  24822. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24823. * In other words, more vertices, no more indices and a single bigger VBO.
  24824. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24825. * @returns current mesh
  24826. */
  24827. convertToUnIndexedMesh(): Mesh;
  24828. /**
  24829. * Inverses facet orientations.
  24830. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24831. * @param flipNormals will also inverts the normals
  24832. * @returns current mesh
  24833. */
  24834. flipFaces(flipNormals?: boolean): Mesh;
  24835. /**
  24836. * Increase the number of facets and hence vertices in a mesh
  24837. * Vertex normals are interpolated from existing vertex normals
  24838. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24839. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24840. */
  24841. increaseVertices(numberPerEdge: number): void;
  24842. /**
  24843. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24844. * This will undo any application of covertToFlatShadedMesh
  24845. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24846. */
  24847. forceSharedVertices(): void;
  24848. /** @hidden */
  24849. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24850. /** @hidden */
  24851. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24852. /**
  24853. * Creates a new InstancedMesh object from the mesh model.
  24854. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24855. * @param name defines the name of the new instance
  24856. * @returns a new InstancedMesh
  24857. */
  24858. createInstance(name: string): InstancedMesh;
  24859. /**
  24860. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24861. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24862. * @returns the current mesh
  24863. */
  24864. synchronizeInstances(): Mesh;
  24865. /**
  24866. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24867. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24868. * This should be used together with the simplification to avoid disappearing triangles.
  24869. * @param successCallback an optional success callback to be called after the optimization finished.
  24870. * @returns the current mesh
  24871. */
  24872. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24873. /**
  24874. * Serialize current mesh
  24875. * @param serializationObject defines the object which will receive the serialization data
  24876. */
  24877. serialize(serializationObject: any): void;
  24878. /** @hidden */
  24879. _syncGeometryWithMorphTargetManager(): void;
  24880. /** @hidden */
  24881. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24882. /**
  24883. * Returns a new Mesh object parsed from the source provided.
  24884. * @param parsedMesh is the source
  24885. * @param scene defines the hosting scene
  24886. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24887. * @returns a new Mesh
  24888. */
  24889. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24890. /**
  24891. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24892. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24893. * @param name defines the name of the mesh to create
  24894. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24895. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24896. * @param closePath creates a seam between the first and the last points of each path of the path array
  24897. * @param offset is taken in account only if the `pathArray` is containing a single path
  24898. * @param scene defines the hosting scene
  24899. * @param updatable defines if the mesh must be flagged as updatable
  24900. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24901. * @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)
  24902. * @returns a new Mesh
  24903. */
  24904. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24905. /**
  24906. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24907. * @param name defines the name of the mesh to create
  24908. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24909. * @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
  24910. * @param scene defines the hosting scene
  24911. * @param updatable defines if the mesh must be flagged as updatable
  24912. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24913. * @returns a new Mesh
  24914. */
  24915. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24916. /**
  24917. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24918. * @param name defines the name of the mesh to create
  24919. * @param size sets the size (float) of each box side (default 1)
  24920. * @param scene defines the hosting scene
  24921. * @param updatable defines if the mesh must be flagged as updatable
  24922. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24923. * @returns a new Mesh
  24924. */
  24925. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24926. /**
  24927. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24928. * @param name defines the name of the mesh to create
  24929. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24930. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24931. * @param scene defines the hosting scene
  24932. * @param updatable defines if the mesh must be flagged as updatable
  24933. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24934. * @returns a new Mesh
  24935. */
  24936. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24937. /**
  24938. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24939. * @param name defines the name of the mesh to create
  24940. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24941. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24942. * @param scene defines the hosting scene
  24943. * @returns a new Mesh
  24944. */
  24945. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24946. /**
  24947. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24948. * @param name defines the name of the mesh to create
  24949. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24950. * @param diameterTop set the top cap diameter (floats, default 1)
  24951. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24952. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24953. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24954. * @param scene defines the hosting scene
  24955. * @param updatable defines if the mesh must be flagged as updatable
  24956. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24957. * @returns a new Mesh
  24958. */
  24959. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24960. /**
  24961. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24962. * @param name defines the name of the mesh to create
  24963. * @param diameter sets the diameter size (float) of the torus (default 1)
  24964. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24965. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24966. * @param scene defines the hosting scene
  24967. * @param updatable defines if the mesh must be flagged as updatable
  24968. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24969. * @returns a new Mesh
  24970. */
  24971. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24972. /**
  24973. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24974. * @param name defines the name of the mesh to create
  24975. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24976. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24977. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24978. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24979. * @param p the number of windings on X axis (positive integers, default 2)
  24980. * @param q the number of windings on Y axis (positive integers, default 3)
  24981. * @param scene defines the hosting scene
  24982. * @param updatable defines if the mesh must be flagged as updatable
  24983. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24984. * @returns a new Mesh
  24985. */
  24986. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24987. /**
  24988. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24989. * @param name defines the name of the mesh to create
  24990. * @param points is an array successive Vector3
  24991. * @param scene defines the hosting scene
  24992. * @param updatable defines if the mesh must be flagged as updatable
  24993. * @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).
  24994. * @returns a new Mesh
  24995. */
  24996. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24997. /**
  24998. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24999. * @param name defines the name of the mesh to create
  25000. * @param points is an array successive Vector3
  25001. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25002. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25003. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25004. * @param scene defines the hosting scene
  25005. * @param updatable defines if the mesh must be flagged as updatable
  25006. * @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)
  25007. * @returns a new Mesh
  25008. */
  25009. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25010. /**
  25011. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25012. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25013. * 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.
  25014. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25015. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25016. * Remember you can only change the shape positions, not their number when updating a polygon.
  25017. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25018. * @param name defines the name of the mesh to create
  25019. * @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
  25020. * @param scene defines the hosting scene
  25021. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25022. * @param updatable defines if the mesh must be flagged as updatable
  25023. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25024. * @param earcutInjection can be used to inject your own earcut reference
  25025. * @returns a new Mesh
  25026. */
  25027. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25028. /**
  25029. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25030. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25031. * @param name defines the name of the mesh to create
  25032. * @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
  25033. * @param depth defines the height of extrusion
  25034. * @param scene defines the hosting scene
  25035. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25036. * @param updatable defines if the mesh must be flagged as updatable
  25037. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25038. * @param earcutInjection can be used to inject your own earcut reference
  25039. * @returns a new Mesh
  25040. */
  25041. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25042. /**
  25043. * Creates an extruded shape mesh.
  25044. * 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
  25045. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25046. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25047. * @param name defines the name of the mesh to create
  25048. * @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
  25049. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25050. * @param scale is the value to scale the shape
  25051. * @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
  25052. * @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
  25053. * @param scene defines the hosting scene
  25054. * @param updatable defines if the mesh must be flagged as updatable
  25055. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25056. * @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)
  25057. * @returns a new Mesh
  25058. */
  25059. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25060. /**
  25061. * Creates an custom extruded shape mesh.
  25062. * The custom extrusion is a parametric shape.
  25063. * It has no predefined shape. Its final shape will depend on the input parameters.
  25064. * Please consider using the same method from the MeshBuilder class instead
  25065. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25066. * @param name defines the name of the mesh to create
  25067. * @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
  25068. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25069. * @param scaleFunction is a custom Javascript function called on each path point
  25070. * @param rotationFunction is a custom Javascript function called on each path point
  25071. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25072. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25073. * @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
  25074. * @param scene defines the hosting scene
  25075. * @param updatable defines if the mesh must be flagged as updatable
  25076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25077. * @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)
  25078. * @returns a new Mesh
  25079. */
  25080. 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;
  25081. /**
  25082. * Creates lathe mesh.
  25083. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25084. * Please consider using the same method from the MeshBuilder class instead
  25085. * @param name defines the name of the mesh to create
  25086. * @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
  25087. * @param radius is the radius value of the lathe
  25088. * @param tessellation is the side number of the lathe.
  25089. * @param scene defines the hosting scene
  25090. * @param updatable defines if the mesh must be flagged as updatable
  25091. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25092. * @returns a new Mesh
  25093. */
  25094. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25095. /**
  25096. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25097. * @param name defines the name of the mesh to create
  25098. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25099. * @param scene defines the hosting scene
  25100. * @param updatable defines if the mesh must be flagged as updatable
  25101. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25102. * @returns a new Mesh
  25103. */
  25104. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25105. /**
  25106. * Creates a ground mesh.
  25107. * Please consider using the same method from the MeshBuilder class instead
  25108. * @param name defines the name of the mesh to create
  25109. * @param width set the width of the ground
  25110. * @param height set the height of the ground
  25111. * @param subdivisions sets the number of subdivisions per side
  25112. * @param scene defines the hosting scene
  25113. * @param updatable defines if the mesh must be flagged as updatable
  25114. * @returns a new Mesh
  25115. */
  25116. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25117. /**
  25118. * Creates a tiled ground mesh.
  25119. * Please consider using the same method from the MeshBuilder class instead
  25120. * @param name defines the name of the mesh to create
  25121. * @param xmin set the ground minimum X coordinate
  25122. * @param zmin set the ground minimum Y coordinate
  25123. * @param xmax set the ground maximum X coordinate
  25124. * @param zmax set the ground maximum Z coordinate
  25125. * @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
  25126. * @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
  25127. * @param scene defines the hosting scene
  25128. * @param updatable defines if the mesh must be flagged as updatable
  25129. * @returns a new Mesh
  25130. */
  25131. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25132. w: number;
  25133. h: number;
  25134. }, precision: {
  25135. w: number;
  25136. h: number;
  25137. }, scene: Scene, updatable?: boolean): Mesh;
  25138. /**
  25139. * Creates a ground mesh from a height map.
  25140. * Please consider using the same method from the MeshBuilder class instead
  25141. * @see http://doc.babylonjs.com/babylon101/height_map
  25142. * @param name defines the name of the mesh to create
  25143. * @param url sets the URL of the height map image resource
  25144. * @param width set the ground width size
  25145. * @param height set the ground height size
  25146. * @param subdivisions sets the number of subdivision per side
  25147. * @param minHeight is the minimum altitude on the ground
  25148. * @param maxHeight is the maximum altitude on the ground
  25149. * @param scene defines the hosting scene
  25150. * @param updatable defines if the mesh must be flagged as updatable
  25151. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25152. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25153. * @returns a new Mesh
  25154. */
  25155. 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;
  25156. /**
  25157. * Creates a tube mesh.
  25158. * The tube is a parametric shape.
  25159. * It has no predefined shape. Its final shape will depend on the input parameters.
  25160. * Please consider using the same method from the MeshBuilder class instead
  25161. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25162. * @param name defines the name of the mesh to create
  25163. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25164. * @param radius sets the tube radius size
  25165. * @param tessellation is the number of sides on the tubular surface
  25166. * @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
  25167. * @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
  25168. * @param scene defines the hosting scene
  25169. * @param updatable defines if the mesh must be flagged as updatable
  25170. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25171. * @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)
  25172. * @returns a new Mesh
  25173. */
  25174. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25175. (i: number, distance: number): number;
  25176. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25177. /**
  25178. * Creates a polyhedron mesh.
  25179. * Please consider using the same method from the MeshBuilder class instead.
  25180. * * 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
  25181. * * The parameter `size` (positive float, default 1) sets the polygon size
  25182. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25183. * * 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`
  25184. * * 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
  25185. * * 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)`)
  25186. * * 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
  25187. * * 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
  25188. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25189. * * 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
  25190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25191. * @param name defines the name of the mesh to create
  25192. * @param options defines the options used to create the mesh
  25193. * @param scene defines the hosting scene
  25194. * @returns a new Mesh
  25195. */
  25196. static CreatePolyhedron(name: string, options: {
  25197. type?: number;
  25198. size?: number;
  25199. sizeX?: number;
  25200. sizeY?: number;
  25201. sizeZ?: number;
  25202. custom?: any;
  25203. faceUV?: Vector4[];
  25204. faceColors?: Color4[];
  25205. updatable?: boolean;
  25206. sideOrientation?: number;
  25207. }, scene: Scene): Mesh;
  25208. /**
  25209. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25210. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25211. * * 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`)
  25212. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25213. * * 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
  25214. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25215. * * 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
  25216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25217. * @param name defines the name of the mesh
  25218. * @param options defines the options used to create the mesh
  25219. * @param scene defines the hosting scene
  25220. * @returns a new Mesh
  25221. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25222. */
  25223. static CreateIcoSphere(name: string, options: {
  25224. radius?: number;
  25225. flat?: boolean;
  25226. subdivisions?: number;
  25227. sideOrientation?: number;
  25228. updatable?: boolean;
  25229. }, scene: Scene): Mesh;
  25230. /**
  25231. * Creates a decal mesh.
  25232. * Please consider using the same method from the MeshBuilder class instead.
  25233. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25234. * @param name defines the name of the mesh
  25235. * @param sourceMesh defines the mesh receiving the decal
  25236. * @param position sets the position of the decal in world coordinates
  25237. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25238. * @param size sets the decal scaling
  25239. * @param angle sets the angle to rotate the decal
  25240. * @returns a new Mesh
  25241. */
  25242. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25243. /**
  25244. * Prepare internal position array for software CPU skinning
  25245. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25246. */
  25247. setPositionsForCPUSkinning(): Float32Array;
  25248. /**
  25249. * Prepare internal normal array for software CPU skinning
  25250. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25251. */
  25252. setNormalsForCPUSkinning(): Float32Array;
  25253. /**
  25254. * Updates the vertex buffer by applying transformation from the bones
  25255. * @param skeleton defines the skeleton to apply to current mesh
  25256. * @returns the current mesh
  25257. */
  25258. applySkeleton(skeleton: Skeleton): Mesh;
  25259. /**
  25260. * 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
  25261. * @param meshes defines the list of meshes to scan
  25262. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25263. */
  25264. static MinMax(meshes: AbstractMesh[]): {
  25265. min: Vector3;
  25266. max: Vector3;
  25267. };
  25268. /**
  25269. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25270. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25271. * @returns a vector3
  25272. */
  25273. static Center(meshesOrMinMaxVector: {
  25274. min: Vector3;
  25275. max: Vector3;
  25276. } | AbstractMesh[]): Vector3;
  25277. /**
  25278. * Merge the array of meshes into a single mesh for performance reasons.
  25279. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25280. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25281. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25282. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25283. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25284. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25285. * @returns a new mesh
  25286. */
  25287. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25288. /** @hidden */
  25289. addInstance(instance: InstancedMesh): void;
  25290. /** @hidden */
  25291. removeInstance(instance: InstancedMesh): void;
  25292. }
  25293. }
  25294. declare module BABYLON {
  25295. /**
  25296. * This is the base class of all the camera used in the application.
  25297. * @see http://doc.babylonjs.com/features/cameras
  25298. */
  25299. export class Camera extends Node {
  25300. /** @hidden */
  25301. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25302. /**
  25303. * This is the default projection mode used by the cameras.
  25304. * It helps recreating a feeling of perspective and better appreciate depth.
  25305. * This is the best way to simulate real life cameras.
  25306. */
  25307. static readonly PERSPECTIVE_CAMERA: number;
  25308. /**
  25309. * This helps creating camera with an orthographic mode.
  25310. * 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.
  25311. */
  25312. static readonly ORTHOGRAPHIC_CAMERA: number;
  25313. /**
  25314. * This is the default FOV mode for perspective cameras.
  25315. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25316. */
  25317. static readonly FOVMODE_VERTICAL_FIXED: number;
  25318. /**
  25319. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25320. */
  25321. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25322. /**
  25323. * This specifies ther is no need for a camera rig.
  25324. * Basically only one eye is rendered corresponding to the camera.
  25325. */
  25326. static readonly RIG_MODE_NONE: number;
  25327. /**
  25328. * Simulates a camera Rig with one blue eye and one red eye.
  25329. * This can be use with 3d blue and red glasses.
  25330. */
  25331. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25332. /**
  25333. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25334. */
  25335. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25336. /**
  25337. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25338. */
  25339. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25340. /**
  25341. * Defines that both eyes of the camera will be rendered over under each other.
  25342. */
  25343. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25344. /**
  25345. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25346. */
  25347. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25348. /**
  25349. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25350. */
  25351. static readonly RIG_MODE_VR: number;
  25352. /**
  25353. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25354. */
  25355. static readonly RIG_MODE_WEBVR: number;
  25356. /**
  25357. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25358. */
  25359. static readonly RIG_MODE_CUSTOM: number;
  25360. /**
  25361. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25362. */
  25363. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25364. /**
  25365. * Define the input manager associated with the camera.
  25366. */
  25367. inputs: CameraInputsManager<Camera>;
  25368. /** @hidden */
  25369. _position: Vector3;
  25370. /**
  25371. * Define the current local position of the camera in the scene
  25372. */
  25373. get position(): Vector3;
  25374. set position(newPosition: Vector3);
  25375. /**
  25376. * The vector the camera should consider as up.
  25377. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25378. */
  25379. upVector: Vector3;
  25380. /**
  25381. * Define the current limit on the left side for an orthographic camera
  25382. * In scene unit
  25383. */
  25384. orthoLeft: Nullable<number>;
  25385. /**
  25386. * Define the current limit on the right side for an orthographic camera
  25387. * In scene unit
  25388. */
  25389. orthoRight: Nullable<number>;
  25390. /**
  25391. * Define the current limit on the bottom side for an orthographic camera
  25392. * In scene unit
  25393. */
  25394. orthoBottom: Nullable<number>;
  25395. /**
  25396. * Define the current limit on the top side for an orthographic camera
  25397. * In scene unit
  25398. */
  25399. orthoTop: Nullable<number>;
  25400. /**
  25401. * Field Of View is set in Radians. (default is 0.8)
  25402. */
  25403. fov: number;
  25404. /**
  25405. * Define the minimum distance the camera can see from.
  25406. * This is important to note that the depth buffer are not infinite and the closer it starts
  25407. * the more your scene might encounter depth fighting issue.
  25408. */
  25409. minZ: number;
  25410. /**
  25411. * Define the maximum distance the camera can see to.
  25412. * This is important to note that the depth buffer are not infinite and the further it end
  25413. * the more your scene might encounter depth fighting issue.
  25414. */
  25415. maxZ: number;
  25416. /**
  25417. * Define the default inertia of the camera.
  25418. * This helps giving a smooth feeling to the camera movement.
  25419. */
  25420. inertia: number;
  25421. /**
  25422. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25423. */
  25424. mode: number;
  25425. /**
  25426. * Define wether the camera is intermediate.
  25427. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25428. */
  25429. isIntermediate: boolean;
  25430. /**
  25431. * Define the viewport of the camera.
  25432. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25433. */
  25434. viewport: Viewport;
  25435. /**
  25436. * Restricts the camera to viewing objects with the same layerMask.
  25437. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25438. */
  25439. layerMask: number;
  25440. /**
  25441. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25442. */
  25443. fovMode: number;
  25444. /**
  25445. * Rig mode of the camera.
  25446. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25447. * This is normally controlled byt the camera themselves as internal use.
  25448. */
  25449. cameraRigMode: number;
  25450. /**
  25451. * Defines the distance between both "eyes" in case of a RIG
  25452. */
  25453. interaxialDistance: number;
  25454. /**
  25455. * Defines if stereoscopic rendering is done side by side or over under.
  25456. */
  25457. isStereoscopicSideBySide: boolean;
  25458. /**
  25459. * 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
  25460. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25461. * else in the scene. (Eg. security camera)
  25462. *
  25463. * 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)
  25464. */
  25465. customRenderTargets: RenderTargetTexture[];
  25466. /**
  25467. * When set, the camera will render to this render target instead of the default canvas
  25468. *
  25469. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25470. */
  25471. outputRenderTarget: Nullable<RenderTargetTexture>;
  25472. /**
  25473. * Observable triggered when the camera view matrix has changed.
  25474. */
  25475. onViewMatrixChangedObservable: Observable<Camera>;
  25476. /**
  25477. * Observable triggered when the camera Projection matrix has changed.
  25478. */
  25479. onProjectionMatrixChangedObservable: Observable<Camera>;
  25480. /**
  25481. * Observable triggered when the inputs have been processed.
  25482. */
  25483. onAfterCheckInputsObservable: Observable<Camera>;
  25484. /**
  25485. * Observable triggered when reset has been called and applied to the camera.
  25486. */
  25487. onRestoreStateObservable: Observable<Camera>;
  25488. /**
  25489. * Is this camera a part of a rig system?
  25490. */
  25491. isRigCamera: boolean;
  25492. /**
  25493. * If isRigCamera set to true this will be set with the parent camera.
  25494. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25495. */
  25496. rigParent?: Camera;
  25497. /** @hidden */
  25498. _cameraRigParams: any;
  25499. /** @hidden */
  25500. _rigCameras: Camera[];
  25501. /** @hidden */
  25502. _rigPostProcess: Nullable<PostProcess>;
  25503. protected _webvrViewMatrix: Matrix;
  25504. /** @hidden */
  25505. _skipRendering: boolean;
  25506. /** @hidden */
  25507. _projectionMatrix: Matrix;
  25508. /** @hidden */
  25509. _postProcesses: Nullable<PostProcess>[];
  25510. /** @hidden */
  25511. _activeMeshes: SmartArray<AbstractMesh>;
  25512. protected _globalPosition: Vector3;
  25513. /** @hidden */
  25514. _computedViewMatrix: Matrix;
  25515. private _doNotComputeProjectionMatrix;
  25516. private _transformMatrix;
  25517. private _frustumPlanes;
  25518. private _refreshFrustumPlanes;
  25519. private _storedFov;
  25520. private _stateStored;
  25521. /**
  25522. * Instantiates a new camera object.
  25523. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25524. * @see http://doc.babylonjs.com/features/cameras
  25525. * @param name Defines the name of the camera in the scene
  25526. * @param position Defines the position of the camera
  25527. * @param scene Defines the scene the camera belongs too
  25528. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25529. */
  25530. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25531. /**
  25532. * Store current camera state (fov, position, etc..)
  25533. * @returns the camera
  25534. */
  25535. storeState(): Camera;
  25536. /**
  25537. * Restores the camera state values if it has been stored. You must call storeState() first
  25538. */
  25539. protected _restoreStateValues(): boolean;
  25540. /**
  25541. * Restored camera state. You must call storeState() first.
  25542. * @returns true if restored and false otherwise
  25543. */
  25544. restoreState(): boolean;
  25545. /**
  25546. * Gets the class name of the camera.
  25547. * @returns the class name
  25548. */
  25549. getClassName(): string;
  25550. /** @hidden */
  25551. readonly _isCamera: boolean;
  25552. /**
  25553. * Gets a string representation of the camera useful for debug purpose.
  25554. * @param fullDetails Defines that a more verboe level of logging is required
  25555. * @returns the string representation
  25556. */
  25557. toString(fullDetails?: boolean): string;
  25558. /**
  25559. * Gets the current world space position of the camera.
  25560. */
  25561. get globalPosition(): Vector3;
  25562. /**
  25563. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25564. * @returns the active meshe list
  25565. */
  25566. getActiveMeshes(): SmartArray<AbstractMesh>;
  25567. /**
  25568. * Check wether a mesh is part of the current active mesh list of the camera
  25569. * @param mesh Defines the mesh to check
  25570. * @returns true if active, false otherwise
  25571. */
  25572. isActiveMesh(mesh: Mesh): boolean;
  25573. /**
  25574. * Is this camera ready to be used/rendered
  25575. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25576. * @return true if the camera is ready
  25577. */
  25578. isReady(completeCheck?: boolean): boolean;
  25579. /** @hidden */
  25580. _initCache(): void;
  25581. /** @hidden */
  25582. _updateCache(ignoreParentClass?: boolean): void;
  25583. /** @hidden */
  25584. _isSynchronized(): boolean;
  25585. /** @hidden */
  25586. _isSynchronizedViewMatrix(): boolean;
  25587. /** @hidden */
  25588. _isSynchronizedProjectionMatrix(): boolean;
  25589. /**
  25590. * Attach the input controls to a specific dom element to get the input from.
  25591. * @param element Defines the element the controls should be listened from
  25592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25593. */
  25594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25595. /**
  25596. * Detach the current controls from the specified dom element.
  25597. * @param element Defines the element to stop listening the inputs from
  25598. */
  25599. detachControl(element: HTMLElement): void;
  25600. /**
  25601. * Update the camera state according to the different inputs gathered during the frame.
  25602. */
  25603. update(): void;
  25604. /** @hidden */
  25605. _checkInputs(): void;
  25606. /** @hidden */
  25607. get rigCameras(): Camera[];
  25608. /**
  25609. * Gets the post process used by the rig cameras
  25610. */
  25611. get rigPostProcess(): Nullable<PostProcess>;
  25612. /**
  25613. * Internal, gets the first post proces.
  25614. * @returns the first post process to be run on this camera.
  25615. */
  25616. _getFirstPostProcess(): Nullable<PostProcess>;
  25617. private _cascadePostProcessesToRigCams;
  25618. /**
  25619. * Attach a post process to the camera.
  25620. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25621. * @param postProcess The post process to attach to the camera
  25622. * @param insertAt The position of the post process in case several of them are in use in the scene
  25623. * @returns the position the post process has been inserted at
  25624. */
  25625. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25626. /**
  25627. * Detach a post process to the camera.
  25628. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25629. * @param postProcess The post process to detach from the camera
  25630. */
  25631. detachPostProcess(postProcess: PostProcess): void;
  25632. /**
  25633. * Gets the current world matrix of the camera
  25634. */
  25635. getWorldMatrix(): Matrix;
  25636. /** @hidden */
  25637. _getViewMatrix(): Matrix;
  25638. /**
  25639. * Gets the current view matrix of the camera.
  25640. * @param force forces the camera to recompute the matrix without looking at the cached state
  25641. * @returns the view matrix
  25642. */
  25643. getViewMatrix(force?: boolean): Matrix;
  25644. /**
  25645. * Freeze the projection matrix.
  25646. * It will prevent the cache check of the camera projection compute and can speed up perf
  25647. * if no parameter of the camera are meant to change
  25648. * @param projection Defines manually a projection if necessary
  25649. */
  25650. freezeProjectionMatrix(projection?: Matrix): void;
  25651. /**
  25652. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25653. */
  25654. unfreezeProjectionMatrix(): void;
  25655. /**
  25656. * Gets the current projection matrix of the camera.
  25657. * @param force forces the camera to recompute the matrix without looking at the cached state
  25658. * @returns the projection matrix
  25659. */
  25660. getProjectionMatrix(force?: boolean): Matrix;
  25661. /**
  25662. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25663. * @returns a Matrix
  25664. */
  25665. getTransformationMatrix(): Matrix;
  25666. private _updateFrustumPlanes;
  25667. /**
  25668. * Checks if a cullable object (mesh...) is in the camera frustum
  25669. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25670. * @param target The object to check
  25671. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25672. * @returns true if the object is in frustum otherwise false
  25673. */
  25674. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25675. /**
  25676. * Checks if a cullable object (mesh...) is in the camera frustum
  25677. * Unlike isInFrustum this cheks the full bounding box
  25678. * @param target The object to check
  25679. * @returns true if the object is in frustum otherwise false
  25680. */
  25681. isCompletelyInFrustum(target: ICullable): boolean;
  25682. /**
  25683. * Gets a ray in the forward direction from the camera.
  25684. * @param length Defines the length of the ray to create
  25685. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25686. * @param origin Defines the start point of the ray which defaults to the camera position
  25687. * @returns the forward ray
  25688. */
  25689. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25690. /**
  25691. * Releases resources associated with this node.
  25692. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25693. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25694. */
  25695. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25696. /** @hidden */
  25697. _isLeftCamera: boolean;
  25698. /**
  25699. * Gets the left camera of a rig setup in case of Rigged Camera
  25700. */
  25701. get isLeftCamera(): boolean;
  25702. /** @hidden */
  25703. _isRightCamera: boolean;
  25704. /**
  25705. * Gets the right camera of a rig setup in case of Rigged Camera
  25706. */
  25707. get isRightCamera(): boolean;
  25708. /**
  25709. * Gets the left camera of a rig setup in case of Rigged Camera
  25710. */
  25711. get leftCamera(): Nullable<FreeCamera>;
  25712. /**
  25713. * Gets the right camera of a rig setup in case of Rigged Camera
  25714. */
  25715. get rightCamera(): Nullable<FreeCamera>;
  25716. /**
  25717. * Gets the left camera target of a rig setup in case of Rigged Camera
  25718. * @returns the target position
  25719. */
  25720. getLeftTarget(): Nullable<Vector3>;
  25721. /**
  25722. * Gets the right camera target of a rig setup in case of Rigged Camera
  25723. * @returns the target position
  25724. */
  25725. getRightTarget(): Nullable<Vector3>;
  25726. /**
  25727. * @hidden
  25728. */
  25729. setCameraRigMode(mode: number, rigParams: any): void;
  25730. /** @hidden */
  25731. static _setStereoscopicRigMode(camera: Camera): void;
  25732. /** @hidden */
  25733. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25734. /** @hidden */
  25735. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25736. /** @hidden */
  25737. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25738. /** @hidden */
  25739. _getVRProjectionMatrix(): Matrix;
  25740. protected _updateCameraRotationMatrix(): void;
  25741. protected _updateWebVRCameraRotationMatrix(): void;
  25742. /**
  25743. * This function MUST be overwritten by the different WebVR cameras available.
  25744. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25745. * @hidden
  25746. */
  25747. _getWebVRProjectionMatrix(): Matrix;
  25748. /**
  25749. * This function MUST be overwritten by the different WebVR cameras available.
  25750. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25751. * @hidden
  25752. */
  25753. _getWebVRViewMatrix(): Matrix;
  25754. /** @hidden */
  25755. setCameraRigParameter(name: string, value: any): void;
  25756. /**
  25757. * needs to be overridden by children so sub has required properties to be copied
  25758. * @hidden
  25759. */
  25760. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25761. /**
  25762. * May need to be overridden by children
  25763. * @hidden
  25764. */
  25765. _updateRigCameras(): void;
  25766. /** @hidden */
  25767. _setupInputs(): void;
  25768. /**
  25769. * Serialiaze the camera setup to a json represention
  25770. * @returns the JSON representation
  25771. */
  25772. serialize(): any;
  25773. /**
  25774. * Clones the current camera.
  25775. * @param name The cloned camera name
  25776. * @returns the cloned camera
  25777. */
  25778. clone(name: string): Camera;
  25779. /**
  25780. * Gets the direction of the camera relative to a given local axis.
  25781. * @param localAxis Defines the reference axis to provide a relative direction.
  25782. * @return the direction
  25783. */
  25784. getDirection(localAxis: Vector3): Vector3;
  25785. /**
  25786. * Returns the current camera absolute rotation
  25787. */
  25788. get absoluteRotation(): Quaternion;
  25789. /**
  25790. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25791. * @param localAxis Defines the reference axis to provide a relative direction.
  25792. * @param result Defines the vector to store the result in
  25793. */
  25794. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25795. /**
  25796. * Gets a camera constructor for a given camera type
  25797. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25798. * @param name The name of the camera the result will be able to instantiate
  25799. * @param scene The scene the result will construct the camera in
  25800. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25801. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25802. * @returns a factory method to construc the camera
  25803. */
  25804. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25805. /**
  25806. * Compute the world matrix of the camera.
  25807. * @returns the camera world matrix
  25808. */
  25809. computeWorldMatrix(): Matrix;
  25810. /**
  25811. * Parse a JSON and creates the camera from the parsed information
  25812. * @param parsedCamera The JSON to parse
  25813. * @param scene The scene to instantiate the camera in
  25814. * @returns the newly constructed camera
  25815. */
  25816. static Parse(parsedCamera: any, scene: Scene): Camera;
  25817. }
  25818. }
  25819. declare module BABYLON {
  25820. /**
  25821. * Class containing static functions to help procedurally build meshes
  25822. */
  25823. export class DiscBuilder {
  25824. /**
  25825. * Creates a plane polygonal mesh. By default, this is a disc
  25826. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25827. * * 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
  25828. * * 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
  25829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25830. * * 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
  25831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25832. * @param name defines the name of the mesh
  25833. * @param options defines the options used to create the mesh
  25834. * @param scene defines the hosting scene
  25835. * @returns the plane polygonal mesh
  25836. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25837. */
  25838. static CreateDisc(name: string, options: {
  25839. radius?: number;
  25840. tessellation?: number;
  25841. arc?: number;
  25842. updatable?: boolean;
  25843. sideOrientation?: number;
  25844. frontUVs?: Vector4;
  25845. backUVs?: Vector4;
  25846. }, scene?: Nullable<Scene>): Mesh;
  25847. }
  25848. }
  25849. declare module BABYLON {
  25850. /**
  25851. * This represents all the required information to add a fresnel effect on a material:
  25852. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25853. */
  25854. export class FresnelParameters {
  25855. private _isEnabled;
  25856. /**
  25857. * Define if the fresnel effect is enable or not.
  25858. */
  25859. get isEnabled(): boolean;
  25860. set isEnabled(value: boolean);
  25861. /**
  25862. * Define the color used on edges (grazing angle)
  25863. */
  25864. leftColor: Color3;
  25865. /**
  25866. * Define the color used on center
  25867. */
  25868. rightColor: Color3;
  25869. /**
  25870. * Define bias applied to computed fresnel term
  25871. */
  25872. bias: number;
  25873. /**
  25874. * Defined the power exponent applied to fresnel term
  25875. */
  25876. power: number;
  25877. /**
  25878. * Clones the current fresnel and its valuues
  25879. * @returns a clone fresnel configuration
  25880. */
  25881. clone(): FresnelParameters;
  25882. /**
  25883. * Serializes the current fresnel parameters to a JSON representation.
  25884. * @return the JSON serialization
  25885. */
  25886. serialize(): any;
  25887. /**
  25888. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25889. * @param parsedFresnelParameters Define the JSON representation
  25890. * @returns the parsed parameters
  25891. */
  25892. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25893. }
  25894. }
  25895. declare module BABYLON {
  25896. /**
  25897. * Base class of materials working in push mode in babylon JS
  25898. * @hidden
  25899. */
  25900. export class PushMaterial extends Material {
  25901. protected _activeEffect: Effect;
  25902. protected _normalMatrix: Matrix;
  25903. /**
  25904. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25905. * This means that the material can keep using a previous shader while a new one is being compiled.
  25906. * This is mostly used when shader parallel compilation is supported (true by default)
  25907. */
  25908. allowShaderHotSwapping: boolean;
  25909. constructor(name: string, scene: Scene);
  25910. getEffect(): Effect;
  25911. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25912. /**
  25913. * Binds the given world matrix to the active effect
  25914. *
  25915. * @param world the matrix to bind
  25916. */
  25917. bindOnlyWorldMatrix(world: Matrix): void;
  25918. /**
  25919. * Binds the given normal matrix to the active effect
  25920. *
  25921. * @param normalMatrix the matrix to bind
  25922. */
  25923. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25924. bind(world: Matrix, mesh?: Mesh): void;
  25925. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25926. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25927. }
  25928. }
  25929. declare module BABYLON {
  25930. /**
  25931. * This groups all the flags used to control the materials channel.
  25932. */
  25933. export class MaterialFlags {
  25934. private static _DiffuseTextureEnabled;
  25935. /**
  25936. * Are diffuse textures enabled in the application.
  25937. */
  25938. static get DiffuseTextureEnabled(): boolean;
  25939. static set DiffuseTextureEnabled(value: boolean);
  25940. private static _AmbientTextureEnabled;
  25941. /**
  25942. * Are ambient textures enabled in the application.
  25943. */
  25944. static get AmbientTextureEnabled(): boolean;
  25945. static set AmbientTextureEnabled(value: boolean);
  25946. private static _OpacityTextureEnabled;
  25947. /**
  25948. * Are opacity textures enabled in the application.
  25949. */
  25950. static get OpacityTextureEnabled(): boolean;
  25951. static set OpacityTextureEnabled(value: boolean);
  25952. private static _ReflectionTextureEnabled;
  25953. /**
  25954. * Are reflection textures enabled in the application.
  25955. */
  25956. static get ReflectionTextureEnabled(): boolean;
  25957. static set ReflectionTextureEnabled(value: boolean);
  25958. private static _EmissiveTextureEnabled;
  25959. /**
  25960. * Are emissive textures enabled in the application.
  25961. */
  25962. static get EmissiveTextureEnabled(): boolean;
  25963. static set EmissiveTextureEnabled(value: boolean);
  25964. private static _SpecularTextureEnabled;
  25965. /**
  25966. * Are specular textures enabled in the application.
  25967. */
  25968. static get SpecularTextureEnabled(): boolean;
  25969. static set SpecularTextureEnabled(value: boolean);
  25970. private static _BumpTextureEnabled;
  25971. /**
  25972. * Are bump textures enabled in the application.
  25973. */
  25974. static get BumpTextureEnabled(): boolean;
  25975. static set BumpTextureEnabled(value: boolean);
  25976. private static _LightmapTextureEnabled;
  25977. /**
  25978. * Are lightmap textures enabled in the application.
  25979. */
  25980. static get LightmapTextureEnabled(): boolean;
  25981. static set LightmapTextureEnabled(value: boolean);
  25982. private static _RefractionTextureEnabled;
  25983. /**
  25984. * Are refraction textures enabled in the application.
  25985. */
  25986. static get RefractionTextureEnabled(): boolean;
  25987. static set RefractionTextureEnabled(value: boolean);
  25988. private static _ColorGradingTextureEnabled;
  25989. /**
  25990. * Are color grading textures enabled in the application.
  25991. */
  25992. static get ColorGradingTextureEnabled(): boolean;
  25993. static set ColorGradingTextureEnabled(value: boolean);
  25994. private static _FresnelEnabled;
  25995. /**
  25996. * Are fresnels enabled in the application.
  25997. */
  25998. static get FresnelEnabled(): boolean;
  25999. static set FresnelEnabled(value: boolean);
  26000. private static _ClearCoatTextureEnabled;
  26001. /**
  26002. * Are clear coat textures enabled in the application.
  26003. */
  26004. static get ClearCoatTextureEnabled(): boolean;
  26005. static set ClearCoatTextureEnabled(value: boolean);
  26006. private static _ClearCoatBumpTextureEnabled;
  26007. /**
  26008. * Are clear coat bump textures enabled in the application.
  26009. */
  26010. static get ClearCoatBumpTextureEnabled(): boolean;
  26011. static set ClearCoatBumpTextureEnabled(value: boolean);
  26012. private static _ClearCoatTintTextureEnabled;
  26013. /**
  26014. * Are clear coat tint textures enabled in the application.
  26015. */
  26016. static get ClearCoatTintTextureEnabled(): boolean;
  26017. static set ClearCoatTintTextureEnabled(value: boolean);
  26018. private static _SheenTextureEnabled;
  26019. /**
  26020. * Are sheen textures enabled in the application.
  26021. */
  26022. static get SheenTextureEnabled(): boolean;
  26023. static set SheenTextureEnabled(value: boolean);
  26024. private static _AnisotropicTextureEnabled;
  26025. /**
  26026. * Are anisotropic textures enabled in the application.
  26027. */
  26028. static get AnisotropicTextureEnabled(): boolean;
  26029. static set AnisotropicTextureEnabled(value: boolean);
  26030. private static _ThicknessTextureEnabled;
  26031. /**
  26032. * Are thickness textures enabled in the application.
  26033. */
  26034. static get ThicknessTextureEnabled(): boolean;
  26035. static set ThicknessTextureEnabled(value: boolean);
  26036. }
  26037. }
  26038. declare module BABYLON {
  26039. /** @hidden */
  26040. export var defaultFragmentDeclaration: {
  26041. name: string;
  26042. shader: string;
  26043. };
  26044. }
  26045. declare module BABYLON {
  26046. /** @hidden */
  26047. export var defaultUboDeclaration: {
  26048. name: string;
  26049. shader: string;
  26050. };
  26051. }
  26052. declare module BABYLON {
  26053. /** @hidden */
  26054. export var lightFragmentDeclaration: {
  26055. name: string;
  26056. shader: string;
  26057. };
  26058. }
  26059. declare module BABYLON {
  26060. /** @hidden */
  26061. export var lightUboDeclaration: {
  26062. name: string;
  26063. shader: string;
  26064. };
  26065. }
  26066. declare module BABYLON {
  26067. /** @hidden */
  26068. export var lightsFragmentFunctions: {
  26069. name: string;
  26070. shader: string;
  26071. };
  26072. }
  26073. declare module BABYLON {
  26074. /** @hidden */
  26075. export var shadowsFragmentFunctions: {
  26076. name: string;
  26077. shader: string;
  26078. };
  26079. }
  26080. declare module BABYLON {
  26081. /** @hidden */
  26082. export var fresnelFunction: {
  26083. name: string;
  26084. shader: string;
  26085. };
  26086. }
  26087. declare module BABYLON {
  26088. /** @hidden */
  26089. export var reflectionFunction: {
  26090. name: string;
  26091. shader: string;
  26092. };
  26093. }
  26094. declare module BABYLON {
  26095. /** @hidden */
  26096. export var bumpFragmentFunctions: {
  26097. name: string;
  26098. shader: string;
  26099. };
  26100. }
  26101. declare module BABYLON {
  26102. /** @hidden */
  26103. export var logDepthDeclaration: {
  26104. name: string;
  26105. shader: string;
  26106. };
  26107. }
  26108. declare module BABYLON {
  26109. /** @hidden */
  26110. export var bumpFragment: {
  26111. name: string;
  26112. shader: string;
  26113. };
  26114. }
  26115. declare module BABYLON {
  26116. /** @hidden */
  26117. export var depthPrePass: {
  26118. name: string;
  26119. shader: string;
  26120. };
  26121. }
  26122. declare module BABYLON {
  26123. /** @hidden */
  26124. export var lightFragment: {
  26125. name: string;
  26126. shader: string;
  26127. };
  26128. }
  26129. declare module BABYLON {
  26130. /** @hidden */
  26131. export var logDepthFragment: {
  26132. name: string;
  26133. shader: string;
  26134. };
  26135. }
  26136. declare module BABYLON {
  26137. /** @hidden */
  26138. export var defaultPixelShader: {
  26139. name: string;
  26140. shader: string;
  26141. };
  26142. }
  26143. declare module BABYLON {
  26144. /** @hidden */
  26145. export var defaultVertexDeclaration: {
  26146. name: string;
  26147. shader: string;
  26148. };
  26149. }
  26150. declare module BABYLON {
  26151. /** @hidden */
  26152. export var bumpVertexDeclaration: {
  26153. name: string;
  26154. shader: string;
  26155. };
  26156. }
  26157. declare module BABYLON {
  26158. /** @hidden */
  26159. export var bumpVertex: {
  26160. name: string;
  26161. shader: string;
  26162. };
  26163. }
  26164. declare module BABYLON {
  26165. /** @hidden */
  26166. export var fogVertex: {
  26167. name: string;
  26168. shader: string;
  26169. };
  26170. }
  26171. declare module BABYLON {
  26172. /** @hidden */
  26173. export var shadowsVertex: {
  26174. name: string;
  26175. shader: string;
  26176. };
  26177. }
  26178. declare module BABYLON {
  26179. /** @hidden */
  26180. export var pointCloudVertex: {
  26181. name: string;
  26182. shader: string;
  26183. };
  26184. }
  26185. declare module BABYLON {
  26186. /** @hidden */
  26187. export var logDepthVertex: {
  26188. name: string;
  26189. shader: string;
  26190. };
  26191. }
  26192. declare module BABYLON {
  26193. /** @hidden */
  26194. export var defaultVertexShader: {
  26195. name: string;
  26196. shader: string;
  26197. };
  26198. }
  26199. declare module BABYLON {
  26200. /** @hidden */
  26201. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26202. MAINUV1: boolean;
  26203. MAINUV2: boolean;
  26204. DIFFUSE: boolean;
  26205. DIFFUSEDIRECTUV: number;
  26206. AMBIENT: boolean;
  26207. AMBIENTDIRECTUV: number;
  26208. OPACITY: boolean;
  26209. OPACITYDIRECTUV: number;
  26210. OPACITYRGB: boolean;
  26211. REFLECTION: boolean;
  26212. EMISSIVE: boolean;
  26213. EMISSIVEDIRECTUV: number;
  26214. SPECULAR: boolean;
  26215. SPECULARDIRECTUV: number;
  26216. BUMP: boolean;
  26217. BUMPDIRECTUV: number;
  26218. PARALLAX: boolean;
  26219. PARALLAXOCCLUSION: boolean;
  26220. SPECULAROVERALPHA: boolean;
  26221. CLIPPLANE: boolean;
  26222. CLIPPLANE2: boolean;
  26223. CLIPPLANE3: boolean;
  26224. CLIPPLANE4: boolean;
  26225. CLIPPLANE5: boolean;
  26226. CLIPPLANE6: boolean;
  26227. ALPHATEST: boolean;
  26228. DEPTHPREPASS: boolean;
  26229. ALPHAFROMDIFFUSE: boolean;
  26230. POINTSIZE: boolean;
  26231. FOG: boolean;
  26232. SPECULARTERM: boolean;
  26233. DIFFUSEFRESNEL: boolean;
  26234. OPACITYFRESNEL: boolean;
  26235. REFLECTIONFRESNEL: boolean;
  26236. REFRACTIONFRESNEL: boolean;
  26237. EMISSIVEFRESNEL: boolean;
  26238. FRESNEL: boolean;
  26239. NORMAL: boolean;
  26240. UV1: boolean;
  26241. UV2: boolean;
  26242. VERTEXCOLOR: boolean;
  26243. VERTEXALPHA: boolean;
  26244. NUM_BONE_INFLUENCERS: number;
  26245. BonesPerMesh: number;
  26246. BONETEXTURE: boolean;
  26247. INSTANCES: boolean;
  26248. GLOSSINESS: boolean;
  26249. ROUGHNESS: boolean;
  26250. EMISSIVEASILLUMINATION: boolean;
  26251. LINKEMISSIVEWITHDIFFUSE: boolean;
  26252. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26253. LIGHTMAP: boolean;
  26254. LIGHTMAPDIRECTUV: number;
  26255. OBJECTSPACE_NORMALMAP: boolean;
  26256. USELIGHTMAPASSHADOWMAP: boolean;
  26257. REFLECTIONMAP_3D: boolean;
  26258. REFLECTIONMAP_SPHERICAL: boolean;
  26259. REFLECTIONMAP_PLANAR: boolean;
  26260. REFLECTIONMAP_CUBIC: boolean;
  26261. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26262. REFLECTIONMAP_PROJECTION: boolean;
  26263. REFLECTIONMAP_SKYBOX: boolean;
  26264. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26265. REFLECTIONMAP_EXPLICIT: boolean;
  26266. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26267. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26268. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26269. INVERTCUBICMAP: boolean;
  26270. LOGARITHMICDEPTH: boolean;
  26271. REFRACTION: boolean;
  26272. REFRACTIONMAP_3D: boolean;
  26273. REFLECTIONOVERALPHA: boolean;
  26274. TWOSIDEDLIGHTING: boolean;
  26275. SHADOWFLOAT: boolean;
  26276. MORPHTARGETS: boolean;
  26277. MORPHTARGETS_NORMAL: boolean;
  26278. MORPHTARGETS_TANGENT: boolean;
  26279. MORPHTARGETS_UV: boolean;
  26280. NUM_MORPH_INFLUENCERS: number;
  26281. NONUNIFORMSCALING: boolean;
  26282. PREMULTIPLYALPHA: boolean;
  26283. IMAGEPROCESSING: boolean;
  26284. VIGNETTE: boolean;
  26285. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26286. VIGNETTEBLENDMODEOPAQUE: boolean;
  26287. TONEMAPPING: boolean;
  26288. TONEMAPPING_ACES: boolean;
  26289. CONTRAST: boolean;
  26290. COLORCURVES: boolean;
  26291. COLORGRADING: boolean;
  26292. COLORGRADING3D: boolean;
  26293. SAMPLER3DGREENDEPTH: boolean;
  26294. SAMPLER3DBGRMAP: boolean;
  26295. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26296. MULTIVIEW: boolean;
  26297. /**
  26298. * If the reflection texture on this material is in linear color space
  26299. * @hidden
  26300. */
  26301. IS_REFLECTION_LINEAR: boolean;
  26302. /**
  26303. * If the refraction texture on this material is in linear color space
  26304. * @hidden
  26305. */
  26306. IS_REFRACTION_LINEAR: boolean;
  26307. EXPOSURE: boolean;
  26308. constructor();
  26309. setReflectionMode(modeToEnable: string): void;
  26310. }
  26311. /**
  26312. * This is the default material used in Babylon. It is the best trade off between quality
  26313. * and performances.
  26314. * @see http://doc.babylonjs.com/babylon101/materials
  26315. */
  26316. export class StandardMaterial extends PushMaterial {
  26317. private _diffuseTexture;
  26318. /**
  26319. * The basic texture of the material as viewed under a light.
  26320. */
  26321. diffuseTexture: Nullable<BaseTexture>;
  26322. private _ambientTexture;
  26323. /**
  26324. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26325. */
  26326. ambientTexture: Nullable<BaseTexture>;
  26327. private _opacityTexture;
  26328. /**
  26329. * Define the transparency of the material from a texture.
  26330. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26331. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26332. */
  26333. opacityTexture: Nullable<BaseTexture>;
  26334. private _reflectionTexture;
  26335. /**
  26336. * Define the texture used to display the reflection.
  26337. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26338. */
  26339. reflectionTexture: Nullable<BaseTexture>;
  26340. private _emissiveTexture;
  26341. /**
  26342. * Define texture of the material as if self lit.
  26343. * This will be mixed in the final result even in the absence of light.
  26344. */
  26345. emissiveTexture: Nullable<BaseTexture>;
  26346. private _specularTexture;
  26347. /**
  26348. * Define how the color and intensity of the highlight given by the light in the material.
  26349. */
  26350. specularTexture: Nullable<BaseTexture>;
  26351. private _bumpTexture;
  26352. /**
  26353. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26354. * 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.
  26355. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26356. */
  26357. bumpTexture: Nullable<BaseTexture>;
  26358. private _lightmapTexture;
  26359. /**
  26360. * Complex lighting can be computationally expensive to compute at runtime.
  26361. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26362. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26363. */
  26364. lightmapTexture: Nullable<BaseTexture>;
  26365. private _refractionTexture;
  26366. /**
  26367. * Define the texture used to display the refraction.
  26368. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26369. */
  26370. refractionTexture: Nullable<BaseTexture>;
  26371. /**
  26372. * The color of the material lit by the environmental background lighting.
  26373. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26374. */
  26375. ambientColor: Color3;
  26376. /**
  26377. * The basic color of the material as viewed under a light.
  26378. */
  26379. diffuseColor: Color3;
  26380. /**
  26381. * Define how the color and intensity of the highlight given by the light in the material.
  26382. */
  26383. specularColor: Color3;
  26384. /**
  26385. * Define the color of the material as if self lit.
  26386. * This will be mixed in the final result even in the absence of light.
  26387. */
  26388. emissiveColor: Color3;
  26389. /**
  26390. * Defines how sharp are the highlights in the material.
  26391. * The bigger the value the sharper giving a more glossy feeling to the result.
  26392. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26393. */
  26394. specularPower: number;
  26395. private _useAlphaFromDiffuseTexture;
  26396. /**
  26397. * Does the transparency come from the diffuse texture alpha channel.
  26398. */
  26399. useAlphaFromDiffuseTexture: boolean;
  26400. private _useEmissiveAsIllumination;
  26401. /**
  26402. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26403. */
  26404. useEmissiveAsIllumination: boolean;
  26405. private _linkEmissiveWithDiffuse;
  26406. /**
  26407. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26408. * the emissive level when the final color is close to one.
  26409. */
  26410. linkEmissiveWithDiffuse: boolean;
  26411. private _useSpecularOverAlpha;
  26412. /**
  26413. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26414. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26415. */
  26416. useSpecularOverAlpha: boolean;
  26417. private _useReflectionOverAlpha;
  26418. /**
  26419. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26420. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26421. */
  26422. useReflectionOverAlpha: boolean;
  26423. private _disableLighting;
  26424. /**
  26425. * Does lights from the scene impacts this material.
  26426. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26427. */
  26428. disableLighting: boolean;
  26429. private _useObjectSpaceNormalMap;
  26430. /**
  26431. * Allows using an object space normal map (instead of tangent space).
  26432. */
  26433. useObjectSpaceNormalMap: boolean;
  26434. private _useParallax;
  26435. /**
  26436. * Is parallax enabled or not.
  26437. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26438. */
  26439. useParallax: boolean;
  26440. private _useParallaxOcclusion;
  26441. /**
  26442. * Is parallax occlusion enabled or not.
  26443. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26444. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26445. */
  26446. useParallaxOcclusion: boolean;
  26447. /**
  26448. * 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.
  26449. */
  26450. parallaxScaleBias: number;
  26451. private _roughness;
  26452. /**
  26453. * Helps to define how blurry the reflections should appears in the material.
  26454. */
  26455. roughness: number;
  26456. /**
  26457. * In case of refraction, define the value of the index of refraction.
  26458. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26459. */
  26460. indexOfRefraction: number;
  26461. /**
  26462. * Invert the refraction texture alongside the y axis.
  26463. * It can be useful with procedural textures or probe for instance.
  26464. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26465. */
  26466. invertRefractionY: boolean;
  26467. /**
  26468. * Defines the alpha limits in alpha test mode.
  26469. */
  26470. alphaCutOff: number;
  26471. private _useLightmapAsShadowmap;
  26472. /**
  26473. * In case of light mapping, define whether the map contains light or shadow informations.
  26474. */
  26475. useLightmapAsShadowmap: boolean;
  26476. private _diffuseFresnelParameters;
  26477. /**
  26478. * Define the diffuse fresnel parameters of the material.
  26479. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26480. */
  26481. diffuseFresnelParameters: FresnelParameters;
  26482. private _opacityFresnelParameters;
  26483. /**
  26484. * Define the opacity fresnel parameters of the material.
  26485. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26486. */
  26487. opacityFresnelParameters: FresnelParameters;
  26488. private _reflectionFresnelParameters;
  26489. /**
  26490. * Define the reflection fresnel parameters of the material.
  26491. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26492. */
  26493. reflectionFresnelParameters: FresnelParameters;
  26494. private _refractionFresnelParameters;
  26495. /**
  26496. * Define the refraction fresnel parameters of the material.
  26497. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26498. */
  26499. refractionFresnelParameters: FresnelParameters;
  26500. private _emissiveFresnelParameters;
  26501. /**
  26502. * Define the emissive fresnel parameters of the material.
  26503. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26504. */
  26505. emissiveFresnelParameters: FresnelParameters;
  26506. private _useReflectionFresnelFromSpecular;
  26507. /**
  26508. * If true automatically deducts the fresnels values from the material specularity.
  26509. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26510. */
  26511. useReflectionFresnelFromSpecular: boolean;
  26512. private _useGlossinessFromSpecularMapAlpha;
  26513. /**
  26514. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26515. */
  26516. useGlossinessFromSpecularMapAlpha: boolean;
  26517. private _maxSimultaneousLights;
  26518. /**
  26519. * Defines the maximum number of lights that can be used in the material
  26520. */
  26521. maxSimultaneousLights: number;
  26522. private _invertNormalMapX;
  26523. /**
  26524. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26525. */
  26526. invertNormalMapX: boolean;
  26527. private _invertNormalMapY;
  26528. /**
  26529. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26530. */
  26531. invertNormalMapY: boolean;
  26532. private _twoSidedLighting;
  26533. /**
  26534. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26535. */
  26536. twoSidedLighting: boolean;
  26537. /**
  26538. * Default configuration related to image processing available in the standard Material.
  26539. */
  26540. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26541. /**
  26542. * Gets the image processing configuration used either in this material.
  26543. */
  26544. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26545. /**
  26546. * Sets the Default image processing configuration used either in the this material.
  26547. *
  26548. * If sets to null, the scene one is in use.
  26549. */
  26550. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26551. /**
  26552. * Keep track of the image processing observer to allow dispose and replace.
  26553. */
  26554. private _imageProcessingObserver;
  26555. /**
  26556. * Attaches a new image processing configuration to the Standard Material.
  26557. * @param configuration
  26558. */
  26559. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26560. /**
  26561. * Gets wether the color curves effect is enabled.
  26562. */
  26563. get cameraColorCurvesEnabled(): boolean;
  26564. /**
  26565. * Sets wether the color curves effect is enabled.
  26566. */
  26567. set cameraColorCurvesEnabled(value: boolean);
  26568. /**
  26569. * Gets wether the color grading effect is enabled.
  26570. */
  26571. get cameraColorGradingEnabled(): boolean;
  26572. /**
  26573. * Gets wether the color grading effect is enabled.
  26574. */
  26575. set cameraColorGradingEnabled(value: boolean);
  26576. /**
  26577. * Gets wether tonemapping is enabled or not.
  26578. */
  26579. get cameraToneMappingEnabled(): boolean;
  26580. /**
  26581. * Sets wether tonemapping is enabled or not
  26582. */
  26583. set cameraToneMappingEnabled(value: boolean);
  26584. /**
  26585. * The camera exposure used on this material.
  26586. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26587. * This corresponds to a photographic exposure.
  26588. */
  26589. get cameraExposure(): number;
  26590. /**
  26591. * The camera exposure used on this material.
  26592. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26593. * This corresponds to a photographic exposure.
  26594. */
  26595. set cameraExposure(value: number);
  26596. /**
  26597. * Gets The camera contrast used on this material.
  26598. */
  26599. get cameraContrast(): number;
  26600. /**
  26601. * Sets The camera contrast used on this material.
  26602. */
  26603. set cameraContrast(value: number);
  26604. /**
  26605. * Gets the Color Grading 2D Lookup Texture.
  26606. */
  26607. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26608. /**
  26609. * Sets the Color Grading 2D Lookup Texture.
  26610. */
  26611. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26612. /**
  26613. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26614. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26615. * 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;
  26616. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26617. */
  26618. get cameraColorCurves(): Nullable<ColorCurves>;
  26619. /**
  26620. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26621. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26622. * 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;
  26623. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26624. */
  26625. set cameraColorCurves(value: Nullable<ColorCurves>);
  26626. /**
  26627. * Custom callback helping to override the default shader used in the material.
  26628. */
  26629. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26630. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26631. protected _worldViewProjectionMatrix: Matrix;
  26632. protected _globalAmbientColor: Color3;
  26633. protected _useLogarithmicDepth: boolean;
  26634. protected _rebuildInParallel: boolean;
  26635. /**
  26636. * Instantiates a new standard material.
  26637. * This is the default material used in Babylon. It is the best trade off between quality
  26638. * and performances.
  26639. * @see http://doc.babylonjs.com/babylon101/materials
  26640. * @param name Define the name of the material in the scene
  26641. * @param scene Define the scene the material belong to
  26642. */
  26643. constructor(name: string, scene: Scene);
  26644. /**
  26645. * Gets a boolean indicating that current material needs to register RTT
  26646. */
  26647. get hasRenderTargetTextures(): boolean;
  26648. /**
  26649. * Gets the current class name of the material e.g. "StandardMaterial"
  26650. * Mainly use in serialization.
  26651. * @returns the class name
  26652. */
  26653. getClassName(): string;
  26654. /**
  26655. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26656. * You can try switching to logarithmic depth.
  26657. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26658. */
  26659. get useLogarithmicDepth(): boolean;
  26660. set useLogarithmicDepth(value: boolean);
  26661. /**
  26662. * Specifies if the material will require alpha blending
  26663. * @returns a boolean specifying if alpha blending is needed
  26664. */
  26665. needAlphaBlending(): boolean;
  26666. /**
  26667. * Specifies if this material should be rendered in alpha test mode
  26668. * @returns a boolean specifying if an alpha test is needed.
  26669. */
  26670. needAlphaTesting(): boolean;
  26671. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26672. /**
  26673. * Get the texture used for alpha test purpose.
  26674. * @returns the diffuse texture in case of the standard material.
  26675. */
  26676. getAlphaTestTexture(): Nullable<BaseTexture>;
  26677. /**
  26678. * Get if the submesh is ready to be used and all its information available.
  26679. * Child classes can use it to update shaders
  26680. * @param mesh defines the mesh to check
  26681. * @param subMesh defines which submesh to check
  26682. * @param useInstances specifies that instances should be used
  26683. * @returns a boolean indicating that the submesh is ready or not
  26684. */
  26685. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26686. /**
  26687. * Builds the material UBO layouts.
  26688. * Used internally during the effect preparation.
  26689. */
  26690. buildUniformLayout(): void;
  26691. /**
  26692. * Unbinds the material from the mesh
  26693. */
  26694. unbind(): void;
  26695. /**
  26696. * Binds the submesh to this material by preparing the effect and shader to draw
  26697. * @param world defines the world transformation matrix
  26698. * @param mesh defines the mesh containing the submesh
  26699. * @param subMesh defines the submesh to bind the material to
  26700. */
  26701. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26702. /**
  26703. * Get the list of animatables in the material.
  26704. * @returns the list of animatables object used in the material
  26705. */
  26706. getAnimatables(): IAnimatable[];
  26707. /**
  26708. * Gets the active textures from the material
  26709. * @returns an array of textures
  26710. */
  26711. getActiveTextures(): BaseTexture[];
  26712. /**
  26713. * Specifies if the material uses a texture
  26714. * @param texture defines the texture to check against the material
  26715. * @returns a boolean specifying if the material uses the texture
  26716. */
  26717. hasTexture(texture: BaseTexture): boolean;
  26718. /**
  26719. * Disposes the material
  26720. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26721. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26722. */
  26723. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26724. /**
  26725. * Makes a duplicate of the material, and gives it a new name
  26726. * @param name defines the new name for the duplicated material
  26727. * @returns the cloned material
  26728. */
  26729. clone(name: string): StandardMaterial;
  26730. /**
  26731. * Serializes this material in a JSON representation
  26732. * @returns the serialized material object
  26733. */
  26734. serialize(): any;
  26735. /**
  26736. * Creates a standard material from parsed material data
  26737. * @param source defines the JSON representation of the material
  26738. * @param scene defines the hosting scene
  26739. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26740. * @returns a new standard material
  26741. */
  26742. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26743. /**
  26744. * Are diffuse textures enabled in the application.
  26745. */
  26746. static get DiffuseTextureEnabled(): boolean;
  26747. static set DiffuseTextureEnabled(value: boolean);
  26748. /**
  26749. * Are ambient textures enabled in the application.
  26750. */
  26751. static get AmbientTextureEnabled(): boolean;
  26752. static set AmbientTextureEnabled(value: boolean);
  26753. /**
  26754. * Are opacity textures enabled in the application.
  26755. */
  26756. static get OpacityTextureEnabled(): boolean;
  26757. static set OpacityTextureEnabled(value: boolean);
  26758. /**
  26759. * Are reflection textures enabled in the application.
  26760. */
  26761. static get ReflectionTextureEnabled(): boolean;
  26762. static set ReflectionTextureEnabled(value: boolean);
  26763. /**
  26764. * Are emissive textures enabled in the application.
  26765. */
  26766. static get EmissiveTextureEnabled(): boolean;
  26767. static set EmissiveTextureEnabled(value: boolean);
  26768. /**
  26769. * Are specular textures enabled in the application.
  26770. */
  26771. static get SpecularTextureEnabled(): boolean;
  26772. static set SpecularTextureEnabled(value: boolean);
  26773. /**
  26774. * Are bump textures enabled in the application.
  26775. */
  26776. static get BumpTextureEnabled(): boolean;
  26777. static set BumpTextureEnabled(value: boolean);
  26778. /**
  26779. * Are lightmap textures enabled in the application.
  26780. */
  26781. static get LightmapTextureEnabled(): boolean;
  26782. static set LightmapTextureEnabled(value: boolean);
  26783. /**
  26784. * Are refraction textures enabled in the application.
  26785. */
  26786. static get RefractionTextureEnabled(): boolean;
  26787. static set RefractionTextureEnabled(value: boolean);
  26788. /**
  26789. * Are color grading textures enabled in the application.
  26790. */
  26791. static get ColorGradingTextureEnabled(): boolean;
  26792. static set ColorGradingTextureEnabled(value: boolean);
  26793. /**
  26794. * Are fresnels enabled in the application.
  26795. */
  26796. static get FresnelEnabled(): boolean;
  26797. static set FresnelEnabled(value: boolean);
  26798. }
  26799. }
  26800. declare module BABYLON {
  26801. /**
  26802. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26803. *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.
  26804. * The SPS is also a particle system. It provides some methods to manage the particles.
  26805. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26806. *
  26807. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26808. */
  26809. export class SolidParticleSystem implements IDisposable {
  26810. /**
  26811. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26812. * Example : var p = SPS.particles[i];
  26813. */
  26814. particles: SolidParticle[];
  26815. /**
  26816. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26817. */
  26818. nbParticles: number;
  26819. /**
  26820. * If the particles must ever face the camera (default false). Useful for planar particles.
  26821. */
  26822. billboard: boolean;
  26823. /**
  26824. * Recompute normals when adding a shape
  26825. */
  26826. recomputeNormals: boolean;
  26827. /**
  26828. * This a counter ofr your own usage. It's not set by any SPS functions.
  26829. */
  26830. counter: number;
  26831. /**
  26832. * The SPS name. This name is also given to the underlying mesh.
  26833. */
  26834. name: string;
  26835. /**
  26836. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26837. */
  26838. mesh: Mesh;
  26839. /**
  26840. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26841. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26842. */
  26843. vars: any;
  26844. /**
  26845. * This array is populated when the SPS is set as 'pickable'.
  26846. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26847. * Each element of this array is an object `{idx: int, faceId: int}`.
  26848. * `idx` is the picked particle index in the `SPS.particles` array
  26849. * `faceId` is the picked face index counted within this particle.
  26850. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26851. */
  26852. pickedParticles: {
  26853. idx: number;
  26854. faceId: number;
  26855. }[];
  26856. /**
  26857. * This array is populated when `enableDepthSort` is set to true.
  26858. * Each element of this array is an instance of the class DepthSortedParticle.
  26859. */
  26860. depthSortedParticles: DepthSortedParticle[];
  26861. /**
  26862. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26863. * @hidden
  26864. */
  26865. _bSphereOnly: boolean;
  26866. /**
  26867. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26868. * @hidden
  26869. */
  26870. _bSphereRadiusFactor: number;
  26871. private _scene;
  26872. private _positions;
  26873. private _indices;
  26874. private _normals;
  26875. private _colors;
  26876. private _uvs;
  26877. private _indices32;
  26878. private _positions32;
  26879. private _normals32;
  26880. private _fixedNormal32;
  26881. private _colors32;
  26882. private _uvs32;
  26883. private _index;
  26884. private _updatable;
  26885. private _pickable;
  26886. private _isVisibilityBoxLocked;
  26887. private _alwaysVisible;
  26888. private _depthSort;
  26889. private _expandable;
  26890. private _shapeCounter;
  26891. private _copy;
  26892. private _color;
  26893. private _computeParticleColor;
  26894. private _computeParticleTexture;
  26895. private _computeParticleRotation;
  26896. private _computeParticleVertex;
  26897. private _computeBoundingBox;
  26898. private _depthSortParticles;
  26899. private _camera;
  26900. private _mustUnrotateFixedNormals;
  26901. private _particlesIntersect;
  26902. private _needs32Bits;
  26903. private _isNotBuilt;
  26904. private _lastParticleId;
  26905. private _idxOfId;
  26906. private _multimaterialEnabled;
  26907. private _useModelMaterial;
  26908. private _indicesByMaterial;
  26909. private _materialIndexes;
  26910. private _depthSortFunction;
  26911. private _materialSortFunction;
  26912. private _materials;
  26913. private _multimaterial;
  26914. private _materialIndexesById;
  26915. private _defaultMaterial;
  26916. private _autoUpdateSubMeshes;
  26917. /**
  26918. * Creates a SPS (Solid Particle System) object.
  26919. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26920. * @param scene (Scene) is the scene in which the SPS is added.
  26921. * @param options defines the options of the sps e.g.
  26922. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26923. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26924. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26925. * * 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.
  26926. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26927. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26928. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26929. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26930. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26931. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26932. */
  26933. constructor(name: string, scene: Scene, options?: {
  26934. updatable?: boolean;
  26935. isPickable?: boolean;
  26936. enableDepthSort?: boolean;
  26937. particleIntersection?: boolean;
  26938. boundingSphereOnly?: boolean;
  26939. bSphereRadiusFactor?: number;
  26940. expandable?: boolean;
  26941. useModelMaterial?: boolean;
  26942. enableMultiMaterial?: boolean;
  26943. });
  26944. /**
  26945. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26946. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26947. * @returns the created mesh
  26948. */
  26949. buildMesh(): Mesh;
  26950. /**
  26951. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26952. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26953. * Thus the particles generated from `digest()` have their property `position` set yet.
  26954. * @param mesh ( Mesh ) is the mesh to be digested
  26955. * @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
  26956. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26957. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26958. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26959. * @returns the current SPS
  26960. */
  26961. digest(mesh: Mesh, options?: {
  26962. facetNb?: number;
  26963. number?: number;
  26964. delta?: number;
  26965. storage?: [];
  26966. }): SolidParticleSystem;
  26967. /**
  26968. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26969. * @hidden
  26970. */
  26971. private _unrotateFixedNormals;
  26972. /**
  26973. * Resets the temporary working copy particle
  26974. * @hidden
  26975. */
  26976. private _resetCopy;
  26977. /**
  26978. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26979. * @param p the current index in the positions array to be updated
  26980. * @param ind the current index in the indices array
  26981. * @param shape a Vector3 array, the shape geometry
  26982. * @param positions the positions array to be updated
  26983. * @param meshInd the shape indices array
  26984. * @param indices the indices array to be updated
  26985. * @param meshUV the shape uv array
  26986. * @param uvs the uv array to be updated
  26987. * @param meshCol the shape color array
  26988. * @param colors the color array to be updated
  26989. * @param meshNor the shape normals array
  26990. * @param normals the normals array to be updated
  26991. * @param idx the particle index
  26992. * @param idxInShape the particle index in its shape
  26993. * @param options the addShape() method passed options
  26994. * @model the particle model
  26995. * @hidden
  26996. */
  26997. private _meshBuilder;
  26998. /**
  26999. * Returns a shape Vector3 array from positions float array
  27000. * @param positions float array
  27001. * @returns a vector3 array
  27002. * @hidden
  27003. */
  27004. private _posToShape;
  27005. /**
  27006. * Returns a shapeUV array from a float uvs (array deep copy)
  27007. * @param uvs as a float array
  27008. * @returns a shapeUV array
  27009. * @hidden
  27010. */
  27011. private _uvsToShapeUV;
  27012. /**
  27013. * Adds a new particle object in the particles array
  27014. * @param idx particle index in particles array
  27015. * @param id particle id
  27016. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27017. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27018. * @param model particle ModelShape object
  27019. * @param shapeId model shape identifier
  27020. * @param idxInShape index of the particle in the current model
  27021. * @param bInfo model bounding info object
  27022. * @param storage target storage array, if any
  27023. * @hidden
  27024. */
  27025. private _addParticle;
  27026. /**
  27027. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27028. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27029. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27030. * @param nb (positive integer) the number of particles to be created from this model
  27031. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27032. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27033. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27034. * @returns the number of shapes in the system
  27035. */
  27036. addShape(mesh: Mesh, nb: number, options?: {
  27037. positionFunction?: any;
  27038. vertexFunction?: any;
  27039. storage?: [];
  27040. }): number;
  27041. /**
  27042. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27043. * @hidden
  27044. */
  27045. private _rebuildParticle;
  27046. /**
  27047. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27048. * @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.
  27049. * @returns the SPS.
  27050. */
  27051. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27052. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27053. * Returns an array with the removed particles.
  27054. * 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.
  27055. * The SPS can't be empty so at least one particle needs to remain in place.
  27056. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27057. * @param start index of the first particle to remove
  27058. * @param end index of the last particle to remove (included)
  27059. * @returns an array populated with the removed particles
  27060. */
  27061. removeParticles(start: number, end: number): SolidParticle[];
  27062. /**
  27063. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27064. * @param solidParticleArray an array populated with Solid Particles objects
  27065. * @returns the SPS
  27066. */
  27067. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27068. /**
  27069. * Creates a new particle and modifies the SPS mesh geometry :
  27070. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27071. * - calls _addParticle() to populate the particle array
  27072. * factorized code from addShape() and insertParticlesFromArray()
  27073. * @param idx particle index in the particles array
  27074. * @param i particle index in its shape
  27075. * @param modelShape particle ModelShape object
  27076. * @param shape shape vertex array
  27077. * @param meshInd shape indices array
  27078. * @param meshUV shape uv array
  27079. * @param meshCol shape color array
  27080. * @param meshNor shape normals array
  27081. * @param bbInfo shape bounding info
  27082. * @param storage target particle storage
  27083. * @options addShape() passed options
  27084. * @hidden
  27085. */
  27086. private _insertNewParticle;
  27087. /**
  27088. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27089. * This method calls `updateParticle()` for each particle of the SPS.
  27090. * For an animated SPS, it is usually called within the render loop.
  27091. * 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.
  27092. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27093. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27094. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27095. * @returns the SPS.
  27096. */
  27097. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27098. /**
  27099. * Disposes the SPS.
  27100. */
  27101. dispose(): void;
  27102. /**
  27103. * Returns a SolidParticle object from its identifier : particle.id
  27104. * @param id (integer) the particle Id
  27105. * @returns the searched particle or null if not found in the SPS.
  27106. */
  27107. getParticleById(id: number): Nullable<SolidParticle>;
  27108. /**
  27109. * Returns a new array populated with the particles having the passed shapeId.
  27110. * @param shapeId (integer) the shape identifier
  27111. * @returns a new solid particle array
  27112. */
  27113. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27114. /**
  27115. * Populates the passed array "ref" with the particles having the passed shapeId.
  27116. * @param shapeId the shape identifier
  27117. * @returns the SPS
  27118. * @param ref
  27119. */
  27120. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27121. /**
  27122. * Computes the required SubMeshes according the materials assigned to the particles.
  27123. * @returns the solid particle system.
  27124. * Does nothing if called before the SPS mesh is built.
  27125. */
  27126. computeSubMeshes(): SolidParticleSystem;
  27127. /**
  27128. * Sorts the solid particles by material when MultiMaterial is enabled.
  27129. * Updates the indices32 array.
  27130. * Updates the indicesByMaterial array.
  27131. * Updates the mesh indices array.
  27132. * @returns the SPS
  27133. * @hidden
  27134. */
  27135. private _sortParticlesByMaterial;
  27136. /**
  27137. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27138. * @hidden
  27139. */
  27140. private _setMaterialIndexesById;
  27141. /**
  27142. * Returns an array with unique values of Materials from the passed array
  27143. * @param array the material array to be checked and filtered
  27144. * @hidden
  27145. */
  27146. private _filterUniqueMaterialId;
  27147. /**
  27148. * Sets a new Standard Material as _defaultMaterial if not already set.
  27149. * @hidden
  27150. */
  27151. private _setDefaultMaterial;
  27152. /**
  27153. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27154. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27155. * @returns the SPS.
  27156. */
  27157. refreshVisibleSize(): SolidParticleSystem;
  27158. /**
  27159. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27160. * @param size the size (float) of the visibility box
  27161. * note : this doesn't lock the SPS mesh bounding box.
  27162. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27163. */
  27164. setVisibilityBox(size: number): void;
  27165. /**
  27166. * Gets whether the SPS as always visible or not
  27167. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27168. */
  27169. get isAlwaysVisible(): boolean;
  27170. /**
  27171. * Sets the SPS as always visible or not
  27172. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27173. */
  27174. set isAlwaysVisible(val: boolean);
  27175. /**
  27176. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27177. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27178. */
  27179. set isVisibilityBoxLocked(val: boolean);
  27180. /**
  27181. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27182. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27183. */
  27184. get isVisibilityBoxLocked(): boolean;
  27185. /**
  27186. * Tells to `setParticles()` to compute the particle rotations or not.
  27187. * Default value : true. The SPS is faster when it's set to false.
  27188. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27189. */
  27190. set computeParticleRotation(val: boolean);
  27191. /**
  27192. * Tells to `setParticles()` to compute the particle colors or not.
  27193. * Default value : true. The SPS is faster when it's set to false.
  27194. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27195. */
  27196. set computeParticleColor(val: boolean);
  27197. set computeParticleTexture(val: boolean);
  27198. /**
  27199. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27200. * Default value : false. The SPS is faster when it's set to false.
  27201. * Note : the particle custom vertex positions aren't stored values.
  27202. */
  27203. set computeParticleVertex(val: boolean);
  27204. /**
  27205. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27206. */
  27207. set computeBoundingBox(val: boolean);
  27208. /**
  27209. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27210. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27211. * Default : `true`
  27212. */
  27213. set depthSortParticles(val: boolean);
  27214. /**
  27215. * Gets if `setParticles()` computes the particle rotations or not.
  27216. * Default value : true. The SPS is faster when it's set to false.
  27217. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27218. */
  27219. get computeParticleRotation(): boolean;
  27220. /**
  27221. * Gets if `setParticles()` computes the particle colors or not.
  27222. * Default value : true. The SPS is faster when it's set to false.
  27223. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27224. */
  27225. get computeParticleColor(): boolean;
  27226. /**
  27227. * Gets if `setParticles()` computes the particle textures or not.
  27228. * Default value : true. The SPS is faster when it's set to false.
  27229. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27230. */
  27231. get computeParticleTexture(): boolean;
  27232. /**
  27233. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27234. * Default value : false. The SPS is faster when it's set to false.
  27235. * Note : the particle custom vertex positions aren't stored values.
  27236. */
  27237. get computeParticleVertex(): boolean;
  27238. /**
  27239. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27240. */
  27241. get computeBoundingBox(): boolean;
  27242. /**
  27243. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27244. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27245. * Default : `true`
  27246. */
  27247. get depthSortParticles(): boolean;
  27248. /**
  27249. * Gets if the SPS is created as expandable at construction time.
  27250. * Default : `false`
  27251. */
  27252. get expandable(): boolean;
  27253. /**
  27254. * Gets if the SPS supports the Multi Materials
  27255. */
  27256. get multimaterialEnabled(): boolean;
  27257. /**
  27258. * Gets if the SPS uses the model materials for its own multimaterial.
  27259. */
  27260. get useModelMaterial(): boolean;
  27261. /**
  27262. * The SPS used material array.
  27263. */
  27264. get materials(): Material[];
  27265. /**
  27266. * Sets the SPS MultiMaterial from the passed materials.
  27267. * Note : the passed array is internally copied and not used then by reference.
  27268. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27269. */
  27270. setMultiMaterial(materials: Material[]): void;
  27271. /**
  27272. * The SPS computed multimaterial object
  27273. */
  27274. get multimaterial(): MultiMaterial;
  27275. set multimaterial(mm: MultiMaterial);
  27276. /**
  27277. * If the subMeshes must be updated on the next call to setParticles()
  27278. */
  27279. get autoUpdateSubMeshes(): boolean;
  27280. set autoUpdateSubMeshes(val: boolean);
  27281. /**
  27282. * This function does nothing. It may be overwritten to set all the particle first values.
  27283. * The SPS doesn't call this function, you may have to call it by your own.
  27284. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27285. */
  27286. initParticles(): void;
  27287. /**
  27288. * This function does nothing. It may be overwritten to recycle a particle.
  27289. * The SPS doesn't call this function, you may have to call it by your own.
  27290. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27291. * @param particle The particle to recycle
  27292. * @returns the recycled particle
  27293. */
  27294. recycleParticle(particle: SolidParticle): SolidParticle;
  27295. /**
  27296. * Updates a particle : this function should be overwritten by the user.
  27297. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27298. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27299. * @example : just set a particle position or velocity and recycle conditions
  27300. * @param particle The particle to update
  27301. * @returns the updated particle
  27302. */
  27303. updateParticle(particle: SolidParticle): SolidParticle;
  27304. /**
  27305. * Updates a vertex of a particle : it can be overwritten by the user.
  27306. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27307. * @param particle the current particle
  27308. * @param vertex the current index of the current particle
  27309. * @param pt the index of the current vertex in the particle shape
  27310. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27311. * @example : just set a vertex particle position
  27312. * @returns the updated vertex
  27313. */
  27314. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27315. /**
  27316. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27317. * This does nothing and may be overwritten by the user.
  27318. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27319. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27320. * @param update the boolean update value actually passed to setParticles()
  27321. */
  27322. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27323. /**
  27324. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27325. * This will be passed three parameters.
  27326. * This does nothing and may be overwritten by the user.
  27327. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27328. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27329. * @param update the boolean update value actually passed to setParticles()
  27330. */
  27331. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27332. }
  27333. }
  27334. declare module BABYLON {
  27335. /**
  27336. * Represents one particle of a solid particle system.
  27337. */
  27338. export class SolidParticle {
  27339. /**
  27340. * particle global index
  27341. */
  27342. idx: number;
  27343. /**
  27344. * particle identifier
  27345. */
  27346. id: number;
  27347. /**
  27348. * The color of the particle
  27349. */
  27350. color: Nullable<Color4>;
  27351. /**
  27352. * The world space position of the particle.
  27353. */
  27354. position: Vector3;
  27355. /**
  27356. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27357. */
  27358. rotation: Vector3;
  27359. /**
  27360. * The world space rotation quaternion of the particle.
  27361. */
  27362. rotationQuaternion: Nullable<Quaternion>;
  27363. /**
  27364. * The scaling of the particle.
  27365. */
  27366. scaling: Vector3;
  27367. /**
  27368. * The uvs of the particle.
  27369. */
  27370. uvs: Vector4;
  27371. /**
  27372. * The current speed of the particle.
  27373. */
  27374. velocity: Vector3;
  27375. /**
  27376. * The pivot point in the particle local space.
  27377. */
  27378. pivot: Vector3;
  27379. /**
  27380. * Must the particle be translated from its pivot point in its local space ?
  27381. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27382. * Default : false
  27383. */
  27384. translateFromPivot: boolean;
  27385. /**
  27386. * Is the particle active or not ?
  27387. */
  27388. alive: boolean;
  27389. /**
  27390. * Is the particle visible or not ?
  27391. */
  27392. isVisible: boolean;
  27393. /**
  27394. * Index of this particle in the global "positions" array (Internal use)
  27395. * @hidden
  27396. */
  27397. _pos: number;
  27398. /**
  27399. * @hidden Index of this particle in the global "indices" array (Internal use)
  27400. */
  27401. _ind: number;
  27402. /**
  27403. * @hidden ModelShape of this particle (Internal use)
  27404. */
  27405. _model: ModelShape;
  27406. /**
  27407. * ModelShape id of this particle
  27408. */
  27409. shapeId: number;
  27410. /**
  27411. * Index of the particle in its shape id
  27412. */
  27413. idxInShape: number;
  27414. /**
  27415. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27416. */
  27417. _modelBoundingInfo: BoundingInfo;
  27418. /**
  27419. * @hidden Particle BoundingInfo object (Internal use)
  27420. */
  27421. _boundingInfo: BoundingInfo;
  27422. /**
  27423. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27424. */
  27425. _sps: SolidParticleSystem;
  27426. /**
  27427. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27428. */
  27429. _stillInvisible: boolean;
  27430. /**
  27431. * @hidden Last computed particle rotation matrix
  27432. */
  27433. _rotationMatrix: number[];
  27434. /**
  27435. * Parent particle Id, if any.
  27436. * Default null.
  27437. */
  27438. parentId: Nullable<number>;
  27439. /**
  27440. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27441. */
  27442. materialIndex: Nullable<number>;
  27443. /**
  27444. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27445. * The possible values are :
  27446. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27447. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27448. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27449. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27450. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27451. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27452. * */
  27453. cullingStrategy: number;
  27454. /**
  27455. * @hidden Internal global position in the SPS.
  27456. */
  27457. _globalPosition: Vector3;
  27458. /**
  27459. * Creates a Solid Particle object.
  27460. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27461. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27462. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27463. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27464. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27465. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27466. * @param shapeId (integer) is the model shape identifier in the SPS.
  27467. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27468. * @param sps defines the sps it is associated to
  27469. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27470. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27471. */
  27472. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27473. /**
  27474. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27475. * @param target the particle target
  27476. * @returns the current particle
  27477. */
  27478. copyToRef(target: SolidParticle): SolidParticle;
  27479. /**
  27480. * Legacy support, changed scale to scaling
  27481. */
  27482. get scale(): Vector3;
  27483. /**
  27484. * Legacy support, changed scale to scaling
  27485. */
  27486. set scale(scale: Vector3);
  27487. /**
  27488. * Legacy support, changed quaternion to rotationQuaternion
  27489. */
  27490. get quaternion(): Nullable<Quaternion>;
  27491. /**
  27492. * Legacy support, changed quaternion to rotationQuaternion
  27493. */
  27494. set quaternion(q: Nullable<Quaternion>);
  27495. /**
  27496. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27497. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27498. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27499. * @returns true if it intersects
  27500. */
  27501. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27502. /**
  27503. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27504. * A particle is in the frustum if its bounding box intersects the frustum
  27505. * @param frustumPlanes defines the frustum to test
  27506. * @returns true if the particle is in the frustum planes
  27507. */
  27508. isInFrustum(frustumPlanes: Plane[]): boolean;
  27509. /**
  27510. * get the rotation matrix of the particle
  27511. * @hidden
  27512. */
  27513. getRotationMatrix(m: Matrix): void;
  27514. }
  27515. /**
  27516. * Represents the shape of the model used by one particle of a solid particle system.
  27517. * SPS internal tool, don't use it manually.
  27518. */
  27519. export class ModelShape {
  27520. /**
  27521. * The shape id
  27522. * @hidden
  27523. */
  27524. shapeID: number;
  27525. /**
  27526. * flat array of model positions (internal use)
  27527. * @hidden
  27528. */
  27529. _shape: Vector3[];
  27530. /**
  27531. * flat array of model UVs (internal use)
  27532. * @hidden
  27533. */
  27534. _shapeUV: number[];
  27535. /**
  27536. * color array of the model
  27537. * @hidden
  27538. */
  27539. _shapeColors: number[];
  27540. /**
  27541. * indices array of the model
  27542. * @hidden
  27543. */
  27544. _indices: number[];
  27545. /**
  27546. * normals array of the model
  27547. * @hidden
  27548. */
  27549. _normals: number[];
  27550. /**
  27551. * length of the shape in the model indices array (internal use)
  27552. * @hidden
  27553. */
  27554. _indicesLength: number;
  27555. /**
  27556. * Custom position function (internal use)
  27557. * @hidden
  27558. */
  27559. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27560. /**
  27561. * Custom vertex function (internal use)
  27562. * @hidden
  27563. */
  27564. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27565. /**
  27566. * Model material (internal use)
  27567. * @hidden
  27568. */
  27569. _material: Nullable<Material>;
  27570. /**
  27571. * 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.
  27572. * SPS internal tool, don't use it manually.
  27573. * @hidden
  27574. */
  27575. 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>);
  27576. }
  27577. /**
  27578. * Represents a Depth Sorted Particle in the solid particle system.
  27579. * @hidden
  27580. */
  27581. export class DepthSortedParticle {
  27582. /**
  27583. * Index of the particle in the "indices" array
  27584. */
  27585. ind: number;
  27586. /**
  27587. * Length of the particle shape in the "indices" array
  27588. */
  27589. indicesLength: number;
  27590. /**
  27591. * Squared distance from the particle to the camera
  27592. */
  27593. sqDistance: number;
  27594. /**
  27595. * Material index when used with MultiMaterials
  27596. */
  27597. materialIndex: number;
  27598. /**
  27599. * Creates a new sorted particle
  27600. * @param materialIndex
  27601. */
  27602. constructor(ind: number, indLength: number, materialIndex: number);
  27603. }
  27604. }
  27605. declare module BABYLON {
  27606. /**
  27607. * @hidden
  27608. */
  27609. export class _MeshCollisionData {
  27610. _checkCollisions: boolean;
  27611. _collisionMask: number;
  27612. _collisionGroup: number;
  27613. _collider: Nullable<Collider>;
  27614. _oldPositionForCollisions: Vector3;
  27615. _diffPositionForCollisions: Vector3;
  27616. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27617. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27618. }
  27619. }
  27620. declare module BABYLON {
  27621. /** @hidden */
  27622. class _FacetDataStorage {
  27623. facetPositions: Vector3[];
  27624. facetNormals: Vector3[];
  27625. facetPartitioning: number[][];
  27626. facetNb: number;
  27627. partitioningSubdivisions: number;
  27628. partitioningBBoxRatio: number;
  27629. facetDataEnabled: boolean;
  27630. facetParameters: any;
  27631. bbSize: Vector3;
  27632. subDiv: {
  27633. max: number;
  27634. X: number;
  27635. Y: number;
  27636. Z: number;
  27637. };
  27638. facetDepthSort: boolean;
  27639. facetDepthSortEnabled: boolean;
  27640. depthSortedIndices: IndicesArray;
  27641. depthSortedFacets: {
  27642. ind: number;
  27643. sqDistance: number;
  27644. }[];
  27645. facetDepthSortFunction: (f1: {
  27646. ind: number;
  27647. sqDistance: number;
  27648. }, f2: {
  27649. ind: number;
  27650. sqDistance: number;
  27651. }) => number;
  27652. facetDepthSortFrom: Vector3;
  27653. facetDepthSortOrigin: Vector3;
  27654. invertedMatrix: Matrix;
  27655. }
  27656. /**
  27657. * @hidden
  27658. **/
  27659. class _InternalAbstractMeshDataInfo {
  27660. _hasVertexAlpha: boolean;
  27661. _useVertexColors: boolean;
  27662. _numBoneInfluencers: number;
  27663. _applyFog: boolean;
  27664. _receiveShadows: boolean;
  27665. _facetData: _FacetDataStorage;
  27666. _visibility: number;
  27667. _skeleton: Nullable<Skeleton>;
  27668. _layerMask: number;
  27669. _computeBonesUsingShaders: boolean;
  27670. _isActive: boolean;
  27671. _onlyForInstances: boolean;
  27672. _isActiveIntermediate: boolean;
  27673. _onlyForInstancesIntermediate: boolean;
  27674. _actAsRegularMesh: boolean;
  27675. }
  27676. /**
  27677. * Class used to store all common mesh properties
  27678. */
  27679. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27680. /** No occlusion */
  27681. static OCCLUSION_TYPE_NONE: number;
  27682. /** Occlusion set to optimisitic */
  27683. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27684. /** Occlusion set to strict */
  27685. static OCCLUSION_TYPE_STRICT: number;
  27686. /** Use an accurante occlusion algorithm */
  27687. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27688. /** Use a conservative occlusion algorithm */
  27689. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27690. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27691. * Test order :
  27692. * Is the bounding sphere outside the frustum ?
  27693. * If not, are the bounding box vertices outside the frustum ?
  27694. * It not, then the cullable object is in the frustum.
  27695. */
  27696. static readonly CULLINGSTRATEGY_STANDARD: number;
  27697. /** Culling strategy : Bounding Sphere Only.
  27698. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27699. * It's also less accurate than the standard because some not visible objects can still be selected.
  27700. * Test : is the bounding sphere outside the frustum ?
  27701. * If not, then the cullable object is in the frustum.
  27702. */
  27703. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27704. /** Culling strategy : Optimistic Inclusion.
  27705. * This in an inclusion test first, then the standard exclusion test.
  27706. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27707. * 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.
  27708. * Anyway, it's as accurate as the standard strategy.
  27709. * Test :
  27710. * Is the cullable object bounding sphere center in the frustum ?
  27711. * If not, apply the default culling strategy.
  27712. */
  27713. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27714. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27715. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27716. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27717. * 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.
  27718. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27719. * Test :
  27720. * Is the cullable object bounding sphere center in the frustum ?
  27721. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27722. */
  27723. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27724. /**
  27725. * No billboard
  27726. */
  27727. static get BILLBOARDMODE_NONE(): number;
  27728. /** Billboard on X axis */
  27729. static get BILLBOARDMODE_X(): number;
  27730. /** Billboard on Y axis */
  27731. static get BILLBOARDMODE_Y(): number;
  27732. /** Billboard on Z axis */
  27733. static get BILLBOARDMODE_Z(): number;
  27734. /** Billboard on all axes */
  27735. static get BILLBOARDMODE_ALL(): number;
  27736. /** Billboard on using position instead of orientation */
  27737. static get BILLBOARDMODE_USE_POSITION(): number;
  27738. /** @hidden */
  27739. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27740. /**
  27741. * The culling strategy to use to check whether the mesh must be rendered or not.
  27742. * This value can be changed at any time and will be used on the next render mesh selection.
  27743. * The possible values are :
  27744. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27745. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27746. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27747. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27748. * Please read each static variable documentation to get details about the culling process.
  27749. * */
  27750. cullingStrategy: number;
  27751. /**
  27752. * Gets the number of facets in the mesh
  27753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27754. */
  27755. get facetNb(): number;
  27756. /**
  27757. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27759. */
  27760. get partitioningSubdivisions(): number;
  27761. set partitioningSubdivisions(nb: number);
  27762. /**
  27763. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27764. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27765. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27766. */
  27767. get partitioningBBoxRatio(): number;
  27768. set partitioningBBoxRatio(ratio: number);
  27769. /**
  27770. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27771. * Works only for updatable meshes.
  27772. * Doesn't work with multi-materials
  27773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27774. */
  27775. get mustDepthSortFacets(): boolean;
  27776. set mustDepthSortFacets(sort: boolean);
  27777. /**
  27778. * The location (Vector3) where the facet depth sort must be computed from.
  27779. * By default, the active camera position.
  27780. * Used only when facet depth sort is enabled
  27781. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27782. */
  27783. get facetDepthSortFrom(): Vector3;
  27784. set facetDepthSortFrom(location: Vector3);
  27785. /**
  27786. * gets a boolean indicating if facetData is enabled
  27787. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27788. */
  27789. get isFacetDataEnabled(): boolean;
  27790. /** @hidden */
  27791. _updateNonUniformScalingState(value: boolean): boolean;
  27792. /**
  27793. * An event triggered when this mesh collides with another one
  27794. */
  27795. onCollideObservable: Observable<AbstractMesh>;
  27796. /** Set a function to call when this mesh collides with another one */
  27797. set onCollide(callback: () => void);
  27798. /**
  27799. * An event triggered when the collision's position changes
  27800. */
  27801. onCollisionPositionChangeObservable: Observable<Vector3>;
  27802. /** Set a function to call when the collision's position changes */
  27803. set onCollisionPositionChange(callback: () => void);
  27804. /**
  27805. * An event triggered when material is changed
  27806. */
  27807. onMaterialChangedObservable: Observable<AbstractMesh>;
  27808. /**
  27809. * Gets or sets the orientation for POV movement & rotation
  27810. */
  27811. definedFacingForward: boolean;
  27812. /** @hidden */
  27813. _occlusionQuery: Nullable<WebGLQuery>;
  27814. /** @hidden */
  27815. _renderingGroup: Nullable<RenderingGroup>;
  27816. /**
  27817. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27818. */
  27819. get visibility(): number;
  27820. /**
  27821. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27822. */
  27823. set visibility(value: number);
  27824. /** Gets or sets the alpha index used to sort transparent meshes
  27825. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27826. */
  27827. alphaIndex: number;
  27828. /**
  27829. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27830. */
  27831. isVisible: boolean;
  27832. /**
  27833. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27834. */
  27835. isPickable: boolean;
  27836. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27837. showSubMeshesBoundingBox: boolean;
  27838. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27839. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27840. */
  27841. isBlocker: boolean;
  27842. /**
  27843. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27844. */
  27845. enablePointerMoveEvents: boolean;
  27846. /**
  27847. * Specifies the rendering group id for this mesh (0 by default)
  27848. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27849. */
  27850. renderingGroupId: number;
  27851. private _material;
  27852. /** Gets or sets current material */
  27853. get material(): Nullable<Material>;
  27854. set material(value: Nullable<Material>);
  27855. /**
  27856. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27857. * @see http://doc.babylonjs.com/babylon101/shadows
  27858. */
  27859. get receiveShadows(): boolean;
  27860. set receiveShadows(value: boolean);
  27861. /** Defines color to use when rendering outline */
  27862. outlineColor: Color3;
  27863. /** Define width to use when rendering outline */
  27864. outlineWidth: number;
  27865. /** Defines color to use when rendering overlay */
  27866. overlayColor: Color3;
  27867. /** Defines alpha to use when rendering overlay */
  27868. overlayAlpha: number;
  27869. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27870. get hasVertexAlpha(): boolean;
  27871. set hasVertexAlpha(value: boolean);
  27872. /** 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) */
  27873. get useVertexColors(): boolean;
  27874. set useVertexColors(value: boolean);
  27875. /**
  27876. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27877. */
  27878. get computeBonesUsingShaders(): boolean;
  27879. set computeBonesUsingShaders(value: boolean);
  27880. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27881. get numBoneInfluencers(): number;
  27882. set numBoneInfluencers(value: number);
  27883. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27884. get applyFog(): boolean;
  27885. set applyFog(value: boolean);
  27886. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27887. useOctreeForRenderingSelection: boolean;
  27888. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27889. useOctreeForPicking: boolean;
  27890. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27891. useOctreeForCollisions: boolean;
  27892. /**
  27893. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27894. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27895. */
  27896. get layerMask(): number;
  27897. set layerMask(value: number);
  27898. /**
  27899. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27900. */
  27901. alwaysSelectAsActiveMesh: boolean;
  27902. /**
  27903. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27904. */
  27905. doNotSyncBoundingInfo: boolean;
  27906. /**
  27907. * Gets or sets the current action manager
  27908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27909. */
  27910. actionManager: Nullable<AbstractActionManager>;
  27911. private _meshCollisionData;
  27912. /**
  27913. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27914. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27915. */
  27916. ellipsoid: Vector3;
  27917. /**
  27918. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27919. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27920. */
  27921. ellipsoidOffset: Vector3;
  27922. /**
  27923. * Gets or sets a collision mask used to mask collisions (default is -1).
  27924. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27925. */
  27926. get collisionMask(): number;
  27927. set collisionMask(mask: number);
  27928. /**
  27929. * Gets or sets the current collision group mask (-1 by default).
  27930. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27931. */
  27932. get collisionGroup(): number;
  27933. set collisionGroup(mask: number);
  27934. /**
  27935. * Defines edge width used when edgesRenderer is enabled
  27936. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27937. */
  27938. edgesWidth: number;
  27939. /**
  27940. * Defines edge color used when edgesRenderer is enabled
  27941. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27942. */
  27943. edgesColor: Color4;
  27944. /** @hidden */
  27945. _edgesRenderer: Nullable<IEdgesRenderer>;
  27946. /** @hidden */
  27947. _masterMesh: Nullable<AbstractMesh>;
  27948. /** @hidden */
  27949. _boundingInfo: Nullable<BoundingInfo>;
  27950. /** @hidden */
  27951. _renderId: number;
  27952. /**
  27953. * Gets or sets the list of subMeshes
  27954. * @see http://doc.babylonjs.com/how_to/multi_materials
  27955. */
  27956. subMeshes: SubMesh[];
  27957. /** @hidden */
  27958. _intersectionsInProgress: AbstractMesh[];
  27959. /** @hidden */
  27960. _unIndexed: boolean;
  27961. /** @hidden */
  27962. _lightSources: Light[];
  27963. /** Gets the list of lights affecting that mesh */
  27964. get lightSources(): Light[];
  27965. /** @hidden */
  27966. get _positions(): Nullable<Vector3[]>;
  27967. /** @hidden */
  27968. _waitingData: {
  27969. lods: Nullable<any>;
  27970. actions: Nullable<any>;
  27971. freezeWorldMatrix: Nullable<boolean>;
  27972. };
  27973. /** @hidden */
  27974. _bonesTransformMatrices: Nullable<Float32Array>;
  27975. /** @hidden */
  27976. _transformMatrixTexture: Nullable<RawTexture>;
  27977. /**
  27978. * Gets or sets a skeleton to apply skining transformations
  27979. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27980. */
  27981. set skeleton(value: Nullable<Skeleton>);
  27982. get skeleton(): Nullable<Skeleton>;
  27983. /**
  27984. * An event triggered when the mesh is rebuilt.
  27985. */
  27986. onRebuildObservable: Observable<AbstractMesh>;
  27987. /**
  27988. * Creates a new AbstractMesh
  27989. * @param name defines the name of the mesh
  27990. * @param scene defines the hosting scene
  27991. */
  27992. constructor(name: string, scene?: Nullable<Scene>);
  27993. /**
  27994. * Returns the string "AbstractMesh"
  27995. * @returns "AbstractMesh"
  27996. */
  27997. getClassName(): string;
  27998. /**
  27999. * Gets a string representation of the current mesh
  28000. * @param fullDetails defines a boolean indicating if full details must be included
  28001. * @returns a string representation of the current mesh
  28002. */
  28003. toString(fullDetails?: boolean): string;
  28004. /**
  28005. * @hidden
  28006. */
  28007. protected _getEffectiveParent(): Nullable<Node>;
  28008. /** @hidden */
  28009. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28010. /** @hidden */
  28011. _rebuild(): void;
  28012. /** @hidden */
  28013. _resyncLightSources(): void;
  28014. /** @hidden */
  28015. _resyncLightSource(light: Light): void;
  28016. /** @hidden */
  28017. _unBindEffect(): void;
  28018. /** @hidden */
  28019. _removeLightSource(light: Light, dispose: boolean): void;
  28020. private _markSubMeshesAsDirty;
  28021. /** @hidden */
  28022. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28023. /** @hidden */
  28024. _markSubMeshesAsAttributesDirty(): void;
  28025. /** @hidden */
  28026. _markSubMeshesAsMiscDirty(): void;
  28027. /**
  28028. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28029. */
  28030. get scaling(): Vector3;
  28031. set scaling(newScaling: Vector3);
  28032. /**
  28033. * Returns true if the mesh is blocked. Implemented by child classes
  28034. */
  28035. get isBlocked(): boolean;
  28036. /**
  28037. * Returns the mesh itself by default. Implemented by child classes
  28038. * @param camera defines the camera to use to pick the right LOD level
  28039. * @returns the currentAbstractMesh
  28040. */
  28041. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28042. /**
  28043. * Returns 0 by default. Implemented by child classes
  28044. * @returns an integer
  28045. */
  28046. getTotalVertices(): number;
  28047. /**
  28048. * Returns a positive integer : the total number of indices in this mesh geometry.
  28049. * @returns the numner of indices or zero if the mesh has no geometry.
  28050. */
  28051. getTotalIndices(): number;
  28052. /**
  28053. * Returns null by default. Implemented by child classes
  28054. * @returns null
  28055. */
  28056. getIndices(): Nullable<IndicesArray>;
  28057. /**
  28058. * Returns the array of the requested vertex data kind. Implemented by child classes
  28059. * @param kind defines the vertex data kind to use
  28060. * @returns null
  28061. */
  28062. getVerticesData(kind: string): Nullable<FloatArray>;
  28063. /**
  28064. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28065. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28066. * Note that a new underlying VertexBuffer object is created each call.
  28067. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28068. * @param kind defines vertex data kind:
  28069. * * VertexBuffer.PositionKind
  28070. * * VertexBuffer.UVKind
  28071. * * VertexBuffer.UV2Kind
  28072. * * VertexBuffer.UV3Kind
  28073. * * VertexBuffer.UV4Kind
  28074. * * VertexBuffer.UV5Kind
  28075. * * VertexBuffer.UV6Kind
  28076. * * VertexBuffer.ColorKind
  28077. * * VertexBuffer.MatricesIndicesKind
  28078. * * VertexBuffer.MatricesIndicesExtraKind
  28079. * * VertexBuffer.MatricesWeightsKind
  28080. * * VertexBuffer.MatricesWeightsExtraKind
  28081. * @param data defines the data source
  28082. * @param updatable defines if the data must be flagged as updatable (or static)
  28083. * @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
  28084. * @returns the current mesh
  28085. */
  28086. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28087. /**
  28088. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28089. * If the mesh has no geometry, it is simply returned as it is.
  28090. * @param kind defines vertex data kind:
  28091. * * VertexBuffer.PositionKind
  28092. * * VertexBuffer.UVKind
  28093. * * VertexBuffer.UV2Kind
  28094. * * VertexBuffer.UV3Kind
  28095. * * VertexBuffer.UV4Kind
  28096. * * VertexBuffer.UV5Kind
  28097. * * VertexBuffer.UV6Kind
  28098. * * VertexBuffer.ColorKind
  28099. * * VertexBuffer.MatricesIndicesKind
  28100. * * VertexBuffer.MatricesIndicesExtraKind
  28101. * * VertexBuffer.MatricesWeightsKind
  28102. * * VertexBuffer.MatricesWeightsExtraKind
  28103. * @param data defines the data source
  28104. * @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
  28105. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28106. * @returns the current mesh
  28107. */
  28108. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28109. /**
  28110. * Sets the mesh indices,
  28111. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28112. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28113. * @param totalVertices Defines the total number of vertices
  28114. * @returns the current mesh
  28115. */
  28116. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28117. /**
  28118. * Gets a boolean indicating if specific vertex data is present
  28119. * @param kind defines the vertex data kind to use
  28120. * @returns true is data kind is present
  28121. */
  28122. isVerticesDataPresent(kind: string): boolean;
  28123. /**
  28124. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28125. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28126. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28127. * @returns a BoundingInfo
  28128. */
  28129. getBoundingInfo(): BoundingInfo;
  28130. /**
  28131. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28132. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28133. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28134. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28135. * @returns the current mesh
  28136. */
  28137. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28138. /**
  28139. * Overwrite the current bounding info
  28140. * @param boundingInfo defines the new bounding info
  28141. * @returns the current mesh
  28142. */
  28143. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28144. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28145. get useBones(): boolean;
  28146. /** @hidden */
  28147. _preActivate(): void;
  28148. /** @hidden */
  28149. _preActivateForIntermediateRendering(renderId: number): void;
  28150. /** @hidden */
  28151. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28152. /** @hidden */
  28153. _postActivate(): void;
  28154. /** @hidden */
  28155. _freeze(): void;
  28156. /** @hidden */
  28157. _unFreeze(): void;
  28158. /**
  28159. * Gets the current world matrix
  28160. * @returns a Matrix
  28161. */
  28162. getWorldMatrix(): Matrix;
  28163. /** @hidden */
  28164. _getWorldMatrixDeterminant(): number;
  28165. /**
  28166. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28167. */
  28168. get isAnInstance(): boolean;
  28169. /**
  28170. * Gets a boolean indicating if this mesh has instances
  28171. */
  28172. get hasInstances(): boolean;
  28173. /**
  28174. * Perform relative position change from the point of view of behind the front of the mesh.
  28175. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28176. * Supports definition of mesh facing forward or backward
  28177. * @param amountRight defines the distance on the right axis
  28178. * @param amountUp defines the distance on the up axis
  28179. * @param amountForward defines the distance on the forward axis
  28180. * @returns the current mesh
  28181. */
  28182. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28183. /**
  28184. * Calculate relative position change from the point of view of behind the front of the mesh.
  28185. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28186. * Supports definition of mesh facing forward or backward
  28187. * @param amountRight defines the distance on the right axis
  28188. * @param amountUp defines the distance on the up axis
  28189. * @param amountForward defines the distance on the forward axis
  28190. * @returns the new displacement vector
  28191. */
  28192. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28193. /**
  28194. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28195. * Supports definition of mesh facing forward or backward
  28196. * @param flipBack defines the flip
  28197. * @param twirlClockwise defines the twirl
  28198. * @param tiltRight defines the tilt
  28199. * @returns the current mesh
  28200. */
  28201. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28202. /**
  28203. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28204. * Supports definition of mesh facing forward or backward.
  28205. * @param flipBack defines the flip
  28206. * @param twirlClockwise defines the twirl
  28207. * @param tiltRight defines the tilt
  28208. * @returns the new rotation vector
  28209. */
  28210. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28211. /**
  28212. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28213. * This means the mesh underlying bounding box and sphere are recomputed.
  28214. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28215. * @returns the current mesh
  28216. */
  28217. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28218. /** @hidden */
  28219. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28220. /** @hidden */
  28221. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28222. /** @hidden */
  28223. _updateBoundingInfo(): AbstractMesh;
  28224. /** @hidden */
  28225. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28226. /** @hidden */
  28227. protected _afterComputeWorldMatrix(): void;
  28228. /** @hidden */
  28229. get _effectiveMesh(): AbstractMesh;
  28230. /**
  28231. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28232. * A mesh is in the frustum if its bounding box intersects the frustum
  28233. * @param frustumPlanes defines the frustum to test
  28234. * @returns true if the mesh is in the frustum planes
  28235. */
  28236. isInFrustum(frustumPlanes: Plane[]): boolean;
  28237. /**
  28238. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28239. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28240. * @param frustumPlanes defines the frustum to test
  28241. * @returns true if the mesh is completely in the frustum planes
  28242. */
  28243. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28244. /**
  28245. * True if the mesh intersects another mesh or a SolidParticle object
  28246. * @param mesh defines a target mesh or SolidParticle to test
  28247. * @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)
  28248. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28249. * @returns true if there is an intersection
  28250. */
  28251. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28252. /**
  28253. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28254. * @param point defines the point to test
  28255. * @returns true if there is an intersection
  28256. */
  28257. intersectsPoint(point: Vector3): boolean;
  28258. /**
  28259. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28260. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28261. */
  28262. get checkCollisions(): boolean;
  28263. set checkCollisions(collisionEnabled: boolean);
  28264. /**
  28265. * Gets Collider object used to compute collisions (not physics)
  28266. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28267. */
  28268. get collider(): Nullable<Collider>;
  28269. /**
  28270. * Move the mesh using collision engine
  28271. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28272. * @param displacement defines the requested displacement vector
  28273. * @returns the current mesh
  28274. */
  28275. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28276. private _onCollisionPositionChange;
  28277. /** @hidden */
  28278. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28279. /** @hidden */
  28280. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28281. /** @hidden */
  28282. _checkCollision(collider: Collider): AbstractMesh;
  28283. /** @hidden */
  28284. _generatePointsArray(): boolean;
  28285. /**
  28286. * Checks if the passed Ray intersects with the mesh
  28287. * @param ray defines the ray to use
  28288. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28289. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28290. * @returns the picking info
  28291. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28292. */
  28293. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28294. /**
  28295. * Clones the current mesh
  28296. * @param name defines the mesh name
  28297. * @param newParent defines the new mesh parent
  28298. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28299. * @returns the new mesh
  28300. */
  28301. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28302. /**
  28303. * Disposes all the submeshes of the current meshnp
  28304. * @returns the current mesh
  28305. */
  28306. releaseSubMeshes(): AbstractMesh;
  28307. /**
  28308. * Releases resources associated with this abstract mesh.
  28309. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28310. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28311. */
  28312. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28313. /**
  28314. * Adds the passed mesh as a child to the current mesh
  28315. * @param mesh defines the child mesh
  28316. * @returns the current mesh
  28317. */
  28318. addChild(mesh: AbstractMesh): AbstractMesh;
  28319. /**
  28320. * Removes the passed mesh from the current mesh children list
  28321. * @param mesh defines the child mesh
  28322. * @returns the current mesh
  28323. */
  28324. removeChild(mesh: AbstractMesh): AbstractMesh;
  28325. /** @hidden */
  28326. private _initFacetData;
  28327. /**
  28328. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28329. * This method can be called within the render loop.
  28330. * 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
  28331. * @returns the current mesh
  28332. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28333. */
  28334. updateFacetData(): AbstractMesh;
  28335. /**
  28336. * Returns the facetLocalNormals array.
  28337. * The normals are expressed in the mesh local spac
  28338. * @returns an array of Vector3
  28339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28340. */
  28341. getFacetLocalNormals(): Vector3[];
  28342. /**
  28343. * Returns the facetLocalPositions array.
  28344. * The facet positions are expressed in the mesh local space
  28345. * @returns an array of Vector3
  28346. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28347. */
  28348. getFacetLocalPositions(): Vector3[];
  28349. /**
  28350. * Returns the facetLocalPartioning array
  28351. * @returns an array of array of numbers
  28352. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28353. */
  28354. getFacetLocalPartitioning(): number[][];
  28355. /**
  28356. * Returns the i-th facet position in the world system.
  28357. * This method allocates a new Vector3 per call
  28358. * @param i defines the facet index
  28359. * @returns a new Vector3
  28360. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28361. */
  28362. getFacetPosition(i: number): Vector3;
  28363. /**
  28364. * Sets the reference Vector3 with the i-th facet position in the world system
  28365. * @param i defines the facet index
  28366. * @param ref defines the target vector
  28367. * @returns the current mesh
  28368. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28369. */
  28370. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28371. /**
  28372. * Returns the i-th facet normal in the world system.
  28373. * This method allocates a new Vector3 per call
  28374. * @param i defines the facet index
  28375. * @returns a new Vector3
  28376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28377. */
  28378. getFacetNormal(i: number): Vector3;
  28379. /**
  28380. * Sets the reference Vector3 with the i-th facet normal in the world system
  28381. * @param i defines the facet index
  28382. * @param ref defines the target vector
  28383. * @returns the current mesh
  28384. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28385. */
  28386. getFacetNormalToRef(i: number, ref: Vector3): this;
  28387. /**
  28388. * 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)
  28389. * @param x defines x coordinate
  28390. * @param y defines y coordinate
  28391. * @param z defines z coordinate
  28392. * @returns the array of facet indexes
  28393. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28394. */
  28395. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28396. /**
  28397. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28398. * @param projected sets as the (x,y,z) world projection on the facet
  28399. * @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
  28400. * @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
  28401. * @param x defines x coordinate
  28402. * @param y defines y coordinate
  28403. * @param z defines z coordinate
  28404. * @returns the face index if found (or null instead)
  28405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28406. */
  28407. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28408. /**
  28409. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28410. * @param projected sets as the (x,y,z) local projection on the facet
  28411. * @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
  28412. * @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
  28413. * @param x defines x coordinate
  28414. * @param y defines y coordinate
  28415. * @param z defines z coordinate
  28416. * @returns the face index if found (or null instead)
  28417. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28418. */
  28419. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28420. /**
  28421. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28422. * @returns the parameters
  28423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28424. */
  28425. getFacetDataParameters(): any;
  28426. /**
  28427. * Disables the feature FacetData and frees the related memory
  28428. * @returns the current mesh
  28429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28430. */
  28431. disableFacetData(): AbstractMesh;
  28432. /**
  28433. * Updates the AbstractMesh indices array
  28434. * @param indices defines the data source
  28435. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28436. * @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)
  28437. * @returns the current mesh
  28438. */
  28439. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28440. /**
  28441. * Creates new normals data for the mesh
  28442. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28443. * @returns the current mesh
  28444. */
  28445. createNormals(updatable: boolean): AbstractMesh;
  28446. /**
  28447. * Align the mesh with a normal
  28448. * @param normal defines the normal to use
  28449. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28450. * @returns the current mesh
  28451. */
  28452. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28453. /** @hidden */
  28454. _checkOcclusionQuery(): boolean;
  28455. /**
  28456. * Disables the mesh edge rendering mode
  28457. * @returns the currentAbstractMesh
  28458. */
  28459. disableEdgesRendering(): AbstractMesh;
  28460. /**
  28461. * Enables the edge rendering mode on the mesh.
  28462. * This mode makes the mesh edges visible
  28463. * @param epsilon defines the maximal distance between two angles to detect a face
  28464. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28465. * @returns the currentAbstractMesh
  28466. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28467. */
  28468. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28469. }
  28470. }
  28471. declare module BABYLON {
  28472. /**
  28473. * Interface used to define ActionEvent
  28474. */
  28475. export interface IActionEvent {
  28476. /** The mesh or sprite that triggered the action */
  28477. source: any;
  28478. /** The X mouse cursor position at the time of the event */
  28479. pointerX: number;
  28480. /** The Y mouse cursor position at the time of the event */
  28481. pointerY: number;
  28482. /** The mesh that is currently pointed at (can be null) */
  28483. meshUnderPointer: Nullable<AbstractMesh>;
  28484. /** the original (browser) event that triggered the ActionEvent */
  28485. sourceEvent?: any;
  28486. /** additional data for the event */
  28487. additionalData?: any;
  28488. }
  28489. /**
  28490. * ActionEvent is the event being sent when an action is triggered.
  28491. */
  28492. export class ActionEvent implements IActionEvent {
  28493. /** The mesh or sprite that triggered the action */
  28494. source: any;
  28495. /** The X mouse cursor position at the time of the event */
  28496. pointerX: number;
  28497. /** The Y mouse cursor position at the time of the event */
  28498. pointerY: number;
  28499. /** The mesh that is currently pointed at (can be null) */
  28500. meshUnderPointer: Nullable<AbstractMesh>;
  28501. /** the original (browser) event that triggered the ActionEvent */
  28502. sourceEvent?: any;
  28503. /** additional data for the event */
  28504. additionalData?: any;
  28505. /**
  28506. * Creates a new ActionEvent
  28507. * @param source The mesh or sprite that triggered the action
  28508. * @param pointerX The X mouse cursor position at the time of the event
  28509. * @param pointerY The Y mouse cursor position at the time of the event
  28510. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28511. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28512. * @param additionalData additional data for the event
  28513. */
  28514. constructor(
  28515. /** The mesh or sprite that triggered the action */
  28516. source: any,
  28517. /** The X mouse cursor position at the time of the event */
  28518. pointerX: number,
  28519. /** The Y mouse cursor position at the time of the event */
  28520. pointerY: number,
  28521. /** The mesh that is currently pointed at (can be null) */
  28522. meshUnderPointer: Nullable<AbstractMesh>,
  28523. /** the original (browser) event that triggered the ActionEvent */
  28524. sourceEvent?: any,
  28525. /** additional data for the event */
  28526. additionalData?: any);
  28527. /**
  28528. * Helper function to auto-create an ActionEvent from a source mesh.
  28529. * @param source The source mesh that triggered the event
  28530. * @param evt The original (browser) event
  28531. * @param additionalData additional data for the event
  28532. * @returns the new ActionEvent
  28533. */
  28534. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28535. /**
  28536. * Helper function to auto-create an ActionEvent from a source sprite
  28537. * @param source The source sprite that triggered the event
  28538. * @param scene Scene associated with the sprite
  28539. * @param evt The original (browser) event
  28540. * @param additionalData additional data for the event
  28541. * @returns the new ActionEvent
  28542. */
  28543. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28544. /**
  28545. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28546. * @param scene the scene where the event occurred
  28547. * @param evt The original (browser) event
  28548. * @returns the new ActionEvent
  28549. */
  28550. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28551. /**
  28552. * Helper function to auto-create an ActionEvent from a primitive
  28553. * @param prim defines the target primitive
  28554. * @param pointerPos defines the pointer position
  28555. * @param evt The original (browser) event
  28556. * @param additionalData additional data for the event
  28557. * @returns the new ActionEvent
  28558. */
  28559. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28560. }
  28561. }
  28562. declare module BABYLON {
  28563. /**
  28564. * Abstract class used to decouple action Manager from scene and meshes.
  28565. * Do not instantiate.
  28566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28567. */
  28568. export abstract class AbstractActionManager implements IDisposable {
  28569. /** Gets the list of active triggers */
  28570. static Triggers: {
  28571. [key: string]: number;
  28572. };
  28573. /** Gets the cursor to use when hovering items */
  28574. hoverCursor: string;
  28575. /** Gets the list of actions */
  28576. actions: IAction[];
  28577. /**
  28578. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28579. */
  28580. isRecursive: boolean;
  28581. /**
  28582. * Releases all associated resources
  28583. */
  28584. abstract dispose(): void;
  28585. /**
  28586. * Does this action manager has pointer triggers
  28587. */
  28588. abstract get hasPointerTriggers(): boolean;
  28589. /**
  28590. * Does this action manager has pick triggers
  28591. */
  28592. abstract get hasPickTriggers(): boolean;
  28593. /**
  28594. * Process a specific trigger
  28595. * @param trigger defines the trigger to process
  28596. * @param evt defines the event details to be processed
  28597. */
  28598. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28599. /**
  28600. * Does this action manager handles actions of any of the given triggers
  28601. * @param triggers defines the triggers to be tested
  28602. * @return a boolean indicating whether one (or more) of the triggers is handled
  28603. */
  28604. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28605. /**
  28606. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28607. * speed.
  28608. * @param triggerA defines the trigger to be tested
  28609. * @param triggerB defines the trigger to be tested
  28610. * @return a boolean indicating whether one (or more) of the triggers is handled
  28611. */
  28612. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28613. /**
  28614. * Does this action manager handles actions of a given trigger
  28615. * @param trigger defines the trigger to be tested
  28616. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28617. * @return whether the trigger is handled
  28618. */
  28619. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28620. /**
  28621. * Serialize this manager to a JSON object
  28622. * @param name defines the property name to store this manager
  28623. * @returns a JSON representation of this manager
  28624. */
  28625. abstract serialize(name: string): any;
  28626. /**
  28627. * Registers an action to this action manager
  28628. * @param action defines the action to be registered
  28629. * @return the action amended (prepared) after registration
  28630. */
  28631. abstract registerAction(action: IAction): Nullable<IAction>;
  28632. /**
  28633. * Unregisters an action to this action manager
  28634. * @param action defines the action to be unregistered
  28635. * @return a boolean indicating whether the action has been unregistered
  28636. */
  28637. abstract unregisterAction(action: IAction): Boolean;
  28638. /**
  28639. * Does exist one action manager with at least one trigger
  28640. **/
  28641. static get HasTriggers(): boolean;
  28642. /**
  28643. * Does exist one action manager with at least one pick trigger
  28644. **/
  28645. static get HasPickTriggers(): boolean;
  28646. /**
  28647. * Does exist one action manager that handles actions of a given trigger
  28648. * @param trigger defines the trigger to be tested
  28649. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28650. **/
  28651. static HasSpecificTrigger(trigger: number): boolean;
  28652. }
  28653. }
  28654. declare module BABYLON {
  28655. /**
  28656. * Defines how a node can be built from a string name.
  28657. */
  28658. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28659. /**
  28660. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28661. */
  28662. export class Node implements IBehaviorAware<Node> {
  28663. /** @hidden */
  28664. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28665. private static _NodeConstructors;
  28666. /**
  28667. * Add a new node constructor
  28668. * @param type defines the type name of the node to construct
  28669. * @param constructorFunc defines the constructor function
  28670. */
  28671. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28672. /**
  28673. * Returns a node constructor based on type name
  28674. * @param type defines the type name
  28675. * @param name defines the new node name
  28676. * @param scene defines the hosting scene
  28677. * @param options defines optional options to transmit to constructors
  28678. * @returns the new constructor or null
  28679. */
  28680. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28681. /**
  28682. * Gets or sets the name of the node
  28683. */
  28684. name: string;
  28685. /**
  28686. * Gets or sets the id of the node
  28687. */
  28688. id: string;
  28689. /**
  28690. * Gets or sets the unique id of the node
  28691. */
  28692. uniqueId: number;
  28693. /**
  28694. * Gets or sets a string used to store user defined state for the node
  28695. */
  28696. state: string;
  28697. /**
  28698. * Gets or sets an object used to store user defined information for the node
  28699. */
  28700. metadata: any;
  28701. /**
  28702. * For internal use only. Please do not use.
  28703. */
  28704. reservedDataStore: any;
  28705. /**
  28706. * List of inspectable custom properties (used by the Inspector)
  28707. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28708. */
  28709. inspectableCustomProperties: IInspectable[];
  28710. private _doNotSerialize;
  28711. /**
  28712. * Gets or sets a boolean used to define if the node must be serialized
  28713. */
  28714. get doNotSerialize(): boolean;
  28715. set doNotSerialize(value: boolean);
  28716. /** @hidden */
  28717. _isDisposed: boolean;
  28718. /**
  28719. * Gets a list of Animations associated with the node
  28720. */
  28721. animations: Animation[];
  28722. protected _ranges: {
  28723. [name: string]: Nullable<AnimationRange>;
  28724. };
  28725. /**
  28726. * Callback raised when the node is ready to be used
  28727. */
  28728. onReady: Nullable<(node: Node) => void>;
  28729. private _isEnabled;
  28730. private _isParentEnabled;
  28731. private _isReady;
  28732. /** @hidden */
  28733. _currentRenderId: number;
  28734. private _parentUpdateId;
  28735. /** @hidden */
  28736. _childUpdateId: number;
  28737. /** @hidden */
  28738. _waitingParentId: Nullable<string>;
  28739. /** @hidden */
  28740. _scene: Scene;
  28741. /** @hidden */
  28742. _cache: any;
  28743. private _parentNode;
  28744. private _children;
  28745. /** @hidden */
  28746. _worldMatrix: Matrix;
  28747. /** @hidden */
  28748. _worldMatrixDeterminant: number;
  28749. /** @hidden */
  28750. _worldMatrixDeterminantIsDirty: boolean;
  28751. /** @hidden */
  28752. private _sceneRootNodesIndex;
  28753. /**
  28754. * Gets a boolean indicating if the node has been disposed
  28755. * @returns true if the node was disposed
  28756. */
  28757. isDisposed(): boolean;
  28758. /**
  28759. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28760. * @see https://doc.babylonjs.com/how_to/parenting
  28761. */
  28762. set parent(parent: Nullable<Node>);
  28763. get parent(): Nullable<Node>;
  28764. /** @hidden */
  28765. _addToSceneRootNodes(): void;
  28766. /** @hidden */
  28767. _removeFromSceneRootNodes(): void;
  28768. private _animationPropertiesOverride;
  28769. /**
  28770. * Gets or sets the animation properties override
  28771. */
  28772. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28773. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28774. /**
  28775. * Gets a string idenfifying the name of the class
  28776. * @returns "Node" string
  28777. */
  28778. getClassName(): string;
  28779. /** @hidden */
  28780. readonly _isNode: boolean;
  28781. /**
  28782. * An event triggered when the mesh is disposed
  28783. */
  28784. onDisposeObservable: Observable<Node>;
  28785. private _onDisposeObserver;
  28786. /**
  28787. * Sets a callback that will be raised when the node will be disposed
  28788. */
  28789. set onDispose(callback: () => void);
  28790. /**
  28791. * Creates a new Node
  28792. * @param name the name and id to be given to this node
  28793. * @param scene the scene this node will be added to
  28794. */
  28795. constructor(name: string, scene?: Nullable<Scene>);
  28796. /**
  28797. * Gets the scene of the node
  28798. * @returns a scene
  28799. */
  28800. getScene(): Scene;
  28801. /**
  28802. * Gets the engine of the node
  28803. * @returns a Engine
  28804. */
  28805. getEngine(): Engine;
  28806. private _behaviors;
  28807. /**
  28808. * Attach a behavior to the node
  28809. * @see http://doc.babylonjs.com/features/behaviour
  28810. * @param behavior defines the behavior to attach
  28811. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28812. * @returns the current Node
  28813. */
  28814. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28815. /**
  28816. * Remove an attached behavior
  28817. * @see http://doc.babylonjs.com/features/behaviour
  28818. * @param behavior defines the behavior to attach
  28819. * @returns the current Node
  28820. */
  28821. removeBehavior(behavior: Behavior<Node>): Node;
  28822. /**
  28823. * Gets the list of attached behaviors
  28824. * @see http://doc.babylonjs.com/features/behaviour
  28825. */
  28826. get behaviors(): Behavior<Node>[];
  28827. /**
  28828. * Gets an attached behavior by name
  28829. * @param name defines the name of the behavior to look for
  28830. * @see http://doc.babylonjs.com/features/behaviour
  28831. * @returns null if behavior was not found else the requested behavior
  28832. */
  28833. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28834. /**
  28835. * Returns the latest update of the World matrix
  28836. * @returns a Matrix
  28837. */
  28838. getWorldMatrix(): Matrix;
  28839. /** @hidden */
  28840. _getWorldMatrixDeterminant(): number;
  28841. /**
  28842. * Returns directly the latest state of the mesh World matrix.
  28843. * A Matrix is returned.
  28844. */
  28845. get worldMatrixFromCache(): Matrix;
  28846. /** @hidden */
  28847. _initCache(): void;
  28848. /** @hidden */
  28849. updateCache(force?: boolean): void;
  28850. /** @hidden */
  28851. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28852. /** @hidden */
  28853. _updateCache(ignoreParentClass?: boolean): void;
  28854. /** @hidden */
  28855. _isSynchronized(): boolean;
  28856. /** @hidden */
  28857. _markSyncedWithParent(): void;
  28858. /** @hidden */
  28859. isSynchronizedWithParent(): boolean;
  28860. /** @hidden */
  28861. isSynchronized(): boolean;
  28862. /**
  28863. * Is this node ready to be used/rendered
  28864. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28865. * @return true if the node is ready
  28866. */
  28867. isReady(completeCheck?: boolean): boolean;
  28868. /**
  28869. * Is this node enabled?
  28870. * 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
  28871. * @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
  28872. * @return whether this node (and its parent) is enabled
  28873. */
  28874. isEnabled(checkAncestors?: boolean): boolean;
  28875. /** @hidden */
  28876. protected _syncParentEnabledState(): void;
  28877. /**
  28878. * Set the enabled state of this node
  28879. * @param value defines the new enabled state
  28880. */
  28881. setEnabled(value: boolean): void;
  28882. /**
  28883. * Is this node a descendant of the given node?
  28884. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28885. * @param ancestor defines the parent node to inspect
  28886. * @returns a boolean indicating if this node is a descendant of the given node
  28887. */
  28888. isDescendantOf(ancestor: Node): boolean;
  28889. /** @hidden */
  28890. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28891. /**
  28892. * Will return all nodes that have this node as ascendant
  28893. * @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
  28894. * @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
  28895. * @return all children nodes of all types
  28896. */
  28897. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28898. /**
  28899. * Get all child-meshes of this node
  28900. * @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)
  28901. * @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
  28902. * @returns an array of AbstractMesh
  28903. */
  28904. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28905. /**
  28906. * Get all direct children of this node
  28907. * @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
  28908. * @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)
  28909. * @returns an array of Node
  28910. */
  28911. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28912. /** @hidden */
  28913. _setReady(state: boolean): void;
  28914. /**
  28915. * Get an animation by name
  28916. * @param name defines the name of the animation to look for
  28917. * @returns null if not found else the requested animation
  28918. */
  28919. getAnimationByName(name: string): Nullable<Animation>;
  28920. /**
  28921. * Creates an animation range for this node
  28922. * @param name defines the name of the range
  28923. * @param from defines the starting key
  28924. * @param to defines the end key
  28925. */
  28926. createAnimationRange(name: string, from: number, to: number): void;
  28927. /**
  28928. * Delete a specific animation range
  28929. * @param name defines the name of the range to delete
  28930. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28931. */
  28932. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28933. /**
  28934. * Get an animation range by name
  28935. * @param name defines the name of the animation range to look for
  28936. * @returns null if not found else the requested animation range
  28937. */
  28938. getAnimationRange(name: string): Nullable<AnimationRange>;
  28939. /**
  28940. * Gets the list of all animation ranges defined on this node
  28941. * @returns an array
  28942. */
  28943. getAnimationRanges(): Nullable<AnimationRange>[];
  28944. /**
  28945. * Will start the animation sequence
  28946. * @param name defines the range frames for animation sequence
  28947. * @param loop defines if the animation should loop (false by default)
  28948. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28949. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28950. * @returns the object created for this animation. If range does not exist, it will return null
  28951. */
  28952. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28953. /**
  28954. * Serialize animation ranges into a JSON compatible object
  28955. * @returns serialization object
  28956. */
  28957. serializeAnimationRanges(): any;
  28958. /**
  28959. * Computes the world matrix of the node
  28960. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28961. * @returns the world matrix
  28962. */
  28963. computeWorldMatrix(force?: boolean): Matrix;
  28964. /**
  28965. * Releases resources associated with this node.
  28966. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28967. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28968. */
  28969. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28970. /**
  28971. * Parse animation range data from a serialization object and store them into a given node
  28972. * @param node defines where to store the animation ranges
  28973. * @param parsedNode defines the serialization object to read data from
  28974. * @param scene defines the hosting scene
  28975. */
  28976. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28977. /**
  28978. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28979. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28980. * @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
  28981. * @returns the new bounding vectors
  28982. */
  28983. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28984. min: Vector3;
  28985. max: Vector3;
  28986. };
  28987. }
  28988. }
  28989. declare module BABYLON {
  28990. /**
  28991. * @hidden
  28992. */
  28993. export class _IAnimationState {
  28994. key: number;
  28995. repeatCount: number;
  28996. workValue?: any;
  28997. loopMode?: number;
  28998. offsetValue?: any;
  28999. highLimitValue?: any;
  29000. }
  29001. /**
  29002. * Class used to store any kind of animation
  29003. */
  29004. export class Animation {
  29005. /**Name of the animation */
  29006. name: string;
  29007. /**Property to animate */
  29008. targetProperty: string;
  29009. /**The frames per second of the animation */
  29010. framePerSecond: number;
  29011. /**The data type of the animation */
  29012. dataType: number;
  29013. /**The loop mode of the animation */
  29014. loopMode?: number | undefined;
  29015. /**Specifies if blending should be enabled */
  29016. enableBlending?: boolean | undefined;
  29017. /**
  29018. * Use matrix interpolation instead of using direct key value when animating matrices
  29019. */
  29020. static AllowMatricesInterpolation: boolean;
  29021. /**
  29022. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29023. */
  29024. static AllowMatrixDecomposeForInterpolation: boolean;
  29025. /**
  29026. * Stores the key frames of the animation
  29027. */
  29028. private _keys;
  29029. /**
  29030. * Stores the easing function of the animation
  29031. */
  29032. private _easingFunction;
  29033. /**
  29034. * @hidden Internal use only
  29035. */
  29036. _runtimeAnimations: RuntimeAnimation[];
  29037. /**
  29038. * The set of event that will be linked to this animation
  29039. */
  29040. private _events;
  29041. /**
  29042. * Stores an array of target property paths
  29043. */
  29044. targetPropertyPath: string[];
  29045. /**
  29046. * Stores the blending speed of the animation
  29047. */
  29048. blendingSpeed: number;
  29049. /**
  29050. * Stores the animation ranges for the animation
  29051. */
  29052. private _ranges;
  29053. /**
  29054. * @hidden Internal use
  29055. */
  29056. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29057. /**
  29058. * Sets up an animation
  29059. * @param property The property to animate
  29060. * @param animationType The animation type to apply
  29061. * @param framePerSecond The frames per second of the animation
  29062. * @param easingFunction The easing function used in the animation
  29063. * @returns The created animation
  29064. */
  29065. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29066. /**
  29067. * Create and start an animation on a node
  29068. * @param name defines the name of the global animation that will be run on all nodes
  29069. * @param node defines the root node where the animation will take place
  29070. * @param targetProperty defines property to animate
  29071. * @param framePerSecond defines the number of frame per second yo use
  29072. * @param totalFrame defines the number of frames in total
  29073. * @param from defines the initial value
  29074. * @param to defines the final value
  29075. * @param loopMode defines which loop mode you want to use (off by default)
  29076. * @param easingFunction defines the easing function to use (linear by default)
  29077. * @param onAnimationEnd defines the callback to call when animation end
  29078. * @returns the animatable created for this animation
  29079. */
  29080. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29081. /**
  29082. * Create and start an animation on a node and its descendants
  29083. * @param name defines the name of the global animation that will be run on all nodes
  29084. * @param node defines the root node where the animation will take place
  29085. * @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
  29086. * @param targetProperty defines property to animate
  29087. * @param framePerSecond defines the number of frame per second to use
  29088. * @param totalFrame defines the number of frames in total
  29089. * @param from defines the initial value
  29090. * @param to defines the final value
  29091. * @param loopMode defines which loop mode you want to use (off by default)
  29092. * @param easingFunction defines the easing function to use (linear by default)
  29093. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29094. * @returns the list of animatables created for all nodes
  29095. * @example https://www.babylonjs-playground.com/#MH0VLI
  29096. */
  29097. 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[]>;
  29098. /**
  29099. * Creates a new animation, merges it with the existing animations and starts it
  29100. * @param name Name of the animation
  29101. * @param node Node which contains the scene that begins the animations
  29102. * @param targetProperty Specifies which property to animate
  29103. * @param framePerSecond The frames per second of the animation
  29104. * @param totalFrame The total number of frames
  29105. * @param from The frame at the beginning of the animation
  29106. * @param to The frame at the end of the animation
  29107. * @param loopMode Specifies the loop mode of the animation
  29108. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29109. * @param onAnimationEnd Callback to run once the animation is complete
  29110. * @returns Nullable animation
  29111. */
  29112. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29113. /**
  29114. * Transition property of an host to the target Value
  29115. * @param property The property to transition
  29116. * @param targetValue The target Value of the property
  29117. * @param host The object where the property to animate belongs
  29118. * @param scene Scene used to run the animation
  29119. * @param frameRate Framerate (in frame/s) to use
  29120. * @param transition The transition type we want to use
  29121. * @param duration The duration of the animation, in milliseconds
  29122. * @param onAnimationEnd Callback trigger at the end of the animation
  29123. * @returns Nullable animation
  29124. */
  29125. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29126. /**
  29127. * Return the array of runtime animations currently using this animation
  29128. */
  29129. get runtimeAnimations(): RuntimeAnimation[];
  29130. /**
  29131. * Specifies if any of the runtime animations are currently running
  29132. */
  29133. get hasRunningRuntimeAnimations(): boolean;
  29134. /**
  29135. * Initializes the animation
  29136. * @param name Name of the animation
  29137. * @param targetProperty Property to animate
  29138. * @param framePerSecond The frames per second of the animation
  29139. * @param dataType The data type of the animation
  29140. * @param loopMode The loop mode of the animation
  29141. * @param enableBlending Specifies if blending should be enabled
  29142. */
  29143. constructor(
  29144. /**Name of the animation */
  29145. name: string,
  29146. /**Property to animate */
  29147. targetProperty: string,
  29148. /**The frames per second of the animation */
  29149. framePerSecond: number,
  29150. /**The data type of the animation */
  29151. dataType: number,
  29152. /**The loop mode of the animation */
  29153. loopMode?: number | undefined,
  29154. /**Specifies if blending should be enabled */
  29155. enableBlending?: boolean | undefined);
  29156. /**
  29157. * Converts the animation to a string
  29158. * @param fullDetails support for multiple levels of logging within scene loading
  29159. * @returns String form of the animation
  29160. */
  29161. toString(fullDetails?: boolean): string;
  29162. /**
  29163. * Add an event to this animation
  29164. * @param event Event to add
  29165. */
  29166. addEvent(event: AnimationEvent): void;
  29167. /**
  29168. * Remove all events found at the given frame
  29169. * @param frame The frame to remove events from
  29170. */
  29171. removeEvents(frame: number): void;
  29172. /**
  29173. * Retrieves all the events from the animation
  29174. * @returns Events from the animation
  29175. */
  29176. getEvents(): AnimationEvent[];
  29177. /**
  29178. * Creates an animation range
  29179. * @param name Name of the animation range
  29180. * @param from Starting frame of the animation range
  29181. * @param to Ending frame of the animation
  29182. */
  29183. createRange(name: string, from: number, to: number): void;
  29184. /**
  29185. * Deletes an animation range by name
  29186. * @param name Name of the animation range to delete
  29187. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29188. */
  29189. deleteRange(name: string, deleteFrames?: boolean): void;
  29190. /**
  29191. * Gets the animation range by name, or null if not defined
  29192. * @param name Name of the animation range
  29193. * @returns Nullable animation range
  29194. */
  29195. getRange(name: string): Nullable<AnimationRange>;
  29196. /**
  29197. * Gets the key frames from the animation
  29198. * @returns The key frames of the animation
  29199. */
  29200. getKeys(): Array<IAnimationKey>;
  29201. /**
  29202. * Gets the highest frame rate of the animation
  29203. * @returns Highest frame rate of the animation
  29204. */
  29205. getHighestFrame(): number;
  29206. /**
  29207. * Gets the easing function of the animation
  29208. * @returns Easing function of the animation
  29209. */
  29210. getEasingFunction(): IEasingFunction;
  29211. /**
  29212. * Sets the easing function of the animation
  29213. * @param easingFunction A custom mathematical formula for animation
  29214. */
  29215. setEasingFunction(easingFunction: EasingFunction): void;
  29216. /**
  29217. * Interpolates a scalar linearly
  29218. * @param startValue Start value of the animation curve
  29219. * @param endValue End value of the animation curve
  29220. * @param gradient Scalar amount to interpolate
  29221. * @returns Interpolated scalar value
  29222. */
  29223. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29224. /**
  29225. * Interpolates a scalar cubically
  29226. * @param startValue Start value of the animation curve
  29227. * @param outTangent End tangent of the animation
  29228. * @param endValue End value of the animation curve
  29229. * @param inTangent Start tangent of the animation curve
  29230. * @param gradient Scalar amount to interpolate
  29231. * @returns Interpolated scalar value
  29232. */
  29233. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29234. /**
  29235. * Interpolates a quaternion using a spherical linear interpolation
  29236. * @param startValue Start value of the animation curve
  29237. * @param endValue End value of the animation curve
  29238. * @param gradient Scalar amount to interpolate
  29239. * @returns Interpolated quaternion value
  29240. */
  29241. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29242. /**
  29243. * Interpolates a quaternion cubically
  29244. * @param startValue Start value of the animation curve
  29245. * @param outTangent End tangent of the animation curve
  29246. * @param endValue End value of the animation curve
  29247. * @param inTangent Start tangent of the animation curve
  29248. * @param gradient Scalar amount to interpolate
  29249. * @returns Interpolated quaternion value
  29250. */
  29251. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29252. /**
  29253. * Interpolates a Vector3 linearl
  29254. * @param startValue Start value of the animation curve
  29255. * @param endValue End value of the animation curve
  29256. * @param gradient Scalar amount to interpolate
  29257. * @returns Interpolated scalar value
  29258. */
  29259. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29260. /**
  29261. * Interpolates a Vector3 cubically
  29262. * @param startValue Start value of the animation curve
  29263. * @param outTangent End tangent of the animation
  29264. * @param endValue End value of the animation curve
  29265. * @param inTangent Start tangent of the animation curve
  29266. * @param gradient Scalar amount to interpolate
  29267. * @returns InterpolatedVector3 value
  29268. */
  29269. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29270. /**
  29271. * Interpolates a Vector2 linearly
  29272. * @param startValue Start value of the animation curve
  29273. * @param endValue End value of the animation curve
  29274. * @param gradient Scalar amount to interpolate
  29275. * @returns Interpolated Vector2 value
  29276. */
  29277. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29278. /**
  29279. * Interpolates a Vector2 cubically
  29280. * @param startValue Start value of the animation curve
  29281. * @param outTangent End tangent of the animation
  29282. * @param endValue End value of the animation curve
  29283. * @param inTangent Start tangent of the animation curve
  29284. * @param gradient Scalar amount to interpolate
  29285. * @returns Interpolated Vector2 value
  29286. */
  29287. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29288. /**
  29289. * Interpolates a size linearly
  29290. * @param startValue Start value of the animation curve
  29291. * @param endValue End value of the animation curve
  29292. * @param gradient Scalar amount to interpolate
  29293. * @returns Interpolated Size value
  29294. */
  29295. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29296. /**
  29297. * Interpolates a Color3 linearly
  29298. * @param startValue Start value of the animation curve
  29299. * @param endValue End value of the animation curve
  29300. * @param gradient Scalar amount to interpolate
  29301. * @returns Interpolated Color3 value
  29302. */
  29303. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29304. /**
  29305. * Interpolates a Color4 linearly
  29306. * @param startValue Start value of the animation curve
  29307. * @param endValue End value of the animation curve
  29308. * @param gradient Scalar amount to interpolate
  29309. * @returns Interpolated Color3 value
  29310. */
  29311. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29312. /**
  29313. * @hidden Internal use only
  29314. */
  29315. _getKeyValue(value: any): any;
  29316. /**
  29317. * @hidden Internal use only
  29318. */
  29319. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29320. /**
  29321. * Defines the function to use to interpolate matrices
  29322. * @param startValue defines the start matrix
  29323. * @param endValue defines the end matrix
  29324. * @param gradient defines the gradient between both matrices
  29325. * @param result defines an optional target matrix where to store the interpolation
  29326. * @returns the interpolated matrix
  29327. */
  29328. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29329. /**
  29330. * Makes a copy of the animation
  29331. * @returns Cloned animation
  29332. */
  29333. clone(): Animation;
  29334. /**
  29335. * Sets the key frames of the animation
  29336. * @param values The animation key frames to set
  29337. */
  29338. setKeys(values: Array<IAnimationKey>): void;
  29339. /**
  29340. * Serializes the animation to an object
  29341. * @returns Serialized object
  29342. */
  29343. serialize(): any;
  29344. /**
  29345. * Float animation type
  29346. */
  29347. static readonly ANIMATIONTYPE_FLOAT: number;
  29348. /**
  29349. * Vector3 animation type
  29350. */
  29351. static readonly ANIMATIONTYPE_VECTOR3: number;
  29352. /**
  29353. * Quaternion animation type
  29354. */
  29355. static readonly ANIMATIONTYPE_QUATERNION: number;
  29356. /**
  29357. * Matrix animation type
  29358. */
  29359. static readonly ANIMATIONTYPE_MATRIX: number;
  29360. /**
  29361. * Color3 animation type
  29362. */
  29363. static readonly ANIMATIONTYPE_COLOR3: number;
  29364. /**
  29365. * Color3 animation type
  29366. */
  29367. static readonly ANIMATIONTYPE_COLOR4: number;
  29368. /**
  29369. * Vector2 animation type
  29370. */
  29371. static readonly ANIMATIONTYPE_VECTOR2: number;
  29372. /**
  29373. * Size animation type
  29374. */
  29375. static readonly ANIMATIONTYPE_SIZE: number;
  29376. /**
  29377. * Relative Loop Mode
  29378. */
  29379. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29380. /**
  29381. * Cycle Loop Mode
  29382. */
  29383. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29384. /**
  29385. * Constant Loop Mode
  29386. */
  29387. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29388. /** @hidden */
  29389. static _UniversalLerp(left: any, right: any, amount: number): any;
  29390. /**
  29391. * Parses an animation object and creates an animation
  29392. * @param parsedAnimation Parsed animation object
  29393. * @returns Animation object
  29394. */
  29395. static Parse(parsedAnimation: any): Animation;
  29396. /**
  29397. * Appends the serialized animations from the source animations
  29398. * @param source Source containing the animations
  29399. * @param destination Target to store the animations
  29400. */
  29401. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29402. }
  29403. }
  29404. declare module BABYLON {
  29405. /**
  29406. * Interface containing an array of animations
  29407. */
  29408. export interface IAnimatable {
  29409. /**
  29410. * Array of animations
  29411. */
  29412. animations: Nullable<Array<Animation>>;
  29413. }
  29414. }
  29415. declare module BABYLON {
  29416. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29417. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29418. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29419. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29420. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29421. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29422. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29423. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29424. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29425. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29426. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29427. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29428. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29429. /**
  29430. * Decorator used to define property that can be serialized as reference to a camera
  29431. * @param sourceName defines the name of the property to decorate
  29432. */
  29433. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29434. /**
  29435. * Class used to help serialization objects
  29436. */
  29437. export class SerializationHelper {
  29438. /** @hidden */
  29439. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29440. /** @hidden */
  29441. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29442. /** @hidden */
  29443. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29444. /** @hidden */
  29445. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29446. /**
  29447. * Appends the serialized animations from the source animations
  29448. * @param source Source containing the animations
  29449. * @param destination Target to store the animations
  29450. */
  29451. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29452. /**
  29453. * Static function used to serialized a specific entity
  29454. * @param entity defines the entity to serialize
  29455. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29456. * @returns a JSON compatible object representing the serialization of the entity
  29457. */
  29458. static Serialize<T>(entity: T, serializationObject?: any): any;
  29459. /**
  29460. * Creates a new entity from a serialization data object
  29461. * @param creationFunction defines a function used to instanciated the new entity
  29462. * @param source defines the source serialization data
  29463. * @param scene defines the hosting scene
  29464. * @param rootUrl defines the root url for resources
  29465. * @returns a new entity
  29466. */
  29467. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29468. /**
  29469. * Clones an object
  29470. * @param creationFunction defines the function used to instanciate the new object
  29471. * @param source defines the source object
  29472. * @returns the cloned object
  29473. */
  29474. static Clone<T>(creationFunction: () => T, source: T): T;
  29475. /**
  29476. * Instanciates a new object based on a source one (some data will be shared between both object)
  29477. * @param creationFunction defines the function used to instanciate the new object
  29478. * @param source defines the source object
  29479. * @returns the new object
  29480. */
  29481. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29482. }
  29483. }
  29484. declare module BABYLON {
  29485. /**
  29486. * Class used to manipulate GUIDs
  29487. */
  29488. export class GUID {
  29489. /**
  29490. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29491. * Be aware Math.random() could cause collisions, but:
  29492. * "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"
  29493. * @returns a pseudo random id
  29494. */
  29495. static RandomId(): string;
  29496. }
  29497. }
  29498. declare module BABYLON {
  29499. /**
  29500. * Base class of all the textures in babylon.
  29501. * It groups all the common properties the materials, post process, lights... might need
  29502. * in order to make a correct use of the texture.
  29503. */
  29504. export class BaseTexture implements IAnimatable {
  29505. /**
  29506. * Default anisotropic filtering level for the application.
  29507. * It is set to 4 as a good tradeoff between perf and quality.
  29508. */
  29509. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29510. /**
  29511. * Gets or sets the unique id of the texture
  29512. */
  29513. uniqueId: number;
  29514. /**
  29515. * Define the name of the texture.
  29516. */
  29517. name: string;
  29518. /**
  29519. * Gets or sets an object used to store user defined information.
  29520. */
  29521. metadata: any;
  29522. /**
  29523. * For internal use only. Please do not use.
  29524. */
  29525. reservedDataStore: any;
  29526. private _hasAlpha;
  29527. /**
  29528. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29529. */
  29530. set hasAlpha(value: boolean);
  29531. get hasAlpha(): boolean;
  29532. /**
  29533. * Defines if the alpha value should be determined via the rgb values.
  29534. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29535. */
  29536. getAlphaFromRGB: boolean;
  29537. /**
  29538. * Intensity or strength of the texture.
  29539. * It is commonly used by materials to fine tune the intensity of the texture
  29540. */
  29541. level: number;
  29542. /**
  29543. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29544. * This is part of the texture as textures usually maps to one uv set.
  29545. */
  29546. coordinatesIndex: number;
  29547. private _coordinatesMode;
  29548. /**
  29549. * How a texture is mapped.
  29550. *
  29551. * | Value | Type | Description |
  29552. * | ----- | ----------------------------------- | ----------- |
  29553. * | 0 | EXPLICIT_MODE | |
  29554. * | 1 | SPHERICAL_MODE | |
  29555. * | 2 | PLANAR_MODE | |
  29556. * | 3 | CUBIC_MODE | |
  29557. * | 4 | PROJECTION_MODE | |
  29558. * | 5 | SKYBOX_MODE | |
  29559. * | 6 | INVCUBIC_MODE | |
  29560. * | 7 | EQUIRECTANGULAR_MODE | |
  29561. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29562. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29563. */
  29564. set coordinatesMode(value: number);
  29565. get coordinatesMode(): number;
  29566. /**
  29567. * | Value | Type | Description |
  29568. * | ----- | ------------------ | ----------- |
  29569. * | 0 | CLAMP_ADDRESSMODE | |
  29570. * | 1 | WRAP_ADDRESSMODE | |
  29571. * | 2 | MIRROR_ADDRESSMODE | |
  29572. */
  29573. wrapU: number;
  29574. /**
  29575. * | Value | Type | Description |
  29576. * | ----- | ------------------ | ----------- |
  29577. * | 0 | CLAMP_ADDRESSMODE | |
  29578. * | 1 | WRAP_ADDRESSMODE | |
  29579. * | 2 | MIRROR_ADDRESSMODE | |
  29580. */
  29581. wrapV: number;
  29582. /**
  29583. * | Value | Type | Description |
  29584. * | ----- | ------------------ | ----------- |
  29585. * | 0 | CLAMP_ADDRESSMODE | |
  29586. * | 1 | WRAP_ADDRESSMODE | |
  29587. * | 2 | MIRROR_ADDRESSMODE | |
  29588. */
  29589. wrapR: number;
  29590. /**
  29591. * With compliant hardware and browser (supporting anisotropic filtering)
  29592. * this defines the level of anisotropic filtering in the texture.
  29593. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29594. */
  29595. anisotropicFilteringLevel: number;
  29596. /**
  29597. * Define if the texture is a cube texture or if false a 2d texture.
  29598. */
  29599. get isCube(): boolean;
  29600. set isCube(value: boolean);
  29601. /**
  29602. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29603. */
  29604. get is3D(): boolean;
  29605. set is3D(value: boolean);
  29606. /**
  29607. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29608. */
  29609. get is2DArray(): boolean;
  29610. set is2DArray(value: boolean);
  29611. /**
  29612. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29613. * HDR texture are usually stored in linear space.
  29614. * This only impacts the PBR and Background materials
  29615. */
  29616. gammaSpace: boolean;
  29617. /**
  29618. * Gets or sets whether or not the texture contains RGBD data.
  29619. */
  29620. get isRGBD(): boolean;
  29621. set isRGBD(value: boolean);
  29622. /**
  29623. * Is Z inverted in the texture (useful in a cube texture).
  29624. */
  29625. invertZ: boolean;
  29626. /**
  29627. * Are mip maps generated for this texture or not.
  29628. */
  29629. get noMipmap(): boolean;
  29630. /**
  29631. * @hidden
  29632. */
  29633. lodLevelInAlpha: boolean;
  29634. /**
  29635. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29636. */
  29637. get lodGenerationOffset(): number;
  29638. set lodGenerationOffset(value: number);
  29639. /**
  29640. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29641. */
  29642. get lodGenerationScale(): number;
  29643. set lodGenerationScale(value: number);
  29644. /**
  29645. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29646. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29647. * average roughness values.
  29648. */
  29649. get linearSpecularLOD(): boolean;
  29650. set linearSpecularLOD(value: boolean);
  29651. /**
  29652. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29653. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29654. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29655. */
  29656. get irradianceTexture(): Nullable<BaseTexture>;
  29657. set irradianceTexture(value: Nullable<BaseTexture>);
  29658. /**
  29659. * Define if the texture is a render target.
  29660. */
  29661. isRenderTarget: boolean;
  29662. /**
  29663. * Define the unique id of the texture in the scene.
  29664. */
  29665. get uid(): string;
  29666. /**
  29667. * Return a string representation of the texture.
  29668. * @returns the texture as a string
  29669. */
  29670. toString(): string;
  29671. /**
  29672. * Get the class name of the texture.
  29673. * @returns "BaseTexture"
  29674. */
  29675. getClassName(): string;
  29676. /**
  29677. * Define the list of animation attached to the texture.
  29678. */
  29679. animations: Animation[];
  29680. /**
  29681. * An event triggered when the texture is disposed.
  29682. */
  29683. onDisposeObservable: Observable<BaseTexture>;
  29684. private _onDisposeObserver;
  29685. /**
  29686. * Callback triggered when the texture has been disposed.
  29687. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29688. */
  29689. set onDispose(callback: () => void);
  29690. /**
  29691. * Define the current state of the loading sequence when in delayed load mode.
  29692. */
  29693. delayLoadState: number;
  29694. private _scene;
  29695. /** @hidden */
  29696. _texture: Nullable<InternalTexture>;
  29697. private _uid;
  29698. /**
  29699. * Define if the texture is preventinga material to render or not.
  29700. * If not and the texture is not ready, the engine will use a default black texture instead.
  29701. */
  29702. get isBlocking(): boolean;
  29703. /**
  29704. * Instantiates a new BaseTexture.
  29705. * Base class of all the textures in babylon.
  29706. * It groups all the common properties the materials, post process, lights... might need
  29707. * in order to make a correct use of the texture.
  29708. * @param scene Define the scene the texture blongs to
  29709. */
  29710. constructor(scene: Nullable<Scene>);
  29711. /**
  29712. * Get the scene the texture belongs to.
  29713. * @returns the scene or null if undefined
  29714. */
  29715. getScene(): Nullable<Scene>;
  29716. /**
  29717. * Get the texture transform matrix used to offset tile the texture for istance.
  29718. * @returns the transformation matrix
  29719. */
  29720. getTextureMatrix(): Matrix;
  29721. /**
  29722. * Get the texture reflection matrix used to rotate/transform the reflection.
  29723. * @returns the reflection matrix
  29724. */
  29725. getReflectionTextureMatrix(): Matrix;
  29726. /**
  29727. * Get the underlying lower level texture from Babylon.
  29728. * @returns the insternal texture
  29729. */
  29730. getInternalTexture(): Nullable<InternalTexture>;
  29731. /**
  29732. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29733. * @returns true if ready or not blocking
  29734. */
  29735. isReadyOrNotBlocking(): boolean;
  29736. /**
  29737. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29738. * @returns true if fully ready
  29739. */
  29740. isReady(): boolean;
  29741. private _cachedSize;
  29742. /**
  29743. * Get the size of the texture.
  29744. * @returns the texture size.
  29745. */
  29746. getSize(): ISize;
  29747. /**
  29748. * Get the base size of the texture.
  29749. * It can be different from the size if the texture has been resized for POT for instance
  29750. * @returns the base size
  29751. */
  29752. getBaseSize(): ISize;
  29753. /**
  29754. * Update the sampling mode of the texture.
  29755. * Default is Trilinear mode.
  29756. *
  29757. * | Value | Type | Description |
  29758. * | ----- | ------------------ | ----------- |
  29759. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29760. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29761. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29762. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29763. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29764. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29765. * | 7 | NEAREST_LINEAR | |
  29766. * | 8 | NEAREST_NEAREST | |
  29767. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29768. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29769. * | 11 | LINEAR_LINEAR | |
  29770. * | 12 | LINEAR_NEAREST | |
  29771. *
  29772. * > _mag_: magnification filter (close to the viewer)
  29773. * > _min_: minification filter (far from the viewer)
  29774. * > _mip_: filter used between mip map levels
  29775. *@param samplingMode Define the new sampling mode of the texture
  29776. */
  29777. updateSamplingMode(samplingMode: number): void;
  29778. /**
  29779. * Scales the texture if is `canRescale()`
  29780. * @param ratio the resize factor we want to use to rescale
  29781. */
  29782. scale(ratio: number): void;
  29783. /**
  29784. * Get if the texture can rescale.
  29785. */
  29786. get canRescale(): boolean;
  29787. /** @hidden */
  29788. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29789. /** @hidden */
  29790. _rebuild(): void;
  29791. /**
  29792. * Triggers the load sequence in delayed load mode.
  29793. */
  29794. delayLoad(): void;
  29795. /**
  29796. * Clones the texture.
  29797. * @returns the cloned texture
  29798. */
  29799. clone(): Nullable<BaseTexture>;
  29800. /**
  29801. * Get the texture underlying type (INT, FLOAT...)
  29802. */
  29803. get textureType(): number;
  29804. /**
  29805. * Get the texture underlying format (RGB, RGBA...)
  29806. */
  29807. get textureFormat(): number;
  29808. /**
  29809. * Indicates that textures need to be re-calculated for all materials
  29810. */
  29811. protected _markAllSubMeshesAsTexturesDirty(): void;
  29812. /**
  29813. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29814. * This will returns an RGBA array buffer containing either in values (0-255) or
  29815. * float values (0-1) depending of the underlying buffer type.
  29816. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29817. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29818. * @param buffer defines a user defined buffer to fill with data (can be null)
  29819. * @returns The Array buffer containing the pixels data.
  29820. */
  29821. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29822. /**
  29823. * Release and destroy the underlying lower level texture aka internalTexture.
  29824. */
  29825. releaseInternalTexture(): void;
  29826. /** @hidden */
  29827. get _lodTextureHigh(): Nullable<BaseTexture>;
  29828. /** @hidden */
  29829. get _lodTextureMid(): Nullable<BaseTexture>;
  29830. /** @hidden */
  29831. get _lodTextureLow(): Nullable<BaseTexture>;
  29832. /**
  29833. * Dispose the texture and release its associated resources.
  29834. */
  29835. dispose(): void;
  29836. /**
  29837. * Serialize the texture into a JSON representation that can be parsed later on.
  29838. * @returns the JSON representation of the texture
  29839. */
  29840. serialize(): any;
  29841. /**
  29842. * Helper function to be called back once a list of texture contains only ready textures.
  29843. * @param textures Define the list of textures to wait for
  29844. * @param callback Define the callback triggered once the entire list will be ready
  29845. */
  29846. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29847. }
  29848. }
  29849. declare module BABYLON {
  29850. /**
  29851. * Options to be used when creating an effect.
  29852. */
  29853. export interface IEffectCreationOptions {
  29854. /**
  29855. * Atrributes that will be used in the shader.
  29856. */
  29857. attributes: string[];
  29858. /**
  29859. * Uniform varible names that will be set in the shader.
  29860. */
  29861. uniformsNames: string[];
  29862. /**
  29863. * Uniform buffer variable names that will be set in the shader.
  29864. */
  29865. uniformBuffersNames: string[];
  29866. /**
  29867. * Sampler texture variable names that will be set in the shader.
  29868. */
  29869. samplers: string[];
  29870. /**
  29871. * Define statements that will be set in the shader.
  29872. */
  29873. defines: any;
  29874. /**
  29875. * Possible fallbacks for this effect to improve performance when needed.
  29876. */
  29877. fallbacks: Nullable<IEffectFallbacks>;
  29878. /**
  29879. * Callback that will be called when the shader is compiled.
  29880. */
  29881. onCompiled: Nullable<(effect: Effect) => void>;
  29882. /**
  29883. * Callback that will be called if an error occurs during shader compilation.
  29884. */
  29885. onError: Nullable<(effect: Effect, errors: string) => void>;
  29886. /**
  29887. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29888. */
  29889. indexParameters?: any;
  29890. /**
  29891. * Max number of lights that can be used in the shader.
  29892. */
  29893. maxSimultaneousLights?: number;
  29894. /**
  29895. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29896. */
  29897. transformFeedbackVaryings?: Nullable<string[]>;
  29898. }
  29899. /**
  29900. * Effect containing vertex and fragment shader that can be executed on an object.
  29901. */
  29902. export class Effect implements IDisposable {
  29903. /**
  29904. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29905. */
  29906. static ShadersRepository: string;
  29907. /**
  29908. * Name of the effect.
  29909. */
  29910. name: any;
  29911. /**
  29912. * String container all the define statements that should be set on the shader.
  29913. */
  29914. defines: string;
  29915. /**
  29916. * Callback that will be called when the shader is compiled.
  29917. */
  29918. onCompiled: Nullable<(effect: Effect) => void>;
  29919. /**
  29920. * Callback that will be called if an error occurs during shader compilation.
  29921. */
  29922. onError: Nullable<(effect: Effect, errors: string) => void>;
  29923. /**
  29924. * Callback that will be called when effect is bound.
  29925. */
  29926. onBind: Nullable<(effect: Effect) => void>;
  29927. /**
  29928. * Unique ID of the effect.
  29929. */
  29930. uniqueId: number;
  29931. /**
  29932. * Observable that will be called when the shader is compiled.
  29933. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29934. */
  29935. onCompileObservable: Observable<Effect>;
  29936. /**
  29937. * Observable that will be called if an error occurs during shader compilation.
  29938. */
  29939. onErrorObservable: Observable<Effect>;
  29940. /** @hidden */
  29941. _onBindObservable: Nullable<Observable<Effect>>;
  29942. /**
  29943. * @hidden
  29944. * Specifies if the effect was previously ready
  29945. */
  29946. _wasPreviouslyReady: boolean;
  29947. /**
  29948. * Observable that will be called when effect is bound.
  29949. */
  29950. get onBindObservable(): Observable<Effect>;
  29951. /** @hidden */
  29952. _bonesComputationForcedToCPU: boolean;
  29953. private static _uniqueIdSeed;
  29954. private _engine;
  29955. private _uniformBuffersNames;
  29956. private _uniformsNames;
  29957. private _samplerList;
  29958. private _samplers;
  29959. private _isReady;
  29960. private _compilationError;
  29961. private _allFallbacksProcessed;
  29962. private _attributesNames;
  29963. private _attributes;
  29964. private _attributeLocationByName;
  29965. private _uniforms;
  29966. /**
  29967. * Key for the effect.
  29968. * @hidden
  29969. */
  29970. _key: string;
  29971. private _indexParameters;
  29972. private _fallbacks;
  29973. private _vertexSourceCode;
  29974. private _fragmentSourceCode;
  29975. private _vertexSourceCodeOverride;
  29976. private _fragmentSourceCodeOverride;
  29977. private _transformFeedbackVaryings;
  29978. /**
  29979. * Compiled shader to webGL program.
  29980. * @hidden
  29981. */
  29982. _pipelineContext: Nullable<IPipelineContext>;
  29983. private _valueCache;
  29984. private static _baseCache;
  29985. /**
  29986. * Instantiates an effect.
  29987. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29988. * @param baseName Name of the effect.
  29989. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29990. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29991. * @param samplers List of sampler variables that will be passed to the shader.
  29992. * @param engine Engine to be used to render the effect
  29993. * @param defines Define statements to be added to the shader.
  29994. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29995. * @param onCompiled Callback that will be called when the shader is compiled.
  29996. * @param onError Callback that will be called if an error occurs during shader compilation.
  29997. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29998. */
  29999. 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);
  30000. private _useFinalCode;
  30001. /**
  30002. * Unique key for this effect
  30003. */
  30004. get key(): string;
  30005. /**
  30006. * If the effect has been compiled and prepared.
  30007. * @returns if the effect is compiled and prepared.
  30008. */
  30009. isReady(): boolean;
  30010. private _isReadyInternal;
  30011. /**
  30012. * The engine the effect was initialized with.
  30013. * @returns the engine.
  30014. */
  30015. getEngine(): Engine;
  30016. /**
  30017. * The pipeline context for this effect
  30018. * @returns the associated pipeline context
  30019. */
  30020. getPipelineContext(): Nullable<IPipelineContext>;
  30021. /**
  30022. * The set of names of attribute variables for the shader.
  30023. * @returns An array of attribute names.
  30024. */
  30025. getAttributesNames(): string[];
  30026. /**
  30027. * Returns the attribute at the given index.
  30028. * @param index The index of the attribute.
  30029. * @returns The location of the attribute.
  30030. */
  30031. getAttributeLocation(index: number): number;
  30032. /**
  30033. * Returns the attribute based on the name of the variable.
  30034. * @param name of the attribute to look up.
  30035. * @returns the attribute location.
  30036. */
  30037. getAttributeLocationByName(name: string): number;
  30038. /**
  30039. * The number of attributes.
  30040. * @returns the numnber of attributes.
  30041. */
  30042. getAttributesCount(): number;
  30043. /**
  30044. * Gets the index of a uniform variable.
  30045. * @param uniformName of the uniform to look up.
  30046. * @returns the index.
  30047. */
  30048. getUniformIndex(uniformName: string): number;
  30049. /**
  30050. * Returns the attribute based on the name of the variable.
  30051. * @param uniformName of the uniform to look up.
  30052. * @returns the location of the uniform.
  30053. */
  30054. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30055. /**
  30056. * Returns an array of sampler variable names
  30057. * @returns The array of sampler variable neames.
  30058. */
  30059. getSamplers(): string[];
  30060. /**
  30061. * The error from the last compilation.
  30062. * @returns the error string.
  30063. */
  30064. getCompilationError(): string;
  30065. /**
  30066. * Gets a boolean indicating that all fallbacks were used during compilation
  30067. * @returns true if all fallbacks were used
  30068. */
  30069. allFallbacksProcessed(): boolean;
  30070. /**
  30071. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30072. * @param func The callback to be used.
  30073. */
  30074. executeWhenCompiled(func: (effect: Effect) => void): void;
  30075. private _checkIsReady;
  30076. private _loadShader;
  30077. /**
  30078. * Recompiles the webGL program
  30079. * @param vertexSourceCode The source code for the vertex shader.
  30080. * @param fragmentSourceCode The source code for the fragment shader.
  30081. * @param onCompiled Callback called when completed.
  30082. * @param onError Callback called on error.
  30083. * @hidden
  30084. */
  30085. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30086. /**
  30087. * Prepares the effect
  30088. * @hidden
  30089. */
  30090. _prepareEffect(): void;
  30091. private _processCompilationErrors;
  30092. /**
  30093. * Checks if the effect is supported. (Must be called after compilation)
  30094. */
  30095. get isSupported(): boolean;
  30096. /**
  30097. * Binds a texture to the engine to be used as output of the shader.
  30098. * @param channel Name of the output variable.
  30099. * @param texture Texture to bind.
  30100. * @hidden
  30101. */
  30102. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30103. /**
  30104. * Sets a texture on the engine to be used in the shader.
  30105. * @param channel Name of the sampler variable.
  30106. * @param texture Texture to set.
  30107. */
  30108. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30109. /**
  30110. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30111. * @param channel Name of the sampler variable.
  30112. * @param texture Texture to set.
  30113. */
  30114. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30115. /**
  30116. * Sets an array of textures on the engine to be used in the shader.
  30117. * @param channel Name of the variable.
  30118. * @param textures Textures to set.
  30119. */
  30120. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30121. /**
  30122. * 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)
  30123. * @param channel Name of the sampler variable.
  30124. * @param postProcess Post process to get the input texture from.
  30125. */
  30126. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30127. /**
  30128. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30129. * 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)
  30130. * @param channel Name of the sampler variable.
  30131. * @param postProcess Post process to get the output texture from.
  30132. */
  30133. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30134. /** @hidden */
  30135. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30136. /** @hidden */
  30137. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30138. /** @hidden */
  30139. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30140. /** @hidden */
  30141. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30142. /**
  30143. * Binds a buffer to a uniform.
  30144. * @param buffer Buffer to bind.
  30145. * @param name Name of the uniform variable to bind to.
  30146. */
  30147. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30148. /**
  30149. * Binds block to a uniform.
  30150. * @param blockName Name of the block to bind.
  30151. * @param index Index to bind.
  30152. */
  30153. bindUniformBlock(blockName: string, index: number): void;
  30154. /**
  30155. * Sets an interger value on a uniform variable.
  30156. * @param uniformName Name of the variable.
  30157. * @param value Value to be set.
  30158. * @returns this effect.
  30159. */
  30160. setInt(uniformName: string, value: number): Effect;
  30161. /**
  30162. * Sets an int array on a uniform variable.
  30163. * @param uniformName Name of the variable.
  30164. * @param array array to be set.
  30165. * @returns this effect.
  30166. */
  30167. setIntArray(uniformName: string, array: Int32Array): Effect;
  30168. /**
  30169. * 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)
  30170. * @param uniformName Name of the variable.
  30171. * @param array array to be set.
  30172. * @returns this effect.
  30173. */
  30174. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30175. /**
  30176. * 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)
  30177. * @param uniformName Name of the variable.
  30178. * @param array array to be set.
  30179. * @returns this effect.
  30180. */
  30181. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30182. /**
  30183. * 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)
  30184. * @param uniformName Name of the variable.
  30185. * @param array array to be set.
  30186. * @returns this effect.
  30187. */
  30188. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30189. /**
  30190. * Sets an float array on a uniform variable.
  30191. * @param uniformName Name of the variable.
  30192. * @param array array to be set.
  30193. * @returns this effect.
  30194. */
  30195. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30196. /**
  30197. * 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)
  30198. * @param uniformName Name of the variable.
  30199. * @param array array to be set.
  30200. * @returns this effect.
  30201. */
  30202. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30203. /**
  30204. * 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)
  30205. * @param uniformName Name of the variable.
  30206. * @param array array to be set.
  30207. * @returns this effect.
  30208. */
  30209. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30210. /**
  30211. * 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)
  30212. * @param uniformName Name of the variable.
  30213. * @param array array to be set.
  30214. * @returns this effect.
  30215. */
  30216. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30217. /**
  30218. * Sets an array on a uniform variable.
  30219. * @param uniformName Name of the variable.
  30220. * @param array array to be set.
  30221. * @returns this effect.
  30222. */
  30223. setArray(uniformName: string, array: number[]): Effect;
  30224. /**
  30225. * 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)
  30226. * @param uniformName Name of the variable.
  30227. * @param array array to be set.
  30228. * @returns this effect.
  30229. */
  30230. setArray2(uniformName: string, array: number[]): Effect;
  30231. /**
  30232. * 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)
  30233. * @param uniformName Name of the variable.
  30234. * @param array array to be set.
  30235. * @returns this effect.
  30236. */
  30237. setArray3(uniformName: string, array: number[]): Effect;
  30238. /**
  30239. * 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)
  30240. * @param uniformName Name of the variable.
  30241. * @param array array to be set.
  30242. * @returns this effect.
  30243. */
  30244. setArray4(uniformName: string, array: number[]): Effect;
  30245. /**
  30246. * Sets matrices on a uniform variable.
  30247. * @param uniformName Name of the variable.
  30248. * @param matrices matrices to be set.
  30249. * @returns this effect.
  30250. */
  30251. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30252. /**
  30253. * Sets matrix on a uniform variable.
  30254. * @param uniformName Name of the variable.
  30255. * @param matrix matrix to be set.
  30256. * @returns this effect.
  30257. */
  30258. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30259. /**
  30260. * 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)
  30261. * @param uniformName Name of the variable.
  30262. * @param matrix matrix to be set.
  30263. * @returns this effect.
  30264. */
  30265. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30266. /**
  30267. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30268. * @param uniformName Name of the variable.
  30269. * @param matrix matrix to be set.
  30270. * @returns this effect.
  30271. */
  30272. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30273. /**
  30274. * Sets a float on a uniform variable.
  30275. * @param uniformName Name of the variable.
  30276. * @param value value to be set.
  30277. * @returns this effect.
  30278. */
  30279. setFloat(uniformName: string, value: number): Effect;
  30280. /**
  30281. * Sets a boolean on a uniform variable.
  30282. * @param uniformName Name of the variable.
  30283. * @param bool value to be set.
  30284. * @returns this effect.
  30285. */
  30286. setBool(uniformName: string, bool: boolean): Effect;
  30287. /**
  30288. * Sets a Vector2 on a uniform variable.
  30289. * @param uniformName Name of the variable.
  30290. * @param vector2 vector2 to be set.
  30291. * @returns this effect.
  30292. */
  30293. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30294. /**
  30295. * Sets a float2 on a uniform variable.
  30296. * @param uniformName Name of the variable.
  30297. * @param x First float in float2.
  30298. * @param y Second float in float2.
  30299. * @returns this effect.
  30300. */
  30301. setFloat2(uniformName: string, x: number, y: number): Effect;
  30302. /**
  30303. * Sets a Vector3 on a uniform variable.
  30304. * @param uniformName Name of the variable.
  30305. * @param vector3 Value to be set.
  30306. * @returns this effect.
  30307. */
  30308. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30309. /**
  30310. * Sets a float3 on a uniform variable.
  30311. * @param uniformName Name of the variable.
  30312. * @param x First float in float3.
  30313. * @param y Second float in float3.
  30314. * @param z Third float in float3.
  30315. * @returns this effect.
  30316. */
  30317. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30318. /**
  30319. * Sets a Vector4 on a uniform variable.
  30320. * @param uniformName Name of the variable.
  30321. * @param vector4 Value to be set.
  30322. * @returns this effect.
  30323. */
  30324. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30325. /**
  30326. * Sets a float4 on a uniform variable.
  30327. * @param uniformName Name of the variable.
  30328. * @param x First float in float4.
  30329. * @param y Second float in float4.
  30330. * @param z Third float in float4.
  30331. * @param w Fourth float in float4.
  30332. * @returns this effect.
  30333. */
  30334. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30335. /**
  30336. * Sets a Color3 on a uniform variable.
  30337. * @param uniformName Name of the variable.
  30338. * @param color3 Value to be set.
  30339. * @returns this effect.
  30340. */
  30341. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30342. /**
  30343. * Sets a Color4 on a uniform variable.
  30344. * @param uniformName Name of the variable.
  30345. * @param color3 Value to be set.
  30346. * @param alpha Alpha value to be set.
  30347. * @returns this effect.
  30348. */
  30349. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30350. /**
  30351. * Sets a Color4 on a uniform variable
  30352. * @param uniformName defines the name of the variable
  30353. * @param color4 defines the value to be set
  30354. * @returns this effect.
  30355. */
  30356. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30357. /** Release all associated resources */
  30358. dispose(): void;
  30359. /**
  30360. * This function will add a new shader to the shader store
  30361. * @param name the name of the shader
  30362. * @param pixelShader optional pixel shader content
  30363. * @param vertexShader optional vertex shader content
  30364. */
  30365. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30366. /**
  30367. * Store of each shader (The can be looked up using effect.key)
  30368. */
  30369. static ShadersStore: {
  30370. [key: string]: string;
  30371. };
  30372. /**
  30373. * Store of each included file for a shader (The can be looked up using effect.key)
  30374. */
  30375. static IncludesShadersStore: {
  30376. [key: string]: string;
  30377. };
  30378. /**
  30379. * Resets the cache of effects.
  30380. */
  30381. static ResetCache(): void;
  30382. }
  30383. }
  30384. declare module BABYLON {
  30385. /**
  30386. * Interface used to describe the capabilities of the engine relatively to the current browser
  30387. */
  30388. export interface EngineCapabilities {
  30389. /** Maximum textures units per fragment shader */
  30390. maxTexturesImageUnits: number;
  30391. /** Maximum texture units per vertex shader */
  30392. maxVertexTextureImageUnits: number;
  30393. /** Maximum textures units in the entire pipeline */
  30394. maxCombinedTexturesImageUnits: number;
  30395. /** Maximum texture size */
  30396. maxTextureSize: number;
  30397. /** Maximum texture samples */
  30398. maxSamples?: number;
  30399. /** Maximum cube texture size */
  30400. maxCubemapTextureSize: number;
  30401. /** Maximum render texture size */
  30402. maxRenderTextureSize: number;
  30403. /** Maximum number of vertex attributes */
  30404. maxVertexAttribs: number;
  30405. /** Maximum number of varyings */
  30406. maxVaryingVectors: number;
  30407. /** Maximum number of uniforms per vertex shader */
  30408. maxVertexUniformVectors: number;
  30409. /** Maximum number of uniforms per fragment shader */
  30410. maxFragmentUniformVectors: number;
  30411. /** Defines if standard derivates (dx/dy) are supported */
  30412. standardDerivatives: boolean;
  30413. /** Defines if s3tc texture compression is supported */
  30414. s3tc?: WEBGL_compressed_texture_s3tc;
  30415. /** Defines if pvrtc texture compression is supported */
  30416. pvrtc: any;
  30417. /** Defines if etc1 texture compression is supported */
  30418. etc1: any;
  30419. /** Defines if etc2 texture compression is supported */
  30420. etc2: any;
  30421. /** Defines if astc texture compression is supported */
  30422. astc: any;
  30423. /** Defines if float textures are supported */
  30424. textureFloat: boolean;
  30425. /** Defines if vertex array objects are supported */
  30426. vertexArrayObject: boolean;
  30427. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30428. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30429. /** Gets the maximum level of anisotropy supported */
  30430. maxAnisotropy: number;
  30431. /** Defines if instancing is supported */
  30432. instancedArrays: boolean;
  30433. /** Defines if 32 bits indices are supported */
  30434. uintIndices: boolean;
  30435. /** Defines if high precision shaders are supported */
  30436. highPrecisionShaderSupported: boolean;
  30437. /** Defines if depth reading in the fragment shader is supported */
  30438. fragmentDepthSupported: boolean;
  30439. /** Defines if float texture linear filtering is supported*/
  30440. textureFloatLinearFiltering: boolean;
  30441. /** Defines if rendering to float textures is supported */
  30442. textureFloatRender: boolean;
  30443. /** Defines if half float textures are supported*/
  30444. textureHalfFloat: boolean;
  30445. /** Defines if half float texture linear filtering is supported*/
  30446. textureHalfFloatLinearFiltering: boolean;
  30447. /** Defines if rendering to half float textures is supported */
  30448. textureHalfFloatRender: boolean;
  30449. /** Defines if textureLOD shader command is supported */
  30450. textureLOD: boolean;
  30451. /** Defines if draw buffers extension is supported */
  30452. drawBuffersExtension: boolean;
  30453. /** Defines if depth textures are supported */
  30454. depthTextureExtension: boolean;
  30455. /** Defines if float color buffer are supported */
  30456. colorBufferFloat: boolean;
  30457. /** Gets disjoint timer query extension (null if not supported) */
  30458. timerQuery?: EXT_disjoint_timer_query;
  30459. /** Defines if timestamp can be used with timer query */
  30460. canUseTimestampForTimerQuery: boolean;
  30461. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30462. multiview?: any;
  30463. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30464. oculusMultiview?: any;
  30465. /** Function used to let the system compiles shaders in background */
  30466. parallelShaderCompile?: {
  30467. COMPLETION_STATUS_KHR: number;
  30468. };
  30469. /** Max number of texture samples for MSAA */
  30470. maxMSAASamples: number;
  30471. /** Defines if the blend min max extension is supported */
  30472. blendMinMax: boolean;
  30473. }
  30474. }
  30475. declare module BABYLON {
  30476. /**
  30477. * @hidden
  30478. **/
  30479. export class DepthCullingState {
  30480. private _isDepthTestDirty;
  30481. private _isDepthMaskDirty;
  30482. private _isDepthFuncDirty;
  30483. private _isCullFaceDirty;
  30484. private _isCullDirty;
  30485. private _isZOffsetDirty;
  30486. private _isFrontFaceDirty;
  30487. private _depthTest;
  30488. private _depthMask;
  30489. private _depthFunc;
  30490. private _cull;
  30491. private _cullFace;
  30492. private _zOffset;
  30493. private _frontFace;
  30494. /**
  30495. * Initializes the state.
  30496. */
  30497. constructor();
  30498. get isDirty(): boolean;
  30499. get zOffset(): number;
  30500. set zOffset(value: number);
  30501. get cullFace(): Nullable<number>;
  30502. set cullFace(value: Nullable<number>);
  30503. get cull(): Nullable<boolean>;
  30504. set cull(value: Nullable<boolean>);
  30505. get depthFunc(): Nullable<number>;
  30506. set depthFunc(value: Nullable<number>);
  30507. get depthMask(): boolean;
  30508. set depthMask(value: boolean);
  30509. get depthTest(): boolean;
  30510. set depthTest(value: boolean);
  30511. get frontFace(): Nullable<number>;
  30512. set frontFace(value: Nullable<number>);
  30513. reset(): void;
  30514. apply(gl: WebGLRenderingContext): void;
  30515. }
  30516. }
  30517. declare module BABYLON {
  30518. /**
  30519. * @hidden
  30520. **/
  30521. export class StencilState {
  30522. /** 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 */
  30523. static readonly ALWAYS: number;
  30524. /** Passed to stencilOperation to specify that stencil value must be kept */
  30525. static readonly KEEP: number;
  30526. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30527. static readonly REPLACE: number;
  30528. private _isStencilTestDirty;
  30529. private _isStencilMaskDirty;
  30530. private _isStencilFuncDirty;
  30531. private _isStencilOpDirty;
  30532. private _stencilTest;
  30533. private _stencilMask;
  30534. private _stencilFunc;
  30535. private _stencilFuncRef;
  30536. private _stencilFuncMask;
  30537. private _stencilOpStencilFail;
  30538. private _stencilOpDepthFail;
  30539. private _stencilOpStencilDepthPass;
  30540. get isDirty(): boolean;
  30541. get stencilFunc(): number;
  30542. set stencilFunc(value: number);
  30543. get stencilFuncRef(): number;
  30544. set stencilFuncRef(value: number);
  30545. get stencilFuncMask(): number;
  30546. set stencilFuncMask(value: number);
  30547. get stencilOpStencilFail(): number;
  30548. set stencilOpStencilFail(value: number);
  30549. get stencilOpDepthFail(): number;
  30550. set stencilOpDepthFail(value: number);
  30551. get stencilOpStencilDepthPass(): number;
  30552. set stencilOpStencilDepthPass(value: number);
  30553. get stencilMask(): number;
  30554. set stencilMask(value: number);
  30555. get stencilTest(): boolean;
  30556. set stencilTest(value: boolean);
  30557. constructor();
  30558. reset(): void;
  30559. apply(gl: WebGLRenderingContext): void;
  30560. }
  30561. }
  30562. declare module BABYLON {
  30563. /**
  30564. * @hidden
  30565. **/
  30566. export class AlphaState {
  30567. private _isAlphaBlendDirty;
  30568. private _isBlendFunctionParametersDirty;
  30569. private _isBlendEquationParametersDirty;
  30570. private _isBlendConstantsDirty;
  30571. private _alphaBlend;
  30572. private _blendFunctionParameters;
  30573. private _blendEquationParameters;
  30574. private _blendConstants;
  30575. /**
  30576. * Initializes the state.
  30577. */
  30578. constructor();
  30579. get isDirty(): boolean;
  30580. get alphaBlend(): boolean;
  30581. set alphaBlend(value: boolean);
  30582. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30583. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30584. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30585. reset(): void;
  30586. apply(gl: WebGLRenderingContext): void;
  30587. }
  30588. }
  30589. declare module BABYLON {
  30590. /** @hidden */
  30591. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30592. attributeProcessor(attribute: string): string;
  30593. varyingProcessor(varying: string, isFragment: boolean): string;
  30594. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30595. }
  30596. }
  30597. declare module BABYLON {
  30598. /**
  30599. * Interface for attribute information associated with buffer instanciation
  30600. */
  30601. export interface InstancingAttributeInfo {
  30602. /**
  30603. * Name of the GLSL attribute
  30604. * if attribute index is not specified, this is used to retrieve the index from the effect
  30605. */
  30606. attributeName: string;
  30607. /**
  30608. * Index/offset of the attribute in the vertex shader
  30609. * if not specified, this will be computes from the name.
  30610. */
  30611. index?: number;
  30612. /**
  30613. * size of the attribute, 1, 2, 3 or 4
  30614. */
  30615. attributeSize: number;
  30616. /**
  30617. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30618. */
  30619. offset: number;
  30620. /**
  30621. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30622. * default to 1
  30623. */
  30624. divisor?: number;
  30625. /**
  30626. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30627. * default is FLOAT
  30628. */
  30629. attributeType?: number;
  30630. /**
  30631. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30632. */
  30633. normalized?: boolean;
  30634. }
  30635. }
  30636. declare module BABYLON {
  30637. interface ThinEngine {
  30638. /**
  30639. * Update a video texture
  30640. * @param texture defines the texture to update
  30641. * @param video defines the video element to use
  30642. * @param invertY defines if data must be stored with Y axis inverted
  30643. */
  30644. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30645. }
  30646. }
  30647. declare module BABYLON {
  30648. /**
  30649. * Settings for finer control over video usage
  30650. */
  30651. export interface VideoTextureSettings {
  30652. /**
  30653. * Applies `autoplay` to video, if specified
  30654. */
  30655. autoPlay?: boolean;
  30656. /**
  30657. * Applies `loop` to video, if specified
  30658. */
  30659. loop?: boolean;
  30660. /**
  30661. * Automatically updates internal texture from video at every frame in the render loop
  30662. */
  30663. autoUpdateTexture: boolean;
  30664. /**
  30665. * Image src displayed during the video loading or until the user interacts with the video.
  30666. */
  30667. poster?: string;
  30668. }
  30669. /**
  30670. * If you want to display a video in your scene, this is the special texture for that.
  30671. * This special texture works similar to other textures, with the exception of a few parameters.
  30672. * @see https://doc.babylonjs.com/how_to/video_texture
  30673. */
  30674. export class VideoTexture extends Texture {
  30675. /**
  30676. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30677. */
  30678. readonly autoUpdateTexture: boolean;
  30679. /**
  30680. * The video instance used by the texture internally
  30681. */
  30682. readonly video: HTMLVideoElement;
  30683. private _onUserActionRequestedObservable;
  30684. /**
  30685. * Event triggerd when a dom action is required by the user to play the video.
  30686. * This happens due to recent changes in browser policies preventing video to auto start.
  30687. */
  30688. get onUserActionRequestedObservable(): Observable<Texture>;
  30689. private _generateMipMaps;
  30690. private _engine;
  30691. private _stillImageCaptured;
  30692. private _displayingPosterTexture;
  30693. private _settings;
  30694. private _createInternalTextureOnEvent;
  30695. private _frameId;
  30696. private _currentSrc;
  30697. /**
  30698. * Creates a video texture.
  30699. * If you want to display a video in your scene, this is the special texture for that.
  30700. * This special texture works similar to other textures, with the exception of a few parameters.
  30701. * @see https://doc.babylonjs.com/how_to/video_texture
  30702. * @param name optional name, will detect from video source, if not defined
  30703. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30704. * @param scene is obviously the current scene.
  30705. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30706. * @param invertY is false by default but can be used to invert video on Y axis
  30707. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30708. * @param settings allows finer control over video usage
  30709. */
  30710. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30711. private _getName;
  30712. private _getVideo;
  30713. private _createInternalTexture;
  30714. private reset;
  30715. /**
  30716. * @hidden Internal method to initiate `update`.
  30717. */
  30718. _rebuild(): void;
  30719. /**
  30720. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30721. */
  30722. update(): void;
  30723. /**
  30724. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30725. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30726. */
  30727. updateTexture(isVisible: boolean): void;
  30728. protected _updateInternalTexture: () => void;
  30729. /**
  30730. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30731. * @param url New url.
  30732. */
  30733. updateURL(url: string): void;
  30734. /**
  30735. * Clones the texture.
  30736. * @returns the cloned texture
  30737. */
  30738. clone(): VideoTexture;
  30739. /**
  30740. * Dispose the texture and release its associated resources.
  30741. */
  30742. dispose(): void;
  30743. /**
  30744. * Creates a video texture straight from a stream.
  30745. * @param scene Define the scene the texture should be created in
  30746. * @param stream Define the stream the texture should be created from
  30747. * @returns The created video texture as a promise
  30748. */
  30749. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30750. /**
  30751. * Creates a video texture straight from your WebCam video feed.
  30752. * @param scene Define the scene the texture should be created in
  30753. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30754. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30755. * @returns The created video texture as a promise
  30756. */
  30757. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30758. minWidth: number;
  30759. maxWidth: number;
  30760. minHeight: number;
  30761. maxHeight: number;
  30762. deviceId: string;
  30763. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30764. /**
  30765. * Creates a video texture straight from your WebCam video feed.
  30766. * @param scene Define the scene the texture should be created in
  30767. * @param onReady Define a callback to triggered once the texture will be ready
  30768. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30769. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30770. */
  30771. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30772. minWidth: number;
  30773. maxWidth: number;
  30774. minHeight: number;
  30775. maxHeight: number;
  30776. deviceId: string;
  30777. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30778. }
  30779. }
  30780. declare module BABYLON {
  30781. /**
  30782. * Defines the interface used by objects working like Scene
  30783. * @hidden
  30784. */
  30785. interface ISceneLike {
  30786. _addPendingData(data: any): void;
  30787. _removePendingData(data: any): void;
  30788. offlineProvider: IOfflineProvider;
  30789. }
  30790. /** Interface defining initialization parameters for Engine class */
  30791. export interface EngineOptions extends WebGLContextAttributes {
  30792. /**
  30793. * Defines if the engine should no exceed a specified device ratio
  30794. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30795. */
  30796. limitDeviceRatio?: number;
  30797. /**
  30798. * Defines if webvr should be enabled automatically
  30799. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30800. */
  30801. autoEnableWebVR?: boolean;
  30802. /**
  30803. * Defines if webgl2 should be turned off even if supported
  30804. * @see http://doc.babylonjs.com/features/webgl2
  30805. */
  30806. disableWebGL2Support?: boolean;
  30807. /**
  30808. * Defines if webaudio should be initialized as well
  30809. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30810. */
  30811. audioEngine?: boolean;
  30812. /**
  30813. * Defines if animations should run using a deterministic lock step
  30814. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30815. */
  30816. deterministicLockstep?: boolean;
  30817. /** Defines the maximum steps to use with deterministic lock step mode */
  30818. lockstepMaxSteps?: number;
  30819. /** Defines the seconds between each deterministic lock step */
  30820. timeStep?: number;
  30821. /**
  30822. * Defines that engine should ignore context lost events
  30823. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30824. */
  30825. doNotHandleContextLost?: boolean;
  30826. /**
  30827. * Defines that engine should ignore modifying touch action attribute and style
  30828. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30829. */
  30830. doNotHandleTouchAction?: boolean;
  30831. /**
  30832. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30833. */
  30834. useHighPrecisionFloats?: boolean;
  30835. }
  30836. /**
  30837. * The base engine class (root of all engines)
  30838. */
  30839. export class ThinEngine {
  30840. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30841. static ExceptionList: ({
  30842. key: string;
  30843. capture: string;
  30844. captureConstraint: number;
  30845. targets: string[];
  30846. } | {
  30847. key: string;
  30848. capture: null;
  30849. captureConstraint: null;
  30850. targets: string[];
  30851. })[];
  30852. /** @hidden */
  30853. static _TextureLoaders: IInternalTextureLoader[];
  30854. /**
  30855. * Returns the current npm package of the sdk
  30856. */
  30857. static get NpmPackage(): string;
  30858. /**
  30859. * Returns the current version of the framework
  30860. */
  30861. static get Version(): string;
  30862. /**
  30863. * Returns a string describing the current engine
  30864. */
  30865. get description(): string;
  30866. /**
  30867. * Gets or sets the epsilon value used by collision engine
  30868. */
  30869. static CollisionsEpsilon: number;
  30870. /**
  30871. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30872. */
  30873. static get ShadersRepository(): string;
  30874. static set ShadersRepository(value: string);
  30875. /**
  30876. * Gets or sets the textures that the engine should not attempt to load as compressed
  30877. */
  30878. protected _excludedCompressedTextures: string[];
  30879. /**
  30880. * Filters the compressed texture formats to only include
  30881. * files that are not included in the skippable list
  30882. *
  30883. * @param url the current extension
  30884. * @param textureFormatInUse the current compressed texture format
  30885. * @returns "format" string
  30886. */
  30887. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30888. /** @hidden */
  30889. _shaderProcessor: IShaderProcessor;
  30890. /**
  30891. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30892. */
  30893. forcePOTTextures: boolean;
  30894. /**
  30895. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30896. */
  30897. isFullscreen: boolean;
  30898. /**
  30899. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30900. */
  30901. cullBackFaces: boolean;
  30902. /**
  30903. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30904. */
  30905. renderEvenInBackground: boolean;
  30906. /**
  30907. * Gets or sets a boolean indicating that cache can be kept between frames
  30908. */
  30909. preventCacheWipeBetweenFrames: boolean;
  30910. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30911. validateShaderPrograms: boolean;
  30912. /**
  30913. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30914. * This can provide greater z depth for distant objects.
  30915. */
  30916. useReverseDepthBuffer: boolean;
  30917. /**
  30918. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30919. */
  30920. disableUniformBuffers: boolean;
  30921. /** @hidden */
  30922. _uniformBuffers: UniformBuffer[];
  30923. /**
  30924. * Gets a boolean indicating that the engine supports uniform buffers
  30925. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30926. */
  30927. get supportsUniformBuffers(): boolean;
  30928. /** @hidden */
  30929. _gl: WebGLRenderingContext;
  30930. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30931. protected _windowIsBackground: boolean;
  30932. protected _webGLVersion: number;
  30933. protected _creationOptions: EngineOptions;
  30934. protected _highPrecisionShadersAllowed: boolean;
  30935. /** @hidden */
  30936. get _shouldUseHighPrecisionShader(): boolean;
  30937. /**
  30938. * Gets a boolean indicating that only power of 2 textures are supported
  30939. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30940. */
  30941. get needPOTTextures(): boolean;
  30942. /** @hidden */
  30943. _badOS: boolean;
  30944. /** @hidden */
  30945. _badDesktopOS: boolean;
  30946. private _hardwareScalingLevel;
  30947. /** @hidden */
  30948. _caps: EngineCapabilities;
  30949. private _isStencilEnable;
  30950. private _glVersion;
  30951. private _glRenderer;
  30952. private _glVendor;
  30953. /** @hidden */
  30954. _videoTextureSupported: boolean;
  30955. protected _renderingQueueLaunched: boolean;
  30956. protected _activeRenderLoops: (() => void)[];
  30957. /**
  30958. * Observable signaled when a context lost event is raised
  30959. */
  30960. onContextLostObservable: Observable<ThinEngine>;
  30961. /**
  30962. * Observable signaled when a context restored event is raised
  30963. */
  30964. onContextRestoredObservable: Observable<ThinEngine>;
  30965. private _onContextLost;
  30966. private _onContextRestored;
  30967. protected _contextWasLost: boolean;
  30968. /** @hidden */
  30969. _doNotHandleContextLost: boolean;
  30970. /**
  30971. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30972. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30973. */
  30974. get doNotHandleContextLost(): boolean;
  30975. set doNotHandleContextLost(value: boolean);
  30976. /**
  30977. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30978. */
  30979. disableVertexArrayObjects: boolean;
  30980. /** @hidden */
  30981. protected _colorWrite: boolean;
  30982. /** @hidden */
  30983. protected _colorWriteChanged: boolean;
  30984. /** @hidden */
  30985. protected _depthCullingState: DepthCullingState;
  30986. /** @hidden */
  30987. protected _stencilState: StencilState;
  30988. /** @hidden */
  30989. _alphaState: AlphaState;
  30990. /** @hidden */
  30991. _alphaMode: number;
  30992. /** @hidden */
  30993. _alphaEquation: number;
  30994. /** @hidden */
  30995. _internalTexturesCache: InternalTexture[];
  30996. /** @hidden */
  30997. protected _activeChannel: number;
  30998. private _currentTextureChannel;
  30999. /** @hidden */
  31000. protected _boundTexturesCache: {
  31001. [key: string]: Nullable<InternalTexture>;
  31002. };
  31003. /** @hidden */
  31004. protected _currentEffect: Nullable<Effect>;
  31005. /** @hidden */
  31006. protected _currentProgram: Nullable<WebGLProgram>;
  31007. private _compiledEffects;
  31008. private _vertexAttribArraysEnabled;
  31009. /** @hidden */
  31010. protected _cachedViewport: Nullable<IViewportLike>;
  31011. private _cachedVertexArrayObject;
  31012. /** @hidden */
  31013. protected _cachedVertexBuffers: any;
  31014. /** @hidden */
  31015. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31016. /** @hidden */
  31017. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31018. /** @hidden */
  31019. _currentRenderTarget: Nullable<InternalTexture>;
  31020. private _uintIndicesCurrentlySet;
  31021. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31022. /** @hidden */
  31023. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31024. private _currentBufferPointers;
  31025. private _currentInstanceLocations;
  31026. private _currentInstanceBuffers;
  31027. private _textureUnits;
  31028. /** @hidden */
  31029. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31030. /** @hidden */
  31031. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31032. /** @hidden */
  31033. _boundRenderFunction: any;
  31034. private _vaoRecordInProgress;
  31035. private _mustWipeVertexAttributes;
  31036. private _emptyTexture;
  31037. private _emptyCubeTexture;
  31038. private _emptyTexture3D;
  31039. private _emptyTexture2DArray;
  31040. /** @hidden */
  31041. _frameHandler: number;
  31042. private _nextFreeTextureSlots;
  31043. private _maxSimultaneousTextures;
  31044. private _activeRequests;
  31045. protected _texturesSupported: string[];
  31046. /** @hidden */
  31047. _textureFormatInUse: Nullable<string>;
  31048. protected get _supportsHardwareTextureRescaling(): boolean;
  31049. /**
  31050. * Gets the list of texture formats supported
  31051. */
  31052. get texturesSupported(): Array<string>;
  31053. /**
  31054. * Gets the list of texture formats in use
  31055. */
  31056. get textureFormatInUse(): Nullable<string>;
  31057. /**
  31058. * Gets the current viewport
  31059. */
  31060. get currentViewport(): Nullable<IViewportLike>;
  31061. /**
  31062. * Gets the default empty texture
  31063. */
  31064. get emptyTexture(): InternalTexture;
  31065. /**
  31066. * Gets the default empty 3D texture
  31067. */
  31068. get emptyTexture3D(): InternalTexture;
  31069. /**
  31070. * Gets the default empty 2D array texture
  31071. */
  31072. get emptyTexture2DArray(): InternalTexture;
  31073. /**
  31074. * Gets the default empty cube texture
  31075. */
  31076. get emptyCubeTexture(): InternalTexture;
  31077. /**
  31078. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31079. */
  31080. readonly premultipliedAlpha: boolean;
  31081. /**
  31082. * Observable event triggered before each texture is initialized
  31083. */
  31084. onBeforeTextureInitObservable: Observable<Texture>;
  31085. /**
  31086. * Creates a new engine
  31087. * @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
  31088. * @param antialias defines enable antialiasing (default: false)
  31089. * @param options defines further options to be sent to the getContext() function
  31090. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31091. */
  31092. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31093. private _rebuildInternalTextures;
  31094. private _rebuildEffects;
  31095. /**
  31096. * Gets a boolean indicating if all created effects are ready
  31097. * @returns true if all effects are ready
  31098. */
  31099. areAllEffectsReady(): boolean;
  31100. protected _rebuildBuffers(): void;
  31101. private _initGLContext;
  31102. /**
  31103. * Gets version of the current webGL context
  31104. */
  31105. get webGLVersion(): number;
  31106. /**
  31107. * Gets a string idenfifying the name of the class
  31108. * @returns "Engine" string
  31109. */
  31110. getClassName(): string;
  31111. /**
  31112. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31113. */
  31114. get isStencilEnable(): boolean;
  31115. /** @hidden */
  31116. _prepareWorkingCanvas(): void;
  31117. /**
  31118. * Reset the texture cache to empty state
  31119. */
  31120. resetTextureCache(): void;
  31121. /**
  31122. * Gets an object containing information about the current webGL context
  31123. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31124. */
  31125. getGlInfo(): {
  31126. vendor: string;
  31127. renderer: string;
  31128. version: string;
  31129. };
  31130. /**
  31131. * Defines the hardware scaling level.
  31132. * By default the hardware scaling level is computed from the window device ratio.
  31133. * 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.
  31134. * @param level defines the level to use
  31135. */
  31136. setHardwareScalingLevel(level: number): void;
  31137. /**
  31138. * Gets the current hardware scaling level.
  31139. * By default the hardware scaling level is computed from the window device ratio.
  31140. * 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.
  31141. * @returns a number indicating the current hardware scaling level
  31142. */
  31143. getHardwareScalingLevel(): number;
  31144. /**
  31145. * Gets the list of loaded textures
  31146. * @returns an array containing all loaded textures
  31147. */
  31148. getLoadedTexturesCache(): InternalTexture[];
  31149. /**
  31150. * Gets the object containing all engine capabilities
  31151. * @returns the EngineCapabilities object
  31152. */
  31153. getCaps(): EngineCapabilities;
  31154. /**
  31155. * stop executing a render loop function and remove it from the execution array
  31156. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31157. */
  31158. stopRenderLoop(renderFunction?: () => void): void;
  31159. /** @hidden */
  31160. _renderLoop(): void;
  31161. /**
  31162. * Gets the HTML canvas attached with the current webGL context
  31163. * @returns a HTML canvas
  31164. */
  31165. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31166. /**
  31167. * Gets host window
  31168. * @returns the host window object
  31169. */
  31170. getHostWindow(): Nullable<Window>;
  31171. /**
  31172. * Gets the current render width
  31173. * @param useScreen defines if screen size must be used (or the current render target if any)
  31174. * @returns a number defining the current render width
  31175. */
  31176. getRenderWidth(useScreen?: boolean): number;
  31177. /**
  31178. * Gets the current render height
  31179. * @param useScreen defines if screen size must be used (or the current render target if any)
  31180. * @returns a number defining the current render height
  31181. */
  31182. getRenderHeight(useScreen?: boolean): number;
  31183. /**
  31184. * Can be used to override the current requestAnimationFrame requester.
  31185. * @hidden
  31186. */
  31187. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31188. /**
  31189. * Register and execute a render loop. The engine can have more than one render function
  31190. * @param renderFunction defines the function to continuously execute
  31191. */
  31192. runRenderLoop(renderFunction: () => void): void;
  31193. /**
  31194. * Clear the current render buffer or the current render target (if any is set up)
  31195. * @param color defines the color to use
  31196. * @param backBuffer defines if the back buffer must be cleared
  31197. * @param depth defines if the depth buffer must be cleared
  31198. * @param stencil defines if the stencil buffer must be cleared
  31199. */
  31200. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31201. private _viewportCached;
  31202. /** @hidden */
  31203. _viewport(x: number, y: number, width: number, height: number): void;
  31204. /**
  31205. * Set the WebGL's viewport
  31206. * @param viewport defines the viewport element to be used
  31207. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31208. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31209. */
  31210. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31211. /**
  31212. * Begin a new frame
  31213. */
  31214. beginFrame(): void;
  31215. /**
  31216. * Enf the current frame
  31217. */
  31218. endFrame(): void;
  31219. /**
  31220. * Resize the view according to the canvas' size
  31221. */
  31222. resize(): void;
  31223. /**
  31224. * Force a specific size of the canvas
  31225. * @param width defines the new canvas' width
  31226. * @param height defines the new canvas' height
  31227. */
  31228. setSize(width: number, height: number): void;
  31229. /**
  31230. * Binds the frame buffer to the specified texture.
  31231. * @param texture The texture to render to or null for the default canvas
  31232. * @param faceIndex The face of the texture to render to in case of cube texture
  31233. * @param requiredWidth The width of the target to render to
  31234. * @param requiredHeight The height of the target to render to
  31235. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31236. * @param lodLevel defines the lod level to bind to the frame buffer
  31237. * @param layer defines the 2d array index to bind to frame buffer to
  31238. */
  31239. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31240. /** @hidden */
  31241. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31242. /**
  31243. * Unbind the current render target texture from the webGL context
  31244. * @param texture defines the render target texture to unbind
  31245. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31246. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31247. */
  31248. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31249. /**
  31250. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31251. */
  31252. flushFramebuffer(): void;
  31253. /**
  31254. * Unbind the current render target and bind the default framebuffer
  31255. */
  31256. restoreDefaultFramebuffer(): void;
  31257. /** @hidden */
  31258. protected _resetVertexBufferBinding(): void;
  31259. /**
  31260. * Creates a vertex buffer
  31261. * @param data the data for the vertex buffer
  31262. * @returns the new WebGL static buffer
  31263. */
  31264. createVertexBuffer(data: DataArray): DataBuffer;
  31265. private _createVertexBuffer;
  31266. /**
  31267. * Creates a dynamic vertex buffer
  31268. * @param data the data for the dynamic vertex buffer
  31269. * @returns the new WebGL dynamic buffer
  31270. */
  31271. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31272. protected _resetIndexBufferBinding(): void;
  31273. /**
  31274. * Creates a new index buffer
  31275. * @param indices defines the content of the index buffer
  31276. * @param updatable defines if the index buffer must be updatable
  31277. * @returns a new webGL buffer
  31278. */
  31279. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31280. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31281. /**
  31282. * Bind a webGL buffer to the webGL context
  31283. * @param buffer defines the buffer to bind
  31284. */
  31285. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31286. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31287. private bindBuffer;
  31288. /**
  31289. * update the bound buffer with the given data
  31290. * @param data defines the data to update
  31291. */
  31292. updateArrayBuffer(data: Float32Array): void;
  31293. private _vertexAttribPointer;
  31294. /** @hidden */
  31295. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31296. private _bindVertexBuffersAttributes;
  31297. /**
  31298. * Records a vertex array object
  31299. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31300. * @param vertexBuffers defines the list of vertex buffers to store
  31301. * @param indexBuffer defines the index buffer to store
  31302. * @param effect defines the effect to store
  31303. * @returns the new vertex array object
  31304. */
  31305. recordVertexArrayObject(vertexBuffers: {
  31306. [key: string]: VertexBuffer;
  31307. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31308. /**
  31309. * Bind a specific vertex array object
  31310. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31311. * @param vertexArrayObject defines the vertex array object to bind
  31312. * @param indexBuffer defines the index buffer to bind
  31313. */
  31314. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31315. /**
  31316. * Bind webGl buffers directly to the webGL context
  31317. * @param vertexBuffer defines the vertex buffer to bind
  31318. * @param indexBuffer defines the index buffer to bind
  31319. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31320. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31321. * @param effect defines the effect associated with the vertex buffer
  31322. */
  31323. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31324. private _unbindVertexArrayObject;
  31325. /**
  31326. * Bind a list of vertex buffers to the webGL context
  31327. * @param vertexBuffers defines the list of vertex buffers to bind
  31328. * @param indexBuffer defines the index buffer to bind
  31329. * @param effect defines the effect associated with the vertex buffers
  31330. */
  31331. bindBuffers(vertexBuffers: {
  31332. [key: string]: Nullable<VertexBuffer>;
  31333. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31334. /**
  31335. * Unbind all instance attributes
  31336. */
  31337. unbindInstanceAttributes(): void;
  31338. /**
  31339. * Release and free the memory of a vertex array object
  31340. * @param vao defines the vertex array object to delete
  31341. */
  31342. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31343. /** @hidden */
  31344. _releaseBuffer(buffer: DataBuffer): boolean;
  31345. protected _deleteBuffer(buffer: DataBuffer): void;
  31346. /**
  31347. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31348. * @param instancesBuffer defines the webGL buffer to update and bind
  31349. * @param data defines the data to store in the buffer
  31350. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31351. */
  31352. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31353. /**
  31354. * Bind the content of a webGL buffer used with instanciation
  31355. * @param instancesBuffer defines the webGL buffer to bind
  31356. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31357. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  31358. */
  31359. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31360. /**
  31361. * Disable the instance attribute corresponding to the name in parameter
  31362. * @param name defines the name of the attribute to disable
  31363. */
  31364. disableInstanceAttributeByName(name: string): void;
  31365. /**
  31366. * Disable the instance attribute corresponding to the location in parameter
  31367. * @param attributeLocation defines the attribute location of the attribute to disable
  31368. */
  31369. disableInstanceAttribute(attributeLocation: number): void;
  31370. /**
  31371. * Disable the attribute corresponding to the location in parameter
  31372. * @param attributeLocation defines the attribute location of the attribute to disable
  31373. */
  31374. disableAttributeByIndex(attributeLocation: number): void;
  31375. /**
  31376. * Send a draw order
  31377. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31378. * @param indexStart defines the starting index
  31379. * @param indexCount defines the number of index to draw
  31380. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31381. */
  31382. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31383. /**
  31384. * Draw a list of points
  31385. * @param verticesStart defines the index of first vertex to draw
  31386. * @param verticesCount defines the count of vertices to draw
  31387. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31388. */
  31389. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31390. /**
  31391. * Draw a list of unindexed primitives
  31392. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31393. * @param verticesStart defines the index of first vertex to draw
  31394. * @param verticesCount defines the count of vertices to draw
  31395. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31396. */
  31397. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31398. /**
  31399. * Draw a list of indexed primitives
  31400. * @param fillMode defines the primitive to use
  31401. * @param indexStart defines the starting index
  31402. * @param indexCount defines the number of index to draw
  31403. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31404. */
  31405. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31406. /**
  31407. * Draw a list of unindexed primitives
  31408. * @param fillMode defines the primitive to use
  31409. * @param verticesStart defines the index of first vertex to draw
  31410. * @param verticesCount defines the count of vertices to draw
  31411. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31412. */
  31413. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31414. private _drawMode;
  31415. /** @hidden */
  31416. protected _reportDrawCall(): void;
  31417. /** @hidden */
  31418. _releaseEffect(effect: Effect): void;
  31419. /** @hidden */
  31420. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31421. /**
  31422. * Create a new effect (used to store vertex/fragment shaders)
  31423. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31424. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31425. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31426. * @param samplers defines an array of string used to represent textures
  31427. * @param defines defines the string containing the defines to use to compile the shaders
  31428. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31429. * @param onCompiled defines a function to call when the effect creation is successful
  31430. * @param onError defines a function to call when the effect creation has failed
  31431. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31432. * @returns the new Effect
  31433. */
  31434. 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;
  31435. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31436. private _compileShader;
  31437. private _compileRawShader;
  31438. /**
  31439. * Directly creates a webGL program
  31440. * @param pipelineContext defines the pipeline context to attach to
  31441. * @param vertexCode defines the vertex shader code to use
  31442. * @param fragmentCode defines the fragment shader code to use
  31443. * @param context defines the webGL context to use (if not set, the current one will be used)
  31444. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31445. * @returns the new webGL program
  31446. */
  31447. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31448. /**
  31449. * Creates a webGL program
  31450. * @param pipelineContext defines the pipeline context to attach to
  31451. * @param vertexCode defines the vertex shader code to use
  31452. * @param fragmentCode defines the fragment shader code to use
  31453. * @param defines defines the string containing the defines to use to compile the shaders
  31454. * @param context defines the webGL context to use (if not set, the current one will be used)
  31455. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31456. * @returns the new webGL program
  31457. */
  31458. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31459. /**
  31460. * Creates a new pipeline context
  31461. * @returns the new pipeline
  31462. */
  31463. createPipelineContext(): IPipelineContext;
  31464. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31465. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31466. /** @hidden */
  31467. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31468. /** @hidden */
  31469. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31470. /** @hidden */
  31471. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31472. /**
  31473. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31474. * @param pipelineContext defines the pipeline context to use
  31475. * @param uniformsNames defines the list of uniform names
  31476. * @returns an array of webGL uniform locations
  31477. */
  31478. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31479. /**
  31480. * Gets the lsit of active attributes for a given webGL program
  31481. * @param pipelineContext defines the pipeline context to use
  31482. * @param attributesNames defines the list of attribute names to get
  31483. * @returns an array of indices indicating the offset of each attribute
  31484. */
  31485. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31486. /**
  31487. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31488. * @param effect defines the effect to activate
  31489. */
  31490. enableEffect(effect: Nullable<Effect>): void;
  31491. /**
  31492. * Set the value of an uniform to a number (int)
  31493. * @param uniform defines the webGL uniform location where to store the value
  31494. * @param value defines the int number to store
  31495. */
  31496. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31497. /**
  31498. * Set the value of an uniform to an array of int32
  31499. * @param uniform defines the webGL uniform location where to store the value
  31500. * @param array defines the array of int32 to store
  31501. */
  31502. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31503. /**
  31504. * Set the value of an uniform to an array of int32 (stored as vec2)
  31505. * @param uniform defines the webGL uniform location where to store the value
  31506. * @param array defines the array of int32 to store
  31507. */
  31508. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31509. /**
  31510. * Set the value of an uniform to an array of int32 (stored as vec3)
  31511. * @param uniform defines the webGL uniform location where to store the value
  31512. * @param array defines the array of int32 to store
  31513. */
  31514. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31515. /**
  31516. * Set the value of an uniform to an array of int32 (stored as vec4)
  31517. * @param uniform defines the webGL uniform location where to store the value
  31518. * @param array defines the array of int32 to store
  31519. */
  31520. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31521. /**
  31522. * Set the value of an uniform to an array of number
  31523. * @param uniform defines the webGL uniform location where to store the value
  31524. * @param array defines the array of number to store
  31525. */
  31526. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31527. /**
  31528. * Set the value of an uniform to an array of number (stored as vec2)
  31529. * @param uniform defines the webGL uniform location where to store the value
  31530. * @param array defines the array of number to store
  31531. */
  31532. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31533. /**
  31534. * Set the value of an uniform to an array of number (stored as vec3)
  31535. * @param uniform defines the webGL uniform location where to store the value
  31536. * @param array defines the array of number to store
  31537. */
  31538. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31539. /**
  31540. * Set the value of an uniform to an array of number (stored as vec4)
  31541. * @param uniform defines the webGL uniform location where to store the value
  31542. * @param array defines the array of number to store
  31543. */
  31544. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31545. /**
  31546. * Set the value of an uniform to an array of float32 (stored as matrices)
  31547. * @param uniform defines the webGL uniform location where to store the value
  31548. * @param matrices defines the array of float32 to store
  31549. */
  31550. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31551. /**
  31552. * Set the value of an uniform to a matrix (3x3)
  31553. * @param uniform defines the webGL uniform location where to store the value
  31554. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31555. */
  31556. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31557. /**
  31558. * Set the value of an uniform to a matrix (2x2)
  31559. * @param uniform defines the webGL uniform location where to store the value
  31560. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31561. */
  31562. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31563. /**
  31564. * Set the value of an uniform to a number (float)
  31565. * @param uniform defines the webGL uniform location where to store the value
  31566. * @param value defines the float number to store
  31567. */
  31568. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31569. /**
  31570. * Set the value of an uniform to a vec2
  31571. * @param uniform defines the webGL uniform location where to store the value
  31572. * @param x defines the 1st component of the value
  31573. * @param y defines the 2nd component of the value
  31574. */
  31575. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31576. /**
  31577. * Set the value of an uniform to a vec3
  31578. * @param uniform defines the webGL uniform location where to store the value
  31579. * @param x defines the 1st component of the value
  31580. * @param y defines the 2nd component of the value
  31581. * @param z defines the 3rd component of the value
  31582. */
  31583. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31584. /**
  31585. * Set the value of an uniform to a vec4
  31586. * @param uniform defines the webGL uniform location where to store the value
  31587. * @param x defines the 1st component of the value
  31588. * @param y defines the 2nd component of the value
  31589. * @param z defines the 3rd component of the value
  31590. * @param w defines the 4th component of the value
  31591. */
  31592. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31593. /**
  31594. * Apply all cached states (depth, culling, stencil and alpha)
  31595. */
  31596. applyStates(): void;
  31597. /**
  31598. * Enable or disable color writing
  31599. * @param enable defines the state to set
  31600. */
  31601. setColorWrite(enable: boolean): void;
  31602. /**
  31603. * Gets a boolean indicating if color writing is enabled
  31604. * @returns the current color writing state
  31605. */
  31606. getColorWrite(): boolean;
  31607. /**
  31608. * Gets the depth culling state manager
  31609. */
  31610. get depthCullingState(): DepthCullingState;
  31611. /**
  31612. * Gets the alpha state manager
  31613. */
  31614. get alphaState(): AlphaState;
  31615. /**
  31616. * Gets the stencil state manager
  31617. */
  31618. get stencilState(): StencilState;
  31619. /**
  31620. * Clears the list of texture accessible through engine.
  31621. * This can help preventing texture load conflict due to name collision.
  31622. */
  31623. clearInternalTexturesCache(): void;
  31624. /**
  31625. * Force the entire cache to be cleared
  31626. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31627. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31628. */
  31629. wipeCaches(bruteForce?: boolean): void;
  31630. /** @hidden */
  31631. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31632. min: number;
  31633. mag: number;
  31634. };
  31635. /** @hidden */
  31636. _createTexture(): WebGLTexture;
  31637. /**
  31638. * Usually called from Texture.ts.
  31639. * Passed information to create a WebGLTexture
  31640. * @param urlArg defines a value which contains one of the following:
  31641. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31642. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31643. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31644. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31645. * @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)
  31646. * @param scene needed for loading to the correct scene
  31647. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31648. * @param onLoad optional callback to be called upon successful completion
  31649. * @param onError optional callback to be called upon failure
  31650. * @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
  31651. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31652. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31653. * @param forcedExtension defines the extension to use to pick the right loader
  31654. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31655. * @param mimeType defines an optional mime type
  31656. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31657. */
  31658. 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>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  31659. /**
  31660. * Loads an image as an HTMLImageElement.
  31661. * @param input url string, ArrayBuffer, or Blob to load
  31662. * @param onLoad callback called when the image successfully loads
  31663. * @param onError callback called when the image fails to load
  31664. * @param offlineProvider offline provider for caching
  31665. * @param mimeType optional mime type
  31666. * @returns the HTMLImageElement of the loaded image
  31667. * @hidden
  31668. */
  31669. 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>;
  31670. /**
  31671. * @hidden
  31672. */
  31673. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31674. /**
  31675. * Creates a raw texture
  31676. * @param data defines the data to store in the texture
  31677. * @param width defines the width of the texture
  31678. * @param height defines the height of the texture
  31679. * @param format defines the format of the data
  31680. * @param generateMipMaps defines if the engine should generate the mip levels
  31681. * @param invertY defines if data must be stored with Y axis inverted
  31682. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31683. * @param compression defines the compression used (null by default)
  31684. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31685. * @returns the raw texture inside an InternalTexture
  31686. */
  31687. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31688. /**
  31689. * Creates a new raw cube texture
  31690. * @param data defines the array of data to use to create each face
  31691. * @param size defines the size of the textures
  31692. * @param format defines the format of the data
  31693. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31694. * @param generateMipMaps defines if the engine should generate the mip levels
  31695. * @param invertY defines if data must be stored with Y axis inverted
  31696. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31697. * @param compression defines the compression used (null by default)
  31698. * @returns the cube texture as an InternalTexture
  31699. */
  31700. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31701. /**
  31702. * Creates a new raw 3D texture
  31703. * @param data defines the data used to create the texture
  31704. * @param width defines the width of the texture
  31705. * @param height defines the height of the texture
  31706. * @param depth defines the depth of the texture
  31707. * @param format defines the format of the texture
  31708. * @param generateMipMaps defines if the engine must generate mip levels
  31709. * @param invertY defines if data must be stored with Y axis inverted
  31710. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31711. * @param compression defines the compressed used (can be null)
  31712. * @param textureType defines the compressed used (can be null)
  31713. * @returns a new raw 3D texture (stored in an InternalTexture)
  31714. */
  31715. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31716. /**
  31717. * Creates a new raw 2D array texture
  31718. * @param data defines the data used to create the texture
  31719. * @param width defines the width of the texture
  31720. * @param height defines the height of the texture
  31721. * @param depth defines the number of layers of the texture
  31722. * @param format defines the format of the texture
  31723. * @param generateMipMaps defines if the engine must generate mip levels
  31724. * @param invertY defines if data must be stored with Y axis inverted
  31725. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31726. * @param compression defines the compressed used (can be null)
  31727. * @param textureType defines the compressed used (can be null)
  31728. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31729. */
  31730. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31731. private _unpackFlipYCached;
  31732. /**
  31733. * In case you are sharing the context with other applications, it might
  31734. * be interested to not cache the unpack flip y state to ensure a consistent
  31735. * value would be set.
  31736. */
  31737. enableUnpackFlipYCached: boolean;
  31738. /** @hidden */
  31739. _unpackFlipY(value: boolean): void;
  31740. /** @hidden */
  31741. _getUnpackAlignement(): number;
  31742. private _getTextureTarget;
  31743. /**
  31744. * Update the sampling mode of a given texture
  31745. * @param samplingMode defines the required sampling mode
  31746. * @param texture defines the texture to update
  31747. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31748. */
  31749. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31750. /**
  31751. * Update the sampling mode of a given texture
  31752. * @param texture defines the texture to update
  31753. * @param wrapU defines the texture wrap mode of the u coordinates
  31754. * @param wrapV defines the texture wrap mode of the v coordinates
  31755. * @param wrapR defines the texture wrap mode of the r coordinates
  31756. */
  31757. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31758. /** @hidden */
  31759. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31760. width: number;
  31761. height: number;
  31762. layers?: number;
  31763. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31764. /** @hidden */
  31765. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31766. /** @hidden */
  31767. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31768. /**
  31769. * Update a portion of an internal texture
  31770. * @param texture defines the texture to update
  31771. * @param imageData defines the data to store into the texture
  31772. * @param xOffset defines the x coordinates of the update rectangle
  31773. * @param yOffset defines the y coordinates of the update rectangle
  31774. * @param width defines the width of the update rectangle
  31775. * @param height defines the height of the update rectangle
  31776. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31777. * @param lod defines the lod level to update (0 by default)
  31778. */
  31779. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31780. /** @hidden */
  31781. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31782. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31783. private _prepareWebGLTexture;
  31784. /** @hidden */
  31785. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31786. private _getDepthStencilBuffer;
  31787. /** @hidden */
  31788. _releaseFramebufferObjects(texture: InternalTexture): void;
  31789. /** @hidden */
  31790. _releaseTexture(texture: InternalTexture): void;
  31791. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31792. protected _setProgram(program: WebGLProgram): void;
  31793. protected _boundUniforms: {
  31794. [key: number]: WebGLUniformLocation;
  31795. };
  31796. /**
  31797. * Binds an effect to the webGL context
  31798. * @param effect defines the effect to bind
  31799. */
  31800. bindSamplers(effect: Effect): void;
  31801. private _activateCurrentTexture;
  31802. /** @hidden */
  31803. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31804. /** @hidden */
  31805. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31806. /**
  31807. * Unbind all textures from the webGL context
  31808. */
  31809. unbindAllTextures(): void;
  31810. /**
  31811. * Sets a texture to the according uniform.
  31812. * @param channel The texture channel
  31813. * @param uniform The uniform to set
  31814. * @param texture The texture to apply
  31815. */
  31816. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31817. private _bindSamplerUniformToChannel;
  31818. private _getTextureWrapMode;
  31819. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31820. /**
  31821. * Sets an array of texture to the webGL context
  31822. * @param channel defines the channel where the texture array must be set
  31823. * @param uniform defines the associated uniform location
  31824. * @param textures defines the array of textures to bind
  31825. */
  31826. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31827. /** @hidden */
  31828. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31829. private _setTextureParameterFloat;
  31830. private _setTextureParameterInteger;
  31831. /**
  31832. * Unbind all vertex attributes from the webGL context
  31833. */
  31834. unbindAllAttributes(): void;
  31835. /**
  31836. * 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
  31837. */
  31838. releaseEffects(): void;
  31839. /**
  31840. * Dispose and release all associated resources
  31841. */
  31842. dispose(): void;
  31843. /**
  31844. * Attach a new callback raised when context lost event is fired
  31845. * @param callback defines the callback to call
  31846. */
  31847. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31848. /**
  31849. * Attach a new callback raised when context restored event is fired
  31850. * @param callback defines the callback to call
  31851. */
  31852. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31853. /**
  31854. * Get the current error code of the webGL context
  31855. * @returns the error code
  31856. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31857. */
  31858. getError(): number;
  31859. private _canRenderToFloatFramebuffer;
  31860. private _canRenderToHalfFloatFramebuffer;
  31861. private _canRenderToFramebuffer;
  31862. /** @hidden */
  31863. _getWebGLTextureType(type: number): number;
  31864. /** @hidden */
  31865. _getInternalFormat(format: number): number;
  31866. /** @hidden */
  31867. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31868. /** @hidden */
  31869. _getRGBAMultiSampleBufferFormat(type: number): number;
  31870. /** @hidden */
  31871. _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;
  31872. /**
  31873. * Loads a file from a url
  31874. * @param url url to load
  31875. * @param onSuccess callback called when the file successfully loads
  31876. * @param onProgress callback called while file is loading (if the server supports this mode)
  31877. * @param offlineProvider defines the offline provider for caching
  31878. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31879. * @param onError callback called when the file fails to load
  31880. * @returns a file request object
  31881. * @hidden
  31882. */
  31883. 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;
  31884. /**
  31885. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31886. * @param x defines the x coordinate of the rectangle where pixels must be read
  31887. * @param y defines the y coordinate of the rectangle where pixels must be read
  31888. * @param width defines the width of the rectangle where pixels must be read
  31889. * @param height defines the height of the rectangle where pixels must be read
  31890. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  31891. * @returns a Uint8Array containing RGBA colors
  31892. */
  31893. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31894. private static _isSupported;
  31895. /**
  31896. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31897. * @returns true if the engine can be created
  31898. * @ignorenaming
  31899. */
  31900. static isSupported(): boolean;
  31901. /**
  31902. * Find the next highest power of two.
  31903. * @param x Number to start search from.
  31904. * @return Next highest power of two.
  31905. */
  31906. static CeilingPOT(x: number): number;
  31907. /**
  31908. * Find the next lowest power of two.
  31909. * @param x Number to start search from.
  31910. * @return Next lowest power of two.
  31911. */
  31912. static FloorPOT(x: number): number;
  31913. /**
  31914. * Find the nearest power of two.
  31915. * @param x Number to start search from.
  31916. * @return Next nearest power of two.
  31917. */
  31918. static NearestPOT(x: number): number;
  31919. /**
  31920. * Get the closest exponent of two
  31921. * @param value defines the value to approximate
  31922. * @param max defines the maximum value to return
  31923. * @param mode defines how to define the closest value
  31924. * @returns closest exponent of two of the given value
  31925. */
  31926. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31927. /**
  31928. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31929. * @param func - the function to be called
  31930. * @param requester - the object that will request the next frame. Falls back to window.
  31931. * @returns frame number
  31932. */
  31933. static QueueNewFrame(func: () => void, requester?: any): number;
  31934. /**
  31935. * Gets host document
  31936. * @returns the host document object
  31937. */
  31938. getHostDocument(): Nullable<Document>;
  31939. }
  31940. }
  31941. declare module BABYLON {
  31942. /**
  31943. * Class representing spherical harmonics coefficients to the 3rd degree
  31944. */
  31945. export class SphericalHarmonics {
  31946. /**
  31947. * Defines whether or not the harmonics have been prescaled for rendering.
  31948. */
  31949. preScaled: boolean;
  31950. /**
  31951. * The l0,0 coefficients of the spherical harmonics
  31952. */
  31953. l00: Vector3;
  31954. /**
  31955. * The l1,-1 coefficients of the spherical harmonics
  31956. */
  31957. l1_1: Vector3;
  31958. /**
  31959. * The l1,0 coefficients of the spherical harmonics
  31960. */
  31961. l10: Vector3;
  31962. /**
  31963. * The l1,1 coefficients of the spherical harmonics
  31964. */
  31965. l11: Vector3;
  31966. /**
  31967. * The l2,-2 coefficients of the spherical harmonics
  31968. */
  31969. l2_2: Vector3;
  31970. /**
  31971. * The l2,-1 coefficients of the spherical harmonics
  31972. */
  31973. l2_1: Vector3;
  31974. /**
  31975. * The l2,0 coefficients of the spherical harmonics
  31976. */
  31977. l20: Vector3;
  31978. /**
  31979. * The l2,1 coefficients of the spherical harmonics
  31980. */
  31981. l21: Vector3;
  31982. /**
  31983. * The l2,2 coefficients of the spherical harmonics
  31984. */
  31985. l22: Vector3;
  31986. /**
  31987. * Adds a light to the spherical harmonics
  31988. * @param direction the direction of the light
  31989. * @param color the color of the light
  31990. * @param deltaSolidAngle the delta solid angle of the light
  31991. */
  31992. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31993. /**
  31994. * Scales the spherical harmonics by the given amount
  31995. * @param scale the amount to scale
  31996. */
  31997. scaleInPlace(scale: number): void;
  31998. /**
  31999. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32000. *
  32001. * ```
  32002. * E_lm = A_l * L_lm
  32003. * ```
  32004. *
  32005. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32006. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32007. * the scaling factors are given in equation 9.
  32008. */
  32009. convertIncidentRadianceToIrradiance(): void;
  32010. /**
  32011. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32012. *
  32013. * ```
  32014. * L = (1/pi) * E * rho
  32015. * ```
  32016. *
  32017. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32018. */
  32019. convertIrradianceToLambertianRadiance(): void;
  32020. /**
  32021. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32022. * required operations at run time.
  32023. *
  32024. * This is simply done by scaling back the SH with Ylm constants parameter.
  32025. * The trigonometric part being applied by the shader at run time.
  32026. */
  32027. preScaleForRendering(): void;
  32028. /**
  32029. * Constructs a spherical harmonics from an array.
  32030. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32031. * @returns the spherical harmonics
  32032. */
  32033. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32034. /**
  32035. * Gets the spherical harmonics from polynomial
  32036. * @param polynomial the spherical polynomial
  32037. * @returns the spherical harmonics
  32038. */
  32039. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32040. }
  32041. /**
  32042. * Class representing spherical polynomial coefficients to the 3rd degree
  32043. */
  32044. export class SphericalPolynomial {
  32045. private _harmonics;
  32046. /**
  32047. * The spherical harmonics used to create the polynomials.
  32048. */
  32049. get preScaledHarmonics(): SphericalHarmonics;
  32050. /**
  32051. * The x coefficients of the spherical polynomial
  32052. */
  32053. x: Vector3;
  32054. /**
  32055. * The y coefficients of the spherical polynomial
  32056. */
  32057. y: Vector3;
  32058. /**
  32059. * The z coefficients of the spherical polynomial
  32060. */
  32061. z: Vector3;
  32062. /**
  32063. * The xx coefficients of the spherical polynomial
  32064. */
  32065. xx: Vector3;
  32066. /**
  32067. * The yy coefficients of the spherical polynomial
  32068. */
  32069. yy: Vector3;
  32070. /**
  32071. * The zz coefficients of the spherical polynomial
  32072. */
  32073. zz: Vector3;
  32074. /**
  32075. * The xy coefficients of the spherical polynomial
  32076. */
  32077. xy: Vector3;
  32078. /**
  32079. * The yz coefficients of the spherical polynomial
  32080. */
  32081. yz: Vector3;
  32082. /**
  32083. * The zx coefficients of the spherical polynomial
  32084. */
  32085. zx: Vector3;
  32086. /**
  32087. * Adds an ambient color to the spherical polynomial
  32088. * @param color the color to add
  32089. */
  32090. addAmbient(color: Color3): void;
  32091. /**
  32092. * Scales the spherical polynomial by the given amount
  32093. * @param scale the amount to scale
  32094. */
  32095. scaleInPlace(scale: number): void;
  32096. /**
  32097. * Gets the spherical polynomial from harmonics
  32098. * @param harmonics the spherical harmonics
  32099. * @returns the spherical polynomial
  32100. */
  32101. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32102. /**
  32103. * Constructs a spherical polynomial from an array.
  32104. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32105. * @returns the spherical polynomial
  32106. */
  32107. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32108. }
  32109. }
  32110. declare module BABYLON {
  32111. /**
  32112. * Defines the source of the internal texture
  32113. */
  32114. export enum InternalTextureSource {
  32115. /**
  32116. * The source of the texture data is unknown
  32117. */
  32118. Unknown = 0,
  32119. /**
  32120. * Texture data comes from an URL
  32121. */
  32122. Url = 1,
  32123. /**
  32124. * Texture data is only used for temporary storage
  32125. */
  32126. Temp = 2,
  32127. /**
  32128. * Texture data comes from raw data (ArrayBuffer)
  32129. */
  32130. Raw = 3,
  32131. /**
  32132. * Texture content is dynamic (video or dynamic texture)
  32133. */
  32134. Dynamic = 4,
  32135. /**
  32136. * Texture content is generated by rendering to it
  32137. */
  32138. RenderTarget = 5,
  32139. /**
  32140. * Texture content is part of a multi render target process
  32141. */
  32142. MultiRenderTarget = 6,
  32143. /**
  32144. * Texture data comes from a cube data file
  32145. */
  32146. Cube = 7,
  32147. /**
  32148. * Texture data comes from a raw cube data
  32149. */
  32150. CubeRaw = 8,
  32151. /**
  32152. * Texture data come from a prefiltered cube data file
  32153. */
  32154. CubePrefiltered = 9,
  32155. /**
  32156. * Texture content is raw 3D data
  32157. */
  32158. Raw3D = 10,
  32159. /**
  32160. * Texture content is raw 2D array data
  32161. */
  32162. Raw2DArray = 11,
  32163. /**
  32164. * Texture content is a depth texture
  32165. */
  32166. Depth = 12,
  32167. /**
  32168. * Texture data comes from a raw cube data encoded with RGBD
  32169. */
  32170. CubeRawRGBD = 13
  32171. }
  32172. /**
  32173. * Class used to store data associated with WebGL texture data for the engine
  32174. * This class should not be used directly
  32175. */
  32176. export class InternalTexture {
  32177. /** @hidden */
  32178. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32179. /**
  32180. * Defines if the texture is ready
  32181. */
  32182. isReady: boolean;
  32183. /**
  32184. * Defines if the texture is a cube texture
  32185. */
  32186. isCube: boolean;
  32187. /**
  32188. * Defines if the texture contains 3D data
  32189. */
  32190. is3D: boolean;
  32191. /**
  32192. * Defines if the texture contains 2D array data
  32193. */
  32194. is2DArray: boolean;
  32195. /**
  32196. * Defines if the texture contains multiview data
  32197. */
  32198. isMultiview: boolean;
  32199. /**
  32200. * Gets the URL used to load this texture
  32201. */
  32202. url: string;
  32203. /**
  32204. * Gets the sampling mode of the texture
  32205. */
  32206. samplingMode: number;
  32207. /**
  32208. * Gets a boolean indicating if the texture needs mipmaps generation
  32209. */
  32210. generateMipMaps: boolean;
  32211. /**
  32212. * Gets the number of samples used by the texture (WebGL2+ only)
  32213. */
  32214. samples: number;
  32215. /**
  32216. * Gets the type of the texture (int, float...)
  32217. */
  32218. type: number;
  32219. /**
  32220. * Gets the format of the texture (RGB, RGBA...)
  32221. */
  32222. format: number;
  32223. /**
  32224. * Observable called when the texture is loaded
  32225. */
  32226. onLoadedObservable: Observable<InternalTexture>;
  32227. /**
  32228. * Gets the width of the texture
  32229. */
  32230. width: number;
  32231. /**
  32232. * Gets the height of the texture
  32233. */
  32234. height: number;
  32235. /**
  32236. * Gets the depth of the texture
  32237. */
  32238. depth: number;
  32239. /**
  32240. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32241. */
  32242. baseWidth: number;
  32243. /**
  32244. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32245. */
  32246. baseHeight: number;
  32247. /**
  32248. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32249. */
  32250. baseDepth: number;
  32251. /**
  32252. * Gets a boolean indicating if the texture is inverted on Y axis
  32253. */
  32254. invertY: boolean;
  32255. /** @hidden */
  32256. _invertVScale: boolean;
  32257. /** @hidden */
  32258. _associatedChannel: number;
  32259. /** @hidden */
  32260. _source: InternalTextureSource;
  32261. /** @hidden */
  32262. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32263. /** @hidden */
  32264. _bufferView: Nullable<ArrayBufferView>;
  32265. /** @hidden */
  32266. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32267. /** @hidden */
  32268. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32269. /** @hidden */
  32270. _size: number;
  32271. /** @hidden */
  32272. _extension: string;
  32273. /** @hidden */
  32274. _files: Nullable<string[]>;
  32275. /** @hidden */
  32276. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32277. /** @hidden */
  32278. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32279. /** @hidden */
  32280. _framebuffer: Nullable<WebGLFramebuffer>;
  32281. /** @hidden */
  32282. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32283. /** @hidden */
  32284. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32285. /** @hidden */
  32286. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32287. /** @hidden */
  32288. _attachments: Nullable<number[]>;
  32289. /** @hidden */
  32290. _cachedCoordinatesMode: Nullable<number>;
  32291. /** @hidden */
  32292. _cachedWrapU: Nullable<number>;
  32293. /** @hidden */
  32294. _cachedWrapV: Nullable<number>;
  32295. /** @hidden */
  32296. _cachedWrapR: Nullable<number>;
  32297. /** @hidden */
  32298. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32299. /** @hidden */
  32300. _isDisabled: boolean;
  32301. /** @hidden */
  32302. _compression: Nullable<string>;
  32303. /** @hidden */
  32304. _generateStencilBuffer: boolean;
  32305. /** @hidden */
  32306. _generateDepthBuffer: boolean;
  32307. /** @hidden */
  32308. _comparisonFunction: number;
  32309. /** @hidden */
  32310. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32311. /** @hidden */
  32312. _lodGenerationScale: number;
  32313. /** @hidden */
  32314. _lodGenerationOffset: number;
  32315. /** @hidden */
  32316. _depthStencilTexture: Nullable<InternalTexture>;
  32317. /** @hidden */
  32318. _colorTextureArray: Nullable<WebGLTexture>;
  32319. /** @hidden */
  32320. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32321. /** @hidden */
  32322. _lodTextureHigh: Nullable<BaseTexture>;
  32323. /** @hidden */
  32324. _lodTextureMid: Nullable<BaseTexture>;
  32325. /** @hidden */
  32326. _lodTextureLow: Nullable<BaseTexture>;
  32327. /** @hidden */
  32328. _isRGBD: boolean;
  32329. /** @hidden */
  32330. _linearSpecularLOD: boolean;
  32331. /** @hidden */
  32332. _irradianceTexture: Nullable<BaseTexture>;
  32333. /** @hidden */
  32334. _webGLTexture: Nullable<WebGLTexture>;
  32335. /** @hidden */
  32336. _references: number;
  32337. private _engine;
  32338. /**
  32339. * Gets the Engine the texture belongs to.
  32340. * @returns The babylon engine
  32341. */
  32342. getEngine(): ThinEngine;
  32343. /**
  32344. * Gets the data source type of the texture
  32345. */
  32346. get source(): InternalTextureSource;
  32347. /**
  32348. * Creates a new InternalTexture
  32349. * @param engine defines the engine to use
  32350. * @param source defines the type of data that will be used
  32351. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32352. */
  32353. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32354. /**
  32355. * Increments the number of references (ie. the number of Texture that point to it)
  32356. */
  32357. incrementReferences(): void;
  32358. /**
  32359. * Change the size of the texture (not the size of the content)
  32360. * @param width defines the new width
  32361. * @param height defines the new height
  32362. * @param depth defines the new depth (1 by default)
  32363. */
  32364. updateSize(width: int, height: int, depth?: int): void;
  32365. /** @hidden */
  32366. _rebuild(): void;
  32367. /** @hidden */
  32368. _swapAndDie(target: InternalTexture): void;
  32369. /**
  32370. * Dispose the current allocated resources
  32371. */
  32372. dispose(): void;
  32373. }
  32374. }
  32375. declare module BABYLON {
  32376. /**
  32377. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32378. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32379. */
  32380. export class Analyser {
  32381. /**
  32382. * Gets or sets the smoothing
  32383. * @ignorenaming
  32384. */
  32385. SMOOTHING: number;
  32386. /**
  32387. * Gets or sets the FFT table size
  32388. * @ignorenaming
  32389. */
  32390. FFT_SIZE: number;
  32391. /**
  32392. * Gets or sets the bar graph amplitude
  32393. * @ignorenaming
  32394. */
  32395. BARGRAPHAMPLITUDE: number;
  32396. /**
  32397. * Gets or sets the position of the debug canvas
  32398. * @ignorenaming
  32399. */
  32400. DEBUGCANVASPOS: {
  32401. x: number;
  32402. y: number;
  32403. };
  32404. /**
  32405. * Gets or sets the debug canvas size
  32406. * @ignorenaming
  32407. */
  32408. DEBUGCANVASSIZE: {
  32409. width: number;
  32410. height: number;
  32411. };
  32412. private _byteFreqs;
  32413. private _byteTime;
  32414. private _floatFreqs;
  32415. private _webAudioAnalyser;
  32416. private _debugCanvas;
  32417. private _debugCanvasContext;
  32418. private _scene;
  32419. private _registerFunc;
  32420. private _audioEngine;
  32421. /**
  32422. * Creates a new analyser
  32423. * @param scene defines hosting scene
  32424. */
  32425. constructor(scene: Scene);
  32426. /**
  32427. * Get the number of data values you will have to play with for the visualization
  32428. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32429. * @returns a number
  32430. */
  32431. getFrequencyBinCount(): number;
  32432. /**
  32433. * Gets the current frequency data as a byte array
  32434. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32435. * @returns a Uint8Array
  32436. */
  32437. getByteFrequencyData(): Uint8Array;
  32438. /**
  32439. * Gets the current waveform as a byte array
  32440. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32441. * @returns a Uint8Array
  32442. */
  32443. getByteTimeDomainData(): Uint8Array;
  32444. /**
  32445. * Gets the current frequency data as a float array
  32446. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32447. * @returns a Float32Array
  32448. */
  32449. getFloatFrequencyData(): Float32Array;
  32450. /**
  32451. * Renders the debug canvas
  32452. */
  32453. drawDebugCanvas(): void;
  32454. /**
  32455. * Stops rendering the debug canvas and removes it
  32456. */
  32457. stopDebugCanvas(): void;
  32458. /**
  32459. * Connects two audio nodes
  32460. * @param inputAudioNode defines first node to connect
  32461. * @param outputAudioNode defines second node to connect
  32462. */
  32463. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32464. /**
  32465. * Releases all associated resources
  32466. */
  32467. dispose(): void;
  32468. }
  32469. }
  32470. declare module BABYLON {
  32471. /**
  32472. * This represents an audio engine and it is responsible
  32473. * to play, synchronize and analyse sounds throughout the application.
  32474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32475. */
  32476. export interface IAudioEngine extends IDisposable {
  32477. /**
  32478. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32479. */
  32480. readonly canUseWebAudio: boolean;
  32481. /**
  32482. * Gets the current AudioContext if available.
  32483. */
  32484. readonly audioContext: Nullable<AudioContext>;
  32485. /**
  32486. * The master gain node defines the global audio volume of your audio engine.
  32487. */
  32488. readonly masterGain: GainNode;
  32489. /**
  32490. * Gets whether or not mp3 are supported by your browser.
  32491. */
  32492. readonly isMP3supported: boolean;
  32493. /**
  32494. * Gets whether or not ogg are supported by your browser.
  32495. */
  32496. readonly isOGGsupported: boolean;
  32497. /**
  32498. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32499. * @ignoreNaming
  32500. */
  32501. WarnedWebAudioUnsupported: boolean;
  32502. /**
  32503. * Defines if the audio engine relies on a custom unlocked button.
  32504. * In this case, the embedded button will not be displayed.
  32505. */
  32506. useCustomUnlockedButton: boolean;
  32507. /**
  32508. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32509. */
  32510. readonly unlocked: boolean;
  32511. /**
  32512. * Event raised when audio has been unlocked on the browser.
  32513. */
  32514. onAudioUnlockedObservable: Observable<AudioEngine>;
  32515. /**
  32516. * Event raised when audio has been locked on the browser.
  32517. */
  32518. onAudioLockedObservable: Observable<AudioEngine>;
  32519. /**
  32520. * Flags the audio engine in Locked state.
  32521. * This happens due to new browser policies preventing audio to autoplay.
  32522. */
  32523. lock(): void;
  32524. /**
  32525. * Unlocks the audio engine once a user action has been done on the dom.
  32526. * This is helpful to resume play once browser policies have been satisfied.
  32527. */
  32528. unlock(): void;
  32529. }
  32530. /**
  32531. * This represents the default audio engine used in babylon.
  32532. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32534. */
  32535. export class AudioEngine implements IAudioEngine {
  32536. private _audioContext;
  32537. private _audioContextInitialized;
  32538. private _muteButton;
  32539. private _hostElement;
  32540. /**
  32541. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32542. */
  32543. canUseWebAudio: boolean;
  32544. /**
  32545. * The master gain node defines the global audio volume of your audio engine.
  32546. */
  32547. masterGain: GainNode;
  32548. /**
  32549. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32550. * @ignoreNaming
  32551. */
  32552. WarnedWebAudioUnsupported: boolean;
  32553. /**
  32554. * Gets whether or not mp3 are supported by your browser.
  32555. */
  32556. isMP3supported: boolean;
  32557. /**
  32558. * Gets whether or not ogg are supported by your browser.
  32559. */
  32560. isOGGsupported: boolean;
  32561. /**
  32562. * Gets whether audio has been unlocked on the device.
  32563. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32564. * a user interaction has happened.
  32565. */
  32566. unlocked: boolean;
  32567. /**
  32568. * Defines if the audio engine relies on a custom unlocked button.
  32569. * In this case, the embedded button will not be displayed.
  32570. */
  32571. useCustomUnlockedButton: boolean;
  32572. /**
  32573. * Event raised when audio has been unlocked on the browser.
  32574. */
  32575. onAudioUnlockedObservable: Observable<AudioEngine>;
  32576. /**
  32577. * Event raised when audio has been locked on the browser.
  32578. */
  32579. onAudioLockedObservable: Observable<AudioEngine>;
  32580. /**
  32581. * Gets the current AudioContext if available.
  32582. */
  32583. get audioContext(): Nullable<AudioContext>;
  32584. private _connectedAnalyser;
  32585. /**
  32586. * Instantiates a new audio engine.
  32587. *
  32588. * There should be only one per page as some browsers restrict the number
  32589. * of audio contexts you can create.
  32590. * @param hostElement defines the host element where to display the mute icon if necessary
  32591. */
  32592. constructor(hostElement?: Nullable<HTMLElement>);
  32593. /**
  32594. * Flags the audio engine in Locked state.
  32595. * This happens due to new browser policies preventing audio to autoplay.
  32596. */
  32597. lock(): void;
  32598. /**
  32599. * Unlocks the audio engine once a user action has been done on the dom.
  32600. * This is helpful to resume play once browser policies have been satisfied.
  32601. */
  32602. unlock(): void;
  32603. private _resumeAudioContext;
  32604. private _initializeAudioContext;
  32605. private _tryToRun;
  32606. private _triggerRunningState;
  32607. private _triggerSuspendedState;
  32608. private _displayMuteButton;
  32609. private _moveButtonToTopLeft;
  32610. private _onResize;
  32611. private _hideMuteButton;
  32612. /**
  32613. * Destroy and release the resources associated with the audio ccontext.
  32614. */
  32615. dispose(): void;
  32616. /**
  32617. * Gets the global volume sets on the master gain.
  32618. * @returns the global volume if set or -1 otherwise
  32619. */
  32620. getGlobalVolume(): number;
  32621. /**
  32622. * Sets the global volume of your experience (sets on the master gain).
  32623. * @param newVolume Defines the new global volume of the application
  32624. */
  32625. setGlobalVolume(newVolume: number): void;
  32626. /**
  32627. * Connect the audio engine to an audio analyser allowing some amazing
  32628. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32630. * @param analyser The analyser to connect to the engine
  32631. */
  32632. connectToAnalyser(analyser: Analyser): void;
  32633. }
  32634. }
  32635. declare module BABYLON {
  32636. /**
  32637. * Interface used to present a loading screen while loading a scene
  32638. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32639. */
  32640. export interface ILoadingScreen {
  32641. /**
  32642. * Function called to display the loading screen
  32643. */
  32644. displayLoadingUI: () => void;
  32645. /**
  32646. * Function called to hide the loading screen
  32647. */
  32648. hideLoadingUI: () => void;
  32649. /**
  32650. * Gets or sets the color to use for the background
  32651. */
  32652. loadingUIBackgroundColor: string;
  32653. /**
  32654. * Gets or sets the text to display while loading
  32655. */
  32656. loadingUIText: string;
  32657. }
  32658. /**
  32659. * Class used for the default loading screen
  32660. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32661. */
  32662. export class DefaultLoadingScreen implements ILoadingScreen {
  32663. private _renderingCanvas;
  32664. private _loadingText;
  32665. private _loadingDivBackgroundColor;
  32666. private _loadingDiv;
  32667. private _loadingTextDiv;
  32668. /** Gets or sets the logo url to use for the default loading screen */
  32669. static DefaultLogoUrl: string;
  32670. /** Gets or sets the spinner url to use for the default loading screen */
  32671. static DefaultSpinnerUrl: string;
  32672. /**
  32673. * Creates a new default loading screen
  32674. * @param _renderingCanvas defines the canvas used to render the scene
  32675. * @param _loadingText defines the default text to display
  32676. * @param _loadingDivBackgroundColor defines the default background color
  32677. */
  32678. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32679. /**
  32680. * Function called to display the loading screen
  32681. */
  32682. displayLoadingUI(): void;
  32683. /**
  32684. * Function called to hide the loading screen
  32685. */
  32686. hideLoadingUI(): void;
  32687. /**
  32688. * Gets or sets the text to display while loading
  32689. */
  32690. set loadingUIText(text: string);
  32691. get loadingUIText(): string;
  32692. /**
  32693. * Gets or sets the color to use for the background
  32694. */
  32695. get loadingUIBackgroundColor(): string;
  32696. set loadingUIBackgroundColor(color: string);
  32697. private _resizeLoadingUI;
  32698. }
  32699. }
  32700. declare module BABYLON {
  32701. /**
  32702. * Interface for any object that can request an animation frame
  32703. */
  32704. export interface ICustomAnimationFrameRequester {
  32705. /**
  32706. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32707. */
  32708. renderFunction?: Function;
  32709. /**
  32710. * Called to request the next frame to render to
  32711. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32712. */
  32713. requestAnimationFrame: Function;
  32714. /**
  32715. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32716. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32717. */
  32718. requestID?: number;
  32719. }
  32720. }
  32721. declare module BABYLON {
  32722. /**
  32723. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32724. */
  32725. export class PerformanceMonitor {
  32726. private _enabled;
  32727. private _rollingFrameTime;
  32728. private _lastFrameTimeMs;
  32729. /**
  32730. * constructor
  32731. * @param frameSampleSize The number of samples required to saturate the sliding window
  32732. */
  32733. constructor(frameSampleSize?: number);
  32734. /**
  32735. * Samples current frame
  32736. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32737. */
  32738. sampleFrame(timeMs?: number): void;
  32739. /**
  32740. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32741. */
  32742. get averageFrameTime(): number;
  32743. /**
  32744. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32745. */
  32746. get averageFrameTimeVariance(): number;
  32747. /**
  32748. * Returns the frame time of the most recent frame
  32749. */
  32750. get instantaneousFrameTime(): number;
  32751. /**
  32752. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32753. */
  32754. get averageFPS(): number;
  32755. /**
  32756. * Returns the average framerate in frames per second using the most recent frame time
  32757. */
  32758. get instantaneousFPS(): number;
  32759. /**
  32760. * Returns true if enough samples have been taken to completely fill the sliding window
  32761. */
  32762. get isSaturated(): boolean;
  32763. /**
  32764. * Enables contributions to the sliding window sample set
  32765. */
  32766. enable(): void;
  32767. /**
  32768. * Disables contributions to the sliding window sample set
  32769. * Samples will not be interpolated over the disabled period
  32770. */
  32771. disable(): void;
  32772. /**
  32773. * Returns true if sampling is enabled
  32774. */
  32775. get isEnabled(): boolean;
  32776. /**
  32777. * Resets performance monitor
  32778. */
  32779. reset(): void;
  32780. }
  32781. /**
  32782. * RollingAverage
  32783. *
  32784. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32785. */
  32786. export class RollingAverage {
  32787. /**
  32788. * Current average
  32789. */
  32790. average: number;
  32791. /**
  32792. * Current variance
  32793. */
  32794. variance: number;
  32795. protected _samples: Array<number>;
  32796. protected _sampleCount: number;
  32797. protected _pos: number;
  32798. protected _m2: number;
  32799. /**
  32800. * constructor
  32801. * @param length The number of samples required to saturate the sliding window
  32802. */
  32803. constructor(length: number);
  32804. /**
  32805. * Adds a sample to the sample set
  32806. * @param v The sample value
  32807. */
  32808. add(v: number): void;
  32809. /**
  32810. * Returns previously added values or null if outside of history or outside the sliding window domain
  32811. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32812. * @return Value previously recorded with add() or null if outside of range
  32813. */
  32814. history(i: number): number;
  32815. /**
  32816. * Returns true if enough samples have been taken to completely fill the sliding window
  32817. * @return true if sample-set saturated
  32818. */
  32819. isSaturated(): boolean;
  32820. /**
  32821. * Resets the rolling average (equivalent to 0 samples taken so far)
  32822. */
  32823. reset(): void;
  32824. /**
  32825. * Wraps a value around the sample range boundaries
  32826. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32827. * @return Wrapped position in sample range
  32828. */
  32829. protected _wrapPosition(i: number): number;
  32830. }
  32831. }
  32832. declare module BABYLON {
  32833. /**
  32834. * This class is used to track a performance counter which is number based.
  32835. * The user has access to many properties which give statistics of different nature.
  32836. *
  32837. * The implementer can track two kinds of Performance Counter: time and count.
  32838. * 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.
  32839. * 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.
  32840. */
  32841. export class PerfCounter {
  32842. /**
  32843. * Gets or sets a global boolean to turn on and off all the counters
  32844. */
  32845. static Enabled: boolean;
  32846. /**
  32847. * Returns the smallest value ever
  32848. */
  32849. get min(): number;
  32850. /**
  32851. * Returns the biggest value ever
  32852. */
  32853. get max(): number;
  32854. /**
  32855. * Returns the average value since the performance counter is running
  32856. */
  32857. get average(): number;
  32858. /**
  32859. * Returns the average value of the last second the counter was monitored
  32860. */
  32861. get lastSecAverage(): number;
  32862. /**
  32863. * Returns the current value
  32864. */
  32865. get current(): number;
  32866. /**
  32867. * Gets the accumulated total
  32868. */
  32869. get total(): number;
  32870. /**
  32871. * Gets the total value count
  32872. */
  32873. get count(): number;
  32874. /**
  32875. * Creates a new counter
  32876. */
  32877. constructor();
  32878. /**
  32879. * Call this method to start monitoring a new frame.
  32880. * 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.
  32881. */
  32882. fetchNewFrame(): void;
  32883. /**
  32884. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32885. * @param newCount the count value to add to the monitored count
  32886. * @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.
  32887. */
  32888. addCount(newCount: number, fetchResult: boolean): void;
  32889. /**
  32890. * Start monitoring this performance counter
  32891. */
  32892. beginMonitoring(): void;
  32893. /**
  32894. * Compute the time lapsed since the previous beginMonitoring() call.
  32895. * @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
  32896. */
  32897. endMonitoring(newFrame?: boolean): void;
  32898. private _fetchResult;
  32899. private _startMonitoringTime;
  32900. private _min;
  32901. private _max;
  32902. private _average;
  32903. private _current;
  32904. private _totalValueCount;
  32905. private _totalAccumulated;
  32906. private _lastSecAverage;
  32907. private _lastSecAccumulated;
  32908. private _lastSecTime;
  32909. private _lastSecValueCount;
  32910. }
  32911. }
  32912. declare module BABYLON {
  32913. interface ThinEngine {
  32914. /**
  32915. * Sets alpha constants used by some alpha blending modes
  32916. * @param r defines the red component
  32917. * @param g defines the green component
  32918. * @param b defines the blue component
  32919. * @param a defines the alpha component
  32920. */
  32921. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32922. /**
  32923. * Sets the current alpha mode
  32924. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32925. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32926. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32927. */
  32928. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32929. /**
  32930. * Gets the current alpha mode
  32931. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32932. * @returns the current alpha mode
  32933. */
  32934. getAlphaMode(): number;
  32935. /**
  32936. * Sets the current alpha equation
  32937. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32938. */
  32939. setAlphaEquation(equation: number): void;
  32940. /**
  32941. * Gets the current alpha equation.
  32942. * @returns the current alpha equation
  32943. */
  32944. getAlphaEquation(): number;
  32945. }
  32946. }
  32947. declare module BABYLON {
  32948. /**
  32949. * Defines the interface used by display changed events
  32950. */
  32951. export interface IDisplayChangedEventArgs {
  32952. /** Gets the vrDisplay object (if any) */
  32953. vrDisplay: Nullable<any>;
  32954. /** Gets a boolean indicating if webVR is supported */
  32955. vrSupported: boolean;
  32956. }
  32957. /**
  32958. * Defines the interface used by objects containing a viewport (like a camera)
  32959. */
  32960. interface IViewportOwnerLike {
  32961. /**
  32962. * Gets or sets the viewport
  32963. */
  32964. viewport: IViewportLike;
  32965. }
  32966. /**
  32967. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32968. */
  32969. export class Engine extends ThinEngine {
  32970. /** Defines that alpha blending is disabled */
  32971. static readonly ALPHA_DISABLE: number;
  32972. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32973. static readonly ALPHA_ADD: number;
  32974. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32975. static readonly ALPHA_COMBINE: number;
  32976. /** Defines that alpha blending to DEST - SRC * DEST */
  32977. static readonly ALPHA_SUBTRACT: number;
  32978. /** Defines that alpha blending to SRC * DEST */
  32979. static readonly ALPHA_MULTIPLY: number;
  32980. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32981. static readonly ALPHA_MAXIMIZED: number;
  32982. /** Defines that alpha blending to SRC + DEST */
  32983. static readonly ALPHA_ONEONE: number;
  32984. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32985. static readonly ALPHA_PREMULTIPLIED: number;
  32986. /**
  32987. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32988. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32989. */
  32990. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32991. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32992. static readonly ALPHA_INTERPOLATE: number;
  32993. /**
  32994. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32995. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32996. */
  32997. static readonly ALPHA_SCREENMODE: number;
  32998. /** Defines that the ressource is not delayed*/
  32999. static readonly DELAYLOADSTATE_NONE: number;
  33000. /** Defines that the ressource was successfully delay loaded */
  33001. static readonly DELAYLOADSTATE_LOADED: number;
  33002. /** Defines that the ressource is currently delay loading */
  33003. static readonly DELAYLOADSTATE_LOADING: number;
  33004. /** Defines that the ressource is delayed and has not started loading */
  33005. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33006. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33007. static readonly NEVER: number;
  33008. /** 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 */
  33009. static readonly ALWAYS: number;
  33010. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33011. static readonly LESS: number;
  33012. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33013. static readonly EQUAL: number;
  33014. /** 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 */
  33015. static readonly LEQUAL: number;
  33016. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33017. static readonly GREATER: number;
  33018. /** 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 */
  33019. static readonly GEQUAL: number;
  33020. /** 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 */
  33021. static readonly NOTEQUAL: number;
  33022. /** Passed to stencilOperation to specify that stencil value must be kept */
  33023. static readonly KEEP: number;
  33024. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33025. static readonly REPLACE: number;
  33026. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33027. static readonly INCR: number;
  33028. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33029. static readonly DECR: number;
  33030. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33031. static readonly INVERT: number;
  33032. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33033. static readonly INCR_WRAP: number;
  33034. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33035. static readonly DECR_WRAP: number;
  33036. /** Texture is not repeating outside of 0..1 UVs */
  33037. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33038. /** Texture is repeating outside of 0..1 UVs */
  33039. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33040. /** Texture is repeating and mirrored */
  33041. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33042. /** ALPHA */
  33043. static readonly TEXTUREFORMAT_ALPHA: number;
  33044. /** LUMINANCE */
  33045. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33046. /** LUMINANCE_ALPHA */
  33047. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33048. /** RGB */
  33049. static readonly TEXTUREFORMAT_RGB: number;
  33050. /** RGBA */
  33051. static readonly TEXTUREFORMAT_RGBA: number;
  33052. /** RED */
  33053. static readonly TEXTUREFORMAT_RED: number;
  33054. /** RED (2nd reference) */
  33055. static readonly TEXTUREFORMAT_R: number;
  33056. /** RG */
  33057. static readonly TEXTUREFORMAT_RG: number;
  33058. /** RED_INTEGER */
  33059. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33060. /** RED_INTEGER (2nd reference) */
  33061. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33062. /** RG_INTEGER */
  33063. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33064. /** RGB_INTEGER */
  33065. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33066. /** RGBA_INTEGER */
  33067. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33068. /** UNSIGNED_BYTE */
  33069. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33070. /** UNSIGNED_BYTE (2nd reference) */
  33071. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33072. /** FLOAT */
  33073. static readonly TEXTURETYPE_FLOAT: number;
  33074. /** HALF_FLOAT */
  33075. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33076. /** BYTE */
  33077. static readonly TEXTURETYPE_BYTE: number;
  33078. /** SHORT */
  33079. static readonly TEXTURETYPE_SHORT: number;
  33080. /** UNSIGNED_SHORT */
  33081. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33082. /** INT */
  33083. static readonly TEXTURETYPE_INT: number;
  33084. /** UNSIGNED_INT */
  33085. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33086. /** UNSIGNED_SHORT_4_4_4_4 */
  33087. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33088. /** UNSIGNED_SHORT_5_5_5_1 */
  33089. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33090. /** UNSIGNED_SHORT_5_6_5 */
  33091. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33092. /** UNSIGNED_INT_2_10_10_10_REV */
  33093. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33094. /** UNSIGNED_INT_24_8 */
  33095. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33096. /** UNSIGNED_INT_10F_11F_11F_REV */
  33097. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33098. /** UNSIGNED_INT_5_9_9_9_REV */
  33099. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33100. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33101. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33102. /** nearest is mag = nearest and min = nearest and mip = linear */
  33103. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33104. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33105. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33106. /** Trilinear is mag = linear and min = linear and mip = linear */
  33107. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33108. /** nearest is mag = nearest and min = nearest and mip = linear */
  33109. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33110. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33111. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33112. /** Trilinear is mag = linear and min = linear and mip = linear */
  33113. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33114. /** mag = nearest and min = nearest and mip = nearest */
  33115. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33116. /** mag = nearest and min = linear and mip = nearest */
  33117. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33118. /** mag = nearest and min = linear and mip = linear */
  33119. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33120. /** mag = nearest and min = linear and mip = none */
  33121. static readonly TEXTURE_NEAREST_LINEAR: number;
  33122. /** mag = nearest and min = nearest and mip = none */
  33123. static readonly TEXTURE_NEAREST_NEAREST: number;
  33124. /** mag = linear and min = nearest and mip = nearest */
  33125. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33126. /** mag = linear and min = nearest and mip = linear */
  33127. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33128. /** mag = linear and min = linear and mip = none */
  33129. static readonly TEXTURE_LINEAR_LINEAR: number;
  33130. /** mag = linear and min = nearest and mip = none */
  33131. static readonly TEXTURE_LINEAR_NEAREST: number;
  33132. /** Explicit coordinates mode */
  33133. static readonly TEXTURE_EXPLICIT_MODE: number;
  33134. /** Spherical coordinates mode */
  33135. static readonly TEXTURE_SPHERICAL_MODE: number;
  33136. /** Planar coordinates mode */
  33137. static readonly TEXTURE_PLANAR_MODE: number;
  33138. /** Cubic coordinates mode */
  33139. static readonly TEXTURE_CUBIC_MODE: number;
  33140. /** Projection coordinates mode */
  33141. static readonly TEXTURE_PROJECTION_MODE: number;
  33142. /** Skybox coordinates mode */
  33143. static readonly TEXTURE_SKYBOX_MODE: number;
  33144. /** Inverse Cubic coordinates mode */
  33145. static readonly TEXTURE_INVCUBIC_MODE: number;
  33146. /** Equirectangular coordinates mode */
  33147. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33148. /** Equirectangular Fixed coordinates mode */
  33149. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33150. /** Equirectangular Fixed Mirrored coordinates mode */
  33151. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33152. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33153. static readonly SCALEMODE_FLOOR: number;
  33154. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33155. static readonly SCALEMODE_NEAREST: number;
  33156. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33157. static readonly SCALEMODE_CEILING: number;
  33158. /**
  33159. * Returns the current npm package of the sdk
  33160. */
  33161. static get NpmPackage(): string;
  33162. /**
  33163. * Returns the current version of the framework
  33164. */
  33165. static get Version(): string;
  33166. /** Gets the list of created engines */
  33167. static get Instances(): Engine[];
  33168. /**
  33169. * Gets the latest created engine
  33170. */
  33171. static get LastCreatedEngine(): Nullable<Engine>;
  33172. /**
  33173. * Gets the latest created scene
  33174. */
  33175. static get LastCreatedScene(): Nullable<Scene>;
  33176. /**
  33177. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33178. * @param flag defines which part of the materials must be marked as dirty
  33179. * @param predicate defines a predicate used to filter which materials should be affected
  33180. */
  33181. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33182. /**
  33183. * Method called to create the default loading screen.
  33184. * This can be overriden in your own app.
  33185. * @param canvas The rendering canvas element
  33186. * @returns The loading screen
  33187. */
  33188. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33189. /**
  33190. * Method called to create the default rescale post process on each engine.
  33191. */
  33192. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33193. /**
  33194. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33195. **/
  33196. enableOfflineSupport: boolean;
  33197. /**
  33198. * 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)
  33199. **/
  33200. disableManifestCheck: boolean;
  33201. /**
  33202. * Gets the list of created scenes
  33203. */
  33204. scenes: Scene[];
  33205. /**
  33206. * Event raised when a new scene is created
  33207. */
  33208. onNewSceneAddedObservable: Observable<Scene>;
  33209. /**
  33210. * Gets the list of created postprocesses
  33211. */
  33212. postProcesses: PostProcess[];
  33213. /**
  33214. * Gets a boolean indicating if the pointer is currently locked
  33215. */
  33216. isPointerLock: boolean;
  33217. /**
  33218. * Observable event triggered each time the rendering canvas is resized
  33219. */
  33220. onResizeObservable: Observable<Engine>;
  33221. /**
  33222. * Observable event triggered each time the canvas loses focus
  33223. */
  33224. onCanvasBlurObservable: Observable<Engine>;
  33225. /**
  33226. * Observable event triggered each time the canvas gains focus
  33227. */
  33228. onCanvasFocusObservable: Observable<Engine>;
  33229. /**
  33230. * Observable event triggered each time the canvas receives pointerout event
  33231. */
  33232. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33233. /**
  33234. * Observable raised when the engine begins a new frame
  33235. */
  33236. onBeginFrameObservable: Observable<Engine>;
  33237. /**
  33238. * If set, will be used to request the next animation frame for the render loop
  33239. */
  33240. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33241. /**
  33242. * Observable raised when the engine ends the current frame
  33243. */
  33244. onEndFrameObservable: Observable<Engine>;
  33245. /**
  33246. * Observable raised when the engine is about to compile a shader
  33247. */
  33248. onBeforeShaderCompilationObservable: Observable<Engine>;
  33249. /**
  33250. * Observable raised when the engine has jsut compiled a shader
  33251. */
  33252. onAfterShaderCompilationObservable: Observable<Engine>;
  33253. /**
  33254. * Gets the audio engine
  33255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33256. * @ignorenaming
  33257. */
  33258. static audioEngine: IAudioEngine;
  33259. /**
  33260. * Default AudioEngine factory responsible of creating the Audio Engine.
  33261. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33262. */
  33263. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33264. /**
  33265. * Default offline support factory responsible of creating a tool used to store data locally.
  33266. * By default, this will create a Database object if the workload has been embedded.
  33267. */
  33268. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33269. private _loadingScreen;
  33270. private _pointerLockRequested;
  33271. private _dummyFramebuffer;
  33272. private _rescalePostProcess;
  33273. private _deterministicLockstep;
  33274. private _lockstepMaxSteps;
  33275. private _timeStep;
  33276. protected get _supportsHardwareTextureRescaling(): boolean;
  33277. private _fps;
  33278. private _deltaTime;
  33279. /** @hidden */
  33280. _drawCalls: PerfCounter;
  33281. /** 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 */
  33282. canvasTabIndex: number;
  33283. /**
  33284. * Turn this value on if you want to pause FPS computation when in background
  33285. */
  33286. disablePerformanceMonitorInBackground: boolean;
  33287. private _performanceMonitor;
  33288. /**
  33289. * Gets the performance monitor attached to this engine
  33290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33291. */
  33292. get performanceMonitor(): PerformanceMonitor;
  33293. private _onFocus;
  33294. private _onBlur;
  33295. private _onCanvasPointerOut;
  33296. private _onCanvasBlur;
  33297. private _onCanvasFocus;
  33298. private _onFullscreenChange;
  33299. private _onPointerLockChange;
  33300. /**
  33301. * Gets the HTML element used to attach event listeners
  33302. * @returns a HTML element
  33303. */
  33304. getInputElement(): Nullable<HTMLElement>;
  33305. /**
  33306. * Creates a new engine
  33307. * @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
  33308. * @param antialias defines enable antialiasing (default: false)
  33309. * @param options defines further options to be sent to the getContext() function
  33310. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33311. */
  33312. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33313. /**
  33314. * Gets current aspect ratio
  33315. * @param viewportOwner defines the camera to use to get the aspect ratio
  33316. * @param useScreen defines if screen size must be used (or the current render target if any)
  33317. * @returns a number defining the aspect ratio
  33318. */
  33319. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33320. /**
  33321. * Gets current screen aspect ratio
  33322. * @returns a number defining the aspect ratio
  33323. */
  33324. getScreenAspectRatio(): number;
  33325. /**
  33326. * Gets the client rect of the HTML canvas attached with the current webGL context
  33327. * @returns a client rectanglee
  33328. */
  33329. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33330. /**
  33331. * Gets the client rect of the HTML element used for events
  33332. * @returns a client rectanglee
  33333. */
  33334. getInputElementClientRect(): Nullable<ClientRect>;
  33335. /**
  33336. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33337. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33338. * @returns true if engine is in deterministic lock step mode
  33339. */
  33340. isDeterministicLockStep(): boolean;
  33341. /**
  33342. * Gets the max steps when engine is running in deterministic lock step
  33343. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33344. * @returns the max steps
  33345. */
  33346. getLockstepMaxSteps(): number;
  33347. /**
  33348. * Returns the time in ms between steps when using deterministic lock step.
  33349. * @returns time step in (ms)
  33350. */
  33351. getTimeStep(): number;
  33352. /**
  33353. * Force the mipmap generation for the given render target texture
  33354. * @param texture defines the render target texture to use
  33355. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33356. */
  33357. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33358. /** States */
  33359. /**
  33360. * Set various states to the webGL context
  33361. * @param culling defines backface culling state
  33362. * @param zOffset defines the value to apply to zOffset (0 by default)
  33363. * @param force defines if states must be applied even if cache is up to date
  33364. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33365. */
  33366. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33367. /**
  33368. * Set the z offset to apply to current rendering
  33369. * @param value defines the offset to apply
  33370. */
  33371. setZOffset(value: number): void;
  33372. /**
  33373. * Gets the current value of the zOffset
  33374. * @returns the current zOffset state
  33375. */
  33376. getZOffset(): number;
  33377. /**
  33378. * Enable or disable depth buffering
  33379. * @param enable defines the state to set
  33380. */
  33381. setDepthBuffer(enable: boolean): void;
  33382. /**
  33383. * Gets a boolean indicating if depth writing is enabled
  33384. * @returns the current depth writing state
  33385. */
  33386. getDepthWrite(): boolean;
  33387. /**
  33388. * Enable or disable depth writing
  33389. * @param enable defines the state to set
  33390. */
  33391. setDepthWrite(enable: boolean): void;
  33392. /**
  33393. * Gets a boolean indicating if stencil buffer is enabled
  33394. * @returns the current stencil buffer state
  33395. */
  33396. getStencilBuffer(): boolean;
  33397. /**
  33398. * Enable or disable the stencil buffer
  33399. * @param enable defines if the stencil buffer must be enabled or disabled
  33400. */
  33401. setStencilBuffer(enable: boolean): void;
  33402. /**
  33403. * Gets the current stencil mask
  33404. * @returns a number defining the new stencil mask to use
  33405. */
  33406. getStencilMask(): number;
  33407. /**
  33408. * Sets the current stencil mask
  33409. * @param mask defines the new stencil mask to use
  33410. */
  33411. setStencilMask(mask: number): void;
  33412. /**
  33413. * Gets the current stencil function
  33414. * @returns a number defining the stencil function to use
  33415. */
  33416. getStencilFunction(): number;
  33417. /**
  33418. * Gets the current stencil reference value
  33419. * @returns a number defining the stencil reference value to use
  33420. */
  33421. getStencilFunctionReference(): number;
  33422. /**
  33423. * Gets the current stencil mask
  33424. * @returns a number defining the stencil mask to use
  33425. */
  33426. getStencilFunctionMask(): number;
  33427. /**
  33428. * Sets the current stencil function
  33429. * @param stencilFunc defines the new stencil function to use
  33430. */
  33431. setStencilFunction(stencilFunc: number): void;
  33432. /**
  33433. * Sets the current stencil reference
  33434. * @param reference defines the new stencil reference to use
  33435. */
  33436. setStencilFunctionReference(reference: number): void;
  33437. /**
  33438. * Sets the current stencil mask
  33439. * @param mask defines the new stencil mask to use
  33440. */
  33441. setStencilFunctionMask(mask: number): void;
  33442. /**
  33443. * Gets the current stencil operation when stencil fails
  33444. * @returns a number defining stencil operation to use when stencil fails
  33445. */
  33446. getStencilOperationFail(): number;
  33447. /**
  33448. * Gets the current stencil operation when depth fails
  33449. * @returns a number defining stencil operation to use when depth fails
  33450. */
  33451. getStencilOperationDepthFail(): number;
  33452. /**
  33453. * Gets the current stencil operation when stencil passes
  33454. * @returns a number defining stencil operation to use when stencil passes
  33455. */
  33456. getStencilOperationPass(): number;
  33457. /**
  33458. * Sets the stencil operation to use when stencil fails
  33459. * @param operation defines the stencil operation to use when stencil fails
  33460. */
  33461. setStencilOperationFail(operation: number): void;
  33462. /**
  33463. * Sets the stencil operation to use when depth fails
  33464. * @param operation defines the stencil operation to use when depth fails
  33465. */
  33466. setStencilOperationDepthFail(operation: number): void;
  33467. /**
  33468. * Sets the stencil operation to use when stencil passes
  33469. * @param operation defines the stencil operation to use when stencil passes
  33470. */
  33471. setStencilOperationPass(operation: number): void;
  33472. /**
  33473. * Sets a boolean indicating if the dithering state is enabled or disabled
  33474. * @param value defines the dithering state
  33475. */
  33476. setDitheringState(value: boolean): void;
  33477. /**
  33478. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33479. * @param value defines the rasterizer state
  33480. */
  33481. setRasterizerState(value: boolean): void;
  33482. /**
  33483. * Gets the current depth function
  33484. * @returns a number defining the depth function
  33485. */
  33486. getDepthFunction(): Nullable<number>;
  33487. /**
  33488. * Sets the current depth function
  33489. * @param depthFunc defines the function to use
  33490. */
  33491. setDepthFunction(depthFunc: number): void;
  33492. /**
  33493. * Sets the current depth function to GREATER
  33494. */
  33495. setDepthFunctionToGreater(): void;
  33496. /**
  33497. * Sets the current depth function to GEQUAL
  33498. */
  33499. setDepthFunctionToGreaterOrEqual(): void;
  33500. /**
  33501. * Sets the current depth function to LESS
  33502. */
  33503. setDepthFunctionToLess(): void;
  33504. /**
  33505. * Sets the current depth function to LEQUAL
  33506. */
  33507. setDepthFunctionToLessOrEqual(): void;
  33508. private _cachedStencilBuffer;
  33509. private _cachedStencilFunction;
  33510. private _cachedStencilMask;
  33511. private _cachedStencilOperationPass;
  33512. private _cachedStencilOperationFail;
  33513. private _cachedStencilOperationDepthFail;
  33514. private _cachedStencilReference;
  33515. /**
  33516. * Caches the the state of the stencil buffer
  33517. */
  33518. cacheStencilState(): void;
  33519. /**
  33520. * Restores the state of the stencil buffer
  33521. */
  33522. restoreStencilState(): void;
  33523. /**
  33524. * Directly set the WebGL Viewport
  33525. * @param x defines the x coordinate of the viewport (in screen space)
  33526. * @param y defines the y coordinate of the viewport (in screen space)
  33527. * @param width defines the width of the viewport (in screen space)
  33528. * @param height defines the height of the viewport (in screen space)
  33529. * @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
  33530. */
  33531. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33532. /**
  33533. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33534. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33535. * @param y defines the y-coordinate of the corner of the clear rectangle
  33536. * @param width defines the width of the clear rectangle
  33537. * @param height defines the height of the clear rectangle
  33538. * @param clearColor defines the clear color
  33539. */
  33540. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33541. /**
  33542. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33543. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33544. * @param y defines the y-coordinate of the corner of the clear rectangle
  33545. * @param width defines the width of the clear rectangle
  33546. * @param height defines the height of the clear rectangle
  33547. */
  33548. enableScissor(x: number, y: number, width: number, height: number): void;
  33549. /**
  33550. * Disable previously set scissor test rectangle
  33551. */
  33552. disableScissor(): void;
  33553. protected _reportDrawCall(): void;
  33554. /**
  33555. * Initializes a webVR display and starts listening to display change events
  33556. * The onVRDisplayChangedObservable will be notified upon these changes
  33557. * @returns The onVRDisplayChangedObservable
  33558. */
  33559. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33560. /** @hidden */
  33561. _prepareVRComponent(): void;
  33562. /** @hidden */
  33563. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33564. /** @hidden */
  33565. _submitVRFrame(): void;
  33566. /**
  33567. * Call this function to leave webVR mode
  33568. * Will do nothing if webVR is not supported or if there is no webVR device
  33569. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33570. */
  33571. disableVR(): void;
  33572. /**
  33573. * Gets a boolean indicating that the system is in VR mode and is presenting
  33574. * @returns true if VR mode is engaged
  33575. */
  33576. isVRPresenting(): boolean;
  33577. /** @hidden */
  33578. _requestVRFrame(): void;
  33579. /** @hidden */
  33580. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33581. /**
  33582. * Gets the source code of the vertex shader associated with a specific webGL program
  33583. * @param program defines the program to use
  33584. * @returns a string containing the source code of the vertex shader associated with the program
  33585. */
  33586. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33587. /**
  33588. * Gets the source code of the fragment shader associated with a specific webGL program
  33589. * @param program defines the program to use
  33590. * @returns a string containing the source code of the fragment shader associated with the program
  33591. */
  33592. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33593. /**
  33594. * Sets a depth stencil texture from a render target to the according uniform.
  33595. * @param channel The texture channel
  33596. * @param uniform The uniform to set
  33597. * @param texture The render target texture containing the depth stencil texture to apply
  33598. */
  33599. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33600. /**
  33601. * Sets a texture to the webGL context from a postprocess
  33602. * @param channel defines the channel to use
  33603. * @param postProcess defines the source postprocess
  33604. */
  33605. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33606. /**
  33607. * Binds the output of the passed in post process to the texture channel specified
  33608. * @param channel The channel the texture should be bound to
  33609. * @param postProcess The post process which's output should be bound
  33610. */
  33611. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33612. /** @hidden */
  33613. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33614. protected _rebuildBuffers(): void;
  33615. /** @hidden */
  33616. _renderFrame(): void;
  33617. _renderLoop(): void;
  33618. /** @hidden */
  33619. _renderViews(): boolean;
  33620. /**
  33621. * Toggle full screen mode
  33622. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33623. */
  33624. switchFullscreen(requestPointerLock: boolean): void;
  33625. /**
  33626. * Enters full screen mode
  33627. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33628. */
  33629. enterFullscreen(requestPointerLock: boolean): void;
  33630. /**
  33631. * Exits full screen mode
  33632. */
  33633. exitFullscreen(): void;
  33634. /**
  33635. * Enters Pointerlock mode
  33636. */
  33637. enterPointerlock(): void;
  33638. /**
  33639. * Exits Pointerlock mode
  33640. */
  33641. exitPointerlock(): void;
  33642. /**
  33643. * Begin a new frame
  33644. */
  33645. beginFrame(): void;
  33646. /**
  33647. * Enf the current frame
  33648. */
  33649. endFrame(): void;
  33650. resize(): void;
  33651. /**
  33652. * Set the compressed texture format to use, based on the formats you have, and the formats
  33653. * supported by the hardware / browser.
  33654. *
  33655. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33656. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33657. * to API arguments needed to compressed textures. This puts the burden on the container
  33658. * generator to house the arcane code for determining these for current & future formats.
  33659. *
  33660. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33661. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33662. *
  33663. * Note: The result of this call is not taken into account when a texture is base64.
  33664. *
  33665. * @param formatsAvailable defines the list of those format families you have created
  33666. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33667. *
  33668. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33669. * @returns The extension selected.
  33670. */
  33671. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33672. /**
  33673. * Set the compressed texture extensions or file names to skip.
  33674. *
  33675. * @param skippedFiles defines the list of those texture files you want to skip
  33676. * Example: [".dds", ".env", "myfile.png"]
  33677. */
  33678. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33679. /**
  33680. * Force a specific size of the canvas
  33681. * @param width defines the new canvas' width
  33682. * @param height defines the new canvas' height
  33683. */
  33684. setSize(width: number, height: number): void;
  33685. /**
  33686. * Updates a dynamic vertex buffer.
  33687. * @param vertexBuffer the vertex buffer to update
  33688. * @param data the data used to update the vertex buffer
  33689. * @param byteOffset the byte offset of the data
  33690. * @param byteLength the byte length of the data
  33691. */
  33692. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33693. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33694. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33695. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33696. _releaseTexture(texture: InternalTexture): void;
  33697. /**
  33698. * @hidden
  33699. * Rescales a texture
  33700. * @param source input texutre
  33701. * @param destination destination texture
  33702. * @param scene scene to use to render the resize
  33703. * @param internalFormat format to use when resizing
  33704. * @param onComplete callback to be called when resize has completed
  33705. */
  33706. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33707. /**
  33708. * Gets the current framerate
  33709. * @returns a number representing the framerate
  33710. */
  33711. getFps(): number;
  33712. /**
  33713. * Gets the time spent between current and previous frame
  33714. * @returns a number representing the delta time in ms
  33715. */
  33716. getDeltaTime(): number;
  33717. private _measureFps;
  33718. /** @hidden */
  33719. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33720. /**
  33721. * Update a dynamic index buffer
  33722. * @param indexBuffer defines the target index buffer
  33723. * @param indices defines the data to update
  33724. * @param offset defines the offset in the target index buffer where update should start
  33725. */
  33726. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33727. /**
  33728. * Updates the sample count of a render target texture
  33729. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33730. * @param texture defines the texture to update
  33731. * @param samples defines the sample count to set
  33732. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33733. */
  33734. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33735. /**
  33736. * Updates a depth texture Comparison Mode and Function.
  33737. * If the comparison Function is equal to 0, the mode will be set to none.
  33738. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33739. * @param texture The texture to set the comparison function for
  33740. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33741. */
  33742. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33743. /**
  33744. * Creates a webGL buffer to use with instanciation
  33745. * @param capacity defines the size of the buffer
  33746. * @returns the webGL buffer
  33747. */
  33748. createInstancesBuffer(capacity: number): DataBuffer;
  33749. /**
  33750. * Delete a webGL buffer used with instanciation
  33751. * @param buffer defines the webGL buffer to delete
  33752. */
  33753. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33754. /** @hidden */
  33755. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33756. dispose(): void;
  33757. private _disableTouchAction;
  33758. /**
  33759. * Display the loading screen
  33760. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33761. */
  33762. displayLoadingUI(): void;
  33763. /**
  33764. * Hide the loading screen
  33765. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33766. */
  33767. hideLoadingUI(): void;
  33768. /**
  33769. * Gets the current loading screen object
  33770. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33771. */
  33772. get loadingScreen(): ILoadingScreen;
  33773. /**
  33774. * Sets the current loading screen object
  33775. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33776. */
  33777. set loadingScreen(loadingScreen: ILoadingScreen);
  33778. /**
  33779. * Sets the current loading screen text
  33780. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33781. */
  33782. set loadingUIText(text: string);
  33783. /**
  33784. * Sets the current loading screen background color
  33785. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33786. */
  33787. set loadingUIBackgroundColor(color: string);
  33788. /** Pointerlock and fullscreen */
  33789. /**
  33790. * Ask the browser to promote the current element to pointerlock mode
  33791. * @param element defines the DOM element to promote
  33792. */
  33793. static _RequestPointerlock(element: HTMLElement): void;
  33794. /**
  33795. * Asks the browser to exit pointerlock mode
  33796. */
  33797. static _ExitPointerlock(): void;
  33798. /**
  33799. * Ask the browser to promote the current element to fullscreen rendering mode
  33800. * @param element defines the DOM element to promote
  33801. */
  33802. static _RequestFullscreen(element: HTMLElement): void;
  33803. /**
  33804. * Asks the browser to exit fullscreen mode
  33805. */
  33806. static _ExitFullscreen(): void;
  33807. }
  33808. }
  33809. declare module BABYLON {
  33810. /**
  33811. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33812. * during the life time of the application.
  33813. */
  33814. export class EngineStore {
  33815. /** Gets the list of created engines */
  33816. static Instances: Engine[];
  33817. /** @hidden */
  33818. static _LastCreatedScene: Nullable<Scene>;
  33819. /**
  33820. * Gets the latest created engine
  33821. */
  33822. static get LastCreatedEngine(): Nullable<Engine>;
  33823. /**
  33824. * Gets the latest created scene
  33825. */
  33826. static get LastCreatedScene(): Nullable<Scene>;
  33827. /**
  33828. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33829. * @ignorenaming
  33830. */
  33831. static UseFallbackTexture: boolean;
  33832. /**
  33833. * Texture content used if a texture cannot loaded
  33834. * @ignorenaming
  33835. */
  33836. static FallbackTexture: string;
  33837. }
  33838. }
  33839. declare module BABYLON {
  33840. /**
  33841. * Helper class that provides a small promise polyfill
  33842. */
  33843. export class PromisePolyfill {
  33844. /**
  33845. * Static function used to check if the polyfill is required
  33846. * If this is the case then the function will inject the polyfill to window.Promise
  33847. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33848. */
  33849. static Apply(force?: boolean): void;
  33850. }
  33851. }
  33852. declare module BABYLON {
  33853. /**
  33854. * Interface for screenshot methods with describe argument called `size` as object with options
  33855. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33856. */
  33857. export interface IScreenshotSize {
  33858. /**
  33859. * number in pixels for canvas height
  33860. */
  33861. height?: number;
  33862. /**
  33863. * multiplier allowing render at a higher or lower resolution
  33864. * If value is defined then height and width will be ignored and taken from camera
  33865. */
  33866. precision?: number;
  33867. /**
  33868. * number in pixels for canvas width
  33869. */
  33870. width?: number;
  33871. }
  33872. }
  33873. declare module BABYLON {
  33874. interface IColor4Like {
  33875. r: float;
  33876. g: float;
  33877. b: float;
  33878. a: float;
  33879. }
  33880. /**
  33881. * Class containing a set of static utilities functions
  33882. */
  33883. export class Tools {
  33884. /**
  33885. * Gets or sets the base URL to use to load assets
  33886. */
  33887. static get BaseUrl(): string;
  33888. static set BaseUrl(value: string);
  33889. /**
  33890. * Enable/Disable Custom HTTP Request Headers globally.
  33891. * default = false
  33892. * @see CustomRequestHeaders
  33893. */
  33894. static UseCustomRequestHeaders: boolean;
  33895. /**
  33896. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33897. * i.e. when loading files, where the server/service expects an Authorization header
  33898. */
  33899. static CustomRequestHeaders: {
  33900. [key: string]: string;
  33901. };
  33902. /**
  33903. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33904. */
  33905. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33906. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33907. /**
  33908. * Default behaviour for cors in the application.
  33909. * It can be a string if the expected behavior is identical in the entire app.
  33910. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33911. */
  33912. static CorsBehavior: string | ((url: string | string[]) => string);
  33913. /**
  33914. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33915. * @ignorenaming
  33916. */
  33917. static get UseFallbackTexture(): boolean;
  33918. static set UseFallbackTexture(value: boolean);
  33919. /**
  33920. * Use this object to register external classes like custom textures or material
  33921. * to allow the laoders to instantiate them
  33922. */
  33923. static get RegisteredExternalClasses(): {
  33924. [key: string]: Object;
  33925. };
  33926. static set RegisteredExternalClasses(classes: {
  33927. [key: string]: Object;
  33928. });
  33929. /**
  33930. * Texture content used if a texture cannot loaded
  33931. * @ignorenaming
  33932. */
  33933. static get fallbackTexture(): string;
  33934. static set fallbackTexture(value: string);
  33935. /**
  33936. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33937. * @param u defines the coordinate on X axis
  33938. * @param v defines the coordinate on Y axis
  33939. * @param width defines the width of the source data
  33940. * @param height defines the height of the source data
  33941. * @param pixels defines the source byte array
  33942. * @param color defines the output color
  33943. */
  33944. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33945. /**
  33946. * Interpolates between a and b via alpha
  33947. * @param a The lower value (returned when alpha = 0)
  33948. * @param b The upper value (returned when alpha = 1)
  33949. * @param alpha The interpolation-factor
  33950. * @return The mixed value
  33951. */
  33952. static Mix(a: number, b: number, alpha: number): number;
  33953. /**
  33954. * Tries to instantiate a new object from a given class name
  33955. * @param className defines the class name to instantiate
  33956. * @returns the new object or null if the system was not able to do the instantiation
  33957. */
  33958. static Instantiate(className: string): any;
  33959. /**
  33960. * Provides a slice function that will work even on IE
  33961. * @param data defines the array to slice
  33962. * @param start defines the start of the data (optional)
  33963. * @param end defines the end of the data (optional)
  33964. * @returns the new sliced array
  33965. */
  33966. static Slice<T>(data: T, start?: number, end?: number): T;
  33967. /**
  33968. * Polyfill for setImmediate
  33969. * @param action defines the action to execute after the current execution block
  33970. */
  33971. static SetImmediate(action: () => void): void;
  33972. /**
  33973. * Function indicating if a number is an exponent of 2
  33974. * @param value defines the value to test
  33975. * @returns true if the value is an exponent of 2
  33976. */
  33977. static IsExponentOfTwo(value: number): boolean;
  33978. private static _tmpFloatArray;
  33979. /**
  33980. * Returns the nearest 32-bit single precision float representation of a Number
  33981. * @param value A Number. If the parameter is of a different type, it will get converted
  33982. * to a number or to NaN if it cannot be converted
  33983. * @returns number
  33984. */
  33985. static FloatRound(value: number): number;
  33986. /**
  33987. * Extracts the filename from a path
  33988. * @param path defines the path to use
  33989. * @returns the filename
  33990. */
  33991. static GetFilename(path: string): string;
  33992. /**
  33993. * Extracts the "folder" part of a path (everything before the filename).
  33994. * @param uri The URI to extract the info from
  33995. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33996. * @returns The "folder" part of the path
  33997. */
  33998. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33999. /**
  34000. * Extracts text content from a DOM element hierarchy
  34001. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34002. */
  34003. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34004. /**
  34005. * Convert an angle in radians to degrees
  34006. * @param angle defines the angle to convert
  34007. * @returns the angle in degrees
  34008. */
  34009. static ToDegrees(angle: number): number;
  34010. /**
  34011. * Convert an angle in degrees to radians
  34012. * @param angle defines the angle to convert
  34013. * @returns the angle in radians
  34014. */
  34015. static ToRadians(angle: number): number;
  34016. /**
  34017. * Returns an array if obj is not an array
  34018. * @param obj defines the object to evaluate as an array
  34019. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34020. * @returns either obj directly if obj is an array or a new array containing obj
  34021. */
  34022. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34023. /**
  34024. * Gets the pointer prefix to use
  34025. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34026. */
  34027. static GetPointerPrefix(): string;
  34028. /**
  34029. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34030. * @param url define the url we are trying
  34031. * @param element define the dom element where to configure the cors policy
  34032. */
  34033. static SetCorsBehavior(url: string | string[], element: {
  34034. crossOrigin: string | null;
  34035. }): void;
  34036. /**
  34037. * Removes unwanted characters from an url
  34038. * @param url defines the url to clean
  34039. * @returns the cleaned url
  34040. */
  34041. static CleanUrl(url: string): string;
  34042. /**
  34043. * Gets or sets a function used to pre-process url before using them to load assets
  34044. */
  34045. static get PreprocessUrl(): (url: string) => string;
  34046. static set PreprocessUrl(processor: (url: string) => string);
  34047. /**
  34048. * Loads an image as an HTMLImageElement.
  34049. * @param input url string, ArrayBuffer, or Blob to load
  34050. * @param onLoad callback called when the image successfully loads
  34051. * @param onError callback called when the image fails to load
  34052. * @param offlineProvider offline provider for caching
  34053. * @param mimeType optional mime type
  34054. * @returns the HTMLImageElement of the loaded image
  34055. */
  34056. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34057. /**
  34058. * Loads a file from a url
  34059. * @param url url string, ArrayBuffer, or Blob to load
  34060. * @param onSuccess callback called when the file successfully loads
  34061. * @param onProgress callback called while file is loading (if the server supports this mode)
  34062. * @param offlineProvider defines the offline provider for caching
  34063. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34064. * @param onError callback called when the file fails to load
  34065. * @returns a file request object
  34066. */
  34067. 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;
  34068. /**
  34069. * Loads a file from a url
  34070. * @param url the file url to load
  34071. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34072. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34073. */
  34074. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34075. /**
  34076. * Load a script (identified by an url). When the url returns, the
  34077. * content of this file is added into a new script element, attached to the DOM (body element)
  34078. * @param scriptUrl defines the url of the script to laod
  34079. * @param onSuccess defines the callback called when the script is loaded
  34080. * @param onError defines the callback to call if an error occurs
  34081. * @param scriptId defines the id of the script element
  34082. */
  34083. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34084. /**
  34085. * Load an asynchronous script (identified by an url). When the url returns, the
  34086. * content of this file is added into a new script element, attached to the DOM (body element)
  34087. * @param scriptUrl defines the url of the script to laod
  34088. * @param scriptId defines the id of the script element
  34089. * @returns a promise request object
  34090. */
  34091. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34092. /**
  34093. * Loads a file from a blob
  34094. * @param fileToLoad defines the blob to use
  34095. * @param callback defines the callback to call when data is loaded
  34096. * @param progressCallback defines the callback to call during loading process
  34097. * @returns a file request object
  34098. */
  34099. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34100. /**
  34101. * Reads a file from a File object
  34102. * @param file defines the file to load
  34103. * @param onSuccess defines the callback to call when data is loaded
  34104. * @param onProgress defines the callback to call during loading process
  34105. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34106. * @param onError defines the callback to call when an error occurs
  34107. * @returns a file request object
  34108. */
  34109. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34110. /**
  34111. * Creates a data url from a given string content
  34112. * @param content defines the content to convert
  34113. * @returns the new data url link
  34114. */
  34115. static FileAsURL(content: string): string;
  34116. /**
  34117. * Format the given number to a specific decimal format
  34118. * @param value defines the number to format
  34119. * @param decimals defines the number of decimals to use
  34120. * @returns the formatted string
  34121. */
  34122. static Format(value: number, decimals?: number): string;
  34123. /**
  34124. * Tries to copy an object by duplicating every property
  34125. * @param source defines the source object
  34126. * @param destination defines the target object
  34127. * @param doNotCopyList defines a list of properties to avoid
  34128. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34129. */
  34130. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34131. /**
  34132. * Gets a boolean indicating if the given object has no own property
  34133. * @param obj defines the object to test
  34134. * @returns true if object has no own property
  34135. */
  34136. static IsEmpty(obj: any): boolean;
  34137. /**
  34138. * Function used to register events at window level
  34139. * @param windowElement defines the Window object to use
  34140. * @param events defines the events to register
  34141. */
  34142. static RegisterTopRootEvents(windowElement: Window, events: {
  34143. name: string;
  34144. handler: Nullable<(e: FocusEvent) => any>;
  34145. }[]): void;
  34146. /**
  34147. * Function used to unregister events from window level
  34148. * @param windowElement defines the Window object to use
  34149. * @param events defines the events to unregister
  34150. */
  34151. static UnregisterTopRootEvents(windowElement: Window, events: {
  34152. name: string;
  34153. handler: Nullable<(e: FocusEvent) => any>;
  34154. }[]): void;
  34155. /**
  34156. * @ignore
  34157. */
  34158. static _ScreenshotCanvas: HTMLCanvasElement;
  34159. /**
  34160. * Dumps the current bound framebuffer
  34161. * @param width defines the rendering width
  34162. * @param height defines the rendering height
  34163. * @param engine defines the hosting engine
  34164. * @param successCallback defines the callback triggered once the data are available
  34165. * @param mimeType defines the mime type of the result
  34166. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34167. */
  34168. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34169. /**
  34170. * Converts the canvas data to blob.
  34171. * This acts as a polyfill for browsers not supporting the to blob function.
  34172. * @param canvas Defines the canvas to extract the data from
  34173. * @param successCallback Defines the callback triggered once the data are available
  34174. * @param mimeType Defines the mime type of the result
  34175. */
  34176. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34177. /**
  34178. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34179. * @param successCallback defines the callback triggered once the data are available
  34180. * @param mimeType defines the mime type of the result
  34181. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34182. */
  34183. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34184. /**
  34185. * Downloads a blob in the browser
  34186. * @param blob defines the blob to download
  34187. * @param fileName defines the name of the downloaded file
  34188. */
  34189. static Download(blob: Blob, fileName: string): void;
  34190. /**
  34191. * Captures a screenshot of the current rendering
  34192. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34193. * @param engine defines the rendering engine
  34194. * @param camera defines the source camera
  34195. * @param size This parameter can be set to a single number or to an object with the
  34196. * following (optional) properties: precision, width, height. If a single number is passed,
  34197. * it will be used for both width and height. If an object is passed, the screenshot size
  34198. * will be derived from the parameters. The precision property is a multiplier allowing
  34199. * rendering at a higher or lower resolution
  34200. * @param successCallback defines the callback receives a single parameter which contains the
  34201. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34202. * src parameter of an <img> to display it
  34203. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34204. * Check your browser for supported MIME types
  34205. */
  34206. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34207. /**
  34208. * Captures a screenshot of the current rendering
  34209. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34210. * @param engine defines the rendering engine
  34211. * @param camera defines the source camera
  34212. * @param size This parameter can be set to a single number or to an object with the
  34213. * following (optional) properties: precision, width, height. If a single number is passed,
  34214. * it will be used for both width and height. If an object is passed, the screenshot size
  34215. * will be derived from the parameters. The precision property is a multiplier allowing
  34216. * rendering at a higher or lower resolution
  34217. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34218. * Check your browser for supported MIME types
  34219. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34220. * to the src parameter of an <img> to display it
  34221. */
  34222. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34223. /**
  34224. * Generates an image screenshot from the specified camera.
  34225. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34226. * @param engine The engine to use for rendering
  34227. * @param camera The camera to use for rendering
  34228. * @param size This parameter can be set to a single number or to an object with the
  34229. * following (optional) properties: precision, width, height. If a single number is passed,
  34230. * it will be used for both width and height. If an object is passed, the screenshot size
  34231. * will be derived from the parameters. The precision property is a multiplier allowing
  34232. * rendering at a higher or lower resolution
  34233. * @param successCallback The callback receives a single parameter which contains the
  34234. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34235. * src parameter of an <img> to display it
  34236. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34237. * Check your browser for supported MIME types
  34238. * @param samples Texture samples (default: 1)
  34239. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34240. * @param fileName A name for for the downloaded file.
  34241. */
  34242. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34243. /**
  34244. * Generates an image screenshot from the specified camera.
  34245. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34246. * @param engine The engine to use for rendering
  34247. * @param camera The camera to use for rendering
  34248. * @param size This parameter can be set to a single number or to an object with the
  34249. * following (optional) properties: precision, width, height. If a single number is passed,
  34250. * it will be used for both width and height. If an object is passed, the screenshot size
  34251. * will be derived from the parameters. The precision property is a multiplier allowing
  34252. * rendering at a higher or lower resolution
  34253. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34254. * Check your browser for supported MIME types
  34255. * @param samples Texture samples (default: 1)
  34256. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34257. * @param fileName A name for for the downloaded file.
  34258. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34259. * to the src parameter of an <img> to display it
  34260. */
  34261. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34262. /**
  34263. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34264. * Be aware Math.random() could cause collisions, but:
  34265. * "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"
  34266. * @returns a pseudo random id
  34267. */
  34268. static RandomId(): string;
  34269. /**
  34270. * Test if the given uri is a base64 string
  34271. * @param uri The uri to test
  34272. * @return True if the uri is a base64 string or false otherwise
  34273. */
  34274. static IsBase64(uri: string): boolean;
  34275. /**
  34276. * Decode the given base64 uri.
  34277. * @param uri The uri to decode
  34278. * @return The decoded base64 data.
  34279. */
  34280. static DecodeBase64(uri: string): ArrayBuffer;
  34281. /**
  34282. * Gets the absolute url.
  34283. * @param url the input url
  34284. * @return the absolute url
  34285. */
  34286. static GetAbsoluteUrl(url: string): string;
  34287. /**
  34288. * No log
  34289. */
  34290. static readonly NoneLogLevel: number;
  34291. /**
  34292. * Only message logs
  34293. */
  34294. static readonly MessageLogLevel: number;
  34295. /**
  34296. * Only warning logs
  34297. */
  34298. static readonly WarningLogLevel: number;
  34299. /**
  34300. * Only error logs
  34301. */
  34302. static readonly ErrorLogLevel: number;
  34303. /**
  34304. * All logs
  34305. */
  34306. static readonly AllLogLevel: number;
  34307. /**
  34308. * Gets a value indicating the number of loading errors
  34309. * @ignorenaming
  34310. */
  34311. static get errorsCount(): number;
  34312. /**
  34313. * Callback called when a new log is added
  34314. */
  34315. static OnNewCacheEntry: (entry: string) => void;
  34316. /**
  34317. * Log a message to the console
  34318. * @param message defines the message to log
  34319. */
  34320. static Log(message: string): void;
  34321. /**
  34322. * Write a warning message to the console
  34323. * @param message defines the message to log
  34324. */
  34325. static Warn(message: string): void;
  34326. /**
  34327. * Write an error message to the console
  34328. * @param message defines the message to log
  34329. */
  34330. static Error(message: string): void;
  34331. /**
  34332. * Gets current log cache (list of logs)
  34333. */
  34334. static get LogCache(): string;
  34335. /**
  34336. * Clears the log cache
  34337. */
  34338. static ClearLogCache(): void;
  34339. /**
  34340. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34341. */
  34342. static set LogLevels(level: number);
  34343. /**
  34344. * Checks if the window object exists
  34345. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34346. */
  34347. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34348. /**
  34349. * No performance log
  34350. */
  34351. static readonly PerformanceNoneLogLevel: number;
  34352. /**
  34353. * Use user marks to log performance
  34354. */
  34355. static readonly PerformanceUserMarkLogLevel: number;
  34356. /**
  34357. * Log performance to the console
  34358. */
  34359. static readonly PerformanceConsoleLogLevel: number;
  34360. private static _performance;
  34361. /**
  34362. * Sets the current performance log level
  34363. */
  34364. static set PerformanceLogLevel(level: number);
  34365. private static _StartPerformanceCounterDisabled;
  34366. private static _EndPerformanceCounterDisabled;
  34367. private static _StartUserMark;
  34368. private static _EndUserMark;
  34369. private static _StartPerformanceConsole;
  34370. private static _EndPerformanceConsole;
  34371. /**
  34372. * Starts a performance counter
  34373. */
  34374. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34375. /**
  34376. * Ends a specific performance coutner
  34377. */
  34378. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34379. /**
  34380. * Gets either window.performance.now() if supported or Date.now() else
  34381. */
  34382. static get Now(): number;
  34383. /**
  34384. * This method will return the name of the class used to create the instance of the given object.
  34385. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34386. * @param object the object to get the class name from
  34387. * @param isType defines if the object is actually a type
  34388. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34389. */
  34390. static GetClassName(object: any, isType?: boolean): string;
  34391. /**
  34392. * Gets the first element of an array satisfying a given predicate
  34393. * @param array defines the array to browse
  34394. * @param predicate defines the predicate to use
  34395. * @returns null if not found or the element
  34396. */
  34397. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34398. /**
  34399. * This method will return the name of the full name of the class, including its owning module (if any).
  34400. * 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).
  34401. * @param object the object to get the class name from
  34402. * @param isType defines if the object is actually a type
  34403. * @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.
  34404. * @ignorenaming
  34405. */
  34406. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34407. /**
  34408. * Returns a promise that resolves after the given amount of time.
  34409. * @param delay Number of milliseconds to delay
  34410. * @returns Promise that resolves after the given amount of time
  34411. */
  34412. static DelayAsync(delay: number): Promise<void>;
  34413. /**
  34414. * Utility function to detect if the current user agent is Safari
  34415. * @returns whether or not the current user agent is safari
  34416. */
  34417. static IsSafari(): boolean;
  34418. }
  34419. /**
  34420. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34421. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34422. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34423. * @param name The name of the class, case should be preserved
  34424. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34425. */
  34426. export function className(name: string, module?: string): (target: Object) => void;
  34427. /**
  34428. * An implementation of a loop for asynchronous functions.
  34429. */
  34430. export class AsyncLoop {
  34431. /**
  34432. * Defines the number of iterations for the loop
  34433. */
  34434. iterations: number;
  34435. /**
  34436. * Defines the current index of the loop.
  34437. */
  34438. index: number;
  34439. private _done;
  34440. private _fn;
  34441. private _successCallback;
  34442. /**
  34443. * Constructor.
  34444. * @param iterations the number of iterations.
  34445. * @param func the function to run each iteration
  34446. * @param successCallback the callback that will be called upon succesful execution
  34447. * @param offset starting offset.
  34448. */
  34449. constructor(
  34450. /**
  34451. * Defines the number of iterations for the loop
  34452. */
  34453. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34454. /**
  34455. * Execute the next iteration. Must be called after the last iteration was finished.
  34456. */
  34457. executeNext(): void;
  34458. /**
  34459. * Break the loop and run the success callback.
  34460. */
  34461. breakLoop(): void;
  34462. /**
  34463. * Create and run an async loop.
  34464. * @param iterations the number of iterations.
  34465. * @param fn the function to run each iteration
  34466. * @param successCallback the callback that will be called upon succesful execution
  34467. * @param offset starting offset.
  34468. * @returns the created async loop object
  34469. */
  34470. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34471. /**
  34472. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34473. * @param iterations total number of iterations
  34474. * @param syncedIterations number of synchronous iterations in each async iteration.
  34475. * @param fn the function to call each iteration.
  34476. * @param callback a success call back that will be called when iterating stops.
  34477. * @param breakFunction a break condition (optional)
  34478. * @param timeout timeout settings for the setTimeout function. default - 0.
  34479. * @returns the created async loop object
  34480. */
  34481. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34482. }
  34483. }
  34484. declare module BABYLON {
  34485. /**
  34486. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34487. * The underlying implementation relies on an associative array to ensure the best performances.
  34488. * The value can be anything including 'null' but except 'undefined'
  34489. */
  34490. export class StringDictionary<T> {
  34491. /**
  34492. * This will clear this dictionary and copy the content from the 'source' one.
  34493. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34494. * @param source the dictionary to take the content from and copy to this dictionary
  34495. */
  34496. copyFrom(source: StringDictionary<T>): void;
  34497. /**
  34498. * Get a value based from its key
  34499. * @param key the given key to get the matching value from
  34500. * @return the value if found, otherwise undefined is returned
  34501. */
  34502. get(key: string): T | undefined;
  34503. /**
  34504. * Get a value from its key or add it if it doesn't exist.
  34505. * This method will ensure you that a given key/data will be present in the dictionary.
  34506. * @param key the given key to get the matching value from
  34507. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34508. * The factory will only be invoked if there's no data for the given key.
  34509. * @return the value corresponding to the key.
  34510. */
  34511. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34512. /**
  34513. * Get a value from its key if present in the dictionary otherwise add it
  34514. * @param key the key to get the value from
  34515. * @param val if there's no such key/value pair in the dictionary add it with this value
  34516. * @return the value corresponding to the key
  34517. */
  34518. getOrAdd(key: string, val: T): T;
  34519. /**
  34520. * Check if there's a given key in the dictionary
  34521. * @param key the key to check for
  34522. * @return true if the key is present, false otherwise
  34523. */
  34524. contains(key: string): boolean;
  34525. /**
  34526. * Add a new key and its corresponding value
  34527. * @param key the key to add
  34528. * @param value the value corresponding to the key
  34529. * @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
  34530. */
  34531. add(key: string, value: T): boolean;
  34532. /**
  34533. * Update a specific value associated to a key
  34534. * @param key defines the key to use
  34535. * @param value defines the value to store
  34536. * @returns true if the value was updated (or false if the key was not found)
  34537. */
  34538. set(key: string, value: T): boolean;
  34539. /**
  34540. * Get the element of the given key and remove it from the dictionary
  34541. * @param key defines the key to search
  34542. * @returns the value associated with the key or null if not found
  34543. */
  34544. getAndRemove(key: string): Nullable<T>;
  34545. /**
  34546. * Remove a key/value from the dictionary.
  34547. * @param key the key to remove
  34548. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34549. */
  34550. remove(key: string): boolean;
  34551. /**
  34552. * Clear the whole content of the dictionary
  34553. */
  34554. clear(): void;
  34555. /**
  34556. * Gets the current count
  34557. */
  34558. get count(): number;
  34559. /**
  34560. * Execute a callback on each key/val of the dictionary.
  34561. * Note that you can remove any element in this dictionary in the callback implementation
  34562. * @param callback the callback to execute on a given key/value pair
  34563. */
  34564. forEach(callback: (key: string, val: T) => void): void;
  34565. /**
  34566. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34567. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34568. * Note that you can remove any element in this dictionary in the callback implementation
  34569. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34570. * @returns the first item
  34571. */
  34572. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34573. private _count;
  34574. private _data;
  34575. }
  34576. }
  34577. declare module BABYLON {
  34578. /** @hidden */
  34579. export interface ICollisionCoordinator {
  34580. createCollider(): Collider;
  34581. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34582. init(scene: Scene): void;
  34583. }
  34584. /** @hidden */
  34585. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34586. private _scene;
  34587. private _scaledPosition;
  34588. private _scaledVelocity;
  34589. private _finalPosition;
  34590. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34591. createCollider(): Collider;
  34592. init(scene: Scene): void;
  34593. private _collideWithWorld;
  34594. }
  34595. }
  34596. declare module BABYLON {
  34597. /**
  34598. * Class used to manage all inputs for the scene.
  34599. */
  34600. export class InputManager {
  34601. /** The distance in pixel that you have to move to prevent some events */
  34602. static DragMovementThreshold: number;
  34603. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34604. static LongPressDelay: number;
  34605. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34606. static DoubleClickDelay: number;
  34607. /** If you need to check double click without raising a single click at first click, enable this flag */
  34608. static ExclusiveDoubleClickMode: boolean;
  34609. private _wheelEventName;
  34610. private _onPointerMove;
  34611. private _onPointerDown;
  34612. private _onPointerUp;
  34613. private _initClickEvent;
  34614. private _initActionManager;
  34615. private _delayedSimpleClick;
  34616. private _delayedSimpleClickTimeout;
  34617. private _previousDelayedSimpleClickTimeout;
  34618. private _meshPickProceed;
  34619. private _previousButtonPressed;
  34620. private _currentPickResult;
  34621. private _previousPickResult;
  34622. private _totalPointersPressed;
  34623. private _doubleClickOccured;
  34624. private _pointerOverMesh;
  34625. private _pickedDownMesh;
  34626. private _pickedUpMesh;
  34627. private _pointerX;
  34628. private _pointerY;
  34629. private _unTranslatedPointerX;
  34630. private _unTranslatedPointerY;
  34631. private _startingPointerPosition;
  34632. private _previousStartingPointerPosition;
  34633. private _startingPointerTime;
  34634. private _previousStartingPointerTime;
  34635. private _pointerCaptures;
  34636. private _onKeyDown;
  34637. private _onKeyUp;
  34638. private _onCanvasFocusObserver;
  34639. private _onCanvasBlurObserver;
  34640. private _scene;
  34641. /**
  34642. * Creates a new InputManager
  34643. * @param scene defines the hosting scene
  34644. */
  34645. constructor(scene: Scene);
  34646. /**
  34647. * Gets the mesh that is currently under the pointer
  34648. */
  34649. get meshUnderPointer(): Nullable<AbstractMesh>;
  34650. /**
  34651. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34652. */
  34653. get unTranslatedPointer(): Vector2;
  34654. /**
  34655. * Gets or sets the current on-screen X position of the pointer
  34656. */
  34657. get pointerX(): number;
  34658. set pointerX(value: number);
  34659. /**
  34660. * Gets or sets the current on-screen Y position of the pointer
  34661. */
  34662. get pointerY(): number;
  34663. set pointerY(value: number);
  34664. private _updatePointerPosition;
  34665. private _processPointerMove;
  34666. private _setRayOnPointerInfo;
  34667. private _checkPrePointerObservable;
  34668. /**
  34669. * Use this method to simulate a pointer move on a mesh
  34670. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34671. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34672. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34673. */
  34674. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34675. /**
  34676. * Use this method to simulate a pointer down on a mesh
  34677. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34678. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34679. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34680. */
  34681. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34682. private _processPointerDown;
  34683. /** @hidden */
  34684. _isPointerSwiping(): boolean;
  34685. /**
  34686. * Use this method to simulate a pointer up on a mesh
  34687. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34688. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34689. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34690. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34691. */
  34692. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34693. private _processPointerUp;
  34694. /**
  34695. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34696. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34697. * @returns true if the pointer was captured
  34698. */
  34699. isPointerCaptured(pointerId?: number): boolean;
  34700. /**
  34701. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34702. * @param attachUp defines if you want to attach events to pointerup
  34703. * @param attachDown defines if you want to attach events to pointerdown
  34704. * @param attachMove defines if you want to attach events to pointermove
  34705. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34706. */
  34707. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34708. /**
  34709. * Detaches all event handlers
  34710. */
  34711. detachControl(): void;
  34712. /**
  34713. * Force the value of meshUnderPointer
  34714. * @param mesh defines the mesh to use
  34715. */
  34716. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34717. /**
  34718. * Gets the mesh under the pointer
  34719. * @returns a Mesh or null if no mesh is under the pointer
  34720. */
  34721. getPointerOverMesh(): Nullable<AbstractMesh>;
  34722. }
  34723. }
  34724. declare module BABYLON {
  34725. /**
  34726. * Helper class used to generate session unique ID
  34727. */
  34728. export class UniqueIdGenerator {
  34729. private static _UniqueIdCounter;
  34730. /**
  34731. * Gets an unique (relatively to the current scene) Id
  34732. */
  34733. static get UniqueId(): number;
  34734. }
  34735. }
  34736. declare module BABYLON {
  34737. /**
  34738. * This class defines the direct association between an animation and a target
  34739. */
  34740. export class TargetedAnimation {
  34741. /**
  34742. * Animation to perform
  34743. */
  34744. animation: Animation;
  34745. /**
  34746. * Target to animate
  34747. */
  34748. target: any;
  34749. /**
  34750. * Serialize the object
  34751. * @returns the JSON object representing the current entity
  34752. */
  34753. serialize(): any;
  34754. }
  34755. /**
  34756. * Use this class to create coordinated animations on multiple targets
  34757. */
  34758. export class AnimationGroup implements IDisposable {
  34759. /** The name of the animation group */
  34760. name: string;
  34761. private _scene;
  34762. private _targetedAnimations;
  34763. private _animatables;
  34764. private _from;
  34765. private _to;
  34766. private _isStarted;
  34767. private _isPaused;
  34768. private _speedRatio;
  34769. private _loopAnimation;
  34770. /**
  34771. * Gets or sets the unique id of the node
  34772. */
  34773. uniqueId: number;
  34774. /**
  34775. * This observable will notify when one animation have ended
  34776. */
  34777. onAnimationEndObservable: Observable<TargetedAnimation>;
  34778. /**
  34779. * Observer raised when one animation loops
  34780. */
  34781. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34782. /**
  34783. * Observer raised when all animations have looped
  34784. */
  34785. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34786. /**
  34787. * This observable will notify when all animations have ended.
  34788. */
  34789. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34790. /**
  34791. * This observable will notify when all animations have paused.
  34792. */
  34793. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34794. /**
  34795. * This observable will notify when all animations are playing.
  34796. */
  34797. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34798. /**
  34799. * Gets the first frame
  34800. */
  34801. get from(): number;
  34802. /**
  34803. * Gets the last frame
  34804. */
  34805. get to(): number;
  34806. /**
  34807. * Define if the animations are started
  34808. */
  34809. get isStarted(): boolean;
  34810. /**
  34811. * Gets a value indicating that the current group is playing
  34812. */
  34813. get isPlaying(): boolean;
  34814. /**
  34815. * Gets or sets the speed ratio to use for all animations
  34816. */
  34817. get speedRatio(): number;
  34818. /**
  34819. * Gets or sets the speed ratio to use for all animations
  34820. */
  34821. set speedRatio(value: number);
  34822. /**
  34823. * Gets or sets if all animations should loop or not
  34824. */
  34825. get loopAnimation(): boolean;
  34826. set loopAnimation(value: boolean);
  34827. /**
  34828. * Gets the targeted animations for this animation group
  34829. */
  34830. get targetedAnimations(): Array<TargetedAnimation>;
  34831. /**
  34832. * returning the list of animatables controlled by this animation group.
  34833. */
  34834. get animatables(): Array<Animatable>;
  34835. /**
  34836. * Instantiates a new Animation Group.
  34837. * This helps managing several animations at once.
  34838. * @see http://doc.babylonjs.com/how_to/group
  34839. * @param name Defines the name of the group
  34840. * @param scene Defines the scene the group belongs to
  34841. */
  34842. constructor(
  34843. /** The name of the animation group */
  34844. name: string, scene?: Nullable<Scene>);
  34845. /**
  34846. * Add an animation (with its target) in the group
  34847. * @param animation defines the animation we want to add
  34848. * @param target defines the target of the animation
  34849. * @returns the TargetedAnimation object
  34850. */
  34851. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34852. /**
  34853. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34854. * It can add constant keys at begin or end
  34855. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34856. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34857. * @returns the animation group
  34858. */
  34859. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34860. private _animationLoopCount;
  34861. private _animationLoopFlags;
  34862. private _processLoop;
  34863. /**
  34864. * Start all animations on given targets
  34865. * @param loop defines if animations must loop
  34866. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34867. * @param from defines the from key (optional)
  34868. * @param to defines the to key (optional)
  34869. * @returns the current animation group
  34870. */
  34871. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34872. /**
  34873. * Pause all animations
  34874. * @returns the animation group
  34875. */
  34876. pause(): AnimationGroup;
  34877. /**
  34878. * Play all animations to initial state
  34879. * This function will start() the animations if they were not started or will restart() them if they were paused
  34880. * @param loop defines if animations must loop
  34881. * @returns the animation group
  34882. */
  34883. play(loop?: boolean): AnimationGroup;
  34884. /**
  34885. * Reset all animations to initial state
  34886. * @returns the animation group
  34887. */
  34888. reset(): AnimationGroup;
  34889. /**
  34890. * Restart animations from key 0
  34891. * @returns the animation group
  34892. */
  34893. restart(): AnimationGroup;
  34894. /**
  34895. * Stop all animations
  34896. * @returns the animation group
  34897. */
  34898. stop(): AnimationGroup;
  34899. /**
  34900. * Set animation weight for all animatables
  34901. * @param weight defines the weight to use
  34902. * @return the animationGroup
  34903. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34904. */
  34905. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34906. /**
  34907. * Synchronize and normalize all animatables with a source animatable
  34908. * @param root defines the root animatable to synchronize with
  34909. * @return the animationGroup
  34910. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34911. */
  34912. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34913. /**
  34914. * Goes to a specific frame in this animation group
  34915. * @param frame the frame number to go to
  34916. * @return the animationGroup
  34917. */
  34918. goToFrame(frame: number): AnimationGroup;
  34919. /**
  34920. * Dispose all associated resources
  34921. */
  34922. dispose(): void;
  34923. private _checkAnimationGroupEnded;
  34924. /**
  34925. * Clone the current animation group and returns a copy
  34926. * @param newName defines the name of the new group
  34927. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34928. * @returns the new aniamtion group
  34929. */
  34930. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34931. /**
  34932. * Serializes the animationGroup to an object
  34933. * @returns Serialized object
  34934. */
  34935. serialize(): any;
  34936. /**
  34937. * Returns a new AnimationGroup object parsed from the source provided.
  34938. * @param parsedAnimationGroup defines the source
  34939. * @param scene defines the scene that will receive the animationGroup
  34940. * @returns a new AnimationGroup
  34941. */
  34942. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34943. /**
  34944. * Returns the string "AnimationGroup"
  34945. * @returns "AnimationGroup"
  34946. */
  34947. getClassName(): string;
  34948. /**
  34949. * Creates a detailled string about the object
  34950. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34951. * @returns a string representing the object
  34952. */
  34953. toString(fullDetails?: boolean): string;
  34954. }
  34955. }
  34956. declare module BABYLON {
  34957. /**
  34958. * Define an interface for all classes that will hold resources
  34959. */
  34960. export interface IDisposable {
  34961. /**
  34962. * Releases all held resources
  34963. */
  34964. dispose(): void;
  34965. }
  34966. /** Interface defining initialization parameters for Scene class */
  34967. export interface SceneOptions {
  34968. /**
  34969. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34970. * It will improve performance when the number of geometries becomes important.
  34971. */
  34972. useGeometryUniqueIdsMap?: boolean;
  34973. /**
  34974. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34975. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34976. */
  34977. useMaterialMeshMap?: boolean;
  34978. /**
  34979. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34980. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34981. */
  34982. useClonedMeshMap?: boolean;
  34983. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34984. virtual?: boolean;
  34985. }
  34986. /**
  34987. * Represents a scene to be rendered by the engine.
  34988. * @see http://doc.babylonjs.com/features/scene
  34989. */
  34990. export class Scene extends AbstractScene implements IAnimatable {
  34991. /** The fog is deactivated */
  34992. static readonly FOGMODE_NONE: number;
  34993. /** The fog density is following an exponential function */
  34994. static readonly FOGMODE_EXP: number;
  34995. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34996. static readonly FOGMODE_EXP2: number;
  34997. /** The fog density is following a linear function. */
  34998. static readonly FOGMODE_LINEAR: number;
  34999. /**
  35000. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35001. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35002. */
  35003. static MinDeltaTime: number;
  35004. /**
  35005. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35006. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35007. */
  35008. static MaxDeltaTime: number;
  35009. /**
  35010. * Factory used to create the default material.
  35011. * @param name The name of the material to create
  35012. * @param scene The scene to create the material for
  35013. * @returns The default material
  35014. */
  35015. static DefaultMaterialFactory(scene: Scene): Material;
  35016. /**
  35017. * Factory used to create the a collision coordinator.
  35018. * @returns The collision coordinator
  35019. */
  35020. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35021. /** @hidden */
  35022. _inputManager: InputManager;
  35023. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35024. cameraToUseForPointers: Nullable<Camera>;
  35025. /** @hidden */
  35026. readonly _isScene: boolean;
  35027. /**
  35028. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35029. */
  35030. autoClear: boolean;
  35031. /**
  35032. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35033. */
  35034. autoClearDepthAndStencil: boolean;
  35035. /**
  35036. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35037. */
  35038. clearColor: Color4;
  35039. /**
  35040. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35041. */
  35042. ambientColor: Color3;
  35043. /**
  35044. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35045. * It should only be one of the following (if not the default embedded one):
  35046. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35047. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35048. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35049. * The material properties need to be setup according to the type of texture in use.
  35050. */
  35051. environmentBRDFTexture: BaseTexture;
  35052. /** @hidden */
  35053. protected _environmentTexture: Nullable<BaseTexture>;
  35054. /**
  35055. * Texture used in all pbr material as the reflection texture.
  35056. * As in the majority of the scene they are the same (exception for multi room and so on),
  35057. * this is easier to reference from here than from all the materials.
  35058. */
  35059. get environmentTexture(): Nullable<BaseTexture>;
  35060. /**
  35061. * Texture used in all pbr material as the reflection texture.
  35062. * As in the majority of the scene they are the same (exception for multi room and so on),
  35063. * this is easier to set here than in all the materials.
  35064. */
  35065. set environmentTexture(value: Nullable<BaseTexture>);
  35066. /** @hidden */
  35067. protected _environmentIntensity: number;
  35068. /**
  35069. * Intensity of the environment in all pbr material.
  35070. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35071. * As in the majority of the scene they are the same (exception for multi room and so on),
  35072. * this is easier to reference from here than from all the materials.
  35073. */
  35074. get environmentIntensity(): number;
  35075. /**
  35076. * Intensity of the environment in all pbr material.
  35077. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35078. * As in the majority of the scene they are the same (exception for multi room and so on),
  35079. * this is easier to set here than in all the materials.
  35080. */
  35081. set environmentIntensity(value: number);
  35082. /** @hidden */
  35083. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35084. /**
  35085. * Default image processing configuration used either in the rendering
  35086. * Forward main pass or through the imageProcessingPostProcess if present.
  35087. * As in the majority of the scene they are the same (exception for multi camera),
  35088. * this is easier to reference from here than from all the materials and post process.
  35089. *
  35090. * No setter as we it is a shared configuration, you can set the values instead.
  35091. */
  35092. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35093. private _forceWireframe;
  35094. /**
  35095. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35096. */
  35097. set forceWireframe(value: boolean);
  35098. get forceWireframe(): boolean;
  35099. private _skipFrustumClipping;
  35100. /**
  35101. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35102. */
  35103. set skipFrustumClipping(value: boolean);
  35104. get skipFrustumClipping(): boolean;
  35105. private _forcePointsCloud;
  35106. /**
  35107. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35108. */
  35109. set forcePointsCloud(value: boolean);
  35110. get forcePointsCloud(): boolean;
  35111. /**
  35112. * Gets or sets the active clipplane 1
  35113. */
  35114. clipPlane: Nullable<Plane>;
  35115. /**
  35116. * Gets or sets the active clipplane 2
  35117. */
  35118. clipPlane2: Nullable<Plane>;
  35119. /**
  35120. * Gets or sets the active clipplane 3
  35121. */
  35122. clipPlane3: Nullable<Plane>;
  35123. /**
  35124. * Gets or sets the active clipplane 4
  35125. */
  35126. clipPlane4: Nullable<Plane>;
  35127. /**
  35128. * Gets or sets the active clipplane 5
  35129. */
  35130. clipPlane5: Nullable<Plane>;
  35131. /**
  35132. * Gets or sets the active clipplane 6
  35133. */
  35134. clipPlane6: Nullable<Plane>;
  35135. /**
  35136. * Gets or sets a boolean indicating if animations are enabled
  35137. */
  35138. animationsEnabled: boolean;
  35139. private _animationPropertiesOverride;
  35140. /**
  35141. * Gets or sets the animation properties override
  35142. */
  35143. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35144. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35145. /**
  35146. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35147. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35148. */
  35149. useConstantAnimationDeltaTime: boolean;
  35150. /**
  35151. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35152. * Please note that it requires to run a ray cast through the scene on every frame
  35153. */
  35154. constantlyUpdateMeshUnderPointer: boolean;
  35155. /**
  35156. * Defines the HTML cursor to use when hovering over interactive elements
  35157. */
  35158. hoverCursor: string;
  35159. /**
  35160. * Defines the HTML default cursor to use (empty by default)
  35161. */
  35162. defaultCursor: string;
  35163. /**
  35164. * Defines wether cursors are handled by the scene.
  35165. */
  35166. doNotHandleCursors: boolean;
  35167. /**
  35168. * This is used to call preventDefault() on pointer down
  35169. * in order to block unwanted artifacts like system double clicks
  35170. */
  35171. preventDefaultOnPointerDown: boolean;
  35172. /**
  35173. * This is used to call preventDefault() on pointer up
  35174. * in order to block unwanted artifacts like system double clicks
  35175. */
  35176. preventDefaultOnPointerUp: boolean;
  35177. /**
  35178. * Gets or sets user defined metadata
  35179. */
  35180. metadata: any;
  35181. /**
  35182. * For internal use only. Please do not use.
  35183. */
  35184. reservedDataStore: any;
  35185. /**
  35186. * Gets the name of the plugin used to load this scene (null by default)
  35187. */
  35188. loadingPluginName: string;
  35189. /**
  35190. * Use this array to add regular expressions used to disable offline support for specific urls
  35191. */
  35192. disableOfflineSupportExceptionRules: RegExp[];
  35193. /**
  35194. * An event triggered when the scene is disposed.
  35195. */
  35196. onDisposeObservable: Observable<Scene>;
  35197. private _onDisposeObserver;
  35198. /** Sets a function to be executed when this scene is disposed. */
  35199. set onDispose(callback: () => void);
  35200. /**
  35201. * An event triggered before rendering the scene (right after animations and physics)
  35202. */
  35203. onBeforeRenderObservable: Observable<Scene>;
  35204. private _onBeforeRenderObserver;
  35205. /** Sets a function to be executed before rendering this scene */
  35206. set beforeRender(callback: Nullable<() => void>);
  35207. /**
  35208. * An event triggered after rendering the scene
  35209. */
  35210. onAfterRenderObservable: Observable<Scene>;
  35211. /**
  35212. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35213. */
  35214. onAfterRenderCameraObservable: Observable<Camera>;
  35215. private _onAfterRenderObserver;
  35216. /** Sets a function to be executed after rendering this scene */
  35217. set afterRender(callback: Nullable<() => void>);
  35218. /**
  35219. * An event triggered before animating the scene
  35220. */
  35221. onBeforeAnimationsObservable: Observable<Scene>;
  35222. /**
  35223. * An event triggered after animations processing
  35224. */
  35225. onAfterAnimationsObservable: Observable<Scene>;
  35226. /**
  35227. * An event triggered before draw calls are ready to be sent
  35228. */
  35229. onBeforeDrawPhaseObservable: Observable<Scene>;
  35230. /**
  35231. * An event triggered after draw calls have been sent
  35232. */
  35233. onAfterDrawPhaseObservable: Observable<Scene>;
  35234. /**
  35235. * An event triggered when the scene is ready
  35236. */
  35237. onReadyObservable: Observable<Scene>;
  35238. /**
  35239. * An event triggered before rendering a camera
  35240. */
  35241. onBeforeCameraRenderObservable: Observable<Camera>;
  35242. private _onBeforeCameraRenderObserver;
  35243. /** Sets a function to be executed before rendering a camera*/
  35244. set beforeCameraRender(callback: () => void);
  35245. /**
  35246. * An event triggered after rendering a camera
  35247. */
  35248. onAfterCameraRenderObservable: Observable<Camera>;
  35249. private _onAfterCameraRenderObserver;
  35250. /** Sets a function to be executed after rendering a camera*/
  35251. set afterCameraRender(callback: () => void);
  35252. /**
  35253. * An event triggered when active meshes evaluation is about to start
  35254. */
  35255. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35256. /**
  35257. * An event triggered when active meshes evaluation is done
  35258. */
  35259. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35260. /**
  35261. * An event triggered when particles rendering is about to start
  35262. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35263. */
  35264. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35265. /**
  35266. * An event triggered when particles rendering is done
  35267. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35268. */
  35269. onAfterParticlesRenderingObservable: Observable<Scene>;
  35270. /**
  35271. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35272. */
  35273. onDataLoadedObservable: Observable<Scene>;
  35274. /**
  35275. * An event triggered when a camera is created
  35276. */
  35277. onNewCameraAddedObservable: Observable<Camera>;
  35278. /**
  35279. * An event triggered when a camera is removed
  35280. */
  35281. onCameraRemovedObservable: Observable<Camera>;
  35282. /**
  35283. * An event triggered when a light is created
  35284. */
  35285. onNewLightAddedObservable: Observable<Light>;
  35286. /**
  35287. * An event triggered when a light is removed
  35288. */
  35289. onLightRemovedObservable: Observable<Light>;
  35290. /**
  35291. * An event triggered when a geometry is created
  35292. */
  35293. onNewGeometryAddedObservable: Observable<Geometry>;
  35294. /**
  35295. * An event triggered when a geometry is removed
  35296. */
  35297. onGeometryRemovedObservable: Observable<Geometry>;
  35298. /**
  35299. * An event triggered when a transform node is created
  35300. */
  35301. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35302. /**
  35303. * An event triggered when a transform node is removed
  35304. */
  35305. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35306. /**
  35307. * An event triggered when a mesh is created
  35308. */
  35309. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35310. /**
  35311. * An event triggered when a mesh is removed
  35312. */
  35313. onMeshRemovedObservable: Observable<AbstractMesh>;
  35314. /**
  35315. * An event triggered when a skeleton is created
  35316. */
  35317. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35318. /**
  35319. * An event triggered when a skeleton is removed
  35320. */
  35321. onSkeletonRemovedObservable: Observable<Skeleton>;
  35322. /**
  35323. * An event triggered when a material is created
  35324. */
  35325. onNewMaterialAddedObservable: Observable<Material>;
  35326. /**
  35327. * An event triggered when a material is removed
  35328. */
  35329. onMaterialRemovedObservable: Observable<Material>;
  35330. /**
  35331. * An event triggered when a texture is created
  35332. */
  35333. onNewTextureAddedObservable: Observable<BaseTexture>;
  35334. /**
  35335. * An event triggered when a texture is removed
  35336. */
  35337. onTextureRemovedObservable: Observable<BaseTexture>;
  35338. /**
  35339. * An event triggered when render targets are about to be rendered
  35340. * Can happen multiple times per frame.
  35341. */
  35342. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35343. /**
  35344. * An event triggered when render targets were rendered.
  35345. * Can happen multiple times per frame.
  35346. */
  35347. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35348. /**
  35349. * An event triggered before calculating deterministic simulation step
  35350. */
  35351. onBeforeStepObservable: Observable<Scene>;
  35352. /**
  35353. * An event triggered after calculating deterministic simulation step
  35354. */
  35355. onAfterStepObservable: Observable<Scene>;
  35356. /**
  35357. * An event triggered when the activeCamera property is updated
  35358. */
  35359. onActiveCameraChanged: Observable<Scene>;
  35360. /**
  35361. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35362. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35363. * 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)
  35364. */
  35365. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35366. /**
  35367. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35368. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35369. * 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)
  35370. */
  35371. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35372. /**
  35373. * This Observable will when a mesh has been imported into the scene.
  35374. */
  35375. onMeshImportedObservable: Observable<AbstractMesh>;
  35376. /**
  35377. * This Observable will when an animation file has been imported into the scene.
  35378. */
  35379. onAnimationFileImportedObservable: Observable<Scene>;
  35380. /**
  35381. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35382. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35383. */
  35384. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35385. /** @hidden */
  35386. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35387. /**
  35388. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35389. */
  35390. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35391. /**
  35392. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35393. */
  35394. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35395. /**
  35396. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35397. */
  35398. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35399. /** Callback called when a pointer move is detected */
  35400. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35401. /** Callback called when a pointer down is detected */
  35402. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35403. /** Callback called when a pointer up is detected */
  35404. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35405. /** Callback called when a pointer pick is detected */
  35406. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35407. /**
  35408. * 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).
  35409. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35410. */
  35411. onPrePointerObservable: Observable<PointerInfoPre>;
  35412. /**
  35413. * Observable event triggered each time an input event is received from the rendering canvas
  35414. */
  35415. onPointerObservable: Observable<PointerInfo>;
  35416. /**
  35417. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35418. */
  35419. get unTranslatedPointer(): Vector2;
  35420. /**
  35421. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35422. */
  35423. static get DragMovementThreshold(): number;
  35424. static set DragMovementThreshold(value: number);
  35425. /**
  35426. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35427. */
  35428. static get LongPressDelay(): number;
  35429. static set LongPressDelay(value: number);
  35430. /**
  35431. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35432. */
  35433. static get DoubleClickDelay(): number;
  35434. static set DoubleClickDelay(value: number);
  35435. /** If you need to check double click without raising a single click at first click, enable this flag */
  35436. static get ExclusiveDoubleClickMode(): boolean;
  35437. static set ExclusiveDoubleClickMode(value: boolean);
  35438. /** @hidden */
  35439. _mirroredCameraPosition: Nullable<Vector3>;
  35440. /**
  35441. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35442. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35443. */
  35444. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35445. /**
  35446. * Observable event triggered each time an keyboard event is received from the hosting window
  35447. */
  35448. onKeyboardObservable: Observable<KeyboardInfo>;
  35449. private _useRightHandedSystem;
  35450. /**
  35451. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35452. */
  35453. set useRightHandedSystem(value: boolean);
  35454. get useRightHandedSystem(): boolean;
  35455. private _timeAccumulator;
  35456. private _currentStepId;
  35457. private _currentInternalStep;
  35458. /**
  35459. * Sets the step Id used by deterministic lock step
  35460. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35461. * @param newStepId defines the step Id
  35462. */
  35463. setStepId(newStepId: number): void;
  35464. /**
  35465. * Gets the step Id used by deterministic lock step
  35466. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35467. * @returns the step Id
  35468. */
  35469. getStepId(): number;
  35470. /**
  35471. * Gets the internal step used by deterministic lock step
  35472. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35473. * @returns the internal step
  35474. */
  35475. getInternalStep(): number;
  35476. private _fogEnabled;
  35477. /**
  35478. * Gets or sets a boolean indicating if fog is enabled on this scene
  35479. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35480. * (Default is true)
  35481. */
  35482. set fogEnabled(value: boolean);
  35483. get fogEnabled(): boolean;
  35484. private _fogMode;
  35485. /**
  35486. * Gets or sets the fog mode to use
  35487. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35488. * | mode | value |
  35489. * | --- | --- |
  35490. * | FOGMODE_NONE | 0 |
  35491. * | FOGMODE_EXP | 1 |
  35492. * | FOGMODE_EXP2 | 2 |
  35493. * | FOGMODE_LINEAR | 3 |
  35494. */
  35495. set fogMode(value: number);
  35496. get fogMode(): number;
  35497. /**
  35498. * Gets or sets the fog color to use
  35499. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35500. * (Default is Color3(0.2, 0.2, 0.3))
  35501. */
  35502. fogColor: Color3;
  35503. /**
  35504. * Gets or sets the fog density to use
  35505. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35506. * (Default is 0.1)
  35507. */
  35508. fogDensity: number;
  35509. /**
  35510. * Gets or sets the fog start distance to use
  35511. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35512. * (Default is 0)
  35513. */
  35514. fogStart: number;
  35515. /**
  35516. * Gets or sets the fog end distance to use
  35517. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35518. * (Default is 1000)
  35519. */
  35520. fogEnd: number;
  35521. private _shadowsEnabled;
  35522. /**
  35523. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35524. */
  35525. set shadowsEnabled(value: boolean);
  35526. get shadowsEnabled(): boolean;
  35527. private _lightsEnabled;
  35528. /**
  35529. * Gets or sets a boolean indicating if lights are enabled on this scene
  35530. */
  35531. set lightsEnabled(value: boolean);
  35532. get lightsEnabled(): boolean;
  35533. /** All of the active cameras added to this scene. */
  35534. activeCameras: Camera[];
  35535. /** @hidden */
  35536. _activeCamera: Nullable<Camera>;
  35537. /** Gets or sets the current active camera */
  35538. get activeCamera(): Nullable<Camera>;
  35539. set activeCamera(value: Nullable<Camera>);
  35540. private _defaultMaterial;
  35541. /** The default material used on meshes when no material is affected */
  35542. get defaultMaterial(): Material;
  35543. /** The default material used on meshes when no material is affected */
  35544. set defaultMaterial(value: Material);
  35545. private _texturesEnabled;
  35546. /**
  35547. * Gets or sets a boolean indicating if textures are enabled on this scene
  35548. */
  35549. set texturesEnabled(value: boolean);
  35550. get texturesEnabled(): boolean;
  35551. /**
  35552. * Gets or sets a boolean indicating if particles are enabled on this scene
  35553. */
  35554. particlesEnabled: boolean;
  35555. /**
  35556. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35557. */
  35558. spritesEnabled: boolean;
  35559. private _skeletonsEnabled;
  35560. /**
  35561. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35562. */
  35563. set skeletonsEnabled(value: boolean);
  35564. get skeletonsEnabled(): boolean;
  35565. /**
  35566. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35567. */
  35568. lensFlaresEnabled: boolean;
  35569. /**
  35570. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35571. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35572. */
  35573. collisionsEnabled: boolean;
  35574. private _collisionCoordinator;
  35575. /** @hidden */
  35576. get collisionCoordinator(): ICollisionCoordinator;
  35577. /**
  35578. * Defines the gravity applied to this scene (used only for collisions)
  35579. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35580. */
  35581. gravity: Vector3;
  35582. /**
  35583. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35584. */
  35585. postProcessesEnabled: boolean;
  35586. /**
  35587. * The list of postprocesses added to the scene
  35588. */
  35589. postProcesses: PostProcess[];
  35590. /**
  35591. * Gets the current postprocess manager
  35592. */
  35593. postProcessManager: PostProcessManager;
  35594. /**
  35595. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35596. */
  35597. renderTargetsEnabled: boolean;
  35598. /**
  35599. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35600. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35601. */
  35602. dumpNextRenderTargets: boolean;
  35603. /**
  35604. * The list of user defined render targets added to the scene
  35605. */
  35606. customRenderTargets: RenderTargetTexture[];
  35607. /**
  35608. * Defines if texture loading must be delayed
  35609. * If true, textures will only be loaded when they need to be rendered
  35610. */
  35611. useDelayedTextureLoading: boolean;
  35612. /**
  35613. * Gets the list of meshes imported to the scene through SceneLoader
  35614. */
  35615. importedMeshesFiles: String[];
  35616. /**
  35617. * Gets or sets a boolean indicating if probes are enabled on this scene
  35618. */
  35619. probesEnabled: boolean;
  35620. /**
  35621. * Gets or sets the current offline provider to use to store scene data
  35622. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35623. */
  35624. offlineProvider: IOfflineProvider;
  35625. /**
  35626. * Gets or sets the action manager associated with the scene
  35627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35628. */
  35629. actionManager: AbstractActionManager;
  35630. private _meshesForIntersections;
  35631. /**
  35632. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35633. */
  35634. proceduralTexturesEnabled: boolean;
  35635. private _engine;
  35636. private _totalVertices;
  35637. /** @hidden */
  35638. _activeIndices: PerfCounter;
  35639. /** @hidden */
  35640. _activeParticles: PerfCounter;
  35641. /** @hidden */
  35642. _activeBones: PerfCounter;
  35643. private _animationRatio;
  35644. /** @hidden */
  35645. _animationTimeLast: number;
  35646. /** @hidden */
  35647. _animationTime: number;
  35648. /**
  35649. * Gets or sets a general scale for animation speed
  35650. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35651. */
  35652. animationTimeScale: number;
  35653. /** @hidden */
  35654. _cachedMaterial: Nullable<Material>;
  35655. /** @hidden */
  35656. _cachedEffect: Nullable<Effect>;
  35657. /** @hidden */
  35658. _cachedVisibility: Nullable<number>;
  35659. private _renderId;
  35660. private _frameId;
  35661. private _executeWhenReadyTimeoutId;
  35662. private _intermediateRendering;
  35663. private _viewUpdateFlag;
  35664. private _projectionUpdateFlag;
  35665. /** @hidden */
  35666. _toBeDisposed: Nullable<IDisposable>[];
  35667. private _activeRequests;
  35668. /** @hidden */
  35669. _pendingData: any[];
  35670. private _isDisposed;
  35671. /**
  35672. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35673. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35674. */
  35675. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35676. private _activeMeshes;
  35677. private _processedMaterials;
  35678. private _renderTargets;
  35679. /** @hidden */
  35680. _activeParticleSystems: SmartArray<IParticleSystem>;
  35681. private _activeSkeletons;
  35682. private _softwareSkinnedMeshes;
  35683. private _renderingManager;
  35684. /** @hidden */
  35685. _activeAnimatables: Animatable[];
  35686. private _transformMatrix;
  35687. private _sceneUbo;
  35688. /** @hidden */
  35689. _viewMatrix: Matrix;
  35690. private _projectionMatrix;
  35691. /** @hidden */
  35692. _forcedViewPosition: Nullable<Vector3>;
  35693. /** @hidden */
  35694. _frustumPlanes: Plane[];
  35695. /**
  35696. * Gets the list of frustum planes (built from the active camera)
  35697. */
  35698. get frustumPlanes(): Plane[];
  35699. /**
  35700. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35701. * This is useful if there are more lights that the maximum simulteanous authorized
  35702. */
  35703. requireLightSorting: boolean;
  35704. /** @hidden */
  35705. readonly useMaterialMeshMap: boolean;
  35706. /** @hidden */
  35707. readonly useClonedMeshMap: boolean;
  35708. private _externalData;
  35709. private _uid;
  35710. /**
  35711. * @hidden
  35712. * Backing store of defined scene components.
  35713. */
  35714. _components: ISceneComponent[];
  35715. /**
  35716. * @hidden
  35717. * Backing store of defined scene components.
  35718. */
  35719. _serializableComponents: ISceneSerializableComponent[];
  35720. /**
  35721. * List of components to register on the next registration step.
  35722. */
  35723. private _transientComponents;
  35724. /**
  35725. * Registers the transient components if needed.
  35726. */
  35727. private _registerTransientComponents;
  35728. /**
  35729. * @hidden
  35730. * Add a component to the scene.
  35731. * Note that the ccomponent could be registered on th next frame if this is called after
  35732. * the register component stage.
  35733. * @param component Defines the component to add to the scene
  35734. */
  35735. _addComponent(component: ISceneComponent): void;
  35736. /**
  35737. * @hidden
  35738. * Gets a component from the scene.
  35739. * @param name defines the name of the component to retrieve
  35740. * @returns the component or null if not present
  35741. */
  35742. _getComponent(name: string): Nullable<ISceneComponent>;
  35743. /**
  35744. * @hidden
  35745. * Defines the actions happening before camera updates.
  35746. */
  35747. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35748. /**
  35749. * @hidden
  35750. * Defines the actions happening before clear the canvas.
  35751. */
  35752. _beforeClearStage: Stage<SimpleStageAction>;
  35753. /**
  35754. * @hidden
  35755. * Defines the actions when collecting render targets for the frame.
  35756. */
  35757. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35758. /**
  35759. * @hidden
  35760. * Defines the actions happening for one camera in the frame.
  35761. */
  35762. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35763. /**
  35764. * @hidden
  35765. * Defines the actions happening during the per mesh ready checks.
  35766. */
  35767. _isReadyForMeshStage: Stage<MeshStageAction>;
  35768. /**
  35769. * @hidden
  35770. * Defines the actions happening before evaluate active mesh checks.
  35771. */
  35772. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35773. /**
  35774. * @hidden
  35775. * Defines the actions happening during the evaluate sub mesh checks.
  35776. */
  35777. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35778. /**
  35779. * @hidden
  35780. * Defines the actions happening during the active mesh stage.
  35781. */
  35782. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35783. /**
  35784. * @hidden
  35785. * Defines the actions happening during the per camera render target step.
  35786. */
  35787. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35788. /**
  35789. * @hidden
  35790. * Defines the actions happening just before the active camera is drawing.
  35791. */
  35792. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35793. /**
  35794. * @hidden
  35795. * Defines the actions happening just before a render target is drawing.
  35796. */
  35797. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35798. /**
  35799. * @hidden
  35800. * Defines the actions happening just before a rendering group is drawing.
  35801. */
  35802. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35803. /**
  35804. * @hidden
  35805. * Defines the actions happening just before a mesh is drawing.
  35806. */
  35807. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35808. /**
  35809. * @hidden
  35810. * Defines the actions happening just after a mesh has been drawn.
  35811. */
  35812. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35813. /**
  35814. * @hidden
  35815. * Defines the actions happening just after a rendering group has been drawn.
  35816. */
  35817. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35818. /**
  35819. * @hidden
  35820. * Defines the actions happening just after the active camera has been drawn.
  35821. */
  35822. _afterCameraDrawStage: Stage<CameraStageAction>;
  35823. /**
  35824. * @hidden
  35825. * Defines the actions happening just after a render target has been drawn.
  35826. */
  35827. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35828. /**
  35829. * @hidden
  35830. * Defines the actions happening just after rendering all cameras and computing intersections.
  35831. */
  35832. _afterRenderStage: Stage<SimpleStageAction>;
  35833. /**
  35834. * @hidden
  35835. * Defines the actions happening when a pointer move event happens.
  35836. */
  35837. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35838. /**
  35839. * @hidden
  35840. * Defines the actions happening when a pointer down event happens.
  35841. */
  35842. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35843. /**
  35844. * @hidden
  35845. * Defines the actions happening when a pointer up event happens.
  35846. */
  35847. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35848. /**
  35849. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35850. */
  35851. private geometriesByUniqueId;
  35852. /**
  35853. * Creates a new Scene
  35854. * @param engine defines the engine to use to render this scene
  35855. * @param options defines the scene options
  35856. */
  35857. constructor(engine: Engine, options?: SceneOptions);
  35858. /**
  35859. * Gets a string idenfifying the name of the class
  35860. * @returns "Scene" string
  35861. */
  35862. getClassName(): string;
  35863. private _defaultMeshCandidates;
  35864. /**
  35865. * @hidden
  35866. */
  35867. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35868. private _defaultSubMeshCandidates;
  35869. /**
  35870. * @hidden
  35871. */
  35872. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35873. /**
  35874. * Sets the default candidate providers for the scene.
  35875. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35876. * and getCollidingSubMeshCandidates to their default function
  35877. */
  35878. setDefaultCandidateProviders(): void;
  35879. /**
  35880. * Gets the mesh that is currently under the pointer
  35881. */
  35882. get meshUnderPointer(): Nullable<AbstractMesh>;
  35883. /**
  35884. * Gets or sets the current on-screen X position of the pointer
  35885. */
  35886. get pointerX(): number;
  35887. set pointerX(value: number);
  35888. /**
  35889. * Gets or sets the current on-screen Y position of the pointer
  35890. */
  35891. get pointerY(): number;
  35892. set pointerY(value: number);
  35893. /**
  35894. * Gets the cached material (ie. the latest rendered one)
  35895. * @returns the cached material
  35896. */
  35897. getCachedMaterial(): Nullable<Material>;
  35898. /**
  35899. * Gets the cached effect (ie. the latest rendered one)
  35900. * @returns the cached effect
  35901. */
  35902. getCachedEffect(): Nullable<Effect>;
  35903. /**
  35904. * Gets the cached visibility state (ie. the latest rendered one)
  35905. * @returns the cached visibility state
  35906. */
  35907. getCachedVisibility(): Nullable<number>;
  35908. /**
  35909. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35910. * @param material defines the current material
  35911. * @param effect defines the current effect
  35912. * @param visibility defines the current visibility state
  35913. * @returns true if one parameter is not cached
  35914. */
  35915. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35916. /**
  35917. * Gets the engine associated with the scene
  35918. * @returns an Engine
  35919. */
  35920. getEngine(): Engine;
  35921. /**
  35922. * Gets the total number of vertices rendered per frame
  35923. * @returns the total number of vertices rendered per frame
  35924. */
  35925. getTotalVertices(): number;
  35926. /**
  35927. * Gets the performance counter for total vertices
  35928. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35929. */
  35930. get totalVerticesPerfCounter(): PerfCounter;
  35931. /**
  35932. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35933. * @returns the total number of active indices rendered per frame
  35934. */
  35935. getActiveIndices(): number;
  35936. /**
  35937. * Gets the performance counter for active indices
  35938. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35939. */
  35940. get totalActiveIndicesPerfCounter(): PerfCounter;
  35941. /**
  35942. * Gets the total number of active particles rendered per frame
  35943. * @returns the total number of active particles rendered per frame
  35944. */
  35945. getActiveParticles(): number;
  35946. /**
  35947. * Gets the performance counter for active particles
  35948. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35949. */
  35950. get activeParticlesPerfCounter(): PerfCounter;
  35951. /**
  35952. * Gets the total number of active bones rendered per frame
  35953. * @returns the total number of active bones rendered per frame
  35954. */
  35955. getActiveBones(): number;
  35956. /**
  35957. * Gets the performance counter for active bones
  35958. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35959. */
  35960. get activeBonesPerfCounter(): PerfCounter;
  35961. /**
  35962. * Gets the array of active meshes
  35963. * @returns an array of AbstractMesh
  35964. */
  35965. getActiveMeshes(): SmartArray<AbstractMesh>;
  35966. /**
  35967. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35968. * @returns a number
  35969. */
  35970. getAnimationRatio(): number;
  35971. /**
  35972. * Gets an unique Id for the current render phase
  35973. * @returns a number
  35974. */
  35975. getRenderId(): number;
  35976. /**
  35977. * Gets an unique Id for the current frame
  35978. * @returns a number
  35979. */
  35980. getFrameId(): number;
  35981. /** Call this function if you want to manually increment the render Id*/
  35982. incrementRenderId(): void;
  35983. private _createUbo;
  35984. /**
  35985. * Use this method to simulate a pointer move on a mesh
  35986. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35987. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35988. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35989. * @returns the current scene
  35990. */
  35991. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35992. /**
  35993. * Use this method to simulate a pointer down on a mesh
  35994. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35995. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35996. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35997. * @returns the current scene
  35998. */
  35999. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36000. /**
  36001. * Use this method to simulate a pointer up on a mesh
  36002. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36003. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36004. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36005. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36006. * @returns the current scene
  36007. */
  36008. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36009. /**
  36010. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36011. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36012. * @returns true if the pointer was captured
  36013. */
  36014. isPointerCaptured(pointerId?: number): boolean;
  36015. /**
  36016. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36017. * @param attachUp defines if you want to attach events to pointerup
  36018. * @param attachDown defines if you want to attach events to pointerdown
  36019. * @param attachMove defines if you want to attach events to pointermove
  36020. */
  36021. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36022. /** Detaches all event handlers*/
  36023. detachControl(): void;
  36024. /**
  36025. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36026. * Delay loaded resources are not taking in account
  36027. * @return true if all required resources are ready
  36028. */
  36029. isReady(): boolean;
  36030. /** Resets all cached information relative to material (including effect and visibility) */
  36031. resetCachedMaterial(): void;
  36032. /**
  36033. * Registers a function to be called before every frame render
  36034. * @param func defines the function to register
  36035. */
  36036. registerBeforeRender(func: () => void): void;
  36037. /**
  36038. * Unregisters a function called before every frame render
  36039. * @param func defines the function to unregister
  36040. */
  36041. unregisterBeforeRender(func: () => void): void;
  36042. /**
  36043. * Registers a function to be called after every frame render
  36044. * @param func defines the function to register
  36045. */
  36046. registerAfterRender(func: () => void): void;
  36047. /**
  36048. * Unregisters a function called after every frame render
  36049. * @param func defines the function to unregister
  36050. */
  36051. unregisterAfterRender(func: () => void): void;
  36052. private _executeOnceBeforeRender;
  36053. /**
  36054. * The provided function will run before render once and will be disposed afterwards.
  36055. * A timeout delay can be provided so that the function will be executed in N ms.
  36056. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36057. * @param func The function to be executed.
  36058. * @param timeout optional delay in ms
  36059. */
  36060. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36061. /** @hidden */
  36062. _addPendingData(data: any): void;
  36063. /** @hidden */
  36064. _removePendingData(data: any): void;
  36065. /**
  36066. * Returns the number of items waiting to be loaded
  36067. * @returns the number of items waiting to be loaded
  36068. */
  36069. getWaitingItemsCount(): number;
  36070. /**
  36071. * Returns a boolean indicating if the scene is still loading data
  36072. */
  36073. get isLoading(): boolean;
  36074. /**
  36075. * Registers a function to be executed when the scene is ready
  36076. * @param {Function} func - the function to be executed
  36077. */
  36078. executeWhenReady(func: () => void): void;
  36079. /**
  36080. * Returns a promise that resolves when the scene is ready
  36081. * @returns A promise that resolves when the scene is ready
  36082. */
  36083. whenReadyAsync(): Promise<void>;
  36084. /** @hidden */
  36085. _checkIsReady(): void;
  36086. /**
  36087. * Gets all animatable attached to the scene
  36088. */
  36089. get animatables(): Animatable[];
  36090. /**
  36091. * Resets the last animation time frame.
  36092. * Useful to override when animations start running when loading a scene for the first time.
  36093. */
  36094. resetLastAnimationTimeFrame(): void;
  36095. /**
  36096. * Gets the current view matrix
  36097. * @returns a Matrix
  36098. */
  36099. getViewMatrix(): Matrix;
  36100. /**
  36101. * Gets the current projection matrix
  36102. * @returns a Matrix
  36103. */
  36104. getProjectionMatrix(): Matrix;
  36105. /**
  36106. * Gets the current transform matrix
  36107. * @returns a Matrix made of View * Projection
  36108. */
  36109. getTransformMatrix(): Matrix;
  36110. /**
  36111. * Sets the current transform matrix
  36112. * @param viewL defines the View matrix to use
  36113. * @param projectionL defines the Projection matrix to use
  36114. * @param viewR defines the right View matrix to use (if provided)
  36115. * @param projectionR defines the right Projection matrix to use (if provided)
  36116. */
  36117. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36118. /**
  36119. * Gets the uniform buffer used to store scene data
  36120. * @returns a UniformBuffer
  36121. */
  36122. getSceneUniformBuffer(): UniformBuffer;
  36123. /**
  36124. * Gets an unique (relatively to the current scene) Id
  36125. * @returns an unique number for the scene
  36126. */
  36127. getUniqueId(): number;
  36128. /**
  36129. * Add a mesh to the list of scene's meshes
  36130. * @param newMesh defines the mesh to add
  36131. * @param recursive if all child meshes should also be added to the scene
  36132. */
  36133. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36134. /**
  36135. * Remove a mesh for the list of scene's meshes
  36136. * @param toRemove defines the mesh to remove
  36137. * @param recursive if all child meshes should also be removed from the scene
  36138. * @returns the index where the mesh was in the mesh list
  36139. */
  36140. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36141. /**
  36142. * Add a transform node to the list of scene's transform nodes
  36143. * @param newTransformNode defines the transform node to add
  36144. */
  36145. addTransformNode(newTransformNode: TransformNode): void;
  36146. /**
  36147. * Remove a transform node for the list of scene's transform nodes
  36148. * @param toRemove defines the transform node to remove
  36149. * @returns the index where the transform node was in the transform node list
  36150. */
  36151. removeTransformNode(toRemove: TransformNode): number;
  36152. /**
  36153. * Remove a skeleton for the list of scene's skeletons
  36154. * @param toRemove defines the skeleton to remove
  36155. * @returns the index where the skeleton was in the skeleton list
  36156. */
  36157. removeSkeleton(toRemove: Skeleton): number;
  36158. /**
  36159. * Remove a morph target for the list of scene's morph targets
  36160. * @param toRemove defines the morph target to remove
  36161. * @returns the index where the morph target was in the morph target list
  36162. */
  36163. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36164. /**
  36165. * Remove a light for the list of scene's lights
  36166. * @param toRemove defines the light to remove
  36167. * @returns the index where the light was in the light list
  36168. */
  36169. removeLight(toRemove: Light): number;
  36170. /**
  36171. * Remove a camera for the list of scene's cameras
  36172. * @param toRemove defines the camera to remove
  36173. * @returns the index where the camera was in the camera list
  36174. */
  36175. removeCamera(toRemove: Camera): number;
  36176. /**
  36177. * Remove a particle system for the list of scene's particle systems
  36178. * @param toRemove defines the particle system to remove
  36179. * @returns the index where the particle system was in the particle system list
  36180. */
  36181. removeParticleSystem(toRemove: IParticleSystem): number;
  36182. /**
  36183. * Remove a animation for the list of scene's animations
  36184. * @param toRemove defines the animation to remove
  36185. * @returns the index where the animation was in the animation list
  36186. */
  36187. removeAnimation(toRemove: Animation): number;
  36188. /**
  36189. * Will stop the animation of the given target
  36190. * @param target - the target
  36191. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36192. * @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)
  36193. */
  36194. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36195. /**
  36196. * Removes the given animation group from this scene.
  36197. * @param toRemove The animation group to remove
  36198. * @returns The index of the removed animation group
  36199. */
  36200. removeAnimationGroup(toRemove: AnimationGroup): number;
  36201. /**
  36202. * Removes the given multi-material from this scene.
  36203. * @param toRemove The multi-material to remove
  36204. * @returns The index of the removed multi-material
  36205. */
  36206. removeMultiMaterial(toRemove: MultiMaterial): number;
  36207. /**
  36208. * Removes the given material from this scene.
  36209. * @param toRemove The material to remove
  36210. * @returns The index of the removed material
  36211. */
  36212. removeMaterial(toRemove: Material): number;
  36213. /**
  36214. * Removes the given action manager from this scene.
  36215. * @param toRemove The action manager to remove
  36216. * @returns The index of the removed action manager
  36217. */
  36218. removeActionManager(toRemove: AbstractActionManager): number;
  36219. /**
  36220. * Removes the given texture from this scene.
  36221. * @param toRemove The texture to remove
  36222. * @returns The index of the removed texture
  36223. */
  36224. removeTexture(toRemove: BaseTexture): number;
  36225. /**
  36226. * Adds the given light to this scene
  36227. * @param newLight The light to add
  36228. */
  36229. addLight(newLight: Light): void;
  36230. /**
  36231. * Sorts the list list based on light priorities
  36232. */
  36233. sortLightsByPriority(): void;
  36234. /**
  36235. * Adds the given camera to this scene
  36236. * @param newCamera The camera to add
  36237. */
  36238. addCamera(newCamera: Camera): void;
  36239. /**
  36240. * Adds the given skeleton to this scene
  36241. * @param newSkeleton The skeleton to add
  36242. */
  36243. addSkeleton(newSkeleton: Skeleton): void;
  36244. /**
  36245. * Adds the given particle system to this scene
  36246. * @param newParticleSystem The particle system to add
  36247. */
  36248. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36249. /**
  36250. * Adds the given animation to this scene
  36251. * @param newAnimation The animation to add
  36252. */
  36253. addAnimation(newAnimation: Animation): void;
  36254. /**
  36255. * Adds the given animation group to this scene.
  36256. * @param newAnimationGroup The animation group to add
  36257. */
  36258. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36259. /**
  36260. * Adds the given multi-material to this scene
  36261. * @param newMultiMaterial The multi-material to add
  36262. */
  36263. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36264. /**
  36265. * Adds the given material to this scene
  36266. * @param newMaterial The material to add
  36267. */
  36268. addMaterial(newMaterial: Material): void;
  36269. /**
  36270. * Adds the given morph target to this scene
  36271. * @param newMorphTargetManager The morph target to add
  36272. */
  36273. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36274. /**
  36275. * Adds the given geometry to this scene
  36276. * @param newGeometry The geometry to add
  36277. */
  36278. addGeometry(newGeometry: Geometry): void;
  36279. /**
  36280. * Adds the given action manager to this scene
  36281. * @param newActionManager The action manager to add
  36282. */
  36283. addActionManager(newActionManager: AbstractActionManager): void;
  36284. /**
  36285. * Adds the given texture to this scene.
  36286. * @param newTexture The texture to add
  36287. */
  36288. addTexture(newTexture: BaseTexture): void;
  36289. /**
  36290. * Switch active camera
  36291. * @param newCamera defines the new active camera
  36292. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36293. */
  36294. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36295. /**
  36296. * sets the active camera of the scene using its ID
  36297. * @param id defines the camera's ID
  36298. * @return the new active camera or null if none found.
  36299. */
  36300. setActiveCameraByID(id: string): Nullable<Camera>;
  36301. /**
  36302. * sets the active camera of the scene using its name
  36303. * @param name defines the camera's name
  36304. * @returns the new active camera or null if none found.
  36305. */
  36306. setActiveCameraByName(name: string): Nullable<Camera>;
  36307. /**
  36308. * get an animation group using its name
  36309. * @param name defines the material's name
  36310. * @return the animation group or null if none found.
  36311. */
  36312. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36313. /**
  36314. * Get a material using its unique id
  36315. * @param uniqueId defines the material's unique id
  36316. * @return the material or null if none found.
  36317. */
  36318. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36319. /**
  36320. * get a material using its id
  36321. * @param id defines the material's ID
  36322. * @return the material or null if none found.
  36323. */
  36324. getMaterialByID(id: string): Nullable<Material>;
  36325. /**
  36326. * Gets a the last added material using a given id
  36327. * @param id defines the material's ID
  36328. * @return the last material with the given id or null if none found.
  36329. */
  36330. getLastMaterialByID(id: string): Nullable<Material>;
  36331. /**
  36332. * Gets a material using its name
  36333. * @param name defines the material's name
  36334. * @return the material or null if none found.
  36335. */
  36336. getMaterialByName(name: string): Nullable<Material>;
  36337. /**
  36338. * Get a texture using its unique id
  36339. * @param uniqueId defines the texture's unique id
  36340. * @return the texture or null if none found.
  36341. */
  36342. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36343. /**
  36344. * Gets a camera using its id
  36345. * @param id defines the id to look for
  36346. * @returns the camera or null if not found
  36347. */
  36348. getCameraByID(id: string): Nullable<Camera>;
  36349. /**
  36350. * Gets a camera using its unique id
  36351. * @param uniqueId defines the unique id to look for
  36352. * @returns the camera or null if not found
  36353. */
  36354. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36355. /**
  36356. * Gets a camera using its name
  36357. * @param name defines the camera's name
  36358. * @return the camera or null if none found.
  36359. */
  36360. getCameraByName(name: string): Nullable<Camera>;
  36361. /**
  36362. * Gets a bone using its id
  36363. * @param id defines the bone's id
  36364. * @return the bone or null if not found
  36365. */
  36366. getBoneByID(id: string): Nullable<Bone>;
  36367. /**
  36368. * Gets a bone using its id
  36369. * @param name defines the bone's name
  36370. * @return the bone or null if not found
  36371. */
  36372. getBoneByName(name: string): Nullable<Bone>;
  36373. /**
  36374. * Gets a light node using its name
  36375. * @param name defines the the light's name
  36376. * @return the light or null if none found.
  36377. */
  36378. getLightByName(name: string): Nullable<Light>;
  36379. /**
  36380. * Gets a light node using its id
  36381. * @param id defines the light's id
  36382. * @return the light or null if none found.
  36383. */
  36384. getLightByID(id: string): Nullable<Light>;
  36385. /**
  36386. * Gets a light node using its scene-generated unique ID
  36387. * @param uniqueId defines the light's unique id
  36388. * @return the light or null if none found.
  36389. */
  36390. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36391. /**
  36392. * Gets a particle system by id
  36393. * @param id defines the particle system id
  36394. * @return the corresponding system or null if none found
  36395. */
  36396. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36397. /**
  36398. * Gets a geometry using its ID
  36399. * @param id defines the geometry's id
  36400. * @return the geometry or null if none found.
  36401. */
  36402. getGeometryByID(id: string): Nullable<Geometry>;
  36403. private _getGeometryByUniqueID;
  36404. /**
  36405. * Add a new geometry to this scene
  36406. * @param geometry defines the geometry to be added to the scene.
  36407. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36408. * @return a boolean defining if the geometry was added or not
  36409. */
  36410. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36411. /**
  36412. * Removes an existing geometry
  36413. * @param geometry defines the geometry to be removed from the scene
  36414. * @return a boolean defining if the geometry was removed or not
  36415. */
  36416. removeGeometry(geometry: Geometry): boolean;
  36417. /**
  36418. * Gets the list of geometries attached to the scene
  36419. * @returns an array of Geometry
  36420. */
  36421. getGeometries(): Geometry[];
  36422. /**
  36423. * Gets the first added mesh found of a given ID
  36424. * @param id defines the id to search for
  36425. * @return the mesh found or null if not found at all
  36426. */
  36427. getMeshByID(id: string): Nullable<AbstractMesh>;
  36428. /**
  36429. * Gets a list of meshes using their id
  36430. * @param id defines the id to search for
  36431. * @returns a list of meshes
  36432. */
  36433. getMeshesByID(id: string): Array<AbstractMesh>;
  36434. /**
  36435. * Gets the first added transform node found of a given ID
  36436. * @param id defines the id to search for
  36437. * @return the found transform node or null if not found at all.
  36438. */
  36439. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36440. /**
  36441. * Gets a transform node with its auto-generated unique id
  36442. * @param uniqueId efines the unique id to search for
  36443. * @return the found transform node or null if not found at all.
  36444. */
  36445. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36446. /**
  36447. * Gets a list of transform nodes using their id
  36448. * @param id defines the id to search for
  36449. * @returns a list of transform nodes
  36450. */
  36451. getTransformNodesByID(id: string): Array<TransformNode>;
  36452. /**
  36453. * Gets a mesh with its auto-generated unique id
  36454. * @param uniqueId defines the unique id to search for
  36455. * @return the found mesh or null if not found at all.
  36456. */
  36457. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36458. /**
  36459. * Gets a the last added mesh using a given id
  36460. * @param id defines the id to search for
  36461. * @return the found mesh or null if not found at all.
  36462. */
  36463. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36464. /**
  36465. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36466. * @param id defines the id to search for
  36467. * @return the found node or null if not found at all
  36468. */
  36469. getLastEntryByID(id: string): Nullable<Node>;
  36470. /**
  36471. * Gets a node (Mesh, Camera, Light) using a given id
  36472. * @param id defines the id to search for
  36473. * @return the found node or null if not found at all
  36474. */
  36475. getNodeByID(id: string): Nullable<Node>;
  36476. /**
  36477. * Gets a node (Mesh, Camera, Light) using a given name
  36478. * @param name defines the name to search for
  36479. * @return the found node or null if not found at all.
  36480. */
  36481. getNodeByName(name: string): Nullable<Node>;
  36482. /**
  36483. * Gets a mesh using a given name
  36484. * @param name defines the name to search for
  36485. * @return the found mesh or null if not found at all.
  36486. */
  36487. getMeshByName(name: string): Nullable<AbstractMesh>;
  36488. /**
  36489. * Gets a transform node using a given name
  36490. * @param name defines the name to search for
  36491. * @return the found transform node or null if not found at all.
  36492. */
  36493. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36494. /**
  36495. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36496. * @param id defines the id to search for
  36497. * @return the found skeleton or null if not found at all.
  36498. */
  36499. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36500. /**
  36501. * Gets a skeleton using a given auto generated unique id
  36502. * @param uniqueId defines the unique id to search for
  36503. * @return the found skeleton or null if not found at all.
  36504. */
  36505. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36506. /**
  36507. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36508. * @param id defines the id to search for
  36509. * @return the found skeleton or null if not found at all.
  36510. */
  36511. getSkeletonById(id: string): Nullable<Skeleton>;
  36512. /**
  36513. * Gets a skeleton using a given name
  36514. * @param name defines the name to search for
  36515. * @return the found skeleton or null if not found at all.
  36516. */
  36517. getSkeletonByName(name: string): Nullable<Skeleton>;
  36518. /**
  36519. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36520. * @param id defines the id to search for
  36521. * @return the found morph target manager or null if not found at all.
  36522. */
  36523. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36524. /**
  36525. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36526. * @param id defines the id to search for
  36527. * @return the found morph target or null if not found at all.
  36528. */
  36529. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36530. /**
  36531. * Gets a boolean indicating if the given mesh is active
  36532. * @param mesh defines the mesh to look for
  36533. * @returns true if the mesh is in the active list
  36534. */
  36535. isActiveMesh(mesh: AbstractMesh): boolean;
  36536. /**
  36537. * Return a unique id as a string which can serve as an identifier for the scene
  36538. */
  36539. get uid(): string;
  36540. /**
  36541. * Add an externaly attached data from its key.
  36542. * This method call will fail and return false, if such key already exists.
  36543. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36544. * @param key the unique key that identifies the data
  36545. * @param data the data object to associate to the key for this Engine instance
  36546. * @return true if no such key were already present and the data was added successfully, false otherwise
  36547. */
  36548. addExternalData<T>(key: string, data: T): boolean;
  36549. /**
  36550. * Get an externaly attached data from its key
  36551. * @param key the unique key that identifies the data
  36552. * @return the associated data, if present (can be null), or undefined if not present
  36553. */
  36554. getExternalData<T>(key: string): Nullable<T>;
  36555. /**
  36556. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36557. * @param key the unique key that identifies the data
  36558. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36559. * @return the associated data, can be null if the factory returned null.
  36560. */
  36561. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36562. /**
  36563. * Remove an externaly attached data from the Engine instance
  36564. * @param key the unique key that identifies the data
  36565. * @return true if the data was successfully removed, false if it doesn't exist
  36566. */
  36567. removeExternalData(key: string): boolean;
  36568. private _evaluateSubMesh;
  36569. /**
  36570. * Clear the processed materials smart array preventing retention point in material dispose.
  36571. */
  36572. freeProcessedMaterials(): void;
  36573. private _preventFreeActiveMeshesAndRenderingGroups;
  36574. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36575. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36576. * when disposing several meshes in a row or a hierarchy of meshes.
  36577. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36578. */
  36579. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36580. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36581. /**
  36582. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36583. */
  36584. freeActiveMeshes(): void;
  36585. /**
  36586. * Clear the info related to rendering groups preventing retention points during dispose.
  36587. */
  36588. freeRenderingGroups(): void;
  36589. /** @hidden */
  36590. _isInIntermediateRendering(): boolean;
  36591. /**
  36592. * Lambda returning the list of potentially active meshes.
  36593. */
  36594. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36595. /**
  36596. * Lambda returning the list of potentially active sub meshes.
  36597. */
  36598. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36599. /**
  36600. * Lambda returning the list of potentially intersecting sub meshes.
  36601. */
  36602. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36603. /**
  36604. * Lambda returning the list of potentially colliding sub meshes.
  36605. */
  36606. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36607. private _activeMeshesFrozen;
  36608. private _skipEvaluateActiveMeshesCompletely;
  36609. /**
  36610. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36611. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36612. * @returns the current scene
  36613. */
  36614. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36615. /**
  36616. * Use this function to restart evaluating active meshes on every frame
  36617. * @returns the current scene
  36618. */
  36619. unfreezeActiveMeshes(): Scene;
  36620. private _evaluateActiveMeshes;
  36621. private _activeMesh;
  36622. /**
  36623. * Update the transform matrix to update from the current active camera
  36624. * @param force defines a boolean used to force the update even if cache is up to date
  36625. */
  36626. updateTransformMatrix(force?: boolean): void;
  36627. private _bindFrameBuffer;
  36628. /** @hidden */
  36629. _allowPostProcessClearColor: boolean;
  36630. /** @hidden */
  36631. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36632. private _processSubCameras;
  36633. private _checkIntersections;
  36634. /** @hidden */
  36635. _advancePhysicsEngineStep(step: number): void;
  36636. /**
  36637. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36638. */
  36639. getDeterministicFrameTime: () => number;
  36640. /** @hidden */
  36641. _animate(): void;
  36642. /** Execute all animations (for a frame) */
  36643. animate(): void;
  36644. /**
  36645. * Render the scene
  36646. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36647. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36648. */
  36649. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36650. /**
  36651. * Freeze all materials
  36652. * A frozen material will not be updatable but should be faster to render
  36653. */
  36654. freezeMaterials(): void;
  36655. /**
  36656. * Unfreeze all materials
  36657. * A frozen material will not be updatable but should be faster to render
  36658. */
  36659. unfreezeMaterials(): void;
  36660. /**
  36661. * Releases all held ressources
  36662. */
  36663. dispose(): void;
  36664. /**
  36665. * Gets if the scene is already disposed
  36666. */
  36667. get isDisposed(): boolean;
  36668. /**
  36669. * Call this function to reduce memory footprint of the scene.
  36670. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36671. */
  36672. clearCachedVertexData(): void;
  36673. /**
  36674. * This function will remove the local cached buffer data from texture.
  36675. * It will save memory but will prevent the texture from being rebuilt
  36676. */
  36677. cleanCachedTextureBuffer(): void;
  36678. /**
  36679. * Get the world extend vectors with an optional filter
  36680. *
  36681. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36682. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36683. */
  36684. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36685. min: Vector3;
  36686. max: Vector3;
  36687. };
  36688. /**
  36689. * Creates a ray that can be used to pick in the scene
  36690. * @param x defines the x coordinate of the origin (on-screen)
  36691. * @param y defines the y coordinate of the origin (on-screen)
  36692. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36693. * @param camera defines the camera to use for the picking
  36694. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36695. * @returns a Ray
  36696. */
  36697. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36698. /**
  36699. * Creates a ray that can be used to pick in the scene
  36700. * @param x defines the x coordinate of the origin (on-screen)
  36701. * @param y defines the y coordinate of the origin (on-screen)
  36702. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36703. * @param result defines the ray where to store the picking ray
  36704. * @param camera defines the camera to use for the picking
  36705. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36706. * @returns the current scene
  36707. */
  36708. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36709. /**
  36710. * Creates a ray that can be used to pick in the scene
  36711. * @param x defines the x coordinate of the origin (on-screen)
  36712. * @param y defines the y coordinate of the origin (on-screen)
  36713. * @param camera defines the camera to use for the picking
  36714. * @returns a Ray
  36715. */
  36716. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36717. /**
  36718. * Creates a ray that can be used to pick in the scene
  36719. * @param x defines the x coordinate of the origin (on-screen)
  36720. * @param y defines the y coordinate of the origin (on-screen)
  36721. * @param result defines the ray where to store the picking ray
  36722. * @param camera defines the camera to use for the picking
  36723. * @returns the current scene
  36724. */
  36725. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36726. /** Launch a ray to try to pick a mesh in the scene
  36727. * @param x position on screen
  36728. * @param y position on screen
  36729. * @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
  36730. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36731. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36732. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36733. * @returns a PickingInfo
  36734. */
  36735. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36736. /** Use the given ray to pick a mesh in the scene
  36737. * @param ray The ray to use to pick meshes
  36738. * @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
  36739. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36740. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36741. * @returns a PickingInfo
  36742. */
  36743. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36744. /**
  36745. * Launch a ray to try to pick a mesh in the scene
  36746. * @param x X position on screen
  36747. * @param y Y position on screen
  36748. * @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
  36749. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36750. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36751. * @returns an array of PickingInfo
  36752. */
  36753. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36754. /**
  36755. * Launch a ray to try to pick a mesh in the scene
  36756. * @param ray Ray to use
  36757. * @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
  36758. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36759. * @returns an array of PickingInfo
  36760. */
  36761. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36762. /**
  36763. * Force the value of meshUnderPointer
  36764. * @param mesh defines the mesh to use
  36765. */
  36766. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36767. /**
  36768. * Gets the mesh under the pointer
  36769. * @returns a Mesh or null if no mesh is under the pointer
  36770. */
  36771. getPointerOverMesh(): Nullable<AbstractMesh>;
  36772. /** @hidden */
  36773. _rebuildGeometries(): void;
  36774. /** @hidden */
  36775. _rebuildTextures(): void;
  36776. private _getByTags;
  36777. /**
  36778. * Get a list of meshes by tags
  36779. * @param tagsQuery defines the tags query to use
  36780. * @param forEach defines a predicate used to filter results
  36781. * @returns an array of Mesh
  36782. */
  36783. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36784. /**
  36785. * Get a list of cameras by tags
  36786. * @param tagsQuery defines the tags query to use
  36787. * @param forEach defines a predicate used to filter results
  36788. * @returns an array of Camera
  36789. */
  36790. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36791. /**
  36792. * Get a list of lights by tags
  36793. * @param tagsQuery defines the tags query to use
  36794. * @param forEach defines a predicate used to filter results
  36795. * @returns an array of Light
  36796. */
  36797. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36798. /**
  36799. * Get a list of materials by tags
  36800. * @param tagsQuery defines the tags query to use
  36801. * @param forEach defines a predicate used to filter results
  36802. * @returns an array of Material
  36803. */
  36804. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36805. /**
  36806. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36807. * This allowed control for front to back rendering or reversly depending of the special needs.
  36808. *
  36809. * @param renderingGroupId The rendering group id corresponding to its index
  36810. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36811. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36812. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36813. */
  36814. 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;
  36815. /**
  36816. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36817. *
  36818. * @param renderingGroupId The rendering group id corresponding to its index
  36819. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36820. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36821. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36822. */
  36823. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36824. /**
  36825. * Gets the current auto clear configuration for one rendering group of the rendering
  36826. * manager.
  36827. * @param index the rendering group index to get the information for
  36828. * @returns The auto clear setup for the requested rendering group
  36829. */
  36830. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36831. private _blockMaterialDirtyMechanism;
  36832. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36833. get blockMaterialDirtyMechanism(): boolean;
  36834. set blockMaterialDirtyMechanism(value: boolean);
  36835. /**
  36836. * Will flag all materials as dirty to trigger new shader compilation
  36837. * @param flag defines the flag used to specify which material part must be marked as dirty
  36838. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36839. */
  36840. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36841. /** @hidden */
  36842. _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;
  36843. /** @hidden */
  36844. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36845. /** @hidden */
  36846. _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;
  36847. /** @hidden */
  36848. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36849. /** @hidden */
  36850. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36851. /** @hidden */
  36852. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36853. }
  36854. }
  36855. declare module BABYLON {
  36856. /**
  36857. * Set of assets to keep when moving a scene into an asset container.
  36858. */
  36859. export class KeepAssets extends AbstractScene {
  36860. }
  36861. /**
  36862. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36863. */
  36864. export class InstantiatedEntries {
  36865. /**
  36866. * List of new root nodes (eg. nodes with no parent)
  36867. */
  36868. rootNodes: TransformNode[];
  36869. /**
  36870. * List of new skeletons
  36871. */
  36872. skeletons: Skeleton[];
  36873. /**
  36874. * List of new animation groups
  36875. */
  36876. animationGroups: AnimationGroup[];
  36877. }
  36878. /**
  36879. * Container with a set of assets that can be added or removed from a scene.
  36880. */
  36881. export class AssetContainer extends AbstractScene {
  36882. /**
  36883. * The scene the AssetContainer belongs to.
  36884. */
  36885. scene: Scene;
  36886. /**
  36887. * Instantiates an AssetContainer.
  36888. * @param scene The scene the AssetContainer belongs to.
  36889. */
  36890. constructor(scene: Scene);
  36891. /**
  36892. * Instantiate or clone all meshes and add the new ones to the scene.
  36893. * Skeletons and animation groups will all be cloned
  36894. * @param nameFunction defines an optional function used to get new names for clones
  36895. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36896. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36897. */
  36898. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36899. /**
  36900. * Adds all the assets from the container to the scene.
  36901. */
  36902. addAllToScene(): void;
  36903. /**
  36904. * Removes all the assets in the container from the scene
  36905. */
  36906. removeAllFromScene(): void;
  36907. /**
  36908. * Disposes all the assets in the container
  36909. */
  36910. dispose(): void;
  36911. private _moveAssets;
  36912. /**
  36913. * Removes all the assets contained in the scene and adds them to the container.
  36914. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36915. */
  36916. moveAllFromScene(keepAssets?: KeepAssets): void;
  36917. /**
  36918. * 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.
  36919. * @returns the root mesh
  36920. */
  36921. createRootMesh(): Mesh;
  36922. /**
  36923. * Merge animations from this asset container into a scene
  36924. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36925. * @param animatables set of animatables to retarget to a node from the scene
  36926. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36927. */
  36928. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36929. }
  36930. }
  36931. declare module BABYLON {
  36932. /**
  36933. * Defines how the parser contract is defined.
  36934. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36935. */
  36936. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36937. /**
  36938. * Defines how the individual parser contract is defined.
  36939. * These parser can parse an individual asset
  36940. */
  36941. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36942. /**
  36943. * Base class of the scene acting as a container for the different elements composing a scene.
  36944. * This class is dynamically extended by the different components of the scene increasing
  36945. * flexibility and reducing coupling
  36946. */
  36947. export abstract class AbstractScene {
  36948. /**
  36949. * Stores the list of available parsers in the application.
  36950. */
  36951. private static _BabylonFileParsers;
  36952. /**
  36953. * Stores the list of available individual parsers in the application.
  36954. */
  36955. private static _IndividualBabylonFileParsers;
  36956. /**
  36957. * Adds a parser in the list of available ones
  36958. * @param name Defines the name of the parser
  36959. * @param parser Defines the parser to add
  36960. */
  36961. static AddParser(name: string, parser: BabylonFileParser): void;
  36962. /**
  36963. * Gets a general parser from the list of avaialble ones
  36964. * @param name Defines the name of the parser
  36965. * @returns the requested parser or null
  36966. */
  36967. static GetParser(name: string): Nullable<BabylonFileParser>;
  36968. /**
  36969. * Adds n individual parser in the list of available ones
  36970. * @param name Defines the name of the parser
  36971. * @param parser Defines the parser to add
  36972. */
  36973. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36974. /**
  36975. * Gets an individual parser from the list of avaialble ones
  36976. * @param name Defines the name of the parser
  36977. * @returns the requested parser or null
  36978. */
  36979. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36980. /**
  36981. * Parser json data and populate both a scene and its associated container object
  36982. * @param jsonData Defines the data to parse
  36983. * @param scene Defines the scene to parse the data for
  36984. * @param container Defines the container attached to the parsing sequence
  36985. * @param rootUrl Defines the root url of the data
  36986. */
  36987. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36988. /**
  36989. * Gets the list of root nodes (ie. nodes with no parent)
  36990. */
  36991. rootNodes: Node[];
  36992. /** All of the cameras added to this scene
  36993. * @see http://doc.babylonjs.com/babylon101/cameras
  36994. */
  36995. cameras: Camera[];
  36996. /**
  36997. * All of the lights added to this scene
  36998. * @see http://doc.babylonjs.com/babylon101/lights
  36999. */
  37000. lights: Light[];
  37001. /**
  37002. * All of the (abstract) meshes added to this scene
  37003. */
  37004. meshes: AbstractMesh[];
  37005. /**
  37006. * The list of skeletons added to the scene
  37007. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37008. */
  37009. skeletons: Skeleton[];
  37010. /**
  37011. * All of the particle systems added to this scene
  37012. * @see http://doc.babylonjs.com/babylon101/particles
  37013. */
  37014. particleSystems: IParticleSystem[];
  37015. /**
  37016. * Gets a list of Animations associated with the scene
  37017. */
  37018. animations: Animation[];
  37019. /**
  37020. * All of the animation groups added to this scene
  37021. * @see http://doc.babylonjs.com/how_to/group
  37022. */
  37023. animationGroups: AnimationGroup[];
  37024. /**
  37025. * All of the multi-materials added to this scene
  37026. * @see http://doc.babylonjs.com/how_to/multi_materials
  37027. */
  37028. multiMaterials: MultiMaterial[];
  37029. /**
  37030. * All of the materials added to this scene
  37031. * In the context of a Scene, it is not supposed to be modified manually.
  37032. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37033. * Note also that the order of the Material within the array is not significant and might change.
  37034. * @see http://doc.babylonjs.com/babylon101/materials
  37035. */
  37036. materials: Material[];
  37037. /**
  37038. * The list of morph target managers added to the scene
  37039. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37040. */
  37041. morphTargetManagers: MorphTargetManager[];
  37042. /**
  37043. * The list of geometries used in the scene.
  37044. */
  37045. geometries: Geometry[];
  37046. /**
  37047. * All of the tranform nodes added to this scene
  37048. * In the context of a Scene, it is not supposed to be modified manually.
  37049. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37050. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37051. * @see http://doc.babylonjs.com/how_to/transformnode
  37052. */
  37053. transformNodes: TransformNode[];
  37054. /**
  37055. * ActionManagers available on the scene.
  37056. */
  37057. actionManagers: AbstractActionManager[];
  37058. /**
  37059. * Textures to keep.
  37060. */
  37061. textures: BaseTexture[];
  37062. /**
  37063. * Environment texture for the scene
  37064. */
  37065. environmentTexture: Nullable<BaseTexture>;
  37066. /**
  37067. * @returns all meshes, lights, cameras, transformNodes and bones
  37068. */
  37069. getNodes(): Array<Node>;
  37070. }
  37071. }
  37072. declare module BABYLON {
  37073. /**
  37074. * Interface used to define options for Sound class
  37075. */
  37076. export interface ISoundOptions {
  37077. /**
  37078. * Does the sound autoplay once loaded.
  37079. */
  37080. autoplay?: boolean;
  37081. /**
  37082. * Does the sound loop after it finishes playing once.
  37083. */
  37084. loop?: boolean;
  37085. /**
  37086. * Sound's volume
  37087. */
  37088. volume?: number;
  37089. /**
  37090. * Is it a spatial sound?
  37091. */
  37092. spatialSound?: boolean;
  37093. /**
  37094. * Maximum distance to hear that sound
  37095. */
  37096. maxDistance?: number;
  37097. /**
  37098. * Uses user defined attenuation function
  37099. */
  37100. useCustomAttenuation?: boolean;
  37101. /**
  37102. * Define the roll off factor of spatial sounds.
  37103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37104. */
  37105. rolloffFactor?: number;
  37106. /**
  37107. * Define the reference distance the sound should be heard perfectly.
  37108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37109. */
  37110. refDistance?: number;
  37111. /**
  37112. * Define the distance attenuation model the sound will follow.
  37113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37114. */
  37115. distanceModel?: string;
  37116. /**
  37117. * Defines the playback speed (1 by default)
  37118. */
  37119. playbackRate?: number;
  37120. /**
  37121. * Defines if the sound is from a streaming source
  37122. */
  37123. streaming?: boolean;
  37124. /**
  37125. * Defines an optional length (in seconds) inside the sound file
  37126. */
  37127. length?: number;
  37128. /**
  37129. * Defines an optional offset (in seconds) inside the sound file
  37130. */
  37131. offset?: number;
  37132. /**
  37133. * If true, URLs will not be required to state the audio file codec to use.
  37134. */
  37135. skipCodecCheck?: boolean;
  37136. }
  37137. /**
  37138. * Defines a sound that can be played in the application.
  37139. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37140. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37141. */
  37142. export class Sound {
  37143. /**
  37144. * The name of the sound in the scene.
  37145. */
  37146. name: string;
  37147. /**
  37148. * Does the sound autoplay once loaded.
  37149. */
  37150. autoplay: boolean;
  37151. /**
  37152. * Does the sound loop after it finishes playing once.
  37153. */
  37154. loop: boolean;
  37155. /**
  37156. * Does the sound use a custom attenuation curve to simulate the falloff
  37157. * happening when the source gets further away from the camera.
  37158. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37159. */
  37160. useCustomAttenuation: boolean;
  37161. /**
  37162. * The sound track id this sound belongs to.
  37163. */
  37164. soundTrackId: number;
  37165. /**
  37166. * Is this sound currently played.
  37167. */
  37168. isPlaying: boolean;
  37169. /**
  37170. * Is this sound currently paused.
  37171. */
  37172. isPaused: boolean;
  37173. /**
  37174. * Does this sound enables spatial sound.
  37175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37176. */
  37177. spatialSound: boolean;
  37178. /**
  37179. * Define the reference distance the sound should be heard perfectly.
  37180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37181. */
  37182. refDistance: number;
  37183. /**
  37184. * Define the roll off factor of spatial sounds.
  37185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37186. */
  37187. rolloffFactor: number;
  37188. /**
  37189. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37191. */
  37192. maxDistance: number;
  37193. /**
  37194. * Define the distance attenuation model the sound will follow.
  37195. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37196. */
  37197. distanceModel: string;
  37198. /**
  37199. * @hidden
  37200. * Back Compat
  37201. **/
  37202. onended: () => any;
  37203. /**
  37204. * Observable event when the current playing sound finishes.
  37205. */
  37206. onEndedObservable: Observable<Sound>;
  37207. private _panningModel;
  37208. private _playbackRate;
  37209. private _streaming;
  37210. private _startTime;
  37211. private _startOffset;
  37212. private _position;
  37213. /** @hidden */
  37214. _positionInEmitterSpace: boolean;
  37215. private _localDirection;
  37216. private _volume;
  37217. private _isReadyToPlay;
  37218. private _isDirectional;
  37219. private _readyToPlayCallback;
  37220. private _audioBuffer;
  37221. private _soundSource;
  37222. private _streamingSource;
  37223. private _soundPanner;
  37224. private _soundGain;
  37225. private _inputAudioNode;
  37226. private _outputAudioNode;
  37227. private _coneInnerAngle;
  37228. private _coneOuterAngle;
  37229. private _coneOuterGain;
  37230. private _scene;
  37231. private _connectedTransformNode;
  37232. private _customAttenuationFunction;
  37233. private _registerFunc;
  37234. private _isOutputConnected;
  37235. private _htmlAudioElement;
  37236. private _urlType;
  37237. private _length?;
  37238. private _offset?;
  37239. /** @hidden */
  37240. static _SceneComponentInitialization: (scene: Scene) => void;
  37241. /**
  37242. * Create a sound and attach it to a scene
  37243. * @param name Name of your sound
  37244. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37245. * @param scene defines the scene the sound belongs to
  37246. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37247. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37248. */
  37249. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37250. /**
  37251. * Release the sound and its associated resources
  37252. */
  37253. dispose(): void;
  37254. /**
  37255. * Gets if the sounds is ready to be played or not.
  37256. * @returns true if ready, otherwise false
  37257. */
  37258. isReady(): boolean;
  37259. private _soundLoaded;
  37260. /**
  37261. * Sets the data of the sound from an audiobuffer
  37262. * @param audioBuffer The audioBuffer containing the data
  37263. */
  37264. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37265. /**
  37266. * Updates the current sounds options such as maxdistance, loop...
  37267. * @param options A JSON object containing values named as the object properties
  37268. */
  37269. updateOptions(options: ISoundOptions): void;
  37270. private _createSpatialParameters;
  37271. private _updateSpatialParameters;
  37272. /**
  37273. * Switch the panning model to HRTF:
  37274. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37276. */
  37277. switchPanningModelToHRTF(): void;
  37278. /**
  37279. * Switch the panning model to Equal Power:
  37280. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37282. */
  37283. switchPanningModelToEqualPower(): void;
  37284. private _switchPanningModel;
  37285. /**
  37286. * Connect this sound to a sound track audio node like gain...
  37287. * @param soundTrackAudioNode the sound track audio node to connect to
  37288. */
  37289. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37290. /**
  37291. * Transform this sound into a directional source
  37292. * @param coneInnerAngle Size of the inner cone in degree
  37293. * @param coneOuterAngle Size of the outer cone in degree
  37294. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37295. */
  37296. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37297. /**
  37298. * Gets or sets the inner angle for the directional cone.
  37299. */
  37300. get directionalConeInnerAngle(): number;
  37301. /**
  37302. * Gets or sets the inner angle for the directional cone.
  37303. */
  37304. set directionalConeInnerAngle(value: number);
  37305. /**
  37306. * Gets or sets the outer angle for the directional cone.
  37307. */
  37308. get directionalConeOuterAngle(): number;
  37309. /**
  37310. * Gets or sets the outer angle for the directional cone.
  37311. */
  37312. set directionalConeOuterAngle(value: number);
  37313. /**
  37314. * Sets the position of the emitter if spatial sound is enabled
  37315. * @param newPosition Defines the new posisiton
  37316. */
  37317. setPosition(newPosition: Vector3): void;
  37318. /**
  37319. * Sets the local direction of the emitter if spatial sound is enabled
  37320. * @param newLocalDirection Defines the new local direction
  37321. */
  37322. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37323. private _updateDirection;
  37324. /** @hidden */
  37325. updateDistanceFromListener(): void;
  37326. /**
  37327. * Sets a new custom attenuation function for the sound.
  37328. * @param callback Defines the function used for the attenuation
  37329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37330. */
  37331. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37332. /**
  37333. * Play the sound
  37334. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37335. * @param offset (optional) Start the sound at a specific time in seconds
  37336. * @param length (optional) Sound duration (in seconds)
  37337. */
  37338. play(time?: number, offset?: number, length?: number): void;
  37339. private _onended;
  37340. /**
  37341. * Stop the sound
  37342. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37343. */
  37344. stop(time?: number): void;
  37345. /**
  37346. * Put the sound in pause
  37347. */
  37348. pause(): void;
  37349. /**
  37350. * Sets a dedicated volume for this sounds
  37351. * @param newVolume Define the new volume of the sound
  37352. * @param time Define time for gradual change to new volume
  37353. */
  37354. setVolume(newVolume: number, time?: number): void;
  37355. /**
  37356. * Set the sound play back rate
  37357. * @param newPlaybackRate Define the playback rate the sound should be played at
  37358. */
  37359. setPlaybackRate(newPlaybackRate: number): void;
  37360. /**
  37361. * Gets the volume of the sound.
  37362. * @returns the volume of the sound
  37363. */
  37364. getVolume(): number;
  37365. /**
  37366. * Attach the sound to a dedicated mesh
  37367. * @param transformNode The transform node to connect the sound with
  37368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37369. */
  37370. attachToMesh(transformNode: TransformNode): void;
  37371. /**
  37372. * Detach the sound from the previously attached mesh
  37373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37374. */
  37375. detachFromMesh(): void;
  37376. private _onRegisterAfterWorldMatrixUpdate;
  37377. /**
  37378. * Clone the current sound in the scene.
  37379. * @returns the new sound clone
  37380. */
  37381. clone(): Nullable<Sound>;
  37382. /**
  37383. * Gets the current underlying audio buffer containing the data
  37384. * @returns the audio buffer
  37385. */
  37386. getAudioBuffer(): Nullable<AudioBuffer>;
  37387. /**
  37388. * Serializes the Sound in a JSON representation
  37389. * @returns the JSON representation of the sound
  37390. */
  37391. serialize(): any;
  37392. /**
  37393. * Parse a JSON representation of a sound to innstantiate in a given scene
  37394. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37395. * @param scene Define the scene the new parsed sound should be created in
  37396. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37397. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37398. * @returns the newly parsed sound
  37399. */
  37400. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37401. }
  37402. }
  37403. declare module BABYLON {
  37404. /**
  37405. * This defines an action helpful to play a defined sound on a triggered action.
  37406. */
  37407. export class PlaySoundAction extends Action {
  37408. private _sound;
  37409. /**
  37410. * Instantiate the action
  37411. * @param triggerOptions defines the trigger options
  37412. * @param sound defines the sound to play
  37413. * @param condition defines the trigger related conditions
  37414. */
  37415. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37416. /** @hidden */
  37417. _prepare(): void;
  37418. /**
  37419. * Execute the action and play the sound.
  37420. */
  37421. execute(): void;
  37422. /**
  37423. * Serializes the actions and its related information.
  37424. * @param parent defines the object to serialize in
  37425. * @returns the serialized object
  37426. */
  37427. serialize(parent: any): any;
  37428. }
  37429. /**
  37430. * This defines an action helpful to stop a defined sound on a triggered action.
  37431. */
  37432. export class StopSoundAction extends Action {
  37433. private _sound;
  37434. /**
  37435. * Instantiate the action
  37436. * @param triggerOptions defines the trigger options
  37437. * @param sound defines the sound to stop
  37438. * @param condition defines the trigger related conditions
  37439. */
  37440. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37441. /** @hidden */
  37442. _prepare(): void;
  37443. /**
  37444. * Execute the action and stop the sound.
  37445. */
  37446. execute(): void;
  37447. /**
  37448. * Serializes the actions and its related information.
  37449. * @param parent defines the object to serialize in
  37450. * @returns the serialized object
  37451. */
  37452. serialize(parent: any): any;
  37453. }
  37454. }
  37455. declare module BABYLON {
  37456. /**
  37457. * This defines an action responsible to change the value of a property
  37458. * by interpolating between its current value and the newly set one once triggered.
  37459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37460. */
  37461. export class InterpolateValueAction extends Action {
  37462. /**
  37463. * Defines the path of the property where the value should be interpolated
  37464. */
  37465. propertyPath: string;
  37466. /**
  37467. * Defines the target value at the end of the interpolation.
  37468. */
  37469. value: any;
  37470. /**
  37471. * Defines the time it will take for the property to interpolate to the value.
  37472. */
  37473. duration: number;
  37474. /**
  37475. * Defines if the other scene animations should be stopped when the action has been triggered
  37476. */
  37477. stopOtherAnimations?: boolean;
  37478. /**
  37479. * Defines a callback raised once the interpolation animation has been done.
  37480. */
  37481. onInterpolationDone?: () => void;
  37482. /**
  37483. * Observable triggered once the interpolation animation has been done.
  37484. */
  37485. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37486. private _target;
  37487. private _effectiveTarget;
  37488. private _property;
  37489. /**
  37490. * Instantiate the action
  37491. * @param triggerOptions defines the trigger options
  37492. * @param target defines the object containing the value to interpolate
  37493. * @param propertyPath defines the path to the property in the target object
  37494. * @param value defines the target value at the end of the interpolation
  37495. * @param duration deines the time it will take for the property to interpolate to the value.
  37496. * @param condition defines the trigger related conditions
  37497. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37498. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37499. */
  37500. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37501. /** @hidden */
  37502. _prepare(): void;
  37503. /**
  37504. * Execute the action starts the value interpolation.
  37505. */
  37506. execute(): void;
  37507. /**
  37508. * Serializes the actions and its related information.
  37509. * @param parent defines the object to serialize in
  37510. * @returns the serialized object
  37511. */
  37512. serialize(parent: any): any;
  37513. }
  37514. }
  37515. declare module BABYLON {
  37516. /**
  37517. * Options allowed during the creation of a sound track.
  37518. */
  37519. export interface ISoundTrackOptions {
  37520. /**
  37521. * The volume the sound track should take during creation
  37522. */
  37523. volume?: number;
  37524. /**
  37525. * Define if the sound track is the main sound track of the scene
  37526. */
  37527. mainTrack?: boolean;
  37528. }
  37529. /**
  37530. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37531. * It will be also used in a future release to apply effects on a specific track.
  37532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37533. */
  37534. export class SoundTrack {
  37535. /**
  37536. * The unique identifier of the sound track in the scene.
  37537. */
  37538. id: number;
  37539. /**
  37540. * The list of sounds included in the sound track.
  37541. */
  37542. soundCollection: Array<Sound>;
  37543. private _outputAudioNode;
  37544. private _scene;
  37545. private _connectedAnalyser;
  37546. private _options;
  37547. private _isInitialized;
  37548. /**
  37549. * Creates a new sound track.
  37550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37551. * @param scene Define the scene the sound track belongs to
  37552. * @param options
  37553. */
  37554. constructor(scene: Scene, options?: ISoundTrackOptions);
  37555. private _initializeSoundTrackAudioGraph;
  37556. /**
  37557. * Release the sound track and its associated resources
  37558. */
  37559. dispose(): void;
  37560. /**
  37561. * Adds a sound to this sound track
  37562. * @param sound define the cound to add
  37563. * @ignoreNaming
  37564. */
  37565. AddSound(sound: Sound): void;
  37566. /**
  37567. * Removes a sound to this sound track
  37568. * @param sound define the cound to remove
  37569. * @ignoreNaming
  37570. */
  37571. RemoveSound(sound: Sound): void;
  37572. /**
  37573. * Set a global volume for the full sound track.
  37574. * @param newVolume Define the new volume of the sound track
  37575. */
  37576. setVolume(newVolume: number): void;
  37577. /**
  37578. * Switch the panning model to HRTF:
  37579. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37581. */
  37582. switchPanningModelToHRTF(): void;
  37583. /**
  37584. * Switch the panning model to Equal Power:
  37585. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37587. */
  37588. switchPanningModelToEqualPower(): void;
  37589. /**
  37590. * Connect the sound track to an audio analyser allowing some amazing
  37591. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37593. * @param analyser The analyser to connect to the engine
  37594. */
  37595. connectToAnalyser(analyser: Analyser): void;
  37596. }
  37597. }
  37598. declare module BABYLON {
  37599. interface AbstractScene {
  37600. /**
  37601. * The list of sounds used in the scene.
  37602. */
  37603. sounds: Nullable<Array<Sound>>;
  37604. }
  37605. interface Scene {
  37606. /**
  37607. * @hidden
  37608. * Backing field
  37609. */
  37610. _mainSoundTrack: SoundTrack;
  37611. /**
  37612. * The main sound track played by the scene.
  37613. * It cotains your primary collection of sounds.
  37614. */
  37615. mainSoundTrack: SoundTrack;
  37616. /**
  37617. * The list of sound tracks added to the scene
  37618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37619. */
  37620. soundTracks: Nullable<Array<SoundTrack>>;
  37621. /**
  37622. * Gets a sound using a given name
  37623. * @param name defines the name to search for
  37624. * @return the found sound or null if not found at all.
  37625. */
  37626. getSoundByName(name: string): Nullable<Sound>;
  37627. /**
  37628. * Gets or sets if audio support is enabled
  37629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37630. */
  37631. audioEnabled: boolean;
  37632. /**
  37633. * Gets or sets if audio will be output to headphones
  37634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37635. */
  37636. headphone: boolean;
  37637. /**
  37638. * Gets or sets custom audio listener position provider
  37639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37640. */
  37641. audioListenerPositionProvider: Nullable<() => Vector3>;
  37642. /**
  37643. * Gets or sets a refresh rate when using 3D audio positioning
  37644. */
  37645. audioPositioningRefreshRate: number;
  37646. }
  37647. /**
  37648. * Defines the sound scene component responsible to manage any sounds
  37649. * in a given scene.
  37650. */
  37651. export class AudioSceneComponent implements ISceneSerializableComponent {
  37652. /**
  37653. * The component name helpfull to identify the component in the list of scene components.
  37654. */
  37655. readonly name: string;
  37656. /**
  37657. * The scene the component belongs to.
  37658. */
  37659. scene: Scene;
  37660. private _audioEnabled;
  37661. /**
  37662. * Gets whether audio is enabled or not.
  37663. * Please use related enable/disable method to switch state.
  37664. */
  37665. get audioEnabled(): boolean;
  37666. private _headphone;
  37667. /**
  37668. * Gets whether audio is outputing to headphone or not.
  37669. * Please use the according Switch methods to change output.
  37670. */
  37671. get headphone(): boolean;
  37672. /**
  37673. * Gets or sets a refresh rate when using 3D audio positioning
  37674. */
  37675. audioPositioningRefreshRate: number;
  37676. private _audioListenerPositionProvider;
  37677. /**
  37678. * Gets the current audio listener position provider
  37679. */
  37680. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37681. /**
  37682. * Sets a custom listener position for all sounds in the scene
  37683. * By default, this is the position of the first active camera
  37684. */
  37685. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37686. /**
  37687. * Creates a new instance of the component for the given scene
  37688. * @param scene Defines the scene to register the component in
  37689. */
  37690. constructor(scene: Scene);
  37691. /**
  37692. * Registers the component in a given scene
  37693. */
  37694. register(): void;
  37695. /**
  37696. * Rebuilds the elements related to this component in case of
  37697. * context lost for instance.
  37698. */
  37699. rebuild(): void;
  37700. /**
  37701. * Serializes the component data to the specified json object
  37702. * @param serializationObject The object to serialize to
  37703. */
  37704. serialize(serializationObject: any): void;
  37705. /**
  37706. * Adds all the elements from the container to the scene
  37707. * @param container the container holding the elements
  37708. */
  37709. addFromContainer(container: AbstractScene): void;
  37710. /**
  37711. * Removes all the elements in the container from the scene
  37712. * @param container contains the elements to remove
  37713. * @param dispose if the removed element should be disposed (default: false)
  37714. */
  37715. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37716. /**
  37717. * Disposes the component and the associated ressources.
  37718. */
  37719. dispose(): void;
  37720. /**
  37721. * Disables audio in the associated scene.
  37722. */
  37723. disableAudio(): void;
  37724. /**
  37725. * Enables audio in the associated scene.
  37726. */
  37727. enableAudio(): void;
  37728. /**
  37729. * Switch audio to headphone output.
  37730. */
  37731. switchAudioModeForHeadphones(): void;
  37732. /**
  37733. * Switch audio to normal speakers.
  37734. */
  37735. switchAudioModeForNormalSpeakers(): void;
  37736. private _cachedCameraDirection;
  37737. private _cachedCameraPosition;
  37738. private _lastCheck;
  37739. private _afterRender;
  37740. }
  37741. }
  37742. declare module BABYLON {
  37743. /**
  37744. * Wraps one or more Sound objects and selects one with random weight for playback.
  37745. */
  37746. export class WeightedSound {
  37747. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37748. loop: boolean;
  37749. private _coneInnerAngle;
  37750. private _coneOuterAngle;
  37751. private _volume;
  37752. /** A Sound is currently playing. */
  37753. isPlaying: boolean;
  37754. /** A Sound is currently paused. */
  37755. isPaused: boolean;
  37756. private _sounds;
  37757. private _weights;
  37758. private _currentIndex?;
  37759. /**
  37760. * Creates a new WeightedSound from the list of sounds given.
  37761. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37762. * @param sounds Array of Sounds that will be selected from.
  37763. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37764. */
  37765. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37766. /**
  37767. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37768. */
  37769. get directionalConeInnerAngle(): number;
  37770. /**
  37771. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37772. */
  37773. set directionalConeInnerAngle(value: number);
  37774. /**
  37775. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37776. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37777. */
  37778. get directionalConeOuterAngle(): number;
  37779. /**
  37780. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37781. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37782. */
  37783. set directionalConeOuterAngle(value: number);
  37784. /**
  37785. * Playback volume.
  37786. */
  37787. get volume(): number;
  37788. /**
  37789. * Playback volume.
  37790. */
  37791. set volume(value: number);
  37792. private _onended;
  37793. /**
  37794. * Suspend playback
  37795. */
  37796. pause(): void;
  37797. /**
  37798. * Stop playback
  37799. */
  37800. stop(): void;
  37801. /**
  37802. * Start playback.
  37803. * @param startOffset Position the clip head at a specific time in seconds.
  37804. */
  37805. play(startOffset?: number): void;
  37806. }
  37807. }
  37808. declare module BABYLON {
  37809. /**
  37810. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37811. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37812. */
  37813. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37814. /**
  37815. * Gets the name of the behavior.
  37816. */
  37817. get name(): string;
  37818. /**
  37819. * The easing function used by animations
  37820. */
  37821. static EasingFunction: BackEase;
  37822. /**
  37823. * The easing mode used by animations
  37824. */
  37825. static EasingMode: number;
  37826. /**
  37827. * The duration of the animation, in milliseconds
  37828. */
  37829. transitionDuration: number;
  37830. /**
  37831. * Length of the distance animated by the transition when lower radius is reached
  37832. */
  37833. lowerRadiusTransitionRange: number;
  37834. /**
  37835. * Length of the distance animated by the transition when upper radius is reached
  37836. */
  37837. upperRadiusTransitionRange: number;
  37838. private _autoTransitionRange;
  37839. /**
  37840. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37841. */
  37842. get autoTransitionRange(): boolean;
  37843. /**
  37844. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37845. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37846. */
  37847. set autoTransitionRange(value: boolean);
  37848. private _attachedCamera;
  37849. private _onAfterCheckInputsObserver;
  37850. private _onMeshTargetChangedObserver;
  37851. /**
  37852. * Initializes the behavior.
  37853. */
  37854. init(): void;
  37855. /**
  37856. * Attaches the behavior to its arc rotate camera.
  37857. * @param camera Defines the camera to attach the behavior to
  37858. */
  37859. attach(camera: ArcRotateCamera): void;
  37860. /**
  37861. * Detaches the behavior from its current arc rotate camera.
  37862. */
  37863. detach(): void;
  37864. private _radiusIsAnimating;
  37865. private _radiusBounceTransition;
  37866. private _animatables;
  37867. private _cachedWheelPrecision;
  37868. /**
  37869. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37870. * @param radiusLimit The limit to check against.
  37871. * @return Bool to indicate if at limit.
  37872. */
  37873. private _isRadiusAtLimit;
  37874. /**
  37875. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37876. * @param radiusDelta The delta by which to animate to. Can be negative.
  37877. */
  37878. private _applyBoundRadiusAnimation;
  37879. /**
  37880. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37881. */
  37882. protected _clearAnimationLocks(): void;
  37883. /**
  37884. * Stops and removes all animations that have been applied to the camera
  37885. */
  37886. stopAllAnimations(): void;
  37887. }
  37888. }
  37889. declare module BABYLON {
  37890. /**
  37891. * 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.
  37892. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37893. */
  37894. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37895. /**
  37896. * Gets the name of the behavior.
  37897. */
  37898. get name(): string;
  37899. private _mode;
  37900. private _radiusScale;
  37901. private _positionScale;
  37902. private _defaultElevation;
  37903. private _elevationReturnTime;
  37904. private _elevationReturnWaitTime;
  37905. private _zoomStopsAnimation;
  37906. private _framingTime;
  37907. /**
  37908. * The easing function used by animations
  37909. */
  37910. static EasingFunction: ExponentialEase;
  37911. /**
  37912. * The easing mode used by animations
  37913. */
  37914. static EasingMode: number;
  37915. /**
  37916. * Sets the current mode used by the behavior
  37917. */
  37918. set mode(mode: number);
  37919. /**
  37920. * Gets current mode used by the behavior.
  37921. */
  37922. get mode(): number;
  37923. /**
  37924. * Sets the scale applied to the radius (1 by default)
  37925. */
  37926. set radiusScale(radius: number);
  37927. /**
  37928. * Gets the scale applied to the radius
  37929. */
  37930. get radiusScale(): number;
  37931. /**
  37932. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37933. */
  37934. set positionScale(scale: number);
  37935. /**
  37936. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37937. */
  37938. get positionScale(): number;
  37939. /**
  37940. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37941. * behaviour is triggered, in radians.
  37942. */
  37943. set defaultElevation(elevation: number);
  37944. /**
  37945. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37946. * behaviour is triggered, in radians.
  37947. */
  37948. get defaultElevation(): number;
  37949. /**
  37950. * Sets the time (in milliseconds) taken to return to the default beta position.
  37951. * Negative value indicates camera should not return to default.
  37952. */
  37953. set elevationReturnTime(speed: number);
  37954. /**
  37955. * Gets the time (in milliseconds) taken to return to the default beta position.
  37956. * Negative value indicates camera should not return to default.
  37957. */
  37958. get elevationReturnTime(): number;
  37959. /**
  37960. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37961. */
  37962. set elevationReturnWaitTime(time: number);
  37963. /**
  37964. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37965. */
  37966. get elevationReturnWaitTime(): number;
  37967. /**
  37968. * Sets the flag that indicates if user zooming should stop animation.
  37969. */
  37970. set zoomStopsAnimation(flag: boolean);
  37971. /**
  37972. * Gets the flag that indicates if user zooming should stop animation.
  37973. */
  37974. get zoomStopsAnimation(): boolean;
  37975. /**
  37976. * Sets the transition time when framing the mesh, in milliseconds
  37977. */
  37978. set framingTime(time: number);
  37979. /**
  37980. * Gets the transition time when framing the mesh, in milliseconds
  37981. */
  37982. get framingTime(): number;
  37983. /**
  37984. * Define if the behavior should automatically change the configured
  37985. * camera limits and sensibilities.
  37986. */
  37987. autoCorrectCameraLimitsAndSensibility: boolean;
  37988. private _onPrePointerObservableObserver;
  37989. private _onAfterCheckInputsObserver;
  37990. private _onMeshTargetChangedObserver;
  37991. private _attachedCamera;
  37992. private _isPointerDown;
  37993. private _lastInteractionTime;
  37994. /**
  37995. * Initializes the behavior.
  37996. */
  37997. init(): void;
  37998. /**
  37999. * Attaches the behavior to its arc rotate camera.
  38000. * @param camera Defines the camera to attach the behavior to
  38001. */
  38002. attach(camera: ArcRotateCamera): void;
  38003. /**
  38004. * Detaches the behavior from its current arc rotate camera.
  38005. */
  38006. detach(): void;
  38007. private _animatables;
  38008. private _betaIsAnimating;
  38009. private _betaTransition;
  38010. private _radiusTransition;
  38011. private _vectorTransition;
  38012. /**
  38013. * Targets the given mesh and updates zoom level accordingly.
  38014. * @param mesh The mesh to target.
  38015. * @param radius Optional. If a cached radius position already exists, overrides default.
  38016. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38017. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38018. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38019. */
  38020. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38021. /**
  38022. * Targets the given mesh with its children and updates zoom level accordingly.
  38023. * @param mesh The mesh to target.
  38024. * @param radius Optional. If a cached radius position already exists, overrides default.
  38025. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38026. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38027. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38028. */
  38029. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38030. /**
  38031. * Targets the given meshes with their children and updates zoom level accordingly.
  38032. * @param meshes The mesh to target.
  38033. * @param radius Optional. If a cached radius position already exists, overrides default.
  38034. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38035. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38036. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38037. */
  38038. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38039. /**
  38040. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38041. * @param minimumWorld Determines the smaller position of the bounding box extend
  38042. * @param maximumWorld Determines the bigger position of the bounding box extend
  38043. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38044. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38045. */
  38046. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38047. /**
  38048. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38049. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38050. * frustum width.
  38051. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38052. * to fully enclose the mesh in the viewing frustum.
  38053. */
  38054. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38055. /**
  38056. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38057. * is automatically returned to its default position (expected to be above ground plane).
  38058. */
  38059. private _maintainCameraAboveGround;
  38060. /**
  38061. * Returns the frustum slope based on the canvas ratio and camera FOV
  38062. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38063. */
  38064. private _getFrustumSlope;
  38065. /**
  38066. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38067. */
  38068. private _clearAnimationLocks;
  38069. /**
  38070. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38071. */
  38072. private _applyUserInteraction;
  38073. /**
  38074. * Stops and removes all animations that have been applied to the camera
  38075. */
  38076. stopAllAnimations(): void;
  38077. /**
  38078. * Gets a value indicating if the user is moving the camera
  38079. */
  38080. get isUserIsMoving(): boolean;
  38081. /**
  38082. * The camera can move all the way towards the mesh.
  38083. */
  38084. static IgnoreBoundsSizeMode: number;
  38085. /**
  38086. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38087. */
  38088. static FitFrustumSidesMode: number;
  38089. }
  38090. }
  38091. declare module BABYLON {
  38092. /**
  38093. * Base class for Camera Pointer Inputs.
  38094. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38095. * for example usage.
  38096. */
  38097. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38098. /**
  38099. * Defines the camera the input is attached to.
  38100. */
  38101. abstract camera: Camera;
  38102. /**
  38103. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38104. */
  38105. protected _altKey: boolean;
  38106. protected _ctrlKey: boolean;
  38107. protected _metaKey: boolean;
  38108. protected _shiftKey: boolean;
  38109. /**
  38110. * Which mouse buttons were pressed at time of last mouse event.
  38111. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38112. */
  38113. protected _buttonsPressed: number;
  38114. /**
  38115. * Defines the buttons associated with the input to handle camera move.
  38116. */
  38117. buttons: number[];
  38118. /**
  38119. * Attach the input controls to a specific dom element to get the input from.
  38120. * @param element Defines the element the controls should be listened from
  38121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38122. */
  38123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38124. /**
  38125. * Detach the current controls from the specified dom element.
  38126. * @param element Defines the element to stop listening the inputs from
  38127. */
  38128. detachControl(element: Nullable<HTMLElement>): void;
  38129. /**
  38130. * Gets the class name of the current input.
  38131. * @returns the class name
  38132. */
  38133. getClassName(): string;
  38134. /**
  38135. * Get the friendly name associated with the input class.
  38136. * @returns the input friendly name
  38137. */
  38138. getSimpleName(): string;
  38139. /**
  38140. * Called on pointer POINTERDOUBLETAP event.
  38141. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38142. */
  38143. protected onDoubleTap(type: string): void;
  38144. /**
  38145. * Called on pointer POINTERMOVE event if only a single touch is active.
  38146. * Override this method to provide functionality.
  38147. */
  38148. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38149. /**
  38150. * Called on pointer POINTERMOVE event if multiple touches are active.
  38151. * Override this method to provide functionality.
  38152. */
  38153. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38154. /**
  38155. * Called on JS contextmenu event.
  38156. * Override this method to provide functionality.
  38157. */
  38158. protected onContextMenu(evt: PointerEvent): void;
  38159. /**
  38160. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38161. * press.
  38162. * Override this method to provide functionality.
  38163. */
  38164. protected onButtonDown(evt: PointerEvent): void;
  38165. /**
  38166. * Called each time a new POINTERUP event occurs. Ie, for each button
  38167. * release.
  38168. * Override this method to provide functionality.
  38169. */
  38170. protected onButtonUp(evt: PointerEvent): void;
  38171. /**
  38172. * Called when window becomes inactive.
  38173. * Override this method to provide functionality.
  38174. */
  38175. protected onLostFocus(): void;
  38176. private _pointerInput;
  38177. private _observer;
  38178. private _onLostFocus;
  38179. private pointA;
  38180. private pointB;
  38181. }
  38182. }
  38183. declare module BABYLON {
  38184. /**
  38185. * Manage the pointers inputs to control an arc rotate camera.
  38186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38187. */
  38188. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38189. /**
  38190. * Defines the camera the input is attached to.
  38191. */
  38192. camera: ArcRotateCamera;
  38193. /**
  38194. * Gets the class name of the current input.
  38195. * @returns the class name
  38196. */
  38197. getClassName(): string;
  38198. /**
  38199. * Defines the buttons associated with the input to handle camera move.
  38200. */
  38201. buttons: number[];
  38202. /**
  38203. * Defines the pointer angular sensibility along the X axis or how fast is
  38204. * the camera rotating.
  38205. */
  38206. angularSensibilityX: number;
  38207. /**
  38208. * Defines the pointer angular sensibility along the Y axis or how fast is
  38209. * the camera rotating.
  38210. */
  38211. angularSensibilityY: number;
  38212. /**
  38213. * Defines the pointer pinch precision or how fast is the camera zooming.
  38214. */
  38215. pinchPrecision: number;
  38216. /**
  38217. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38218. * from 0.
  38219. * It defines the percentage of current camera.radius to use as delta when
  38220. * pinch zoom is used.
  38221. */
  38222. pinchDeltaPercentage: number;
  38223. /**
  38224. * Defines the pointer panning sensibility or how fast is the camera moving.
  38225. */
  38226. panningSensibility: number;
  38227. /**
  38228. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38229. */
  38230. multiTouchPanning: boolean;
  38231. /**
  38232. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38233. * zoom (pinch) through multitouch.
  38234. */
  38235. multiTouchPanAndZoom: boolean;
  38236. /**
  38237. * Revers pinch action direction.
  38238. */
  38239. pinchInwards: boolean;
  38240. private _isPanClick;
  38241. private _twoFingerActivityCount;
  38242. private _isPinching;
  38243. /**
  38244. * Called on pointer POINTERMOVE event if only a single touch is active.
  38245. */
  38246. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38247. /**
  38248. * Called on pointer POINTERDOUBLETAP event.
  38249. */
  38250. protected onDoubleTap(type: string): void;
  38251. /**
  38252. * Called on pointer POINTERMOVE event if multiple touches are active.
  38253. */
  38254. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38255. /**
  38256. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38257. * press.
  38258. */
  38259. protected onButtonDown(evt: PointerEvent): void;
  38260. /**
  38261. * Called each time a new POINTERUP event occurs. Ie, for each button
  38262. * release.
  38263. */
  38264. protected onButtonUp(evt: PointerEvent): void;
  38265. /**
  38266. * Called when window becomes inactive.
  38267. */
  38268. protected onLostFocus(): void;
  38269. }
  38270. }
  38271. declare module BABYLON {
  38272. /**
  38273. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38275. */
  38276. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38277. /**
  38278. * Defines the camera the input is attached to.
  38279. */
  38280. camera: ArcRotateCamera;
  38281. /**
  38282. * Defines the list of key codes associated with the up action (increase alpha)
  38283. */
  38284. keysUp: number[];
  38285. /**
  38286. * Defines the list of key codes associated with the down action (decrease alpha)
  38287. */
  38288. keysDown: number[];
  38289. /**
  38290. * Defines the list of key codes associated with the left action (increase beta)
  38291. */
  38292. keysLeft: number[];
  38293. /**
  38294. * Defines the list of key codes associated with the right action (decrease beta)
  38295. */
  38296. keysRight: number[];
  38297. /**
  38298. * Defines the list of key codes associated with the reset action.
  38299. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38300. */
  38301. keysReset: number[];
  38302. /**
  38303. * Defines the panning sensibility of the inputs.
  38304. * (How fast is the camera paning)
  38305. */
  38306. panningSensibility: number;
  38307. /**
  38308. * Defines the zooming sensibility of the inputs.
  38309. * (How fast is the camera zooming)
  38310. */
  38311. zoomingSensibility: number;
  38312. /**
  38313. * Defines wether maintaining the alt key down switch the movement mode from
  38314. * orientation to zoom.
  38315. */
  38316. useAltToZoom: boolean;
  38317. /**
  38318. * Rotation speed of the camera
  38319. */
  38320. angularSpeed: number;
  38321. private _keys;
  38322. private _ctrlPressed;
  38323. private _altPressed;
  38324. private _onCanvasBlurObserver;
  38325. private _onKeyboardObserver;
  38326. private _engine;
  38327. private _scene;
  38328. /**
  38329. * Attach the input controls to a specific dom element to get the input from.
  38330. * @param element Defines the element the controls should be listened from
  38331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38332. */
  38333. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38334. /**
  38335. * Detach the current controls from the specified dom element.
  38336. * @param element Defines the element to stop listening the inputs from
  38337. */
  38338. detachControl(element: Nullable<HTMLElement>): void;
  38339. /**
  38340. * Update the current camera state depending on the inputs that have been used this frame.
  38341. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38342. */
  38343. checkInputs(): void;
  38344. /**
  38345. * Gets the class name of the current intput.
  38346. * @returns the class name
  38347. */
  38348. getClassName(): string;
  38349. /**
  38350. * Get the friendly name associated with the input class.
  38351. * @returns the input friendly name
  38352. */
  38353. getSimpleName(): string;
  38354. }
  38355. }
  38356. declare module BABYLON {
  38357. /**
  38358. * Manage the mouse wheel inputs to control an arc rotate camera.
  38359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38360. */
  38361. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38362. /**
  38363. * Defines the camera the input is attached to.
  38364. */
  38365. camera: ArcRotateCamera;
  38366. /**
  38367. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38368. */
  38369. wheelPrecision: number;
  38370. /**
  38371. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38372. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38373. */
  38374. wheelDeltaPercentage: number;
  38375. private _wheel;
  38376. private _observer;
  38377. private computeDeltaFromMouseWheelLegacyEvent;
  38378. /**
  38379. * Attach the input controls to a specific dom element to get the input from.
  38380. * @param element Defines the element the controls should be listened from
  38381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38382. */
  38383. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38384. /**
  38385. * Detach the current controls from the specified dom element.
  38386. * @param element Defines the element to stop listening the inputs from
  38387. */
  38388. detachControl(element: Nullable<HTMLElement>): void;
  38389. /**
  38390. * Gets the class name of the current intput.
  38391. * @returns the class name
  38392. */
  38393. getClassName(): string;
  38394. /**
  38395. * Get the friendly name associated with the input class.
  38396. * @returns the input friendly name
  38397. */
  38398. getSimpleName(): string;
  38399. }
  38400. }
  38401. declare module BABYLON {
  38402. /**
  38403. * Default Inputs manager for the ArcRotateCamera.
  38404. * It groups all the default supported inputs for ease of use.
  38405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38406. */
  38407. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38408. /**
  38409. * Instantiates a new ArcRotateCameraInputsManager.
  38410. * @param camera Defines the camera the inputs belong to
  38411. */
  38412. constructor(camera: ArcRotateCamera);
  38413. /**
  38414. * Add mouse wheel input support to the input manager.
  38415. * @returns the current input manager
  38416. */
  38417. addMouseWheel(): ArcRotateCameraInputsManager;
  38418. /**
  38419. * Add pointers input support to the input manager.
  38420. * @returns the current input manager
  38421. */
  38422. addPointers(): ArcRotateCameraInputsManager;
  38423. /**
  38424. * Add keyboard input support to the input manager.
  38425. * @returns the current input manager
  38426. */
  38427. addKeyboard(): ArcRotateCameraInputsManager;
  38428. }
  38429. }
  38430. declare module BABYLON {
  38431. /**
  38432. * This represents an orbital type of camera.
  38433. *
  38434. * 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.
  38435. * 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.
  38436. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38437. */
  38438. export class ArcRotateCamera extends TargetCamera {
  38439. /**
  38440. * Defines the rotation angle of the camera along the longitudinal axis.
  38441. */
  38442. alpha: number;
  38443. /**
  38444. * Defines the rotation angle of the camera along the latitudinal axis.
  38445. */
  38446. beta: number;
  38447. /**
  38448. * Defines the radius of the camera from it s target point.
  38449. */
  38450. radius: number;
  38451. protected _target: Vector3;
  38452. protected _targetHost: Nullable<AbstractMesh>;
  38453. /**
  38454. * Defines the target point of the camera.
  38455. * The camera looks towards it form the radius distance.
  38456. */
  38457. get target(): Vector3;
  38458. set target(value: Vector3);
  38459. /**
  38460. * Define the current local position of the camera in the scene
  38461. */
  38462. get position(): Vector3;
  38463. set position(newPosition: Vector3);
  38464. protected _upVector: Vector3;
  38465. protected _upToYMatrix: Matrix;
  38466. protected _YToUpMatrix: Matrix;
  38467. /**
  38468. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38469. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38470. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38471. */
  38472. set upVector(vec: Vector3);
  38473. get upVector(): Vector3;
  38474. /**
  38475. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38476. */
  38477. setMatUp(): void;
  38478. /**
  38479. * Current inertia value on the longitudinal axis.
  38480. * The bigger this number the longer it will take for the camera to stop.
  38481. */
  38482. inertialAlphaOffset: number;
  38483. /**
  38484. * Current inertia value on the latitudinal axis.
  38485. * The bigger this number the longer it will take for the camera to stop.
  38486. */
  38487. inertialBetaOffset: number;
  38488. /**
  38489. * Current inertia value on the radius axis.
  38490. * The bigger this number the longer it will take for the camera to stop.
  38491. */
  38492. inertialRadiusOffset: number;
  38493. /**
  38494. * Minimum allowed angle on the longitudinal axis.
  38495. * This can help limiting how the Camera is able to move in the scene.
  38496. */
  38497. lowerAlphaLimit: Nullable<number>;
  38498. /**
  38499. * Maximum allowed angle on the longitudinal axis.
  38500. * This can help limiting how the Camera is able to move in the scene.
  38501. */
  38502. upperAlphaLimit: Nullable<number>;
  38503. /**
  38504. * Minimum allowed angle on the latitudinal axis.
  38505. * This can help limiting how the Camera is able to move in the scene.
  38506. */
  38507. lowerBetaLimit: number;
  38508. /**
  38509. * Maximum allowed angle on the latitudinal axis.
  38510. * This can help limiting how the Camera is able to move in the scene.
  38511. */
  38512. upperBetaLimit: number;
  38513. /**
  38514. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38515. * This can help limiting how the Camera is able to move in the scene.
  38516. */
  38517. lowerRadiusLimit: Nullable<number>;
  38518. /**
  38519. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38520. * This can help limiting how the Camera is able to move in the scene.
  38521. */
  38522. upperRadiusLimit: Nullable<number>;
  38523. /**
  38524. * Defines the current inertia value used during panning of the camera along the X axis.
  38525. */
  38526. inertialPanningX: number;
  38527. /**
  38528. * Defines the current inertia value used during panning of the camera along the Y axis.
  38529. */
  38530. inertialPanningY: number;
  38531. /**
  38532. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38533. * Basically if your fingers moves away from more than this distance you will be considered
  38534. * in pinch mode.
  38535. */
  38536. pinchToPanMaxDistance: number;
  38537. /**
  38538. * Defines the maximum distance the camera can pan.
  38539. * This could help keeping the cammera always in your scene.
  38540. */
  38541. panningDistanceLimit: Nullable<number>;
  38542. /**
  38543. * Defines the target of the camera before paning.
  38544. */
  38545. panningOriginTarget: Vector3;
  38546. /**
  38547. * Defines the value of the inertia used during panning.
  38548. * 0 would mean stop inertia and one would mean no decelleration at all.
  38549. */
  38550. panningInertia: number;
  38551. /**
  38552. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38553. */
  38554. get angularSensibilityX(): number;
  38555. set angularSensibilityX(value: number);
  38556. /**
  38557. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38558. */
  38559. get angularSensibilityY(): number;
  38560. set angularSensibilityY(value: number);
  38561. /**
  38562. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38563. */
  38564. get pinchPrecision(): number;
  38565. set pinchPrecision(value: number);
  38566. /**
  38567. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38568. * It will be used instead of pinchDeltaPrecision if different from 0.
  38569. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38570. */
  38571. get pinchDeltaPercentage(): number;
  38572. set pinchDeltaPercentage(value: number);
  38573. /**
  38574. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38575. */
  38576. get panningSensibility(): number;
  38577. set panningSensibility(value: number);
  38578. /**
  38579. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38580. */
  38581. get keysUp(): number[];
  38582. set keysUp(value: number[]);
  38583. /**
  38584. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38585. */
  38586. get keysDown(): number[];
  38587. set keysDown(value: number[]);
  38588. /**
  38589. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38590. */
  38591. get keysLeft(): number[];
  38592. set keysLeft(value: number[]);
  38593. /**
  38594. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38595. */
  38596. get keysRight(): number[];
  38597. set keysRight(value: number[]);
  38598. /**
  38599. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38600. */
  38601. get wheelPrecision(): number;
  38602. set wheelPrecision(value: number);
  38603. /**
  38604. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38605. * It will be used instead of pinchDeltaPrecision if different from 0.
  38606. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38607. */
  38608. get wheelDeltaPercentage(): number;
  38609. set wheelDeltaPercentage(value: number);
  38610. /**
  38611. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38612. */
  38613. zoomOnFactor: number;
  38614. /**
  38615. * Defines a screen offset for the camera position.
  38616. */
  38617. targetScreenOffset: Vector2;
  38618. /**
  38619. * Allows the camera to be completely reversed.
  38620. * If false the camera can not arrive upside down.
  38621. */
  38622. allowUpsideDown: boolean;
  38623. /**
  38624. * Define if double tap/click is used to restore the previously saved state of the camera.
  38625. */
  38626. useInputToRestoreState: boolean;
  38627. /** @hidden */
  38628. _viewMatrix: Matrix;
  38629. /** @hidden */
  38630. _useCtrlForPanning: boolean;
  38631. /** @hidden */
  38632. _panningMouseButton: number;
  38633. /**
  38634. * Defines the input associated to the camera.
  38635. */
  38636. inputs: ArcRotateCameraInputsManager;
  38637. /** @hidden */
  38638. _reset: () => void;
  38639. /**
  38640. * Defines the allowed panning axis.
  38641. */
  38642. panningAxis: Vector3;
  38643. protected _localDirection: Vector3;
  38644. protected _transformedDirection: Vector3;
  38645. private _bouncingBehavior;
  38646. /**
  38647. * Gets the bouncing behavior of the camera if it has been enabled.
  38648. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38649. */
  38650. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38651. /**
  38652. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38653. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38654. */
  38655. get useBouncingBehavior(): boolean;
  38656. set useBouncingBehavior(value: boolean);
  38657. private _framingBehavior;
  38658. /**
  38659. * Gets the framing behavior of the camera if it has been enabled.
  38660. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38661. */
  38662. get framingBehavior(): Nullable<FramingBehavior>;
  38663. /**
  38664. * Defines if the framing behavior of the camera is enabled on the camera.
  38665. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38666. */
  38667. get useFramingBehavior(): boolean;
  38668. set useFramingBehavior(value: boolean);
  38669. private _autoRotationBehavior;
  38670. /**
  38671. * Gets the auto rotation behavior of the camera if it has been enabled.
  38672. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38673. */
  38674. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38675. /**
  38676. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38677. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38678. */
  38679. get useAutoRotationBehavior(): boolean;
  38680. set useAutoRotationBehavior(value: boolean);
  38681. /**
  38682. * Observable triggered when the mesh target has been changed on the camera.
  38683. */
  38684. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38685. /**
  38686. * Event raised when the camera is colliding with a mesh.
  38687. */
  38688. onCollide: (collidedMesh: AbstractMesh) => void;
  38689. /**
  38690. * Defines whether the camera should check collision with the objects oh the scene.
  38691. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38692. */
  38693. checkCollisions: boolean;
  38694. /**
  38695. * Defines the collision radius of the camera.
  38696. * This simulates a sphere around the camera.
  38697. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38698. */
  38699. collisionRadius: Vector3;
  38700. protected _collider: Collider;
  38701. protected _previousPosition: Vector3;
  38702. protected _collisionVelocity: Vector3;
  38703. protected _newPosition: Vector3;
  38704. protected _previousAlpha: number;
  38705. protected _previousBeta: number;
  38706. protected _previousRadius: number;
  38707. protected _collisionTriggered: boolean;
  38708. protected _targetBoundingCenter: Nullable<Vector3>;
  38709. private _computationVector;
  38710. /**
  38711. * Instantiates a new ArcRotateCamera in a given scene
  38712. * @param name Defines the name of the camera
  38713. * @param alpha Defines the camera rotation along the logitudinal axis
  38714. * @param beta Defines the camera rotation along the latitudinal axis
  38715. * @param radius Defines the camera distance from its target
  38716. * @param target Defines the camera target
  38717. * @param scene Defines the scene the camera belongs to
  38718. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38719. */
  38720. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38721. /** @hidden */
  38722. _initCache(): void;
  38723. /** @hidden */
  38724. _updateCache(ignoreParentClass?: boolean): void;
  38725. protected _getTargetPosition(): Vector3;
  38726. private _storedAlpha;
  38727. private _storedBeta;
  38728. private _storedRadius;
  38729. private _storedTarget;
  38730. private _storedTargetScreenOffset;
  38731. /**
  38732. * Stores the current state of the camera (alpha, beta, radius and target)
  38733. * @returns the camera itself
  38734. */
  38735. storeState(): Camera;
  38736. /**
  38737. * @hidden
  38738. * Restored camera state. You must call storeState() first
  38739. */
  38740. _restoreStateValues(): boolean;
  38741. /** @hidden */
  38742. _isSynchronizedViewMatrix(): boolean;
  38743. /**
  38744. * Attached controls to the current camera.
  38745. * @param element Defines the element the controls should be listened from
  38746. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38747. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38748. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38749. */
  38750. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38751. /**
  38752. * Detach the current controls from the camera.
  38753. * The camera will stop reacting to inputs.
  38754. * @param element Defines the element to stop listening the inputs from
  38755. */
  38756. detachControl(element: HTMLElement): void;
  38757. /** @hidden */
  38758. _checkInputs(): void;
  38759. protected _checkLimits(): void;
  38760. /**
  38761. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38762. */
  38763. rebuildAnglesAndRadius(): void;
  38764. /**
  38765. * Use a position to define the current camera related information like alpha, beta and radius
  38766. * @param position Defines the position to set the camera at
  38767. */
  38768. setPosition(position: Vector3): void;
  38769. /**
  38770. * Defines the target the camera should look at.
  38771. * This will automatically adapt alpha beta and radius to fit within the new target.
  38772. * @param target Defines the new target as a Vector or a mesh
  38773. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38774. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38775. */
  38776. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38777. /** @hidden */
  38778. _getViewMatrix(): Matrix;
  38779. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38780. /**
  38781. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38782. * @param meshes Defines the mesh to zoom on
  38783. * @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)
  38784. */
  38785. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38786. /**
  38787. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38788. * The target will be changed but the radius
  38789. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38790. * @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)
  38791. */
  38792. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38793. min: Vector3;
  38794. max: Vector3;
  38795. distance: number;
  38796. }, doNotUpdateMaxZ?: boolean): void;
  38797. /**
  38798. * @override
  38799. * Override Camera.createRigCamera
  38800. */
  38801. createRigCamera(name: string, cameraIndex: number): Camera;
  38802. /**
  38803. * @hidden
  38804. * @override
  38805. * Override Camera._updateRigCameras
  38806. */
  38807. _updateRigCameras(): void;
  38808. /**
  38809. * Destroy the camera and release the current resources hold by it.
  38810. */
  38811. dispose(): void;
  38812. /**
  38813. * Gets the current object class name.
  38814. * @return the class name
  38815. */
  38816. getClassName(): string;
  38817. }
  38818. }
  38819. declare module BABYLON {
  38820. /**
  38821. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38822. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38823. */
  38824. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38825. /**
  38826. * Gets the name of the behavior.
  38827. */
  38828. get name(): string;
  38829. private _zoomStopsAnimation;
  38830. private _idleRotationSpeed;
  38831. private _idleRotationWaitTime;
  38832. private _idleRotationSpinupTime;
  38833. /**
  38834. * Sets the flag that indicates if user zooming should stop animation.
  38835. */
  38836. set zoomStopsAnimation(flag: boolean);
  38837. /**
  38838. * Gets the flag that indicates if user zooming should stop animation.
  38839. */
  38840. get zoomStopsAnimation(): boolean;
  38841. /**
  38842. * Sets the default speed at which the camera rotates around the model.
  38843. */
  38844. set idleRotationSpeed(speed: number);
  38845. /**
  38846. * Gets the default speed at which the camera rotates around the model.
  38847. */
  38848. get idleRotationSpeed(): number;
  38849. /**
  38850. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38851. */
  38852. set idleRotationWaitTime(time: number);
  38853. /**
  38854. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38855. */
  38856. get idleRotationWaitTime(): number;
  38857. /**
  38858. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38859. */
  38860. set idleRotationSpinupTime(time: number);
  38861. /**
  38862. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38863. */
  38864. get idleRotationSpinupTime(): number;
  38865. /**
  38866. * Gets a value indicating if the camera is currently rotating because of this behavior
  38867. */
  38868. get rotationInProgress(): boolean;
  38869. private _onPrePointerObservableObserver;
  38870. private _onAfterCheckInputsObserver;
  38871. private _attachedCamera;
  38872. private _isPointerDown;
  38873. private _lastFrameTime;
  38874. private _lastInteractionTime;
  38875. private _cameraRotationSpeed;
  38876. /**
  38877. * Initializes the behavior.
  38878. */
  38879. init(): void;
  38880. /**
  38881. * Attaches the behavior to its arc rotate camera.
  38882. * @param camera Defines the camera to attach the behavior to
  38883. */
  38884. attach(camera: ArcRotateCamera): void;
  38885. /**
  38886. * Detaches the behavior from its current arc rotate camera.
  38887. */
  38888. detach(): void;
  38889. /**
  38890. * Returns true if user is scrolling.
  38891. * @return true if user is scrolling.
  38892. */
  38893. private _userIsZooming;
  38894. private _lastFrameRadius;
  38895. private _shouldAnimationStopForInteraction;
  38896. /**
  38897. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38898. */
  38899. private _applyUserInteraction;
  38900. private _userIsMoving;
  38901. }
  38902. }
  38903. declare module BABYLON {
  38904. /**
  38905. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38906. */
  38907. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38908. private ui;
  38909. /**
  38910. * The name of the behavior
  38911. */
  38912. name: string;
  38913. /**
  38914. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38915. */
  38916. distanceAwayFromFace: number;
  38917. /**
  38918. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38919. */
  38920. distanceAwayFromBottomOfFace: number;
  38921. private _faceVectors;
  38922. private _target;
  38923. private _scene;
  38924. private _onRenderObserver;
  38925. private _tmpMatrix;
  38926. private _tmpVector;
  38927. /**
  38928. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38929. * @param ui The transform node that should be attched to the mesh
  38930. */
  38931. constructor(ui: TransformNode);
  38932. /**
  38933. * Initializes the behavior
  38934. */
  38935. init(): void;
  38936. private _closestFace;
  38937. private _zeroVector;
  38938. private _lookAtTmpMatrix;
  38939. private _lookAtToRef;
  38940. /**
  38941. * Attaches the AttachToBoxBehavior to the passed in mesh
  38942. * @param target The mesh that the specified node will be attached to
  38943. */
  38944. attach(target: Mesh): void;
  38945. /**
  38946. * Detaches the behavior from the mesh
  38947. */
  38948. detach(): void;
  38949. }
  38950. }
  38951. declare module BABYLON {
  38952. /**
  38953. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38954. */
  38955. export class FadeInOutBehavior implements Behavior<Mesh> {
  38956. /**
  38957. * Time in milliseconds to delay before fading in (Default: 0)
  38958. */
  38959. delay: number;
  38960. /**
  38961. * Time in milliseconds for the mesh to fade in (Default: 300)
  38962. */
  38963. fadeInTime: number;
  38964. private _millisecondsPerFrame;
  38965. private _hovered;
  38966. private _hoverValue;
  38967. private _ownerNode;
  38968. /**
  38969. * Instatiates the FadeInOutBehavior
  38970. */
  38971. constructor();
  38972. /**
  38973. * The name of the behavior
  38974. */
  38975. get name(): string;
  38976. /**
  38977. * Initializes the behavior
  38978. */
  38979. init(): void;
  38980. /**
  38981. * Attaches the fade behavior on the passed in mesh
  38982. * @param ownerNode The mesh that will be faded in/out once attached
  38983. */
  38984. attach(ownerNode: Mesh): void;
  38985. /**
  38986. * Detaches the behavior from the mesh
  38987. */
  38988. detach(): void;
  38989. /**
  38990. * Triggers the mesh to begin fading in or out
  38991. * @param value if the object should fade in or out (true to fade in)
  38992. */
  38993. fadeIn(value: boolean): void;
  38994. private _update;
  38995. private _setAllVisibility;
  38996. }
  38997. }
  38998. declare module BABYLON {
  38999. /**
  39000. * Class containing a set of static utilities functions for managing Pivots
  39001. * @hidden
  39002. */
  39003. export class PivotTools {
  39004. private static _PivotCached;
  39005. private static _OldPivotPoint;
  39006. private static _PivotTranslation;
  39007. private static _PivotTmpVector;
  39008. /** @hidden */
  39009. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39010. /** @hidden */
  39011. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39012. }
  39013. }
  39014. declare module BABYLON {
  39015. /**
  39016. * Class containing static functions to help procedurally build meshes
  39017. */
  39018. export class PlaneBuilder {
  39019. /**
  39020. * Creates a plane mesh
  39021. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39022. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39023. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39025. * * 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
  39026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39027. * @param name defines the name of the mesh
  39028. * @param options defines the options used to create the mesh
  39029. * @param scene defines the hosting scene
  39030. * @returns the plane mesh
  39031. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39032. */
  39033. static CreatePlane(name: string, options: {
  39034. size?: number;
  39035. width?: number;
  39036. height?: number;
  39037. sideOrientation?: number;
  39038. frontUVs?: Vector4;
  39039. backUVs?: Vector4;
  39040. updatable?: boolean;
  39041. sourcePlane?: Plane;
  39042. }, scene?: Nullable<Scene>): Mesh;
  39043. }
  39044. }
  39045. declare module BABYLON {
  39046. /**
  39047. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39048. */
  39049. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39050. private static _AnyMouseID;
  39051. /**
  39052. * Abstract mesh the behavior is set on
  39053. */
  39054. attachedNode: AbstractMesh;
  39055. private _dragPlane;
  39056. private _scene;
  39057. private _pointerObserver;
  39058. private _beforeRenderObserver;
  39059. private static _planeScene;
  39060. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39061. /**
  39062. * 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)
  39063. */
  39064. maxDragAngle: number;
  39065. /**
  39066. * @hidden
  39067. */
  39068. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39069. /**
  39070. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39071. */
  39072. currentDraggingPointerID: number;
  39073. /**
  39074. * The last position where the pointer hit the drag plane in world space
  39075. */
  39076. lastDragPosition: Vector3;
  39077. /**
  39078. * If the behavior is currently in a dragging state
  39079. */
  39080. dragging: boolean;
  39081. /**
  39082. * 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)
  39083. */
  39084. dragDeltaRatio: number;
  39085. /**
  39086. * If the drag plane orientation should be updated during the dragging (Default: true)
  39087. */
  39088. updateDragPlane: boolean;
  39089. private _debugMode;
  39090. private _moving;
  39091. /**
  39092. * Fires each time the attached mesh is dragged with the pointer
  39093. * * delta between last drag position and current drag position in world space
  39094. * * dragDistance along the drag axis
  39095. * * dragPlaneNormal normal of the current drag plane used during the drag
  39096. * * dragPlanePoint in world space where the drag intersects the drag plane
  39097. */
  39098. onDragObservable: Observable<{
  39099. delta: Vector3;
  39100. dragPlanePoint: Vector3;
  39101. dragPlaneNormal: Vector3;
  39102. dragDistance: number;
  39103. pointerId: number;
  39104. }>;
  39105. /**
  39106. * Fires each time a drag begins (eg. mouse down on mesh)
  39107. */
  39108. onDragStartObservable: Observable<{
  39109. dragPlanePoint: Vector3;
  39110. pointerId: number;
  39111. }>;
  39112. /**
  39113. * Fires each time a drag ends (eg. mouse release after drag)
  39114. */
  39115. onDragEndObservable: Observable<{
  39116. dragPlanePoint: Vector3;
  39117. pointerId: number;
  39118. }>;
  39119. /**
  39120. * If the attached mesh should be moved when dragged
  39121. */
  39122. moveAttached: boolean;
  39123. /**
  39124. * If the drag behavior will react to drag events (Default: true)
  39125. */
  39126. enabled: boolean;
  39127. /**
  39128. * If pointer events should start and release the drag (Default: true)
  39129. */
  39130. startAndReleaseDragOnPointerEvents: boolean;
  39131. /**
  39132. * If camera controls should be detached during the drag
  39133. */
  39134. detachCameraControls: boolean;
  39135. /**
  39136. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39137. */
  39138. useObjectOrientationForDragging: boolean;
  39139. private _options;
  39140. /**
  39141. * Gets the options used by the behavior
  39142. */
  39143. get options(): {
  39144. dragAxis?: Vector3;
  39145. dragPlaneNormal?: Vector3;
  39146. };
  39147. /**
  39148. * Sets the options used by the behavior
  39149. */
  39150. set options(options: {
  39151. dragAxis?: Vector3;
  39152. dragPlaneNormal?: Vector3;
  39153. });
  39154. /**
  39155. * Creates a pointer drag behavior that can be attached to a mesh
  39156. * @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)
  39157. */
  39158. constructor(options?: {
  39159. dragAxis?: Vector3;
  39160. dragPlaneNormal?: Vector3;
  39161. });
  39162. /**
  39163. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39164. */
  39165. validateDrag: (targetPosition: Vector3) => boolean;
  39166. /**
  39167. * The name of the behavior
  39168. */
  39169. get name(): string;
  39170. /**
  39171. * Initializes the behavior
  39172. */
  39173. init(): void;
  39174. private _tmpVector;
  39175. private _alternatePickedPoint;
  39176. private _worldDragAxis;
  39177. private _targetPosition;
  39178. private _attachedElement;
  39179. /**
  39180. * Attaches the drag behavior the passed in mesh
  39181. * @param ownerNode The mesh that will be dragged around once attached
  39182. * @param predicate Predicate to use for pick filtering
  39183. */
  39184. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39185. /**
  39186. * Force relase the drag action by code.
  39187. */
  39188. releaseDrag(): void;
  39189. private _startDragRay;
  39190. private _lastPointerRay;
  39191. /**
  39192. * Simulates the start of a pointer drag event on the behavior
  39193. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39194. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39195. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39196. */
  39197. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39198. private _startDrag;
  39199. private _dragDelta;
  39200. private _moveDrag;
  39201. private _pickWithRayOnDragPlane;
  39202. private _pointA;
  39203. private _pointB;
  39204. private _pointC;
  39205. private _lineA;
  39206. private _lineB;
  39207. private _localAxis;
  39208. private _lookAt;
  39209. private _updateDragPlanePosition;
  39210. /**
  39211. * Detaches the behavior from the mesh
  39212. */
  39213. detach(): void;
  39214. }
  39215. }
  39216. declare module BABYLON {
  39217. /**
  39218. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39219. */
  39220. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39221. private _dragBehaviorA;
  39222. private _dragBehaviorB;
  39223. private _startDistance;
  39224. private _initialScale;
  39225. private _targetScale;
  39226. private _ownerNode;
  39227. private _sceneRenderObserver;
  39228. /**
  39229. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39230. */
  39231. constructor();
  39232. /**
  39233. * The name of the behavior
  39234. */
  39235. get name(): string;
  39236. /**
  39237. * Initializes the behavior
  39238. */
  39239. init(): void;
  39240. private _getCurrentDistance;
  39241. /**
  39242. * Attaches the scale behavior the passed in mesh
  39243. * @param ownerNode The mesh that will be scaled around once attached
  39244. */
  39245. attach(ownerNode: Mesh): void;
  39246. /**
  39247. * Detaches the behavior from the mesh
  39248. */
  39249. detach(): void;
  39250. }
  39251. }
  39252. declare module BABYLON {
  39253. /**
  39254. * 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
  39255. */
  39256. export class SixDofDragBehavior implements Behavior<Mesh> {
  39257. private static _virtualScene;
  39258. private _ownerNode;
  39259. private _sceneRenderObserver;
  39260. private _scene;
  39261. private _targetPosition;
  39262. private _virtualOriginMesh;
  39263. private _virtualDragMesh;
  39264. private _pointerObserver;
  39265. private _moving;
  39266. private _startingOrientation;
  39267. /**
  39268. * 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)
  39269. */
  39270. private zDragFactor;
  39271. /**
  39272. * If the object should rotate to face the drag origin
  39273. */
  39274. rotateDraggedObject: boolean;
  39275. /**
  39276. * If the behavior is currently in a dragging state
  39277. */
  39278. dragging: boolean;
  39279. /**
  39280. * 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)
  39281. */
  39282. dragDeltaRatio: number;
  39283. /**
  39284. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39285. */
  39286. currentDraggingPointerID: number;
  39287. /**
  39288. * If camera controls should be detached during the drag
  39289. */
  39290. detachCameraControls: boolean;
  39291. /**
  39292. * Fires each time a drag starts
  39293. */
  39294. onDragStartObservable: Observable<{}>;
  39295. /**
  39296. * Fires each time a drag ends (eg. mouse release after drag)
  39297. */
  39298. onDragEndObservable: Observable<{}>;
  39299. /**
  39300. * 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
  39301. */
  39302. constructor();
  39303. /**
  39304. * The name of the behavior
  39305. */
  39306. get name(): string;
  39307. /**
  39308. * Initializes the behavior
  39309. */
  39310. init(): void;
  39311. /**
  39312. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39313. */
  39314. private get _pointerCamera();
  39315. /**
  39316. * Attaches the scale behavior the passed in mesh
  39317. * @param ownerNode The mesh that will be scaled around once attached
  39318. */
  39319. attach(ownerNode: Mesh): void;
  39320. /**
  39321. * Detaches the behavior from the mesh
  39322. */
  39323. detach(): void;
  39324. }
  39325. }
  39326. declare module BABYLON {
  39327. /**
  39328. * Class used to apply inverse kinematics to bones
  39329. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39330. */
  39331. export class BoneIKController {
  39332. private static _tmpVecs;
  39333. private static _tmpQuat;
  39334. private static _tmpMats;
  39335. /**
  39336. * Gets or sets the target mesh
  39337. */
  39338. targetMesh: AbstractMesh;
  39339. /** Gets or sets the mesh used as pole */
  39340. poleTargetMesh: AbstractMesh;
  39341. /**
  39342. * Gets or sets the bone used as pole
  39343. */
  39344. poleTargetBone: Nullable<Bone>;
  39345. /**
  39346. * Gets or sets the target position
  39347. */
  39348. targetPosition: Vector3;
  39349. /**
  39350. * Gets or sets the pole target position
  39351. */
  39352. poleTargetPosition: Vector3;
  39353. /**
  39354. * Gets or sets the pole target local offset
  39355. */
  39356. poleTargetLocalOffset: Vector3;
  39357. /**
  39358. * Gets or sets the pole angle
  39359. */
  39360. poleAngle: number;
  39361. /**
  39362. * Gets or sets the mesh associated with the controller
  39363. */
  39364. mesh: AbstractMesh;
  39365. /**
  39366. * 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)
  39367. */
  39368. slerpAmount: number;
  39369. private _bone1Quat;
  39370. private _bone1Mat;
  39371. private _bone2Ang;
  39372. private _bone1;
  39373. private _bone2;
  39374. private _bone1Length;
  39375. private _bone2Length;
  39376. private _maxAngle;
  39377. private _maxReach;
  39378. private _rightHandedSystem;
  39379. private _bendAxis;
  39380. private _slerping;
  39381. private _adjustRoll;
  39382. /**
  39383. * Gets or sets maximum allowed angle
  39384. */
  39385. get maxAngle(): number;
  39386. set maxAngle(value: number);
  39387. /**
  39388. * Creates a new BoneIKController
  39389. * @param mesh defines the mesh to control
  39390. * @param bone defines the bone to control
  39391. * @param options defines options to set up the controller
  39392. */
  39393. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39394. targetMesh?: AbstractMesh;
  39395. poleTargetMesh?: AbstractMesh;
  39396. poleTargetBone?: Bone;
  39397. poleTargetLocalOffset?: Vector3;
  39398. poleAngle?: number;
  39399. bendAxis?: Vector3;
  39400. maxAngle?: number;
  39401. slerpAmount?: number;
  39402. });
  39403. private _setMaxAngle;
  39404. /**
  39405. * Force the controller to update the bones
  39406. */
  39407. update(): void;
  39408. }
  39409. }
  39410. declare module BABYLON {
  39411. /**
  39412. * Class used to make a bone look toward a point in space
  39413. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39414. */
  39415. export class BoneLookController {
  39416. private static _tmpVecs;
  39417. private static _tmpQuat;
  39418. private static _tmpMats;
  39419. /**
  39420. * The target Vector3 that the bone will look at
  39421. */
  39422. target: Vector3;
  39423. /**
  39424. * The mesh that the bone is attached to
  39425. */
  39426. mesh: AbstractMesh;
  39427. /**
  39428. * The bone that will be looking to the target
  39429. */
  39430. bone: Bone;
  39431. /**
  39432. * The up axis of the coordinate system that is used when the bone is rotated
  39433. */
  39434. upAxis: Vector3;
  39435. /**
  39436. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39437. */
  39438. upAxisSpace: Space;
  39439. /**
  39440. * Used to make an adjustment to the yaw of the bone
  39441. */
  39442. adjustYaw: number;
  39443. /**
  39444. * Used to make an adjustment to the pitch of the bone
  39445. */
  39446. adjustPitch: number;
  39447. /**
  39448. * Used to make an adjustment to the roll of the bone
  39449. */
  39450. adjustRoll: number;
  39451. /**
  39452. * 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)
  39453. */
  39454. slerpAmount: number;
  39455. private _minYaw;
  39456. private _maxYaw;
  39457. private _minPitch;
  39458. private _maxPitch;
  39459. private _minYawSin;
  39460. private _minYawCos;
  39461. private _maxYawSin;
  39462. private _maxYawCos;
  39463. private _midYawConstraint;
  39464. private _minPitchTan;
  39465. private _maxPitchTan;
  39466. private _boneQuat;
  39467. private _slerping;
  39468. private _transformYawPitch;
  39469. private _transformYawPitchInv;
  39470. private _firstFrameSkipped;
  39471. private _yawRange;
  39472. private _fowardAxis;
  39473. /**
  39474. * Gets or sets the minimum yaw angle that the bone can look to
  39475. */
  39476. get minYaw(): number;
  39477. set minYaw(value: number);
  39478. /**
  39479. * Gets or sets the maximum yaw angle that the bone can look to
  39480. */
  39481. get maxYaw(): number;
  39482. set maxYaw(value: number);
  39483. /**
  39484. * Gets or sets the minimum pitch angle that the bone can look to
  39485. */
  39486. get minPitch(): number;
  39487. set minPitch(value: number);
  39488. /**
  39489. * Gets or sets the maximum pitch angle that the bone can look to
  39490. */
  39491. get maxPitch(): number;
  39492. set maxPitch(value: number);
  39493. /**
  39494. * Create a BoneLookController
  39495. * @param mesh the mesh that the bone belongs to
  39496. * @param bone the bone that will be looking to the target
  39497. * @param target the target Vector3 to look at
  39498. * @param options optional settings:
  39499. * * maxYaw: the maximum angle the bone will yaw to
  39500. * * minYaw: the minimum angle the bone will yaw to
  39501. * * maxPitch: the maximum angle the bone will pitch to
  39502. * * minPitch: the minimum angle the bone will yaw to
  39503. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39504. * * upAxis: the up axis of the coordinate system
  39505. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39506. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39507. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39508. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39509. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39510. * * adjustRoll: used to make an adjustment to the roll of the bone
  39511. **/
  39512. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39513. maxYaw?: number;
  39514. minYaw?: number;
  39515. maxPitch?: number;
  39516. minPitch?: number;
  39517. slerpAmount?: number;
  39518. upAxis?: Vector3;
  39519. upAxisSpace?: Space;
  39520. yawAxis?: Vector3;
  39521. pitchAxis?: Vector3;
  39522. adjustYaw?: number;
  39523. adjustPitch?: number;
  39524. adjustRoll?: number;
  39525. });
  39526. /**
  39527. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39528. */
  39529. update(): void;
  39530. private _getAngleDiff;
  39531. private _getAngleBetween;
  39532. private _isAngleBetween;
  39533. }
  39534. }
  39535. declare module BABYLON {
  39536. /**
  39537. * Manage the gamepad inputs to control an arc rotate camera.
  39538. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39539. */
  39540. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39541. /**
  39542. * Defines the camera the input is attached to.
  39543. */
  39544. camera: ArcRotateCamera;
  39545. /**
  39546. * Defines the gamepad the input is gathering event from.
  39547. */
  39548. gamepad: Nullable<Gamepad>;
  39549. /**
  39550. * Defines the gamepad rotation sensiblity.
  39551. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39552. */
  39553. gamepadRotationSensibility: number;
  39554. /**
  39555. * Defines the gamepad move sensiblity.
  39556. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39557. */
  39558. gamepadMoveSensibility: number;
  39559. private _yAxisScale;
  39560. /**
  39561. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39562. */
  39563. get invertYAxis(): boolean;
  39564. set invertYAxis(value: boolean);
  39565. private _onGamepadConnectedObserver;
  39566. private _onGamepadDisconnectedObserver;
  39567. /**
  39568. * Attach the input controls to a specific dom element to get the input from.
  39569. * @param element Defines the element the controls should be listened from
  39570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39571. */
  39572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39573. /**
  39574. * Detach the current controls from the specified dom element.
  39575. * @param element Defines the element to stop listening the inputs from
  39576. */
  39577. detachControl(element: Nullable<HTMLElement>): void;
  39578. /**
  39579. * Update the current camera state depending on the inputs that have been used this frame.
  39580. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39581. */
  39582. checkInputs(): void;
  39583. /**
  39584. * Gets the class name of the current intput.
  39585. * @returns the class name
  39586. */
  39587. getClassName(): string;
  39588. /**
  39589. * Get the friendly name associated with the input class.
  39590. * @returns the input friendly name
  39591. */
  39592. getSimpleName(): string;
  39593. }
  39594. }
  39595. declare module BABYLON {
  39596. interface ArcRotateCameraInputsManager {
  39597. /**
  39598. * Add orientation input support to the input manager.
  39599. * @returns the current input manager
  39600. */
  39601. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39602. }
  39603. /**
  39604. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39606. */
  39607. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39608. /**
  39609. * Defines the camera the input is attached to.
  39610. */
  39611. camera: ArcRotateCamera;
  39612. /**
  39613. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39614. */
  39615. alphaCorrection: number;
  39616. /**
  39617. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39618. */
  39619. gammaCorrection: number;
  39620. private _alpha;
  39621. private _gamma;
  39622. private _dirty;
  39623. private _deviceOrientationHandler;
  39624. /**
  39625. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39626. */
  39627. constructor();
  39628. /**
  39629. * Attach the input controls to a specific dom element to get the input from.
  39630. * @param element Defines the element the controls should be listened from
  39631. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39632. */
  39633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39634. /** @hidden */
  39635. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39636. /**
  39637. * Update the current camera state depending on the inputs that have been used this frame.
  39638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39639. */
  39640. checkInputs(): void;
  39641. /**
  39642. * Detach the current controls from the specified dom element.
  39643. * @param element Defines the element to stop listening the inputs from
  39644. */
  39645. detachControl(element: Nullable<HTMLElement>): void;
  39646. /**
  39647. * Gets the class name of the current intput.
  39648. * @returns the class name
  39649. */
  39650. getClassName(): string;
  39651. /**
  39652. * Get the friendly name associated with the input class.
  39653. * @returns the input friendly name
  39654. */
  39655. getSimpleName(): string;
  39656. }
  39657. }
  39658. declare module BABYLON {
  39659. /**
  39660. * Listen to mouse events to control the camera.
  39661. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39662. */
  39663. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39664. /**
  39665. * Defines the camera the input is attached to.
  39666. */
  39667. camera: FlyCamera;
  39668. /**
  39669. * Defines if touch is enabled. (Default is true.)
  39670. */
  39671. touchEnabled: boolean;
  39672. /**
  39673. * Defines the buttons associated with the input to handle camera rotation.
  39674. */
  39675. buttons: number[];
  39676. /**
  39677. * Assign buttons for Yaw control.
  39678. */
  39679. buttonsYaw: number[];
  39680. /**
  39681. * Assign buttons for Pitch control.
  39682. */
  39683. buttonsPitch: number[];
  39684. /**
  39685. * Assign buttons for Roll control.
  39686. */
  39687. buttonsRoll: number[];
  39688. /**
  39689. * Detect if any button is being pressed while mouse is moved.
  39690. * -1 = Mouse locked.
  39691. * 0 = Left button.
  39692. * 1 = Middle Button.
  39693. * 2 = Right Button.
  39694. */
  39695. activeButton: number;
  39696. /**
  39697. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39698. * Higher values reduce its sensitivity.
  39699. */
  39700. angularSensibility: number;
  39701. private _mousemoveCallback;
  39702. private _observer;
  39703. private _rollObserver;
  39704. private previousPosition;
  39705. private noPreventDefault;
  39706. private element;
  39707. /**
  39708. * Listen to mouse events to control the camera.
  39709. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39711. */
  39712. constructor(touchEnabled?: boolean);
  39713. /**
  39714. * Attach the mouse control to the HTML DOM element.
  39715. * @param element Defines the element that listens to the input events.
  39716. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39717. */
  39718. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39719. /**
  39720. * Detach the current controls from the specified dom element.
  39721. * @param element Defines the element to stop listening the inputs from
  39722. */
  39723. detachControl(element: Nullable<HTMLElement>): void;
  39724. /**
  39725. * Gets the class name of the current input.
  39726. * @returns the class name.
  39727. */
  39728. getClassName(): string;
  39729. /**
  39730. * Get the friendly name associated with the input class.
  39731. * @returns the input's friendly name.
  39732. */
  39733. getSimpleName(): string;
  39734. private _pointerInput;
  39735. private _onMouseMove;
  39736. /**
  39737. * Rotate camera by mouse offset.
  39738. */
  39739. private rotateCamera;
  39740. }
  39741. }
  39742. declare module BABYLON {
  39743. /**
  39744. * Default Inputs manager for the FlyCamera.
  39745. * It groups all the default supported inputs for ease of use.
  39746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39747. */
  39748. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39749. /**
  39750. * Instantiates a new FlyCameraInputsManager.
  39751. * @param camera Defines the camera the inputs belong to.
  39752. */
  39753. constructor(camera: FlyCamera);
  39754. /**
  39755. * Add keyboard input support to the input manager.
  39756. * @returns the new FlyCameraKeyboardMoveInput().
  39757. */
  39758. addKeyboard(): FlyCameraInputsManager;
  39759. /**
  39760. * Add mouse input support to the input manager.
  39761. * @param touchEnabled Enable touch screen support.
  39762. * @returns the new FlyCameraMouseInput().
  39763. */
  39764. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39765. }
  39766. }
  39767. declare module BABYLON {
  39768. /**
  39769. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39770. * such as in a 3D Space Shooter or a Flight Simulator.
  39771. */
  39772. export class FlyCamera extends TargetCamera {
  39773. /**
  39774. * Define the collision ellipsoid of the camera.
  39775. * This is helpful for simulating a camera body, like a player's body.
  39776. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39777. */
  39778. ellipsoid: Vector3;
  39779. /**
  39780. * Define an offset for the position of the ellipsoid around the camera.
  39781. * This can be helpful if the camera is attached away from the player's body center,
  39782. * such as at its head.
  39783. */
  39784. ellipsoidOffset: Vector3;
  39785. /**
  39786. * Enable or disable collisions of the camera with the rest of the scene objects.
  39787. */
  39788. checkCollisions: boolean;
  39789. /**
  39790. * Enable or disable gravity on the camera.
  39791. */
  39792. applyGravity: boolean;
  39793. /**
  39794. * Define the current direction the camera is moving to.
  39795. */
  39796. cameraDirection: Vector3;
  39797. /**
  39798. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39799. * This overrides and empties cameraRotation.
  39800. */
  39801. rotationQuaternion: Quaternion;
  39802. /**
  39803. * Track Roll to maintain the wanted Rolling when looking around.
  39804. */
  39805. _trackRoll: number;
  39806. /**
  39807. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39808. */
  39809. rollCorrect: number;
  39810. /**
  39811. * Mimic a banked turn, Rolling the camera when Yawing.
  39812. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39813. */
  39814. bankedTurn: boolean;
  39815. /**
  39816. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39817. */
  39818. bankedTurnLimit: number;
  39819. /**
  39820. * Value of 0 disables the banked Roll.
  39821. * Value of 1 is equal to the Yaw angle in radians.
  39822. */
  39823. bankedTurnMultiplier: number;
  39824. /**
  39825. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39826. */
  39827. inputs: FlyCameraInputsManager;
  39828. /**
  39829. * Gets the input sensibility for mouse input.
  39830. * Higher values reduce sensitivity.
  39831. */
  39832. get angularSensibility(): number;
  39833. /**
  39834. * Sets the input sensibility for a mouse input.
  39835. * Higher values reduce sensitivity.
  39836. */
  39837. set angularSensibility(value: number);
  39838. /**
  39839. * Get the keys for camera movement forward.
  39840. */
  39841. get keysForward(): number[];
  39842. /**
  39843. * Set the keys for camera movement forward.
  39844. */
  39845. set keysForward(value: number[]);
  39846. /**
  39847. * Get the keys for camera movement backward.
  39848. */
  39849. get keysBackward(): number[];
  39850. set keysBackward(value: number[]);
  39851. /**
  39852. * Get the keys for camera movement up.
  39853. */
  39854. get keysUp(): number[];
  39855. /**
  39856. * Set the keys for camera movement up.
  39857. */
  39858. set keysUp(value: number[]);
  39859. /**
  39860. * Get the keys for camera movement down.
  39861. */
  39862. get keysDown(): number[];
  39863. /**
  39864. * Set the keys for camera movement down.
  39865. */
  39866. set keysDown(value: number[]);
  39867. /**
  39868. * Get the keys for camera movement left.
  39869. */
  39870. get keysLeft(): number[];
  39871. /**
  39872. * Set the keys for camera movement left.
  39873. */
  39874. set keysLeft(value: number[]);
  39875. /**
  39876. * Set the keys for camera movement right.
  39877. */
  39878. get keysRight(): number[];
  39879. /**
  39880. * Set the keys for camera movement right.
  39881. */
  39882. set keysRight(value: number[]);
  39883. /**
  39884. * Event raised when the camera collides with a mesh in the scene.
  39885. */
  39886. onCollide: (collidedMesh: AbstractMesh) => void;
  39887. private _collider;
  39888. private _needMoveForGravity;
  39889. private _oldPosition;
  39890. private _diffPosition;
  39891. private _newPosition;
  39892. /** @hidden */
  39893. _localDirection: Vector3;
  39894. /** @hidden */
  39895. _transformedDirection: Vector3;
  39896. /**
  39897. * Instantiates a FlyCamera.
  39898. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39899. * such as in a 3D Space Shooter or a Flight Simulator.
  39900. * @param name Define the name of the camera in the scene.
  39901. * @param position Define the starting position of the camera in the scene.
  39902. * @param scene Define the scene the camera belongs to.
  39903. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39904. */
  39905. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39906. /**
  39907. * Attach a control to the HTML DOM element.
  39908. * @param element Defines the element that listens to the input events.
  39909. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39910. */
  39911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39912. /**
  39913. * Detach a control from the HTML DOM element.
  39914. * The camera will stop reacting to that input.
  39915. * @param element Defines the element that listens to the input events.
  39916. */
  39917. detachControl(element: HTMLElement): void;
  39918. private _collisionMask;
  39919. /**
  39920. * Get the mask that the camera ignores in collision events.
  39921. */
  39922. get collisionMask(): number;
  39923. /**
  39924. * Set the mask that the camera ignores in collision events.
  39925. */
  39926. set collisionMask(mask: number);
  39927. /** @hidden */
  39928. _collideWithWorld(displacement: Vector3): void;
  39929. /** @hidden */
  39930. private _onCollisionPositionChange;
  39931. /** @hidden */
  39932. _checkInputs(): void;
  39933. /** @hidden */
  39934. _decideIfNeedsToMove(): boolean;
  39935. /** @hidden */
  39936. _updatePosition(): void;
  39937. /**
  39938. * Restore the Roll to its target value at the rate specified.
  39939. * @param rate - Higher means slower restoring.
  39940. * @hidden
  39941. */
  39942. restoreRoll(rate: number): void;
  39943. /**
  39944. * Destroy the camera and release the current resources held by it.
  39945. */
  39946. dispose(): void;
  39947. /**
  39948. * Get the current object class name.
  39949. * @returns the class name.
  39950. */
  39951. getClassName(): string;
  39952. }
  39953. }
  39954. declare module BABYLON {
  39955. /**
  39956. * Listen to keyboard events to control the camera.
  39957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39958. */
  39959. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39960. /**
  39961. * Defines the camera the input is attached to.
  39962. */
  39963. camera: FlyCamera;
  39964. /**
  39965. * The list of keyboard keys used to control the forward move of the camera.
  39966. */
  39967. keysForward: number[];
  39968. /**
  39969. * The list of keyboard keys used to control the backward move of the camera.
  39970. */
  39971. keysBackward: number[];
  39972. /**
  39973. * The list of keyboard keys used to control the forward move of the camera.
  39974. */
  39975. keysUp: number[];
  39976. /**
  39977. * The list of keyboard keys used to control the backward move of the camera.
  39978. */
  39979. keysDown: number[];
  39980. /**
  39981. * The list of keyboard keys used to control the right strafe move of the camera.
  39982. */
  39983. keysRight: number[];
  39984. /**
  39985. * The list of keyboard keys used to control the left strafe move of the camera.
  39986. */
  39987. keysLeft: number[];
  39988. private _keys;
  39989. private _onCanvasBlurObserver;
  39990. private _onKeyboardObserver;
  39991. private _engine;
  39992. private _scene;
  39993. /**
  39994. * Attach the input controls to a specific dom element to get the input from.
  39995. * @param element Defines the element the controls should be listened from
  39996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39997. */
  39998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39999. /**
  40000. * Detach the current controls from the specified dom element.
  40001. * @param element Defines the element to stop listening the inputs from
  40002. */
  40003. detachControl(element: Nullable<HTMLElement>): void;
  40004. /**
  40005. * Gets the class name of the current intput.
  40006. * @returns the class name
  40007. */
  40008. getClassName(): string;
  40009. /** @hidden */
  40010. _onLostFocus(e: FocusEvent): void;
  40011. /**
  40012. * Get the friendly name associated with the input class.
  40013. * @returns the input friendly name
  40014. */
  40015. getSimpleName(): string;
  40016. /**
  40017. * Update the current camera state depending on the inputs that have been used this frame.
  40018. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40019. */
  40020. checkInputs(): void;
  40021. }
  40022. }
  40023. declare module BABYLON {
  40024. /**
  40025. * Manage the mouse wheel inputs to control a follow camera.
  40026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40027. */
  40028. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40029. /**
  40030. * Defines the camera the input is attached to.
  40031. */
  40032. camera: FollowCamera;
  40033. /**
  40034. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40035. */
  40036. axisControlRadius: boolean;
  40037. /**
  40038. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40039. */
  40040. axisControlHeight: boolean;
  40041. /**
  40042. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40043. */
  40044. axisControlRotation: boolean;
  40045. /**
  40046. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40047. * relation to mouseWheel events.
  40048. */
  40049. wheelPrecision: number;
  40050. /**
  40051. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40052. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40053. */
  40054. wheelDeltaPercentage: number;
  40055. private _wheel;
  40056. private _observer;
  40057. /**
  40058. * Attach the input controls to a specific dom element to get the input from.
  40059. * @param element Defines the element the controls should be listened from
  40060. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40061. */
  40062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40063. /**
  40064. * Detach the current controls from the specified dom element.
  40065. * @param element Defines the element to stop listening the inputs from
  40066. */
  40067. detachControl(element: Nullable<HTMLElement>): void;
  40068. /**
  40069. * Gets the class name of the current intput.
  40070. * @returns the class name
  40071. */
  40072. getClassName(): string;
  40073. /**
  40074. * Get the friendly name associated with the input class.
  40075. * @returns the input friendly name
  40076. */
  40077. getSimpleName(): string;
  40078. }
  40079. }
  40080. declare module BABYLON {
  40081. /**
  40082. * Manage the pointers inputs to control an follow camera.
  40083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40084. */
  40085. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40086. /**
  40087. * Defines the camera the input is attached to.
  40088. */
  40089. camera: FollowCamera;
  40090. /**
  40091. * Gets the class name of the current input.
  40092. * @returns the class name
  40093. */
  40094. getClassName(): string;
  40095. /**
  40096. * Defines the pointer angular sensibility along the X axis or how fast is
  40097. * the camera rotating.
  40098. * A negative number will reverse the axis direction.
  40099. */
  40100. angularSensibilityX: number;
  40101. /**
  40102. * Defines the pointer angular sensibility along the Y axis or how fast is
  40103. * the camera rotating.
  40104. * A negative number will reverse the axis direction.
  40105. */
  40106. angularSensibilityY: number;
  40107. /**
  40108. * Defines the pointer pinch precision or how fast is the camera zooming.
  40109. * A negative number will reverse the axis direction.
  40110. */
  40111. pinchPrecision: number;
  40112. /**
  40113. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40114. * from 0.
  40115. * It defines the percentage of current camera.radius to use as delta when
  40116. * pinch zoom is used.
  40117. */
  40118. pinchDeltaPercentage: number;
  40119. /**
  40120. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40121. */
  40122. axisXControlRadius: boolean;
  40123. /**
  40124. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40125. */
  40126. axisXControlHeight: boolean;
  40127. /**
  40128. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40129. */
  40130. axisXControlRotation: boolean;
  40131. /**
  40132. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40133. */
  40134. axisYControlRadius: boolean;
  40135. /**
  40136. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40137. */
  40138. axisYControlHeight: boolean;
  40139. /**
  40140. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40141. */
  40142. axisYControlRotation: boolean;
  40143. /**
  40144. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40145. */
  40146. axisPinchControlRadius: boolean;
  40147. /**
  40148. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40149. */
  40150. axisPinchControlHeight: boolean;
  40151. /**
  40152. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40153. */
  40154. axisPinchControlRotation: boolean;
  40155. /**
  40156. * Log error messages if basic misconfiguration has occurred.
  40157. */
  40158. warningEnable: boolean;
  40159. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40160. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40161. private _warningCounter;
  40162. private _warning;
  40163. }
  40164. }
  40165. declare module BABYLON {
  40166. /**
  40167. * Default Inputs manager for the FollowCamera.
  40168. * It groups all the default supported inputs for ease of use.
  40169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40170. */
  40171. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40172. /**
  40173. * Instantiates a new FollowCameraInputsManager.
  40174. * @param camera Defines the camera the inputs belong to
  40175. */
  40176. constructor(camera: FollowCamera);
  40177. /**
  40178. * Add keyboard input support to the input manager.
  40179. * @returns the current input manager
  40180. */
  40181. addKeyboard(): FollowCameraInputsManager;
  40182. /**
  40183. * Add mouse wheel input support to the input manager.
  40184. * @returns the current input manager
  40185. */
  40186. addMouseWheel(): FollowCameraInputsManager;
  40187. /**
  40188. * Add pointers input support to the input manager.
  40189. * @returns the current input manager
  40190. */
  40191. addPointers(): FollowCameraInputsManager;
  40192. /**
  40193. * Add orientation input support to the input manager.
  40194. * @returns the current input manager
  40195. */
  40196. addVRDeviceOrientation(): FollowCameraInputsManager;
  40197. }
  40198. }
  40199. declare module BABYLON {
  40200. /**
  40201. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40202. * an arc rotate version arcFollowCamera are available.
  40203. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40204. */
  40205. export class FollowCamera extends TargetCamera {
  40206. /**
  40207. * Distance the follow camera should follow an object at
  40208. */
  40209. radius: number;
  40210. /**
  40211. * Minimum allowed distance of the camera to the axis of rotation
  40212. * (The camera can not get closer).
  40213. * This can help limiting how the Camera is able to move in the scene.
  40214. */
  40215. lowerRadiusLimit: Nullable<number>;
  40216. /**
  40217. * Maximum allowed distance of the camera to the axis of rotation
  40218. * (The camera can not get further).
  40219. * This can help limiting how the Camera is able to move in the scene.
  40220. */
  40221. upperRadiusLimit: Nullable<number>;
  40222. /**
  40223. * Define a rotation offset between the camera and the object it follows
  40224. */
  40225. rotationOffset: number;
  40226. /**
  40227. * Minimum allowed angle to camera position relative to target object.
  40228. * This can help limiting how the Camera is able to move in the scene.
  40229. */
  40230. lowerRotationOffsetLimit: Nullable<number>;
  40231. /**
  40232. * Maximum allowed angle to camera position relative to target object.
  40233. * This can help limiting how the Camera is able to move in the scene.
  40234. */
  40235. upperRotationOffsetLimit: Nullable<number>;
  40236. /**
  40237. * Define a height offset between the camera and the object it follows.
  40238. * It can help following an object from the top (like a car chaing a plane)
  40239. */
  40240. heightOffset: number;
  40241. /**
  40242. * Minimum allowed height of camera position relative to target object.
  40243. * This can help limiting how the Camera is able to move in the scene.
  40244. */
  40245. lowerHeightOffsetLimit: Nullable<number>;
  40246. /**
  40247. * Maximum allowed height of camera position relative to target object.
  40248. * This can help limiting how the Camera is able to move in the scene.
  40249. */
  40250. upperHeightOffsetLimit: Nullable<number>;
  40251. /**
  40252. * Define how fast the camera can accelerate to follow it s target.
  40253. */
  40254. cameraAcceleration: number;
  40255. /**
  40256. * Define the speed limit of the camera following an object.
  40257. */
  40258. maxCameraSpeed: number;
  40259. /**
  40260. * Define the target of the camera.
  40261. */
  40262. lockedTarget: Nullable<AbstractMesh>;
  40263. /**
  40264. * Defines the input associated with the camera.
  40265. */
  40266. inputs: FollowCameraInputsManager;
  40267. /**
  40268. * Instantiates the follow camera.
  40269. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40270. * @param name Define the name of the camera in the scene
  40271. * @param position Define the position of the camera
  40272. * @param scene Define the scene the camera belong to
  40273. * @param lockedTarget Define the target of the camera
  40274. */
  40275. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40276. private _follow;
  40277. /**
  40278. * Attached controls to the current camera.
  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. /**
  40284. * Detach the current controls from the camera.
  40285. * The camera will stop reacting to inputs.
  40286. * @param element Defines the element to stop listening the inputs from
  40287. */
  40288. detachControl(element: HTMLElement): void;
  40289. /** @hidden */
  40290. _checkInputs(): void;
  40291. private _checkLimits;
  40292. /**
  40293. * Gets the camera class name.
  40294. * @returns the class name
  40295. */
  40296. getClassName(): string;
  40297. }
  40298. /**
  40299. * Arc Rotate version of the follow camera.
  40300. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40301. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40302. */
  40303. export class ArcFollowCamera extends TargetCamera {
  40304. /** The longitudinal angle of the camera */
  40305. alpha: number;
  40306. /** The latitudinal angle of the camera */
  40307. beta: number;
  40308. /** The radius of the camera from its target */
  40309. radius: number;
  40310. /** Define the camera target (the messh it should follow) */
  40311. target: Nullable<AbstractMesh>;
  40312. private _cartesianCoordinates;
  40313. /**
  40314. * Instantiates a new ArcFollowCamera
  40315. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40316. * @param name Define the name of the camera
  40317. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40318. * @param beta Define the rotation angle of the camera around the elevation axis
  40319. * @param radius Define the radius of the camera from its target point
  40320. * @param target Define the target of the camera
  40321. * @param scene Define the scene the camera belongs to
  40322. */
  40323. constructor(name: string,
  40324. /** The longitudinal angle of the camera */
  40325. alpha: number,
  40326. /** The latitudinal angle of the camera */
  40327. beta: number,
  40328. /** The radius of the camera from its target */
  40329. radius: number,
  40330. /** Define the camera target (the messh it should follow) */
  40331. target: Nullable<AbstractMesh>, scene: Scene);
  40332. private _follow;
  40333. /** @hidden */
  40334. _checkInputs(): void;
  40335. /**
  40336. * Returns the class name of the object.
  40337. * It is mostly used internally for serialization purposes.
  40338. */
  40339. getClassName(): string;
  40340. }
  40341. }
  40342. declare module BABYLON {
  40343. /**
  40344. * Manage the keyboard inputs to control the movement of a follow camera.
  40345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40346. */
  40347. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40348. /**
  40349. * Defines the camera the input is attached to.
  40350. */
  40351. camera: FollowCamera;
  40352. /**
  40353. * Defines the list of key codes associated with the up action (increase heightOffset)
  40354. */
  40355. keysHeightOffsetIncr: number[];
  40356. /**
  40357. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40358. */
  40359. keysHeightOffsetDecr: number[];
  40360. /**
  40361. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40362. */
  40363. keysHeightOffsetModifierAlt: boolean;
  40364. /**
  40365. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40366. */
  40367. keysHeightOffsetModifierCtrl: boolean;
  40368. /**
  40369. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40370. */
  40371. keysHeightOffsetModifierShift: boolean;
  40372. /**
  40373. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40374. */
  40375. keysRotationOffsetIncr: number[];
  40376. /**
  40377. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40378. */
  40379. keysRotationOffsetDecr: number[];
  40380. /**
  40381. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40382. */
  40383. keysRotationOffsetModifierAlt: boolean;
  40384. /**
  40385. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40386. */
  40387. keysRotationOffsetModifierCtrl: boolean;
  40388. /**
  40389. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40390. */
  40391. keysRotationOffsetModifierShift: boolean;
  40392. /**
  40393. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40394. */
  40395. keysRadiusIncr: number[];
  40396. /**
  40397. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40398. */
  40399. keysRadiusDecr: number[];
  40400. /**
  40401. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40402. */
  40403. keysRadiusModifierAlt: boolean;
  40404. /**
  40405. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40406. */
  40407. keysRadiusModifierCtrl: boolean;
  40408. /**
  40409. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40410. */
  40411. keysRadiusModifierShift: boolean;
  40412. /**
  40413. * Defines the rate of change of heightOffset.
  40414. */
  40415. heightSensibility: number;
  40416. /**
  40417. * Defines the rate of change of rotationOffset.
  40418. */
  40419. rotationSensibility: number;
  40420. /**
  40421. * Defines the rate of change of radius.
  40422. */
  40423. radiusSensibility: number;
  40424. private _keys;
  40425. private _ctrlPressed;
  40426. private _altPressed;
  40427. private _shiftPressed;
  40428. private _onCanvasBlurObserver;
  40429. private _onKeyboardObserver;
  40430. private _engine;
  40431. private _scene;
  40432. /**
  40433. * Attach the input controls to a specific dom element to get the input from.
  40434. * @param element Defines the element the controls should be listened from
  40435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40436. */
  40437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40438. /**
  40439. * Detach the current controls from the specified dom element.
  40440. * @param element Defines the element to stop listening the inputs from
  40441. */
  40442. detachControl(element: Nullable<HTMLElement>): void;
  40443. /**
  40444. * Update the current camera state depending on the inputs that have been used this frame.
  40445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40446. */
  40447. checkInputs(): void;
  40448. /**
  40449. * Gets the class name of the current input.
  40450. * @returns the class name
  40451. */
  40452. getClassName(): string;
  40453. /**
  40454. * Get the friendly name associated with the input class.
  40455. * @returns the input friendly name
  40456. */
  40457. getSimpleName(): string;
  40458. /**
  40459. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40460. * allow modification of the heightOffset value.
  40461. */
  40462. private _modifierHeightOffset;
  40463. /**
  40464. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40465. * allow modification of the rotationOffset value.
  40466. */
  40467. private _modifierRotationOffset;
  40468. /**
  40469. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40470. * allow modification of the radius value.
  40471. */
  40472. private _modifierRadius;
  40473. }
  40474. }
  40475. declare module BABYLON {
  40476. interface FreeCameraInputsManager {
  40477. /**
  40478. * @hidden
  40479. */
  40480. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40481. /**
  40482. * Add orientation input support to the input manager.
  40483. * @returns the current input manager
  40484. */
  40485. addDeviceOrientation(): FreeCameraInputsManager;
  40486. }
  40487. /**
  40488. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40489. * Screen rotation is taken into account.
  40490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40491. */
  40492. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40493. private _camera;
  40494. private _screenOrientationAngle;
  40495. private _constantTranform;
  40496. private _screenQuaternion;
  40497. private _alpha;
  40498. private _beta;
  40499. private _gamma;
  40500. /**
  40501. * Can be used to detect if a device orientation sensor is available on a device
  40502. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40503. * @returns a promise that will resolve on orientation change
  40504. */
  40505. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40506. /**
  40507. * @hidden
  40508. */
  40509. _onDeviceOrientationChangedObservable: Observable<void>;
  40510. /**
  40511. * Instantiates a new input
  40512. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40513. */
  40514. constructor();
  40515. /**
  40516. * Define the camera controlled by the input.
  40517. */
  40518. get camera(): FreeCamera;
  40519. set camera(camera: FreeCamera);
  40520. /**
  40521. * Attach the input controls to a specific dom element to get the input from.
  40522. * @param element Defines the element the controls should be listened from
  40523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40524. */
  40525. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40526. private _orientationChanged;
  40527. private _deviceOrientation;
  40528. /**
  40529. * Detach the current controls from the specified dom element.
  40530. * @param element Defines the element to stop listening the inputs from
  40531. */
  40532. detachControl(element: Nullable<HTMLElement>): void;
  40533. /**
  40534. * Update the current camera state depending on the inputs that have been used this frame.
  40535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40536. */
  40537. checkInputs(): void;
  40538. /**
  40539. * Gets the class name of the current intput.
  40540. * @returns the class name
  40541. */
  40542. getClassName(): string;
  40543. /**
  40544. * Get the friendly name associated with the input class.
  40545. * @returns the input friendly name
  40546. */
  40547. getSimpleName(): string;
  40548. }
  40549. }
  40550. declare module BABYLON {
  40551. /**
  40552. * Manage the gamepad inputs to control a free camera.
  40553. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40554. */
  40555. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40556. /**
  40557. * Define the camera the input is attached to.
  40558. */
  40559. camera: FreeCamera;
  40560. /**
  40561. * Define the Gamepad controlling the input
  40562. */
  40563. gamepad: Nullable<Gamepad>;
  40564. /**
  40565. * Defines the gamepad rotation sensiblity.
  40566. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40567. */
  40568. gamepadAngularSensibility: number;
  40569. /**
  40570. * Defines the gamepad move sensiblity.
  40571. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40572. */
  40573. gamepadMoveSensibility: number;
  40574. private _yAxisScale;
  40575. /**
  40576. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40577. */
  40578. get invertYAxis(): boolean;
  40579. set invertYAxis(value: boolean);
  40580. private _onGamepadConnectedObserver;
  40581. private _onGamepadDisconnectedObserver;
  40582. private _cameraTransform;
  40583. private _deltaTransform;
  40584. private _vector3;
  40585. private _vector2;
  40586. /**
  40587. * Attach the input controls to a specific dom element to get the input from.
  40588. * @param element Defines the element the controls should be listened from
  40589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40590. */
  40591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40592. /**
  40593. * Detach the current controls from the specified dom element.
  40594. * @param element Defines the element to stop listening the inputs from
  40595. */
  40596. detachControl(element: Nullable<HTMLElement>): void;
  40597. /**
  40598. * Update the current camera state depending on the inputs that have been used this frame.
  40599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40600. */
  40601. checkInputs(): void;
  40602. /**
  40603. * Gets the class name of the current intput.
  40604. * @returns the class name
  40605. */
  40606. getClassName(): string;
  40607. /**
  40608. * Get the friendly name associated with the input class.
  40609. * @returns the input friendly name
  40610. */
  40611. getSimpleName(): string;
  40612. }
  40613. }
  40614. declare module BABYLON {
  40615. /**
  40616. * Defines the potential axis of a Joystick
  40617. */
  40618. export enum JoystickAxis {
  40619. /** X axis */
  40620. X = 0,
  40621. /** Y axis */
  40622. Y = 1,
  40623. /** Z axis */
  40624. Z = 2
  40625. }
  40626. /**
  40627. * Class used to define virtual joystick (used in touch mode)
  40628. */
  40629. export class VirtualJoystick {
  40630. /**
  40631. * Gets or sets a boolean indicating that left and right values must be inverted
  40632. */
  40633. reverseLeftRight: boolean;
  40634. /**
  40635. * Gets or sets a boolean indicating that up and down values must be inverted
  40636. */
  40637. reverseUpDown: boolean;
  40638. /**
  40639. * Gets the offset value for the position (ie. the change of the position value)
  40640. */
  40641. deltaPosition: Vector3;
  40642. /**
  40643. * Gets a boolean indicating if the virtual joystick was pressed
  40644. */
  40645. pressed: boolean;
  40646. /**
  40647. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40648. */
  40649. static Canvas: Nullable<HTMLCanvasElement>;
  40650. private static _globalJoystickIndex;
  40651. private static vjCanvasContext;
  40652. private static vjCanvasWidth;
  40653. private static vjCanvasHeight;
  40654. private static halfWidth;
  40655. private _action;
  40656. private _axisTargetedByLeftAndRight;
  40657. private _axisTargetedByUpAndDown;
  40658. private _joystickSensibility;
  40659. private _inversedSensibility;
  40660. private _joystickPointerID;
  40661. private _joystickColor;
  40662. private _joystickPointerPos;
  40663. private _joystickPreviousPointerPos;
  40664. private _joystickPointerStartPos;
  40665. private _deltaJoystickVector;
  40666. private _leftJoystick;
  40667. private _touches;
  40668. private _onPointerDownHandlerRef;
  40669. private _onPointerMoveHandlerRef;
  40670. private _onPointerUpHandlerRef;
  40671. private _onResize;
  40672. /**
  40673. * Creates a new virtual joystick
  40674. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40675. */
  40676. constructor(leftJoystick?: boolean);
  40677. /**
  40678. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40679. * @param newJoystickSensibility defines the new sensibility
  40680. */
  40681. setJoystickSensibility(newJoystickSensibility: number): void;
  40682. private _onPointerDown;
  40683. private _onPointerMove;
  40684. private _onPointerUp;
  40685. /**
  40686. * Change the color of the virtual joystick
  40687. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40688. */
  40689. setJoystickColor(newColor: string): void;
  40690. /**
  40691. * Defines a callback to call when the joystick is touched
  40692. * @param action defines the callback
  40693. */
  40694. setActionOnTouch(action: () => any): void;
  40695. /**
  40696. * Defines which axis you'd like to control for left & right
  40697. * @param axis defines the axis to use
  40698. */
  40699. setAxisForLeftRight(axis: JoystickAxis): void;
  40700. /**
  40701. * Defines which axis you'd like to control for up & down
  40702. * @param axis defines the axis to use
  40703. */
  40704. setAxisForUpDown(axis: JoystickAxis): void;
  40705. private _drawVirtualJoystick;
  40706. /**
  40707. * Release internal HTML canvas
  40708. */
  40709. releaseCanvas(): void;
  40710. }
  40711. }
  40712. declare module BABYLON {
  40713. interface FreeCameraInputsManager {
  40714. /**
  40715. * Add virtual joystick input support to the input manager.
  40716. * @returns the current input manager
  40717. */
  40718. addVirtualJoystick(): FreeCameraInputsManager;
  40719. }
  40720. /**
  40721. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40723. */
  40724. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40725. /**
  40726. * Defines the camera the input is attached to.
  40727. */
  40728. camera: FreeCamera;
  40729. private _leftjoystick;
  40730. private _rightjoystick;
  40731. /**
  40732. * Gets the left stick of the virtual joystick.
  40733. * @returns The virtual Joystick
  40734. */
  40735. getLeftJoystick(): VirtualJoystick;
  40736. /**
  40737. * Gets the right stick of the virtual joystick.
  40738. * @returns The virtual Joystick
  40739. */
  40740. getRightJoystick(): VirtualJoystick;
  40741. /**
  40742. * Update the current camera state depending on the inputs that have been used this frame.
  40743. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40744. */
  40745. checkInputs(): void;
  40746. /**
  40747. * Attach the input controls to a specific dom element to get the input from.
  40748. * @param element Defines the element the controls should be listened from
  40749. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40750. */
  40751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40752. /**
  40753. * Detach the current controls from the specified dom element.
  40754. * @param element Defines the element to stop listening the inputs from
  40755. */
  40756. detachControl(element: Nullable<HTMLElement>): void;
  40757. /**
  40758. * Gets the class name of the current intput.
  40759. * @returns the class name
  40760. */
  40761. getClassName(): string;
  40762. /**
  40763. * Get the friendly name associated with the input class.
  40764. * @returns the input friendly name
  40765. */
  40766. getSimpleName(): string;
  40767. }
  40768. }
  40769. declare module BABYLON {
  40770. /**
  40771. * This represents a FPS type of camera controlled by touch.
  40772. * This is like a universal camera minus the Gamepad controls.
  40773. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40774. */
  40775. export class TouchCamera extends FreeCamera {
  40776. /**
  40777. * Defines the touch sensibility for rotation.
  40778. * The higher the faster.
  40779. */
  40780. get touchAngularSensibility(): number;
  40781. set touchAngularSensibility(value: number);
  40782. /**
  40783. * Defines the touch sensibility for move.
  40784. * The higher the faster.
  40785. */
  40786. get touchMoveSensibility(): number;
  40787. set touchMoveSensibility(value: number);
  40788. /**
  40789. * Instantiates a new touch camera.
  40790. * This represents a FPS type of camera controlled by touch.
  40791. * This is like a universal camera minus the Gamepad controls.
  40792. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40793. * @param name Define the name of the camera in the scene
  40794. * @param position Define the start position of the camera in the scene
  40795. * @param scene Define the scene the camera belongs to
  40796. */
  40797. constructor(name: string, position: Vector3, scene: Scene);
  40798. /**
  40799. * Gets the current object class name.
  40800. * @return the class name
  40801. */
  40802. getClassName(): string;
  40803. /** @hidden */
  40804. _setupInputs(): void;
  40805. }
  40806. }
  40807. declare module BABYLON {
  40808. /**
  40809. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40810. * being tilted forward or back and left or right.
  40811. */
  40812. export class DeviceOrientationCamera extends FreeCamera {
  40813. private _initialQuaternion;
  40814. private _quaternionCache;
  40815. private _tmpDragQuaternion;
  40816. private _disablePointerInputWhenUsingDeviceOrientation;
  40817. /**
  40818. * Creates a new device orientation camera
  40819. * @param name The name of the camera
  40820. * @param position The start position camera
  40821. * @param scene The scene the camera belongs to
  40822. */
  40823. constructor(name: string, position: Vector3, scene: Scene);
  40824. /**
  40825. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40826. */
  40827. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40828. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40829. private _dragFactor;
  40830. /**
  40831. * Enabled turning on the y axis when the orientation sensor is active
  40832. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40833. */
  40834. enableHorizontalDragging(dragFactor?: number): void;
  40835. /**
  40836. * Gets the current instance class name ("DeviceOrientationCamera").
  40837. * This helps avoiding instanceof at run time.
  40838. * @returns the class name
  40839. */
  40840. getClassName(): string;
  40841. /**
  40842. * @hidden
  40843. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40844. */
  40845. _checkInputs(): void;
  40846. /**
  40847. * Reset the camera to its default orientation on the specified axis only.
  40848. * @param axis The axis to reset
  40849. */
  40850. resetToCurrentRotation(axis?: Axis): void;
  40851. }
  40852. }
  40853. declare module BABYLON {
  40854. /**
  40855. * Defines supported buttons for XBox360 compatible gamepads
  40856. */
  40857. export enum Xbox360Button {
  40858. /** A */
  40859. A = 0,
  40860. /** B */
  40861. B = 1,
  40862. /** X */
  40863. X = 2,
  40864. /** Y */
  40865. Y = 3,
  40866. /** Start */
  40867. Start = 4,
  40868. /** Back */
  40869. Back = 5,
  40870. /** Left button */
  40871. LB = 6,
  40872. /** Right button */
  40873. RB = 7,
  40874. /** Left stick */
  40875. LeftStick = 8,
  40876. /** Right stick */
  40877. RightStick = 9
  40878. }
  40879. /** Defines values for XBox360 DPad */
  40880. export enum Xbox360Dpad {
  40881. /** Up */
  40882. Up = 0,
  40883. /** Down */
  40884. Down = 1,
  40885. /** Left */
  40886. Left = 2,
  40887. /** Right */
  40888. Right = 3
  40889. }
  40890. /**
  40891. * Defines a XBox360 gamepad
  40892. */
  40893. export class Xbox360Pad extends Gamepad {
  40894. private _leftTrigger;
  40895. private _rightTrigger;
  40896. private _onlefttriggerchanged;
  40897. private _onrighttriggerchanged;
  40898. private _onbuttondown;
  40899. private _onbuttonup;
  40900. private _ondpaddown;
  40901. private _ondpadup;
  40902. /** Observable raised when a button is pressed */
  40903. onButtonDownObservable: Observable<Xbox360Button>;
  40904. /** Observable raised when a button is released */
  40905. onButtonUpObservable: Observable<Xbox360Button>;
  40906. /** Observable raised when a pad is pressed */
  40907. onPadDownObservable: Observable<Xbox360Dpad>;
  40908. /** Observable raised when a pad is released */
  40909. onPadUpObservable: Observable<Xbox360Dpad>;
  40910. private _buttonA;
  40911. private _buttonB;
  40912. private _buttonX;
  40913. private _buttonY;
  40914. private _buttonBack;
  40915. private _buttonStart;
  40916. private _buttonLB;
  40917. private _buttonRB;
  40918. private _buttonLeftStick;
  40919. private _buttonRightStick;
  40920. private _dPadUp;
  40921. private _dPadDown;
  40922. private _dPadLeft;
  40923. private _dPadRight;
  40924. private _isXboxOnePad;
  40925. /**
  40926. * Creates a new XBox360 gamepad object
  40927. * @param id defines the id of this gamepad
  40928. * @param index defines its index
  40929. * @param gamepad defines the internal HTML gamepad object
  40930. * @param xboxOne defines if it is a XBox One gamepad
  40931. */
  40932. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40933. /**
  40934. * Defines the callback to call when left trigger is pressed
  40935. * @param callback defines the callback to use
  40936. */
  40937. onlefttriggerchanged(callback: (value: number) => void): void;
  40938. /**
  40939. * Defines the callback to call when right trigger is pressed
  40940. * @param callback defines the callback to use
  40941. */
  40942. onrighttriggerchanged(callback: (value: number) => void): void;
  40943. /**
  40944. * Gets the left trigger value
  40945. */
  40946. get leftTrigger(): number;
  40947. /**
  40948. * Sets the left trigger value
  40949. */
  40950. set leftTrigger(newValue: number);
  40951. /**
  40952. * Gets the right trigger value
  40953. */
  40954. get rightTrigger(): number;
  40955. /**
  40956. * Sets the right trigger value
  40957. */
  40958. set rightTrigger(newValue: number);
  40959. /**
  40960. * Defines the callback to call when a button is pressed
  40961. * @param callback defines the callback to use
  40962. */
  40963. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40964. /**
  40965. * Defines the callback to call when a button is released
  40966. * @param callback defines the callback to use
  40967. */
  40968. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40969. /**
  40970. * Defines the callback to call when a pad is pressed
  40971. * @param callback defines the callback to use
  40972. */
  40973. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40974. /**
  40975. * Defines the callback to call when a pad is released
  40976. * @param callback defines the callback to use
  40977. */
  40978. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40979. private _setButtonValue;
  40980. private _setDPadValue;
  40981. /**
  40982. * Gets the value of the `A` button
  40983. */
  40984. get buttonA(): number;
  40985. /**
  40986. * Sets the value of the `A` button
  40987. */
  40988. set buttonA(value: number);
  40989. /**
  40990. * Gets the value of the `B` button
  40991. */
  40992. get buttonB(): number;
  40993. /**
  40994. * Sets the value of the `B` button
  40995. */
  40996. set buttonB(value: number);
  40997. /**
  40998. * Gets the value of the `X` button
  40999. */
  41000. get buttonX(): number;
  41001. /**
  41002. * Sets the value of the `X` button
  41003. */
  41004. set buttonX(value: number);
  41005. /**
  41006. * Gets the value of the `Y` button
  41007. */
  41008. get buttonY(): number;
  41009. /**
  41010. * Sets the value of the `Y` button
  41011. */
  41012. set buttonY(value: number);
  41013. /**
  41014. * Gets the value of the `Start` button
  41015. */
  41016. get buttonStart(): number;
  41017. /**
  41018. * Sets the value of the `Start` button
  41019. */
  41020. set buttonStart(value: number);
  41021. /**
  41022. * Gets the value of the `Back` button
  41023. */
  41024. get buttonBack(): number;
  41025. /**
  41026. * Sets the value of the `Back` button
  41027. */
  41028. set buttonBack(value: number);
  41029. /**
  41030. * Gets the value of the `Left` button
  41031. */
  41032. get buttonLB(): number;
  41033. /**
  41034. * Sets the value of the `Left` button
  41035. */
  41036. set buttonLB(value: number);
  41037. /**
  41038. * Gets the value of the `Right` button
  41039. */
  41040. get buttonRB(): number;
  41041. /**
  41042. * Sets the value of the `Right` button
  41043. */
  41044. set buttonRB(value: number);
  41045. /**
  41046. * Gets the value of the Left joystick
  41047. */
  41048. get buttonLeftStick(): number;
  41049. /**
  41050. * Sets the value of the Left joystick
  41051. */
  41052. set buttonLeftStick(value: number);
  41053. /**
  41054. * Gets the value of the Right joystick
  41055. */
  41056. get buttonRightStick(): number;
  41057. /**
  41058. * Sets the value of the Right joystick
  41059. */
  41060. set buttonRightStick(value: number);
  41061. /**
  41062. * Gets the value of D-pad up
  41063. */
  41064. get dPadUp(): number;
  41065. /**
  41066. * Sets the value of D-pad up
  41067. */
  41068. set dPadUp(value: number);
  41069. /**
  41070. * Gets the value of D-pad down
  41071. */
  41072. get dPadDown(): number;
  41073. /**
  41074. * Sets the value of D-pad down
  41075. */
  41076. set dPadDown(value: number);
  41077. /**
  41078. * Gets the value of D-pad left
  41079. */
  41080. get dPadLeft(): number;
  41081. /**
  41082. * Sets the value of D-pad left
  41083. */
  41084. set dPadLeft(value: number);
  41085. /**
  41086. * Gets the value of D-pad right
  41087. */
  41088. get dPadRight(): number;
  41089. /**
  41090. * Sets the value of D-pad right
  41091. */
  41092. set dPadRight(value: number);
  41093. /**
  41094. * Force the gamepad to synchronize with device values
  41095. */
  41096. update(): void;
  41097. /**
  41098. * Disposes the gamepad
  41099. */
  41100. dispose(): void;
  41101. }
  41102. }
  41103. declare module BABYLON {
  41104. /**
  41105. * Defines supported buttons for DualShock compatible gamepads
  41106. */
  41107. export enum DualShockButton {
  41108. /** Cross */
  41109. Cross = 0,
  41110. /** Circle */
  41111. Circle = 1,
  41112. /** Square */
  41113. Square = 2,
  41114. /** Triangle */
  41115. Triangle = 3,
  41116. /** Options */
  41117. Options = 4,
  41118. /** Share */
  41119. Share = 5,
  41120. /** L1 */
  41121. L1 = 6,
  41122. /** R1 */
  41123. R1 = 7,
  41124. /** Left stick */
  41125. LeftStick = 8,
  41126. /** Right stick */
  41127. RightStick = 9
  41128. }
  41129. /** Defines values for DualShock DPad */
  41130. export enum DualShockDpad {
  41131. /** Up */
  41132. Up = 0,
  41133. /** Down */
  41134. Down = 1,
  41135. /** Left */
  41136. Left = 2,
  41137. /** Right */
  41138. Right = 3
  41139. }
  41140. /**
  41141. * Defines a DualShock gamepad
  41142. */
  41143. export class DualShockPad extends Gamepad {
  41144. private _leftTrigger;
  41145. private _rightTrigger;
  41146. private _onlefttriggerchanged;
  41147. private _onrighttriggerchanged;
  41148. private _onbuttondown;
  41149. private _onbuttonup;
  41150. private _ondpaddown;
  41151. private _ondpadup;
  41152. /** Observable raised when a button is pressed */
  41153. onButtonDownObservable: Observable<DualShockButton>;
  41154. /** Observable raised when a button is released */
  41155. onButtonUpObservable: Observable<DualShockButton>;
  41156. /** Observable raised when a pad is pressed */
  41157. onPadDownObservable: Observable<DualShockDpad>;
  41158. /** Observable raised when a pad is released */
  41159. onPadUpObservable: Observable<DualShockDpad>;
  41160. private _buttonCross;
  41161. private _buttonCircle;
  41162. private _buttonSquare;
  41163. private _buttonTriangle;
  41164. private _buttonShare;
  41165. private _buttonOptions;
  41166. private _buttonL1;
  41167. private _buttonR1;
  41168. private _buttonLeftStick;
  41169. private _buttonRightStick;
  41170. private _dPadUp;
  41171. private _dPadDown;
  41172. private _dPadLeft;
  41173. private _dPadRight;
  41174. /**
  41175. * Creates a new DualShock gamepad object
  41176. * @param id defines the id of this gamepad
  41177. * @param index defines its index
  41178. * @param gamepad defines the internal HTML gamepad object
  41179. */
  41180. constructor(id: string, index: number, gamepad: any);
  41181. /**
  41182. * Defines the callback to call when left trigger is pressed
  41183. * @param callback defines the callback to use
  41184. */
  41185. onlefttriggerchanged(callback: (value: number) => void): void;
  41186. /**
  41187. * Defines the callback to call when right trigger is pressed
  41188. * @param callback defines the callback to use
  41189. */
  41190. onrighttriggerchanged(callback: (value: number) => void): void;
  41191. /**
  41192. * Gets the left trigger value
  41193. */
  41194. get leftTrigger(): number;
  41195. /**
  41196. * Sets the left trigger value
  41197. */
  41198. set leftTrigger(newValue: number);
  41199. /**
  41200. * Gets the right trigger value
  41201. */
  41202. get rightTrigger(): number;
  41203. /**
  41204. * Sets the right trigger value
  41205. */
  41206. set rightTrigger(newValue: number);
  41207. /**
  41208. * Defines the callback to call when a button is pressed
  41209. * @param callback defines the callback to use
  41210. */
  41211. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41212. /**
  41213. * Defines the callback to call when a button is released
  41214. * @param callback defines the callback to use
  41215. */
  41216. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41217. /**
  41218. * Defines the callback to call when a pad is pressed
  41219. * @param callback defines the callback to use
  41220. */
  41221. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41222. /**
  41223. * Defines the callback to call when a pad is released
  41224. * @param callback defines the callback to use
  41225. */
  41226. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41227. private _setButtonValue;
  41228. private _setDPadValue;
  41229. /**
  41230. * Gets the value of the `Cross` button
  41231. */
  41232. get buttonCross(): number;
  41233. /**
  41234. * Sets the value of the `Cross` button
  41235. */
  41236. set buttonCross(value: number);
  41237. /**
  41238. * Gets the value of the `Circle` button
  41239. */
  41240. get buttonCircle(): number;
  41241. /**
  41242. * Sets the value of the `Circle` button
  41243. */
  41244. set buttonCircle(value: number);
  41245. /**
  41246. * Gets the value of the `Square` button
  41247. */
  41248. get buttonSquare(): number;
  41249. /**
  41250. * Sets the value of the `Square` button
  41251. */
  41252. set buttonSquare(value: number);
  41253. /**
  41254. * Gets the value of the `Triangle` button
  41255. */
  41256. get buttonTriangle(): number;
  41257. /**
  41258. * Sets the value of the `Triangle` button
  41259. */
  41260. set buttonTriangle(value: number);
  41261. /**
  41262. * Gets the value of the `Options` button
  41263. */
  41264. get buttonOptions(): number;
  41265. /**
  41266. * Sets the value of the `Options` button
  41267. */
  41268. set buttonOptions(value: number);
  41269. /**
  41270. * Gets the value of the `Share` button
  41271. */
  41272. get buttonShare(): number;
  41273. /**
  41274. * Sets the value of the `Share` button
  41275. */
  41276. set buttonShare(value: number);
  41277. /**
  41278. * Gets the value of the `L1` button
  41279. */
  41280. get buttonL1(): number;
  41281. /**
  41282. * Sets the value of the `L1` button
  41283. */
  41284. set buttonL1(value: number);
  41285. /**
  41286. * Gets the value of the `R1` button
  41287. */
  41288. get buttonR1(): number;
  41289. /**
  41290. * Sets the value of the `R1` button
  41291. */
  41292. set buttonR1(value: number);
  41293. /**
  41294. * Gets the value of the Left joystick
  41295. */
  41296. get buttonLeftStick(): number;
  41297. /**
  41298. * Sets the value of the Left joystick
  41299. */
  41300. set buttonLeftStick(value: number);
  41301. /**
  41302. * Gets the value of the Right joystick
  41303. */
  41304. get buttonRightStick(): number;
  41305. /**
  41306. * Sets the value of the Right joystick
  41307. */
  41308. set buttonRightStick(value: number);
  41309. /**
  41310. * Gets the value of D-pad up
  41311. */
  41312. get dPadUp(): number;
  41313. /**
  41314. * Sets the value of D-pad up
  41315. */
  41316. set dPadUp(value: number);
  41317. /**
  41318. * Gets the value of D-pad down
  41319. */
  41320. get dPadDown(): number;
  41321. /**
  41322. * Sets the value of D-pad down
  41323. */
  41324. set dPadDown(value: number);
  41325. /**
  41326. * Gets the value of D-pad left
  41327. */
  41328. get dPadLeft(): number;
  41329. /**
  41330. * Sets the value of D-pad left
  41331. */
  41332. set dPadLeft(value: number);
  41333. /**
  41334. * Gets the value of D-pad right
  41335. */
  41336. get dPadRight(): number;
  41337. /**
  41338. * Sets the value of D-pad right
  41339. */
  41340. set dPadRight(value: number);
  41341. /**
  41342. * Force the gamepad to synchronize with device values
  41343. */
  41344. update(): void;
  41345. /**
  41346. * Disposes the gamepad
  41347. */
  41348. dispose(): void;
  41349. }
  41350. }
  41351. declare module BABYLON {
  41352. /**
  41353. * Manager for handling gamepads
  41354. */
  41355. export class GamepadManager {
  41356. private _scene?;
  41357. private _babylonGamepads;
  41358. private _oneGamepadConnected;
  41359. /** @hidden */
  41360. _isMonitoring: boolean;
  41361. private _gamepadEventSupported;
  41362. private _gamepadSupport?;
  41363. /**
  41364. * observable to be triggered when the gamepad controller has been connected
  41365. */
  41366. onGamepadConnectedObservable: Observable<Gamepad>;
  41367. /**
  41368. * observable to be triggered when the gamepad controller has been disconnected
  41369. */
  41370. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41371. private _onGamepadConnectedEvent;
  41372. private _onGamepadDisconnectedEvent;
  41373. /**
  41374. * Initializes the gamepad manager
  41375. * @param _scene BabylonJS scene
  41376. */
  41377. constructor(_scene?: Scene | undefined);
  41378. /**
  41379. * The gamepads in the game pad manager
  41380. */
  41381. get gamepads(): Gamepad[];
  41382. /**
  41383. * Get the gamepad controllers based on type
  41384. * @param type The type of gamepad controller
  41385. * @returns Nullable gamepad
  41386. */
  41387. getGamepadByType(type?: number): Nullable<Gamepad>;
  41388. /**
  41389. * Disposes the gamepad manager
  41390. */
  41391. dispose(): void;
  41392. private _addNewGamepad;
  41393. private _startMonitoringGamepads;
  41394. private _stopMonitoringGamepads;
  41395. /** @hidden */
  41396. _checkGamepadsStatus(): void;
  41397. private _updateGamepadObjects;
  41398. }
  41399. }
  41400. declare module BABYLON {
  41401. interface Scene {
  41402. /** @hidden */
  41403. _gamepadManager: Nullable<GamepadManager>;
  41404. /**
  41405. * Gets the gamepad manager associated with the scene
  41406. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41407. */
  41408. gamepadManager: GamepadManager;
  41409. }
  41410. /**
  41411. * Interface representing a free camera inputs manager
  41412. */
  41413. interface FreeCameraInputsManager {
  41414. /**
  41415. * Adds gamepad input support to the FreeCameraInputsManager.
  41416. * @returns the FreeCameraInputsManager
  41417. */
  41418. addGamepad(): FreeCameraInputsManager;
  41419. }
  41420. /**
  41421. * Interface representing an arc rotate camera inputs manager
  41422. */
  41423. interface ArcRotateCameraInputsManager {
  41424. /**
  41425. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41426. * @returns the camera inputs manager
  41427. */
  41428. addGamepad(): ArcRotateCameraInputsManager;
  41429. }
  41430. /**
  41431. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41432. */
  41433. export class GamepadSystemSceneComponent implements ISceneComponent {
  41434. /**
  41435. * The component name helpfull to identify the component in the list of scene components.
  41436. */
  41437. readonly name: string;
  41438. /**
  41439. * The scene the component belongs to.
  41440. */
  41441. scene: Scene;
  41442. /**
  41443. * Creates a new instance of the component for the given scene
  41444. * @param scene Defines the scene to register the component in
  41445. */
  41446. constructor(scene: Scene);
  41447. /**
  41448. * Registers the component in a given scene
  41449. */
  41450. register(): void;
  41451. /**
  41452. * Rebuilds the elements related to this component in case of
  41453. * context lost for instance.
  41454. */
  41455. rebuild(): void;
  41456. /**
  41457. * Disposes the component and the associated ressources
  41458. */
  41459. dispose(): void;
  41460. private _beforeCameraUpdate;
  41461. }
  41462. }
  41463. declare module BABYLON {
  41464. /**
  41465. * 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,
  41466. * which still works and will still be found in many Playgrounds.
  41467. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41468. */
  41469. export class UniversalCamera extends TouchCamera {
  41470. /**
  41471. * Defines the gamepad rotation sensiblity.
  41472. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41473. */
  41474. get gamepadAngularSensibility(): number;
  41475. set gamepadAngularSensibility(value: number);
  41476. /**
  41477. * Defines the gamepad move sensiblity.
  41478. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41479. */
  41480. get gamepadMoveSensibility(): number;
  41481. set gamepadMoveSensibility(value: number);
  41482. /**
  41483. * 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,
  41484. * which still works and will still be found in many Playgrounds.
  41485. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41486. * @param name Define the name of the camera in the scene
  41487. * @param position Define the start position of the camera in the scene
  41488. * @param scene Define the scene the camera belongs to
  41489. */
  41490. constructor(name: string, position: Vector3, scene: Scene);
  41491. /**
  41492. * Gets the current object class name.
  41493. * @return the class name
  41494. */
  41495. getClassName(): string;
  41496. }
  41497. }
  41498. declare module BABYLON {
  41499. /**
  41500. * This represents a FPS type of camera. This is only here for back compat purpose.
  41501. * Please use the UniversalCamera instead as both are identical.
  41502. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41503. */
  41504. export class GamepadCamera extends UniversalCamera {
  41505. /**
  41506. * Instantiates a new Gamepad Camera
  41507. * This represents a FPS type of camera. This is only here for back compat purpose.
  41508. * Please use the UniversalCamera instead as both are identical.
  41509. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41510. * @param name Define the name of the camera in the scene
  41511. * @param position Define the start position of the camera in the scene
  41512. * @param scene Define the scene the camera belongs to
  41513. */
  41514. constructor(name: string, position: Vector3, scene: Scene);
  41515. /**
  41516. * Gets the current object class name.
  41517. * @return the class name
  41518. */
  41519. getClassName(): string;
  41520. }
  41521. }
  41522. declare module BABYLON {
  41523. /** @hidden */
  41524. export var passPixelShader: {
  41525. name: string;
  41526. shader: string;
  41527. };
  41528. }
  41529. declare module BABYLON {
  41530. /** @hidden */
  41531. export var passCubePixelShader: {
  41532. name: string;
  41533. shader: string;
  41534. };
  41535. }
  41536. declare module BABYLON {
  41537. /**
  41538. * PassPostProcess which produces an output the same as it's input
  41539. */
  41540. export class PassPostProcess extends PostProcess {
  41541. /**
  41542. * Creates the PassPostProcess
  41543. * @param name The name of the effect.
  41544. * @param options The required width/height ratio to downsize to before computing the render pass.
  41545. * @param camera The camera to apply the render pass to.
  41546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41547. * @param engine The engine which the post process will be applied. (default: current engine)
  41548. * @param reusable If the post process can be reused on the same frame. (default: false)
  41549. * @param textureType The type of texture to be used when performing the post processing.
  41550. * @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)
  41551. */
  41552. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41553. }
  41554. /**
  41555. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41556. */
  41557. export class PassCubePostProcess extends PostProcess {
  41558. private _face;
  41559. /**
  41560. * Gets or sets the cube face to display.
  41561. * * 0 is +X
  41562. * * 1 is -X
  41563. * * 2 is +Y
  41564. * * 3 is -Y
  41565. * * 4 is +Z
  41566. * * 5 is -Z
  41567. */
  41568. get face(): number;
  41569. set face(value: number);
  41570. /**
  41571. * Creates the PassCubePostProcess
  41572. * @param name The name of the effect.
  41573. * @param options The required width/height ratio to downsize to before computing the render pass.
  41574. * @param camera The camera to apply the render pass to.
  41575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41576. * @param engine The engine which the post process will be applied. (default: current engine)
  41577. * @param reusable If the post process can be reused on the same frame. (default: false)
  41578. * @param textureType The type of texture to be used when performing the post processing.
  41579. * @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)
  41580. */
  41581. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41582. }
  41583. }
  41584. declare module BABYLON {
  41585. /** @hidden */
  41586. export var anaglyphPixelShader: {
  41587. name: string;
  41588. shader: string;
  41589. };
  41590. }
  41591. declare module BABYLON {
  41592. /**
  41593. * Postprocess used to generate anaglyphic rendering
  41594. */
  41595. export class AnaglyphPostProcess extends PostProcess {
  41596. private _passedProcess;
  41597. /**
  41598. * Creates a new AnaglyphPostProcess
  41599. * @param name defines postprocess name
  41600. * @param options defines creation options or target ratio scale
  41601. * @param rigCameras defines cameras using this postprocess
  41602. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41603. * @param engine defines hosting engine
  41604. * @param reusable defines if the postprocess will be reused multiple times per frame
  41605. */
  41606. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41607. }
  41608. }
  41609. declare module BABYLON {
  41610. /**
  41611. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41612. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41613. */
  41614. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41615. /**
  41616. * Creates a new AnaglyphArcRotateCamera
  41617. * @param name defines camera name
  41618. * @param alpha defines alpha angle (in radians)
  41619. * @param beta defines beta angle (in radians)
  41620. * @param radius defines radius
  41621. * @param target defines camera target
  41622. * @param interaxialDistance defines distance between each color axis
  41623. * @param scene defines the hosting scene
  41624. */
  41625. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41626. /**
  41627. * Gets camera class name
  41628. * @returns AnaglyphArcRotateCamera
  41629. */
  41630. getClassName(): string;
  41631. }
  41632. }
  41633. declare module BABYLON {
  41634. /**
  41635. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41636. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41637. */
  41638. export class AnaglyphFreeCamera extends FreeCamera {
  41639. /**
  41640. * Creates a new AnaglyphFreeCamera
  41641. * @param name defines camera name
  41642. * @param position defines initial position
  41643. * @param interaxialDistance defines distance between each color axis
  41644. * @param scene defines the hosting scene
  41645. */
  41646. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41647. /**
  41648. * Gets camera class name
  41649. * @returns AnaglyphFreeCamera
  41650. */
  41651. getClassName(): string;
  41652. }
  41653. }
  41654. declare module BABYLON {
  41655. /**
  41656. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41657. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41658. */
  41659. export class AnaglyphGamepadCamera extends GamepadCamera {
  41660. /**
  41661. * Creates a new AnaglyphGamepadCamera
  41662. * @param name defines camera name
  41663. * @param position defines initial position
  41664. * @param interaxialDistance defines distance between each color axis
  41665. * @param scene defines the hosting scene
  41666. */
  41667. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41668. /**
  41669. * Gets camera class name
  41670. * @returns AnaglyphGamepadCamera
  41671. */
  41672. getClassName(): string;
  41673. }
  41674. }
  41675. declare module BABYLON {
  41676. /**
  41677. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41678. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41679. */
  41680. export class AnaglyphUniversalCamera extends UniversalCamera {
  41681. /**
  41682. * Creates a new AnaglyphUniversalCamera
  41683. * @param name defines camera name
  41684. * @param position defines initial position
  41685. * @param interaxialDistance defines distance between each color axis
  41686. * @param scene defines the hosting scene
  41687. */
  41688. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41689. /**
  41690. * Gets camera class name
  41691. * @returns AnaglyphUniversalCamera
  41692. */
  41693. getClassName(): string;
  41694. }
  41695. }
  41696. declare module BABYLON {
  41697. /** @hidden */
  41698. export var stereoscopicInterlacePixelShader: {
  41699. name: string;
  41700. shader: string;
  41701. };
  41702. }
  41703. declare module BABYLON {
  41704. /**
  41705. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41706. */
  41707. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41708. private _stepSize;
  41709. private _passedProcess;
  41710. /**
  41711. * Initializes a StereoscopicInterlacePostProcessI
  41712. * @param name The name of the effect.
  41713. * @param rigCameras The rig cameras to be appled to the post process
  41714. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41715. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41716. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41717. * @param engine The engine which the post process will be applied. (default: current engine)
  41718. * @param reusable If the post process can be reused on the same frame. (default: false)
  41719. */
  41720. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41721. }
  41722. /**
  41723. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41724. */
  41725. export class StereoscopicInterlacePostProcess extends PostProcess {
  41726. private _stepSize;
  41727. private _passedProcess;
  41728. /**
  41729. * Initializes a StereoscopicInterlacePostProcess
  41730. * @param name The name of the effect.
  41731. * @param rigCameras The rig cameras to be appled to the post process
  41732. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41734. * @param engine The engine which the post process will be applied. (default: current engine)
  41735. * @param reusable If the post process can be reused on the same frame. (default: false)
  41736. */
  41737. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41738. }
  41739. }
  41740. declare module BABYLON {
  41741. /**
  41742. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41743. * @see http://doc.babylonjs.com/features/cameras
  41744. */
  41745. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41746. /**
  41747. * Creates a new StereoscopicArcRotateCamera
  41748. * @param name defines camera name
  41749. * @param alpha defines alpha angle (in radians)
  41750. * @param beta defines beta angle (in radians)
  41751. * @param radius defines radius
  41752. * @param target defines camera target
  41753. * @param interaxialDistance defines distance between each color axis
  41754. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41755. * @param scene defines the hosting scene
  41756. */
  41757. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41758. /**
  41759. * Gets camera class name
  41760. * @returns StereoscopicArcRotateCamera
  41761. */
  41762. getClassName(): string;
  41763. }
  41764. }
  41765. declare module BABYLON {
  41766. /**
  41767. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41768. * @see http://doc.babylonjs.com/features/cameras
  41769. */
  41770. export class StereoscopicFreeCamera extends FreeCamera {
  41771. /**
  41772. * Creates a new StereoscopicFreeCamera
  41773. * @param name defines camera name
  41774. * @param position defines initial position
  41775. * @param interaxialDistance defines distance between each color axis
  41776. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41777. * @param scene defines the hosting scene
  41778. */
  41779. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41780. /**
  41781. * Gets camera class name
  41782. * @returns StereoscopicFreeCamera
  41783. */
  41784. getClassName(): string;
  41785. }
  41786. }
  41787. declare module BABYLON {
  41788. /**
  41789. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41790. * @see http://doc.babylonjs.com/features/cameras
  41791. */
  41792. export class StereoscopicGamepadCamera extends GamepadCamera {
  41793. /**
  41794. * Creates a new StereoscopicGamepadCamera
  41795. * @param name defines camera name
  41796. * @param position defines initial position
  41797. * @param interaxialDistance defines distance between each color axis
  41798. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41799. * @param scene defines the hosting scene
  41800. */
  41801. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41802. /**
  41803. * Gets camera class name
  41804. * @returns StereoscopicGamepadCamera
  41805. */
  41806. getClassName(): string;
  41807. }
  41808. }
  41809. declare module BABYLON {
  41810. /**
  41811. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41812. * @see http://doc.babylonjs.com/features/cameras
  41813. */
  41814. export class StereoscopicUniversalCamera extends UniversalCamera {
  41815. /**
  41816. * Creates a new StereoscopicUniversalCamera
  41817. * @param name defines camera name
  41818. * @param position defines initial position
  41819. * @param interaxialDistance defines distance between each color axis
  41820. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41821. * @param scene defines the hosting scene
  41822. */
  41823. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41824. /**
  41825. * Gets camera class name
  41826. * @returns StereoscopicUniversalCamera
  41827. */
  41828. getClassName(): string;
  41829. }
  41830. }
  41831. declare module BABYLON {
  41832. /**
  41833. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41834. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41835. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41836. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41837. */
  41838. export class VirtualJoysticksCamera extends FreeCamera {
  41839. /**
  41840. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41841. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41842. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41843. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41844. * @param name Define the name of the camera in the scene
  41845. * @param position Define the start position of the camera in the scene
  41846. * @param scene Define the scene the camera belongs to
  41847. */
  41848. constructor(name: string, position: Vector3, scene: Scene);
  41849. /**
  41850. * Gets the current object class name.
  41851. * @return the class name
  41852. */
  41853. getClassName(): string;
  41854. }
  41855. }
  41856. declare module BABYLON {
  41857. /**
  41858. * This represents all the required metrics to create a VR camera.
  41859. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41860. */
  41861. export class VRCameraMetrics {
  41862. /**
  41863. * Define the horizontal resolution off the screen.
  41864. */
  41865. hResolution: number;
  41866. /**
  41867. * Define the vertical resolution off the screen.
  41868. */
  41869. vResolution: number;
  41870. /**
  41871. * Define the horizontal screen size.
  41872. */
  41873. hScreenSize: number;
  41874. /**
  41875. * Define the vertical screen size.
  41876. */
  41877. vScreenSize: number;
  41878. /**
  41879. * Define the vertical screen center position.
  41880. */
  41881. vScreenCenter: number;
  41882. /**
  41883. * Define the distance of the eyes to the screen.
  41884. */
  41885. eyeToScreenDistance: number;
  41886. /**
  41887. * Define the distance between both lenses
  41888. */
  41889. lensSeparationDistance: number;
  41890. /**
  41891. * Define the distance between both viewer's eyes.
  41892. */
  41893. interpupillaryDistance: number;
  41894. /**
  41895. * Define the distortion factor of the VR postprocess.
  41896. * Please, touch with care.
  41897. */
  41898. distortionK: number[];
  41899. /**
  41900. * Define the chromatic aberration correction factors for the VR post process.
  41901. */
  41902. chromaAbCorrection: number[];
  41903. /**
  41904. * Define the scale factor of the post process.
  41905. * The smaller the better but the slower.
  41906. */
  41907. postProcessScaleFactor: number;
  41908. /**
  41909. * Define an offset for the lens center.
  41910. */
  41911. lensCenterOffset: number;
  41912. /**
  41913. * Define if the current vr camera should compensate the distortion of the lense or not.
  41914. */
  41915. compensateDistortion: boolean;
  41916. /**
  41917. * Defines if multiview should be enabled when rendering (Default: false)
  41918. */
  41919. multiviewEnabled: boolean;
  41920. /**
  41921. * Gets the rendering aspect ratio based on the provided resolutions.
  41922. */
  41923. get aspectRatio(): number;
  41924. /**
  41925. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41926. */
  41927. get aspectRatioFov(): number;
  41928. /**
  41929. * @hidden
  41930. */
  41931. get leftHMatrix(): Matrix;
  41932. /**
  41933. * @hidden
  41934. */
  41935. get rightHMatrix(): Matrix;
  41936. /**
  41937. * @hidden
  41938. */
  41939. get leftPreViewMatrix(): Matrix;
  41940. /**
  41941. * @hidden
  41942. */
  41943. get rightPreViewMatrix(): Matrix;
  41944. /**
  41945. * Get the default VRMetrics based on the most generic setup.
  41946. * @returns the default vr metrics
  41947. */
  41948. static GetDefault(): VRCameraMetrics;
  41949. }
  41950. }
  41951. declare module BABYLON {
  41952. /** @hidden */
  41953. export var vrDistortionCorrectionPixelShader: {
  41954. name: string;
  41955. shader: string;
  41956. };
  41957. }
  41958. declare module BABYLON {
  41959. /**
  41960. * VRDistortionCorrectionPostProcess used for mobile VR
  41961. */
  41962. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41963. private _isRightEye;
  41964. private _distortionFactors;
  41965. private _postProcessScaleFactor;
  41966. private _lensCenterOffset;
  41967. private _scaleIn;
  41968. private _scaleFactor;
  41969. private _lensCenter;
  41970. /**
  41971. * Initializes the VRDistortionCorrectionPostProcess
  41972. * @param name The name of the effect.
  41973. * @param camera The camera to apply the render pass to.
  41974. * @param isRightEye If this is for the right eye distortion
  41975. * @param vrMetrics All the required metrics for the VR camera
  41976. */
  41977. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41978. }
  41979. }
  41980. declare module BABYLON {
  41981. /**
  41982. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41983. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41984. */
  41985. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41986. /**
  41987. * Creates a new VRDeviceOrientationArcRotateCamera
  41988. * @param name defines camera name
  41989. * @param alpha defines the camera rotation along the logitudinal axis
  41990. * @param beta defines the camera rotation along the latitudinal axis
  41991. * @param radius defines the camera distance from its target
  41992. * @param target defines the camera target
  41993. * @param scene defines the scene the camera belongs to
  41994. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41995. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41996. */
  41997. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41998. /**
  41999. * Gets camera class name
  42000. * @returns VRDeviceOrientationArcRotateCamera
  42001. */
  42002. getClassName(): string;
  42003. }
  42004. }
  42005. declare module BABYLON {
  42006. /**
  42007. * Camera used to simulate VR rendering (based on FreeCamera)
  42008. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42009. */
  42010. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42011. /**
  42012. * Creates a new VRDeviceOrientationFreeCamera
  42013. * @param name defines camera name
  42014. * @param position defines the start position of the camera
  42015. * @param scene defines the scene the camera belongs to
  42016. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42017. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42018. */
  42019. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42020. /**
  42021. * Gets camera class name
  42022. * @returns VRDeviceOrientationFreeCamera
  42023. */
  42024. getClassName(): string;
  42025. }
  42026. }
  42027. declare module BABYLON {
  42028. /**
  42029. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42030. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42031. */
  42032. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42033. /**
  42034. * Creates a new VRDeviceOrientationGamepadCamera
  42035. * @param name defines camera name
  42036. * @param position defines the start position of the camera
  42037. * @param scene defines the scene the camera belongs to
  42038. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42039. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42040. */
  42041. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42042. /**
  42043. * Gets camera class name
  42044. * @returns VRDeviceOrientationGamepadCamera
  42045. */
  42046. getClassName(): string;
  42047. }
  42048. }
  42049. declare module BABYLON {
  42050. /** @hidden */
  42051. export var imageProcessingPixelShader: {
  42052. name: string;
  42053. shader: string;
  42054. };
  42055. }
  42056. declare module BABYLON {
  42057. /**
  42058. * ImageProcessingPostProcess
  42059. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42060. */
  42061. export class ImageProcessingPostProcess extends PostProcess {
  42062. /**
  42063. * Default configuration related to image processing available in the PBR Material.
  42064. */
  42065. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42066. /**
  42067. * Gets the image processing configuration used either in this material.
  42068. */
  42069. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42070. /**
  42071. * Sets the Default image processing configuration used either in the this material.
  42072. *
  42073. * If sets to null, the scene one is in use.
  42074. */
  42075. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42076. /**
  42077. * Keep track of the image processing observer to allow dispose and replace.
  42078. */
  42079. private _imageProcessingObserver;
  42080. /**
  42081. * Attaches a new image processing configuration to the PBR Material.
  42082. * @param configuration
  42083. */
  42084. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42085. /**
  42086. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42087. */
  42088. get colorCurves(): Nullable<ColorCurves>;
  42089. /**
  42090. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42091. */
  42092. set colorCurves(value: Nullable<ColorCurves>);
  42093. /**
  42094. * Gets wether the color curves effect is enabled.
  42095. */
  42096. get colorCurvesEnabled(): boolean;
  42097. /**
  42098. * Sets wether the color curves effect is enabled.
  42099. */
  42100. set colorCurvesEnabled(value: boolean);
  42101. /**
  42102. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42103. */
  42104. get colorGradingTexture(): Nullable<BaseTexture>;
  42105. /**
  42106. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42107. */
  42108. set colorGradingTexture(value: Nullable<BaseTexture>);
  42109. /**
  42110. * Gets wether the color grading effect is enabled.
  42111. */
  42112. get colorGradingEnabled(): boolean;
  42113. /**
  42114. * Gets wether the color grading effect is enabled.
  42115. */
  42116. set colorGradingEnabled(value: boolean);
  42117. /**
  42118. * Gets exposure used in the effect.
  42119. */
  42120. get exposure(): number;
  42121. /**
  42122. * Sets exposure used in the effect.
  42123. */
  42124. set exposure(value: number);
  42125. /**
  42126. * Gets wether tonemapping is enabled or not.
  42127. */
  42128. get toneMappingEnabled(): boolean;
  42129. /**
  42130. * Sets wether tonemapping is enabled or not
  42131. */
  42132. set toneMappingEnabled(value: boolean);
  42133. /**
  42134. * Gets the type of tone mapping effect.
  42135. */
  42136. get toneMappingType(): number;
  42137. /**
  42138. * Sets the type of tone mapping effect.
  42139. */
  42140. set toneMappingType(value: number);
  42141. /**
  42142. * Gets contrast used in the effect.
  42143. */
  42144. get contrast(): number;
  42145. /**
  42146. * Sets contrast used in the effect.
  42147. */
  42148. set contrast(value: number);
  42149. /**
  42150. * Gets Vignette stretch size.
  42151. */
  42152. get vignetteStretch(): number;
  42153. /**
  42154. * Sets Vignette stretch size.
  42155. */
  42156. set vignetteStretch(value: number);
  42157. /**
  42158. * Gets Vignette centre X Offset.
  42159. */
  42160. get vignetteCentreX(): number;
  42161. /**
  42162. * Sets Vignette centre X Offset.
  42163. */
  42164. set vignetteCentreX(value: number);
  42165. /**
  42166. * Gets Vignette centre Y Offset.
  42167. */
  42168. get vignetteCentreY(): number;
  42169. /**
  42170. * Sets Vignette centre Y Offset.
  42171. */
  42172. set vignetteCentreY(value: number);
  42173. /**
  42174. * Gets Vignette weight or intensity of the vignette effect.
  42175. */
  42176. get vignetteWeight(): number;
  42177. /**
  42178. * Sets Vignette weight or intensity of the vignette effect.
  42179. */
  42180. set vignetteWeight(value: number);
  42181. /**
  42182. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42183. * if vignetteEnabled is set to true.
  42184. */
  42185. get vignetteColor(): Color4;
  42186. /**
  42187. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42188. * if vignetteEnabled is set to true.
  42189. */
  42190. set vignetteColor(value: Color4);
  42191. /**
  42192. * Gets Camera field of view used by the Vignette effect.
  42193. */
  42194. get vignetteCameraFov(): number;
  42195. /**
  42196. * Sets Camera field of view used by the Vignette effect.
  42197. */
  42198. set vignetteCameraFov(value: number);
  42199. /**
  42200. * Gets the vignette blend mode allowing different kind of effect.
  42201. */
  42202. get vignetteBlendMode(): number;
  42203. /**
  42204. * Sets the vignette blend mode allowing different kind of effect.
  42205. */
  42206. set vignetteBlendMode(value: number);
  42207. /**
  42208. * Gets wether the vignette effect is enabled.
  42209. */
  42210. get vignetteEnabled(): boolean;
  42211. /**
  42212. * Sets wether the vignette effect is enabled.
  42213. */
  42214. set vignetteEnabled(value: boolean);
  42215. private _fromLinearSpace;
  42216. /**
  42217. * Gets wether the input of the processing is in Gamma or Linear Space.
  42218. */
  42219. get fromLinearSpace(): boolean;
  42220. /**
  42221. * Sets wether the input of the processing is in Gamma or Linear Space.
  42222. */
  42223. set fromLinearSpace(value: boolean);
  42224. /**
  42225. * Defines cache preventing GC.
  42226. */
  42227. private _defines;
  42228. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42229. /**
  42230. * "ImageProcessingPostProcess"
  42231. * @returns "ImageProcessingPostProcess"
  42232. */
  42233. getClassName(): string;
  42234. protected _updateParameters(): void;
  42235. dispose(camera?: Camera): void;
  42236. }
  42237. }
  42238. declare module BABYLON {
  42239. /**
  42240. * Class containing static functions to help procedurally build meshes
  42241. */
  42242. export class GroundBuilder {
  42243. /**
  42244. * Creates a ground mesh
  42245. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42246. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42248. * @param name defines the name of the mesh
  42249. * @param options defines the options used to create the mesh
  42250. * @param scene defines the hosting scene
  42251. * @returns the ground mesh
  42252. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42253. */
  42254. static CreateGround(name: string, options: {
  42255. width?: number;
  42256. height?: number;
  42257. subdivisions?: number;
  42258. subdivisionsX?: number;
  42259. subdivisionsY?: number;
  42260. updatable?: boolean;
  42261. }, scene: any): Mesh;
  42262. /**
  42263. * Creates a tiled ground mesh
  42264. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42265. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42266. * * 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
  42267. * * 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
  42268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42269. * @param name defines the name of the mesh
  42270. * @param options defines the options used to create the mesh
  42271. * @param scene defines the hosting scene
  42272. * @returns the tiled ground mesh
  42273. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42274. */
  42275. static CreateTiledGround(name: string, options: {
  42276. xmin: number;
  42277. zmin: number;
  42278. xmax: number;
  42279. zmax: number;
  42280. subdivisions?: {
  42281. w: number;
  42282. h: number;
  42283. };
  42284. precision?: {
  42285. w: number;
  42286. h: number;
  42287. };
  42288. updatable?: boolean;
  42289. }, scene?: Nullable<Scene>): Mesh;
  42290. /**
  42291. * Creates a ground mesh from a height map
  42292. * * The parameter `url` sets the URL of the height map image resource.
  42293. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42294. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42295. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42296. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42297. * * 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.
  42298. * * 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).
  42299. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42301. * @param name defines the name of the mesh
  42302. * @param url defines the url to the height map
  42303. * @param options defines the options used to create the mesh
  42304. * @param scene defines the hosting scene
  42305. * @returns the ground mesh
  42306. * @see https://doc.babylonjs.com/babylon101/height_map
  42307. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42308. */
  42309. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42310. width?: number;
  42311. height?: number;
  42312. subdivisions?: number;
  42313. minHeight?: number;
  42314. maxHeight?: number;
  42315. colorFilter?: Color3;
  42316. alphaFilter?: number;
  42317. updatable?: boolean;
  42318. onReady?: (mesh: GroundMesh) => void;
  42319. }, scene?: Nullable<Scene>): GroundMesh;
  42320. }
  42321. }
  42322. declare module BABYLON {
  42323. /**
  42324. * Class containing static functions to help procedurally build meshes
  42325. */
  42326. export class TorusBuilder {
  42327. /**
  42328. * Creates a torus mesh
  42329. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42330. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42331. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42333. * * 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
  42334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42335. * @param name defines the name of the mesh
  42336. * @param options defines the options used to create the mesh
  42337. * @param scene defines the hosting scene
  42338. * @returns the torus mesh
  42339. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42340. */
  42341. static CreateTorus(name: string, options: {
  42342. diameter?: number;
  42343. thickness?: number;
  42344. tessellation?: number;
  42345. updatable?: boolean;
  42346. sideOrientation?: number;
  42347. frontUVs?: Vector4;
  42348. backUVs?: Vector4;
  42349. }, scene: any): Mesh;
  42350. }
  42351. }
  42352. declare module BABYLON {
  42353. /**
  42354. * Class containing static functions to help procedurally build meshes
  42355. */
  42356. export class CylinderBuilder {
  42357. /**
  42358. * Creates a cylinder or a cone mesh
  42359. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42360. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42361. * * 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.
  42362. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42363. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42364. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42365. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42366. * * 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).
  42367. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42368. * * 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).
  42369. * * 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
  42370. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42371. * * 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
  42372. * * 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.
  42373. * * If `enclose` is false, a ring surface is one element.
  42374. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42375. * * 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
  42376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42377. * * 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
  42378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42379. * @param name defines the name of the mesh
  42380. * @param options defines the options used to create the mesh
  42381. * @param scene defines the hosting scene
  42382. * @returns the cylinder mesh
  42383. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42384. */
  42385. static CreateCylinder(name: string, options: {
  42386. height?: number;
  42387. diameterTop?: number;
  42388. diameterBottom?: number;
  42389. diameter?: number;
  42390. tessellation?: number;
  42391. subdivisions?: number;
  42392. arc?: number;
  42393. faceColors?: Color4[];
  42394. faceUV?: Vector4[];
  42395. updatable?: boolean;
  42396. hasRings?: boolean;
  42397. enclose?: boolean;
  42398. cap?: number;
  42399. sideOrientation?: number;
  42400. frontUVs?: Vector4;
  42401. backUVs?: Vector4;
  42402. }, scene: any): Mesh;
  42403. }
  42404. }
  42405. declare module BABYLON {
  42406. /**
  42407. * States of the webXR experience
  42408. */
  42409. export enum WebXRState {
  42410. /**
  42411. * Transitioning to being in XR mode
  42412. */
  42413. ENTERING_XR = 0,
  42414. /**
  42415. * Transitioning to non XR mode
  42416. */
  42417. EXITING_XR = 1,
  42418. /**
  42419. * In XR mode and presenting
  42420. */
  42421. IN_XR = 2,
  42422. /**
  42423. * Not entered XR mode
  42424. */
  42425. NOT_IN_XR = 3
  42426. }
  42427. /**
  42428. * Abstraction of the XR render target
  42429. */
  42430. export interface WebXRRenderTarget extends IDisposable {
  42431. /**
  42432. * xrpresent context of the canvas which can be used to display/mirror xr content
  42433. */
  42434. canvasContext: WebGLRenderingContext;
  42435. /**
  42436. * xr layer for the canvas
  42437. */
  42438. xrLayer: Nullable<XRWebGLLayer>;
  42439. /**
  42440. * Initializes the xr layer for the session
  42441. * @param xrSession xr session
  42442. * @returns a promise that will resolve once the XR Layer has been created
  42443. */
  42444. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42445. }
  42446. }
  42447. declare module BABYLON {
  42448. /**
  42449. * COnfiguration object for WebXR output canvas
  42450. */
  42451. export class WebXRManagedOutputCanvasOptions {
  42452. /**
  42453. * Options for this XR Layer output
  42454. */
  42455. canvasOptions?: XRWebGLLayerOptions;
  42456. /**
  42457. * CSS styling for a newly created canvas (if not provided)
  42458. */
  42459. newCanvasCssStyle?: string;
  42460. /**
  42461. * An optional canvas in case you wish to create it yourself and provide it here.
  42462. * If not provided, a new canvas will be created
  42463. */
  42464. canvasElement?: HTMLCanvasElement;
  42465. /**
  42466. * Get the default values of the configuration object
  42467. * @returns default values of this configuration object
  42468. */
  42469. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42470. }
  42471. /**
  42472. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42473. */
  42474. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42475. private _options;
  42476. private _engine;
  42477. private _canvas;
  42478. /**
  42479. * Rendering context of the canvas which can be used to display/mirror xr content
  42480. */
  42481. canvasContext: WebGLRenderingContext;
  42482. /**
  42483. * xr layer for the canvas
  42484. */
  42485. xrLayer: Nullable<XRWebGLLayer>;
  42486. /**
  42487. * Initializes the xr layer for the session
  42488. * @param xrSession xr session
  42489. * @returns a promise that will resolve once the XR Layer has been created
  42490. */
  42491. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42492. /**
  42493. * Initializes the canvas to be added/removed upon entering/exiting xr
  42494. * @param _xrSessionManager The XR Session manager
  42495. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42496. */
  42497. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42498. /**
  42499. * Disposes of the object
  42500. */
  42501. dispose(): void;
  42502. private _setManagedOutputCanvas;
  42503. private _addCanvas;
  42504. private _removeCanvas;
  42505. }
  42506. }
  42507. declare module BABYLON {
  42508. /**
  42509. * Manages an XRSession to work with Babylon's engine
  42510. * @see https://doc.babylonjs.com/how_to/webxr
  42511. */
  42512. export class WebXRSessionManager implements IDisposable {
  42513. /** The scene which the session should be created for */
  42514. scene: Scene;
  42515. /**
  42516. * Fires every time a new xrFrame arrives which can be used to update the camera
  42517. */
  42518. onXRFrameObservable: Observable<XRFrame>;
  42519. /**
  42520. * Fires when the xr session is ended either by the device or manually done
  42521. */
  42522. onXRSessionEnded: Observable<any>;
  42523. /**
  42524. * Fires when the xr session is ended either by the device or manually done
  42525. */
  42526. onXRSessionInit: Observable<XRSession>;
  42527. /**
  42528. * Fires when the reference space changed
  42529. */
  42530. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42531. /**
  42532. * Underlying xr session
  42533. */
  42534. session: XRSession;
  42535. /**
  42536. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42537. * or get the offset the player is currently at.
  42538. */
  42539. viewerReferenceSpace: XRReferenceSpace;
  42540. private _referenceSpace;
  42541. /**
  42542. * The current reference space used in this session. This reference space can constantly change!
  42543. * It is mainly used to offset the camera's position.
  42544. */
  42545. get referenceSpace(): XRReferenceSpace;
  42546. /**
  42547. * Set a new reference space and triggers the observable
  42548. */
  42549. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42550. /**
  42551. * The base reference space from which the session started. good if you want to reset your
  42552. * reference space
  42553. */
  42554. baseReferenceSpace: XRReferenceSpace;
  42555. /**
  42556. * Used just in case of a failure to initialize an immersive session.
  42557. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42558. */
  42559. defaultHeightCompensation: number;
  42560. /**
  42561. * Current XR frame
  42562. */
  42563. currentFrame: Nullable<XRFrame>;
  42564. /** WebXR timestamp updated every frame */
  42565. currentTimestamp: number;
  42566. private _xrNavigator;
  42567. private baseLayer;
  42568. private _rttProvider;
  42569. private _sessionEnded;
  42570. /**
  42571. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42572. * @param scene The scene which the session should be created for
  42573. */
  42574. constructor(
  42575. /** The scene which the session should be created for */
  42576. scene: Scene);
  42577. /**
  42578. * Initializes the manager
  42579. * After initialization enterXR can be called to start an XR session
  42580. * @returns Promise which resolves after it is initialized
  42581. */
  42582. initializeAsync(): Promise<void>;
  42583. /**
  42584. * Initializes an xr session
  42585. * @param xrSessionMode mode to initialize
  42586. * @param xrSessionInit defines optional and required values to pass to the session builder
  42587. * @returns a promise which will resolve once the session has been initialized
  42588. */
  42589. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42590. /**
  42591. * Sets the reference space on the xr session
  42592. * @param referenceSpaceType space to set
  42593. * @returns a promise that will resolve once the reference space has been set
  42594. */
  42595. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42596. /**
  42597. * Resets the reference space to the one started the session
  42598. */
  42599. resetReferenceSpace(): void;
  42600. /**
  42601. * Updates the render state of the session
  42602. * @param state state to set
  42603. * @returns a promise that resolves once the render state has been updated
  42604. */
  42605. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42606. /**
  42607. * Starts rendering to the xr layer
  42608. */
  42609. runXRRenderLoop(): void;
  42610. /**
  42611. * Gets the correct render target texture to be rendered this frame for this eye
  42612. * @param eye the eye for which to get the render target
  42613. * @returns the render target for the specified eye
  42614. */
  42615. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42616. /**
  42617. * Stops the xrSession and restores the renderloop
  42618. * @returns Promise which resolves after it exits XR
  42619. */
  42620. exitXRAsync(): Promise<void>;
  42621. /**
  42622. * Checks if a session would be supported for the creation options specified
  42623. * @param sessionMode session mode to check if supported eg. immersive-vr
  42624. * @returns A Promise that resolves to true if supported and false if not
  42625. */
  42626. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42627. /**
  42628. * Creates a WebXRRenderTarget object for the XR session
  42629. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42630. * @param options optional options to provide when creating a new render target
  42631. * @returns a WebXR render target to which the session can render
  42632. */
  42633. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42634. /**
  42635. * @hidden
  42636. * Converts the render layer of xrSession to a render target
  42637. * @param session session to create render target for
  42638. * @param scene scene the new render target should be created for
  42639. * @param baseLayer the webgl layer to create the render target for
  42640. */
  42641. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42642. /**
  42643. * Disposes of the session manager
  42644. */
  42645. dispose(): void;
  42646. /**
  42647. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42648. * @param sessionMode defines the session to test
  42649. * @returns a promise with boolean as final value
  42650. */
  42651. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42652. }
  42653. }
  42654. declare module BABYLON {
  42655. /**
  42656. * WebXR Camera which holds the views for the xrSession
  42657. * @see https://doc.babylonjs.com/how_to/webxr
  42658. */
  42659. export class WebXRCamera extends FreeCamera {
  42660. private _xrSessionManager;
  42661. /**
  42662. * Should position compensation execute on first frame.
  42663. * This is used when copying the position from a native (non XR) camera
  42664. */
  42665. compensateOnFirstFrame: boolean;
  42666. private _firstFrame;
  42667. private _referencedPosition;
  42668. private _referenceQuaternion;
  42669. private _xrInvPositionCache;
  42670. private _xrInvQuaternionCache;
  42671. /**
  42672. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42673. * @param name the name of the camera
  42674. * @param scene the scene to add the camera to
  42675. */
  42676. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42677. private _updateNumberOfRigCameras;
  42678. /**
  42679. * Sets this camera's transformation based on a non-vr camera
  42680. * @param otherCamera the non-vr camera to copy the transformation from
  42681. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42682. */
  42683. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42684. /** @hidden */
  42685. _updateForDualEyeDebugging(): void;
  42686. private _updateReferenceSpace;
  42687. private _updateReferenceSpaceOffset;
  42688. private _updateFromXRSession;
  42689. }
  42690. }
  42691. declare module BABYLON {
  42692. /**
  42693. * Defining the interface required for a (webxr) feature
  42694. */
  42695. export interface IWebXRFeature extends IDisposable {
  42696. /**
  42697. * Is this feature attached
  42698. */
  42699. attached: boolean;
  42700. /**
  42701. * Should auto-attach be disabled?
  42702. */
  42703. disableAutoAttach: boolean;
  42704. /**
  42705. * Attach the feature to the session
  42706. * Will usually be called by the features manager
  42707. *
  42708. * @param force should attachment be forced (even when already attached)
  42709. * @returns true if successful.
  42710. */
  42711. attach(force?: boolean): boolean;
  42712. /**
  42713. * Detach the feature from the session
  42714. * Will usually be called by the features manager
  42715. *
  42716. * @returns true if successful.
  42717. */
  42718. detach(): boolean;
  42719. }
  42720. /**
  42721. * A list of the currently available features without referencing them
  42722. */
  42723. export class WebXRFeatureName {
  42724. /**
  42725. * The name of the hit test feature
  42726. */
  42727. static HIT_TEST: string;
  42728. /**
  42729. * The name of the anchor system feature
  42730. */
  42731. static ANCHOR_SYSTEM: string;
  42732. /**
  42733. * The name of the background remover feature
  42734. */
  42735. static BACKGROUND_REMOVER: string;
  42736. /**
  42737. * The name of the pointer selection feature
  42738. */
  42739. static POINTER_SELECTION: string;
  42740. /**
  42741. * The name of the teleportation feature
  42742. */
  42743. static TELEPORTATION: string;
  42744. /**
  42745. * The name of the plane detection feature
  42746. */
  42747. static PLANE_DETECTION: string;
  42748. }
  42749. /**
  42750. * Defining the constructor of a feature. Used to register the modules.
  42751. */
  42752. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42753. /**
  42754. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42755. * It is mainly used in AR sessions.
  42756. *
  42757. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42758. */
  42759. export class WebXRFeaturesManager implements IDisposable {
  42760. private _xrSessionManager;
  42761. private static readonly _AvailableFeatures;
  42762. /**
  42763. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42764. * Mainly used internally.
  42765. *
  42766. * @param featureName the name of the feature to register
  42767. * @param constructorFunction the function used to construct the module
  42768. * @param version the (babylon) version of the module
  42769. * @param stable is that a stable version of this module
  42770. */
  42771. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42772. /**
  42773. * Returns a constructor of a specific feature.
  42774. *
  42775. * @param featureName the name of the feature to construct
  42776. * @param version the version of the feature to load
  42777. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42778. * @param options optional options provided to the module.
  42779. * @returns a function that, when called, will return a new instance of this feature
  42780. */
  42781. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42782. /**
  42783. * Return the latest unstable version of this feature
  42784. * @param featureName the name of the feature to search
  42785. * @returns the version number. if not found will return -1
  42786. */
  42787. static GetLatestVersionOfFeature(featureName: string): number;
  42788. /**
  42789. * Return the latest stable version of this feature
  42790. * @param featureName the name of the feature to search
  42791. * @returns the version number. if not found will return -1
  42792. */
  42793. static GetStableVersionOfFeature(featureName: string): number;
  42794. /**
  42795. * Can be used to return the list of features currently registered
  42796. *
  42797. * @returns an Array of available features
  42798. */
  42799. static GetAvailableFeatures(): string[];
  42800. /**
  42801. * Gets the versions available for a specific feature
  42802. * @param featureName the name of the feature
  42803. * @returns an array with the available versions
  42804. */
  42805. static GetAvailableVersions(featureName: string): string[];
  42806. private _features;
  42807. /**
  42808. * constructs a new features manages.
  42809. *
  42810. * @param _xrSessionManager an instance of WebXRSessionManager
  42811. */
  42812. constructor(_xrSessionManager: WebXRSessionManager);
  42813. /**
  42814. * 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.
  42815. * 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.
  42816. *
  42817. * @param featureName the name of the feature to load or the class of the feature
  42818. * @param version optional version to load. if not provided the latest version will be enabled
  42819. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42820. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42821. * @returns a new constructed feature or throws an error if feature not found.
  42822. */
  42823. enableFeature(featureName: string | {
  42824. Name: string;
  42825. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42826. /**
  42827. * Used to disable an already-enabled feature
  42828. * The feature will be disposed and will be recreated once enabled.
  42829. * @param featureName the feature to disable
  42830. * @returns true if disable was successful
  42831. */
  42832. disableFeature(featureName: string | {
  42833. Name: string;
  42834. }): boolean;
  42835. /**
  42836. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42837. * Can be used during a session to start a feature
  42838. * @param featureName the name of feature to attach
  42839. */
  42840. attachFeature(featureName: string): void;
  42841. /**
  42842. * Can be used inside a session or when the session ends to detach a specific feature
  42843. * @param featureName the name of the feature to detach
  42844. */
  42845. detachFeature(featureName: string): void;
  42846. /**
  42847. * Get the list of enabled features
  42848. * @returns an array of enabled features
  42849. */
  42850. getEnabledFeatures(): string[];
  42851. /**
  42852. * get the implementation of an enabled feature.
  42853. * @param featureName the name of the feature to load
  42854. * @returns the feature class, if found
  42855. */
  42856. getEnabledFeature(featureName: string): IWebXRFeature;
  42857. /**
  42858. * dispose this features manager
  42859. */
  42860. dispose(): void;
  42861. }
  42862. }
  42863. declare module BABYLON {
  42864. /**
  42865. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42866. * @see https://doc.babylonjs.com/how_to/webxr
  42867. */
  42868. export class WebXRExperienceHelper implements IDisposable {
  42869. private scene;
  42870. /**
  42871. * Camera used to render xr content
  42872. */
  42873. camera: WebXRCamera;
  42874. /**
  42875. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42876. */
  42877. state: WebXRState;
  42878. private _setState;
  42879. /**
  42880. * Fires when the state of the experience helper has changed
  42881. */
  42882. onStateChangedObservable: Observable<WebXRState>;
  42883. /**
  42884. * Observers registered here will be triggered after the camera's initial transformation is set
  42885. * This can be used to set a different ground level or an extra rotation.
  42886. *
  42887. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42888. * to the position set after this observable is done executing.
  42889. */
  42890. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42891. /** Session manager used to keep track of xr session */
  42892. sessionManager: WebXRSessionManager;
  42893. /** A features manager for this xr session */
  42894. featuresManager: WebXRFeaturesManager;
  42895. private _nonVRCamera;
  42896. private _originalSceneAutoClear;
  42897. private _supported;
  42898. /**
  42899. * Creates the experience helper
  42900. * @param scene the scene to attach the experience helper to
  42901. * @returns a promise for the experience helper
  42902. */
  42903. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42904. /**
  42905. * Creates a WebXRExperienceHelper
  42906. * @param scene The scene the helper should be created in
  42907. */
  42908. private constructor();
  42909. /**
  42910. * Exits XR mode and returns the scene to its original state
  42911. * @returns promise that resolves after xr mode has exited
  42912. */
  42913. exitXRAsync(): Promise<void>;
  42914. /**
  42915. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42916. * @param sessionMode options for the XR session
  42917. * @param referenceSpaceType frame of reference of the XR session
  42918. * @param renderTarget the output canvas that will be used to enter XR mode
  42919. * @returns promise that resolves after xr mode has entered
  42920. */
  42921. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42922. /**
  42923. * Disposes of the experience helper
  42924. */
  42925. dispose(): void;
  42926. private _nonXRToXRCamera;
  42927. }
  42928. }
  42929. declare module BABYLON {
  42930. /**
  42931. * X-Y values for axes in WebXR
  42932. */
  42933. export interface IWebXRMotionControllerAxesValue {
  42934. /**
  42935. * The value of the x axis
  42936. */
  42937. x: number;
  42938. /**
  42939. * The value of the y-axis
  42940. */
  42941. y: number;
  42942. }
  42943. /**
  42944. * changed / previous values for the values of this component
  42945. */
  42946. export interface IWebXRMotionControllerComponentChangesValues<T> {
  42947. /**
  42948. * current (this frame) value
  42949. */
  42950. current: T;
  42951. /**
  42952. * previous (last change) value
  42953. */
  42954. previous: T;
  42955. }
  42956. /**
  42957. * Represents changes in the component between current frame and last values recorded
  42958. */
  42959. export interface IWebXRMotionControllerComponentChanges {
  42960. /**
  42961. * will be populated with previous and current values if touched changed
  42962. */
  42963. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  42964. /**
  42965. * will be populated with previous and current values if pressed changed
  42966. */
  42967. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  42968. /**
  42969. * will be populated with previous and current values if value changed
  42970. */
  42971. value?: IWebXRMotionControllerComponentChangesValues<number>;
  42972. /**
  42973. * will be populated with previous and current values if axes changed
  42974. */
  42975. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  42976. }
  42977. /**
  42978. * This class represents a single component (for example button or thumbstick) of a motion controller
  42979. */
  42980. export class WebXRControllerComponent implements IDisposable {
  42981. /**
  42982. * the id of this component
  42983. */
  42984. id: string;
  42985. /**
  42986. * the type of the component
  42987. */
  42988. type: MotionControllerComponentType;
  42989. private _buttonIndex;
  42990. private _axesIndices;
  42991. /**
  42992. * Thumbstick component type
  42993. */
  42994. static THUMBSTICK: MotionControllerComponentType;
  42995. /**
  42996. * Touchpad component type
  42997. */
  42998. static TOUCHPAD: MotionControllerComponentType;
  42999. /**
  43000. * trigger component type
  43001. */
  43002. static TRIGGER: MotionControllerComponentType;
  43003. /**
  43004. * squeeze component type
  43005. */
  43006. static SQUEEZE: MotionControllerComponentType;
  43007. /**
  43008. * button component type
  43009. */
  43010. static BUTTON: MotionControllerComponentType;
  43011. /**
  43012. * Observers registered here will be triggered when the state of a button changes
  43013. * State change is either pressed / touched / value
  43014. */
  43015. onButtonStateChanged: Observable<WebXRControllerComponent>;
  43016. /**
  43017. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43018. * the axes data changes
  43019. */
  43020. onAxisValueChanged: Observable<{
  43021. x: number;
  43022. y: number;
  43023. }>;
  43024. private _currentValue;
  43025. private _touched;
  43026. private _pressed;
  43027. private _axes;
  43028. private _changes;
  43029. private _hasChanges;
  43030. /**
  43031. * Return whether or not the component changed the last frame
  43032. */
  43033. get hasChanges(): boolean;
  43034. /**
  43035. * Creates a new component for a motion controller.
  43036. * It is created by the motion controller itself
  43037. *
  43038. * @param id the id of this component
  43039. * @param type the type of the component
  43040. * @param _buttonIndex index in the buttons array of the gamepad
  43041. * @param _axesIndices indices of the values in the axes array of the gamepad
  43042. */
  43043. constructor(
  43044. /**
  43045. * the id of this component
  43046. */
  43047. id: string,
  43048. /**
  43049. * the type of the component
  43050. */
  43051. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43052. /**
  43053. * Get the current value of this component
  43054. */
  43055. get value(): number;
  43056. /**
  43057. * is the button currently pressed
  43058. */
  43059. get pressed(): boolean;
  43060. /**
  43061. * is the button currently touched
  43062. */
  43063. get touched(): boolean;
  43064. /**
  43065. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43066. */
  43067. get axes(): IWebXRMotionControllerAxesValue;
  43068. /**
  43069. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43070. */
  43071. get changes(): IWebXRMotionControllerComponentChanges;
  43072. /**
  43073. * Is this component a button (hence - pressable)
  43074. * @returns true if can be pressed
  43075. */
  43076. isButton(): boolean;
  43077. /**
  43078. * Are there axes correlating to this component
  43079. * @return true is axes data is available
  43080. */
  43081. isAxes(): boolean;
  43082. /**
  43083. * update this component using the gamepad object it is in. Called on every frame
  43084. * @param nativeController the native gamepad controller object
  43085. */
  43086. update(nativeController: IMinimalMotionControllerObject): void;
  43087. /**
  43088. * Dispose this component
  43089. */
  43090. dispose(): void;
  43091. }
  43092. }
  43093. declare module BABYLON {
  43094. /**
  43095. * Class used to represent data loading progression
  43096. */
  43097. export class SceneLoaderProgressEvent {
  43098. /** defines if data length to load can be evaluated */
  43099. readonly lengthComputable: boolean;
  43100. /** defines the loaded data length */
  43101. readonly loaded: number;
  43102. /** defines the data length to load */
  43103. readonly total: number;
  43104. /**
  43105. * Create a new progress event
  43106. * @param lengthComputable defines if data length to load can be evaluated
  43107. * @param loaded defines the loaded data length
  43108. * @param total defines the data length to load
  43109. */
  43110. constructor(
  43111. /** defines if data length to load can be evaluated */
  43112. lengthComputable: boolean,
  43113. /** defines the loaded data length */
  43114. loaded: number,
  43115. /** defines the data length to load */
  43116. total: number);
  43117. /**
  43118. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43119. * @param event defines the source event
  43120. * @returns a new SceneLoaderProgressEvent
  43121. */
  43122. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43123. }
  43124. /**
  43125. * Interface used by SceneLoader plugins to define supported file extensions
  43126. */
  43127. export interface ISceneLoaderPluginExtensions {
  43128. /**
  43129. * Defines the list of supported extensions
  43130. */
  43131. [extension: string]: {
  43132. isBinary: boolean;
  43133. };
  43134. }
  43135. /**
  43136. * Interface used by SceneLoader plugin factory
  43137. */
  43138. export interface ISceneLoaderPluginFactory {
  43139. /**
  43140. * Defines the name of the factory
  43141. */
  43142. name: string;
  43143. /**
  43144. * Function called to create a new plugin
  43145. * @return the new plugin
  43146. */
  43147. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43148. /**
  43149. * The callback that returns true if the data can be directly loaded.
  43150. * @param data string containing the file data
  43151. * @returns if the data can be loaded directly
  43152. */
  43153. canDirectLoad?(data: string): boolean;
  43154. }
  43155. /**
  43156. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43157. */
  43158. export interface ISceneLoaderPluginBase {
  43159. /**
  43160. * The friendly name of this plugin.
  43161. */
  43162. name: string;
  43163. /**
  43164. * The file extensions supported by this plugin.
  43165. */
  43166. extensions: string | ISceneLoaderPluginExtensions;
  43167. /**
  43168. * The callback called when loading from a url.
  43169. * @param scene scene loading this url
  43170. * @param url url to load
  43171. * @param onSuccess callback called when the file successfully loads
  43172. * @param onProgress callback called while file is loading (if the server supports this mode)
  43173. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43174. * @param onError callback called when the file fails to load
  43175. * @returns a file request object
  43176. */
  43177. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43178. /**
  43179. * The callback called when loading from a file object.
  43180. * @param scene scene loading this file
  43181. * @param file defines the file to load
  43182. * @param onSuccess defines the callback to call when data is loaded
  43183. * @param onProgress defines the callback to call during loading process
  43184. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43185. * @param onError defines the callback to call when an error occurs
  43186. * @returns a file request object
  43187. */
  43188. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43189. /**
  43190. * The callback that returns true if the data can be directly loaded.
  43191. * @param data string containing the file data
  43192. * @returns if the data can be loaded directly
  43193. */
  43194. canDirectLoad?(data: string): boolean;
  43195. /**
  43196. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43197. * @param scene scene loading this data
  43198. * @param data string containing the data
  43199. * @returns data to pass to the plugin
  43200. */
  43201. directLoad?(scene: Scene, data: string): any;
  43202. /**
  43203. * The callback that allows custom handling of the root url based on the response url.
  43204. * @param rootUrl the original root url
  43205. * @param responseURL the response url if available
  43206. * @returns the new root url
  43207. */
  43208. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43209. }
  43210. /**
  43211. * Interface used to define a SceneLoader plugin
  43212. */
  43213. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43214. /**
  43215. * Import meshes into a scene.
  43216. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43217. * @param scene The scene to import into
  43218. * @param data The data to import
  43219. * @param rootUrl The root url for scene and resources
  43220. * @param meshes The meshes array to import into
  43221. * @param particleSystems The particle systems array to import into
  43222. * @param skeletons The skeletons array to import into
  43223. * @param onError The callback when import fails
  43224. * @returns True if successful or false otherwise
  43225. */
  43226. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43227. /**
  43228. * Load into a scene.
  43229. * @param scene The scene to load into
  43230. * @param data The data to import
  43231. * @param rootUrl The root url for scene and resources
  43232. * @param onError The callback when import fails
  43233. * @returns True if successful or false otherwise
  43234. */
  43235. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43236. /**
  43237. * Load into an asset container.
  43238. * @param scene The scene to load into
  43239. * @param data The data to import
  43240. * @param rootUrl The root url for scene and resources
  43241. * @param onError The callback when import fails
  43242. * @returns The loaded asset container
  43243. */
  43244. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43245. }
  43246. /**
  43247. * Interface used to define an async SceneLoader plugin
  43248. */
  43249. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43250. /**
  43251. * Import meshes into a scene.
  43252. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43253. * @param scene The scene to import into
  43254. * @param data The data to import
  43255. * @param rootUrl The root url for scene and resources
  43256. * @param onProgress The callback when the load progresses
  43257. * @param fileName Defines the name of the file to load
  43258. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43259. */
  43260. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43261. meshes: AbstractMesh[];
  43262. particleSystems: IParticleSystem[];
  43263. skeletons: Skeleton[];
  43264. animationGroups: AnimationGroup[];
  43265. }>;
  43266. /**
  43267. * Load into a scene.
  43268. * @param scene The scene to load into
  43269. * @param data The data to import
  43270. * @param rootUrl The root url for scene and resources
  43271. * @param onProgress The callback when the load progresses
  43272. * @param fileName Defines the name of the file to load
  43273. * @returns Nothing
  43274. */
  43275. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43276. /**
  43277. * Load into an asset container.
  43278. * @param scene The scene to load into
  43279. * @param data The data to import
  43280. * @param rootUrl The root url for scene and resources
  43281. * @param onProgress The callback when the load progresses
  43282. * @param fileName Defines the name of the file to load
  43283. * @returns The loaded asset container
  43284. */
  43285. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43286. }
  43287. /**
  43288. * Mode that determines how to handle old animation groups before loading new ones.
  43289. */
  43290. export enum SceneLoaderAnimationGroupLoadingMode {
  43291. /**
  43292. * Reset all old animations to initial state then dispose them.
  43293. */
  43294. Clean = 0,
  43295. /**
  43296. * Stop all old animations.
  43297. */
  43298. Stop = 1,
  43299. /**
  43300. * Restart old animations from first frame.
  43301. */
  43302. Sync = 2,
  43303. /**
  43304. * Old animations remains untouched.
  43305. */
  43306. NoSync = 3
  43307. }
  43308. /**
  43309. * Class used to load scene from various file formats using registered plugins
  43310. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43311. */
  43312. export class SceneLoader {
  43313. /**
  43314. * No logging while loading
  43315. */
  43316. static readonly NO_LOGGING: number;
  43317. /**
  43318. * Minimal logging while loading
  43319. */
  43320. static readonly MINIMAL_LOGGING: number;
  43321. /**
  43322. * Summary logging while loading
  43323. */
  43324. static readonly SUMMARY_LOGGING: number;
  43325. /**
  43326. * Detailled logging while loading
  43327. */
  43328. static readonly DETAILED_LOGGING: number;
  43329. /**
  43330. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43331. */
  43332. static get ForceFullSceneLoadingForIncremental(): boolean;
  43333. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43334. /**
  43335. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43336. */
  43337. static get ShowLoadingScreen(): boolean;
  43338. static set ShowLoadingScreen(value: boolean);
  43339. /**
  43340. * Defines the current logging level (while loading the scene)
  43341. * @ignorenaming
  43342. */
  43343. static get loggingLevel(): number;
  43344. static set loggingLevel(value: number);
  43345. /**
  43346. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43347. */
  43348. static get CleanBoneMatrixWeights(): boolean;
  43349. static set CleanBoneMatrixWeights(value: boolean);
  43350. /**
  43351. * Event raised when a plugin is used to load a scene
  43352. */
  43353. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43354. private static _registeredPlugins;
  43355. private static _getDefaultPlugin;
  43356. private static _getPluginForExtension;
  43357. private static _getPluginForDirectLoad;
  43358. private static _getPluginForFilename;
  43359. private static _getDirectLoad;
  43360. private static _loadData;
  43361. private static _getFileInfo;
  43362. /**
  43363. * Gets a plugin that can load the given extension
  43364. * @param extension defines the extension to load
  43365. * @returns a plugin or null if none works
  43366. */
  43367. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43368. /**
  43369. * Gets a boolean indicating that the given extension can be loaded
  43370. * @param extension defines the extension to load
  43371. * @returns true if the extension is supported
  43372. */
  43373. static IsPluginForExtensionAvailable(extension: string): boolean;
  43374. /**
  43375. * Adds a new plugin to the list of registered plugins
  43376. * @param plugin defines the plugin to add
  43377. */
  43378. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43379. /**
  43380. * Import meshes into a scene
  43381. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43382. * @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)
  43383. * @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)
  43384. * @param scene the instance of BABYLON.Scene to append to
  43385. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43386. * @param onProgress a callback with a progress event for each file being loaded
  43387. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43388. * @param pluginExtension the extension used to determine the plugin
  43389. * @returns The loaded plugin
  43390. */
  43391. 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>;
  43392. /**
  43393. * Import meshes into a scene
  43394. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43395. * @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)
  43396. * @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)
  43397. * @param scene the instance of BABYLON.Scene to append to
  43398. * @param onProgress a callback with a progress event for each file being loaded
  43399. * @param pluginExtension the extension used to determine the plugin
  43400. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43401. */
  43402. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43403. meshes: AbstractMesh[];
  43404. particleSystems: IParticleSystem[];
  43405. skeletons: Skeleton[];
  43406. animationGroups: AnimationGroup[];
  43407. }>;
  43408. /**
  43409. * Load a scene
  43410. * @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)
  43411. * @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)
  43412. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43413. * @param onSuccess a callback with the scene when import succeeds
  43414. * @param onProgress a callback with a progress event for each file being loaded
  43415. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43416. * @param pluginExtension the extension used to determine the plugin
  43417. * @returns The loaded plugin
  43418. */
  43419. 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>;
  43420. /**
  43421. * Load a scene
  43422. * @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)
  43423. * @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)
  43424. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43425. * @param onProgress a callback with a progress event for each file being loaded
  43426. * @param pluginExtension the extension used to determine the plugin
  43427. * @returns The loaded scene
  43428. */
  43429. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43430. /**
  43431. * Append a scene
  43432. * @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)
  43433. * @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)
  43434. * @param scene is the instance of BABYLON.Scene to append to
  43435. * @param onSuccess a callback with the scene when import succeeds
  43436. * @param onProgress a callback with a progress event for each file being loaded
  43437. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43438. * @param pluginExtension the extension used to determine the plugin
  43439. * @returns The loaded plugin
  43440. */
  43441. 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>;
  43442. /**
  43443. * Append a scene
  43444. * @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)
  43445. * @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)
  43446. * @param scene is the instance of BABYLON.Scene to append to
  43447. * @param onProgress a callback with a progress event for each file being loaded
  43448. * @param pluginExtension the extension used to determine the plugin
  43449. * @returns The given scene
  43450. */
  43451. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43452. /**
  43453. * Load a scene into an asset container
  43454. * @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)
  43455. * @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)
  43456. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43457. * @param onSuccess a callback with the scene when import succeeds
  43458. * @param onProgress a callback with a progress event for each file being loaded
  43459. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43460. * @param pluginExtension the extension used to determine the plugin
  43461. * @returns The loaded plugin
  43462. */
  43463. 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>;
  43464. /**
  43465. * Load a scene into an asset container
  43466. * @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)
  43467. * @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)
  43468. * @param scene is the instance of Scene to append to
  43469. * @param onProgress a callback with a progress event for each file being loaded
  43470. * @param pluginExtension the extension used to determine the plugin
  43471. * @returns The loaded asset container
  43472. */
  43473. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43474. /**
  43475. * Import animations from a file into a scene
  43476. * @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)
  43477. * @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)
  43478. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43479. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43480. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43481. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43482. * @param onSuccess a callback with the scene when import succeeds
  43483. * @param onProgress a callback with a progress event for each file being loaded
  43484. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43485. */
  43486. 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;
  43487. /**
  43488. * Import animations from a file into a scene
  43489. * @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)
  43490. * @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)
  43491. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43492. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43493. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43494. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43495. * @param onSuccess a callback with the scene when import succeeds
  43496. * @param onProgress a callback with a progress event for each file being loaded
  43497. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43498. * @returns the updated scene with imported animations
  43499. */
  43500. 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>;
  43501. }
  43502. }
  43503. declare module BABYLON {
  43504. /**
  43505. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43506. */
  43507. export type MotionControllerHandness = "none" | "left" | "right";
  43508. /**
  43509. * The type of components available in motion controllers.
  43510. * This is not the name of the component.
  43511. */
  43512. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43513. /**
  43514. * The state of a controller component
  43515. */
  43516. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43517. /**
  43518. * The schema of motion controller layout.
  43519. * No object will be initialized using this interface
  43520. * This is used just to define the profile.
  43521. */
  43522. export interface IMotionControllerLayout {
  43523. /**
  43524. * Defines the main button component id
  43525. */
  43526. selectComponentId: string;
  43527. /**
  43528. * Available components (unsorted)
  43529. */
  43530. components: {
  43531. /**
  43532. * A map of component Ids
  43533. */
  43534. [componentId: string]: {
  43535. /**
  43536. * The type of input the component outputs
  43537. */
  43538. type: MotionControllerComponentType;
  43539. /**
  43540. * The indices of this component in the gamepad object
  43541. */
  43542. gamepadIndices: {
  43543. /**
  43544. * Index of button
  43545. */
  43546. button?: number;
  43547. /**
  43548. * If available, index of x-axis
  43549. */
  43550. xAxis?: number;
  43551. /**
  43552. * If available, index of y-axis
  43553. */
  43554. yAxis?: number;
  43555. };
  43556. /**
  43557. * The mesh's root node name
  43558. */
  43559. rootNodeName: string;
  43560. /**
  43561. * Animation definitions for this model
  43562. */
  43563. visualResponses: {
  43564. [stateKey: string]: {
  43565. /**
  43566. * What property will be animated
  43567. */
  43568. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43569. /**
  43570. * What states influence this visual reponse
  43571. */
  43572. states: MotionControllerComponentStateType[];
  43573. /**
  43574. * Type of animation - movement or visibility
  43575. */
  43576. valueNodeProperty: "transform" | "visibility";
  43577. /**
  43578. * Base node name to move. Its position will be calculated according to the min and max nodes
  43579. */
  43580. valueNodeName?: string;
  43581. /**
  43582. * Minimum movement node
  43583. */
  43584. minNodeName?: string;
  43585. /**
  43586. * Max movement node
  43587. */
  43588. maxNodeName?: string;
  43589. };
  43590. };
  43591. /**
  43592. * If touch enabled, what is the name of node to display user feedback
  43593. */
  43594. touchPointNodeName?: string;
  43595. };
  43596. };
  43597. /**
  43598. * Is it xr standard mapping or not
  43599. */
  43600. gamepadMapping: "" | "xr-standard";
  43601. /**
  43602. * Base root node of this entire model
  43603. */
  43604. rootNodeName: string;
  43605. /**
  43606. * Path to load the assets. Usually relative to the base path
  43607. */
  43608. assetPath: string;
  43609. }
  43610. /**
  43611. * A definition for the layout map in the input profile
  43612. */
  43613. export interface IMotionControllerLayoutMap {
  43614. /**
  43615. * Layouts with handness type as a key
  43616. */
  43617. [handness: string]: IMotionControllerLayout;
  43618. }
  43619. /**
  43620. * The XR Input profile schema
  43621. * Profiles can be found here:
  43622. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43623. */
  43624. export interface IMotionControllerProfile {
  43625. /**
  43626. * The id of this profile
  43627. * correlates to the profile(s) in the xrInput.profiles array
  43628. */
  43629. profileId: string;
  43630. /**
  43631. * fallback profiles for this profileId
  43632. */
  43633. fallbackProfileIds: string[];
  43634. /**
  43635. * The layout map, with handness as key
  43636. */
  43637. layouts: IMotionControllerLayoutMap;
  43638. }
  43639. /**
  43640. * A helper-interface for the 3 meshes needed for controller button animation
  43641. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43642. */
  43643. export interface IMotionControllerButtonMeshMap {
  43644. /**
  43645. * The mesh that will be changed when value changes
  43646. */
  43647. valueMesh: AbstractMesh;
  43648. /**
  43649. * the mesh that defines the pressed value mesh position.
  43650. * This is used to find the max-position of this button
  43651. */
  43652. pressedMesh: AbstractMesh;
  43653. /**
  43654. * the mesh that defines the unpressed value mesh position.
  43655. * This is used to find the min (or initial) position of this button
  43656. */
  43657. unpressedMesh: AbstractMesh;
  43658. }
  43659. /**
  43660. * A helper-interface for the 3 meshes needed for controller axis animation.
  43661. * This will be expanded when touchpad animations are fully supported
  43662. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43663. */
  43664. export interface IMotionControllerMeshMap {
  43665. /**
  43666. * The mesh that will be changed when axis value changes
  43667. */
  43668. valueMesh: AbstractMesh;
  43669. /**
  43670. * the mesh that defines the minimum value mesh position.
  43671. */
  43672. minMesh?: AbstractMesh;
  43673. /**
  43674. * the mesh that defines the maximum value mesh position.
  43675. */
  43676. maxMesh?: AbstractMesh;
  43677. }
  43678. /**
  43679. * The elements needed for change-detection of the gamepad objects in motion controllers
  43680. */
  43681. export interface IMinimalMotionControllerObject {
  43682. /**
  43683. * An array of available buttons
  43684. */
  43685. buttons: Array<{
  43686. /**
  43687. * Value of the button/trigger
  43688. */
  43689. value: number;
  43690. /**
  43691. * If the button/trigger is currently touched
  43692. */
  43693. touched: boolean;
  43694. /**
  43695. * If the button/trigger is currently pressed
  43696. */
  43697. pressed: boolean;
  43698. }>;
  43699. /**
  43700. * Available axes of this controller
  43701. */
  43702. axes: number[];
  43703. }
  43704. /**
  43705. * An Abstract Motion controller
  43706. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43707. * Each component has an observable to check for changes in value and state
  43708. */
  43709. export abstract class WebXRAbstractMotionController implements IDisposable {
  43710. protected scene: Scene;
  43711. protected layout: IMotionControllerLayout;
  43712. /**
  43713. * The gamepad object correlating to this controller
  43714. */
  43715. gamepadObject: IMinimalMotionControllerObject;
  43716. /**
  43717. * handness (left/right/none) of this controller
  43718. */
  43719. handness: MotionControllerHandness;
  43720. /**
  43721. * The profile id of this motion controller
  43722. */
  43723. abstract profileId: string;
  43724. /**
  43725. * A map of components (WebXRControllerComponent) in this motion controller
  43726. * Components have a ComponentType and can also have both button and axis definitions
  43727. */
  43728. readonly components: {
  43729. [id: string]: WebXRControllerComponent;
  43730. };
  43731. /**
  43732. * Observers registered here will be triggered when the model of this controller is done loading
  43733. */
  43734. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43735. /**
  43736. * The root mesh of the model. It is null if the model was not yet initialized
  43737. */
  43738. rootMesh: Nullable<AbstractMesh>;
  43739. /**
  43740. * Disable the model's animation. Can be set at any time.
  43741. */
  43742. disableAnimation: boolean;
  43743. private _modelReady;
  43744. /**
  43745. * constructs a new abstract motion controller
  43746. * @param scene the scene to which the model of the controller will be added
  43747. * @param layout The profile layout to load
  43748. * @param gamepadObject The gamepad object correlating to this controller
  43749. * @param handness handness (left/right/none) of this controller
  43750. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43751. */
  43752. constructor(scene: Scene, layout: IMotionControllerLayout,
  43753. /**
  43754. * The gamepad object correlating to this controller
  43755. */
  43756. gamepadObject: IMinimalMotionControllerObject,
  43757. /**
  43758. * handness (left/right/none) of this controller
  43759. */
  43760. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43761. private _initComponent;
  43762. /**
  43763. * Update this model using the current XRFrame
  43764. * @param xrFrame the current xr frame to use and update the model
  43765. */
  43766. updateFromXRFrame(xrFrame: XRFrame): void;
  43767. /**
  43768. * Get the list of components available in this motion controller
  43769. * @returns an array of strings correlating to available components
  43770. */
  43771. getComponentIds(): string[];
  43772. /**
  43773. * Get the main (Select) component of this controller as defined in the layout
  43774. * @returns the main component of this controller
  43775. */
  43776. getMainComponent(): WebXRControllerComponent;
  43777. /**
  43778. * get a component based an its component id as defined in layout.components
  43779. * @param id the id of the component
  43780. * @returns the component correlates to the id or undefined if not found
  43781. */
  43782. getComponent(id: string): WebXRControllerComponent;
  43783. /**
  43784. * Get the first component of specific type
  43785. * @param type type of component to find
  43786. * @return a controller component or null if not found
  43787. */
  43788. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  43789. /**
  43790. * Returns all components of specific type
  43791. * @param type the type to search for
  43792. * @return an array of components with this type
  43793. */
  43794. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  43795. /**
  43796. * Loads the model correlating to this controller
  43797. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43798. * @returns A promise fulfilled with the result of the model loading
  43799. */
  43800. loadModel(): Promise<boolean>;
  43801. /**
  43802. * Update the model itself with the current frame data
  43803. * @param xrFrame the frame to use for updating the model mesh
  43804. */
  43805. protected updateModel(xrFrame: XRFrame): void;
  43806. /**
  43807. * Moves the axis on the controller mesh based on its current state
  43808. * @param axis the index of the axis
  43809. * @param axisValue the value of the axis which determines the meshes new position
  43810. * @hidden
  43811. */
  43812. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  43813. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43814. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43815. private _getGenericFilenameAndPath;
  43816. private _getGenericParentMesh;
  43817. /**
  43818. * Get the filename and path for this controller's model
  43819. * @returns a map of filename and path
  43820. */
  43821. protected abstract _getFilenameAndPath(): {
  43822. filename: string;
  43823. path: string;
  43824. };
  43825. /**
  43826. * This function will be called after the model was successfully loaded and can be used
  43827. * for mesh transformations before it is available for the user
  43828. * @param meshes the loaded meshes
  43829. */
  43830. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43831. /**
  43832. * Set the root mesh for this controller. Important for the WebXR controller class
  43833. * @param meshes the loaded meshes
  43834. */
  43835. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43836. /**
  43837. * A function executed each frame that updates the mesh (if needed)
  43838. * @param xrFrame the current xrFrame
  43839. */
  43840. protected abstract _updateModel(xrFrame: XRFrame): void;
  43841. /**
  43842. * This function is called before the mesh is loaded. It checks for loading constraints.
  43843. * For example, this function can check if the GLB loader is available
  43844. * If this function returns false, the generic controller will be loaded instead
  43845. * @returns Is the client ready to load the mesh
  43846. */
  43847. protected abstract _getModelLoadingConstraints(): boolean;
  43848. /**
  43849. * Dispose this controller, the model mesh and all its components
  43850. */
  43851. dispose(): void;
  43852. }
  43853. }
  43854. declare module BABYLON {
  43855. /**
  43856. * A generic trigger-only motion controller for WebXR
  43857. */
  43858. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43859. /**
  43860. * Static version of the profile id of this controller
  43861. */
  43862. static ProfileId: string;
  43863. profileId: string;
  43864. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43865. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43866. protected _updateModel(): void;
  43867. protected _getFilenameAndPath(): {
  43868. filename: string;
  43869. path: string;
  43870. };
  43871. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43872. protected _getModelLoadingConstraints(): boolean;
  43873. }
  43874. }
  43875. declare module BABYLON {
  43876. /**
  43877. * Class containing static functions to help procedurally build meshes
  43878. */
  43879. export class SphereBuilder {
  43880. /**
  43881. * Creates a sphere mesh
  43882. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43883. * * 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`)
  43884. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43885. * * 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
  43886. * * 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)
  43887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43888. * * 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
  43889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43890. * @param name defines the name of the mesh
  43891. * @param options defines the options used to create the mesh
  43892. * @param scene defines the hosting scene
  43893. * @returns the sphere mesh
  43894. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43895. */
  43896. static CreateSphere(name: string, options: {
  43897. segments?: number;
  43898. diameter?: number;
  43899. diameterX?: number;
  43900. diameterY?: number;
  43901. diameterZ?: number;
  43902. arc?: number;
  43903. slice?: number;
  43904. sideOrientation?: number;
  43905. frontUVs?: Vector4;
  43906. backUVs?: Vector4;
  43907. updatable?: boolean;
  43908. }, scene?: Nullable<Scene>): Mesh;
  43909. }
  43910. }
  43911. declare module BABYLON {
  43912. /**
  43913. * A profiled motion controller has its profile loaded from an online repository.
  43914. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  43915. */
  43916. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  43917. private _repositoryUrl;
  43918. /**
  43919. * The profile ID of this controller. Will be populated when the controller initializes.
  43920. */
  43921. profileId: string;
  43922. private _buttonMeshMapping;
  43923. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  43924. protected _getFilenameAndPath(): {
  43925. filename: string;
  43926. path: string;
  43927. };
  43928. private _touchDots;
  43929. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  43930. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43931. protected _updateModel(_xrFrame: XRFrame): void;
  43932. protected _getModelLoadingConstraints(): boolean;
  43933. dispose(): void;
  43934. }
  43935. }
  43936. declare module BABYLON {
  43937. /**
  43938. * A construction function type to create a new controller based on an xrInput object
  43939. */
  43940. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  43941. /**
  43942. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  43943. *
  43944. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  43945. * it should be replaced with auto-loaded controllers.
  43946. *
  43947. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  43948. */
  43949. export class WebXRMotionControllerManager {
  43950. /**
  43951. * The base URL of the online controller repository. Can be changed at any time.
  43952. */
  43953. static BaseRepositoryUrl: string;
  43954. /**
  43955. * Use the online repository, or use only locally-defined controllers
  43956. */
  43957. static UseOnlineRepository: boolean;
  43958. /**
  43959. * Which repository gets priority - local or online
  43960. */
  43961. static PrioritizeOnlineRepository: boolean;
  43962. private static _AvailableControllers;
  43963. private static _Fallbacks;
  43964. /**
  43965. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  43966. *
  43967. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  43968. *
  43969. * @param type the profile type to register
  43970. * @param constructFunction the function to be called when loading this profile
  43971. */
  43972. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  43973. /**
  43974. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  43975. * The order of search:
  43976. *
  43977. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  43978. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  43979. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  43980. * 4) return the generic trigger controller if none were found
  43981. *
  43982. * @param xrInput the xrInput to which a new controller is initialized
  43983. * @param scene the scene to which the model will be added
  43984. * @param forceProfile force a certain profile for this controller
  43985. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  43986. */
  43987. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  43988. private static _LoadProfilesFromAvailableControllers;
  43989. private static _ProfilesList;
  43990. private static _ProfileLoadingPromises;
  43991. private static _LoadProfileFromRepository;
  43992. /**
  43993. * Clear the cache used for profile loading and reload when requested again
  43994. */
  43995. static ClearProfilesCache(): void;
  43996. /**
  43997. * Will update the list of profiles available in the repository
  43998. * @return a promise that resolves to a map of profiles available online
  43999. */
  44000. static UpdateProfilesList(): Promise<{
  44001. [profile: string]: string;
  44002. }>;
  44003. /**
  44004. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44005. * @param profileId the profile to which a fallback needs to be found
  44006. * @return an array with corresponding fallback profiles
  44007. */
  44008. static FindFallbackWithProfileId(profileId: string): string[];
  44009. /**
  44010. * Register a fallback to a specific profile.
  44011. * @param profileId the profileId that will receive the fallbacks
  44012. * @param fallbacks A list of fallback profiles
  44013. */
  44014. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44015. /**
  44016. * Register the default fallbacks.
  44017. * This function is called automatically when this file is imported.
  44018. */
  44019. static DefaultFallbacks(): void;
  44020. }
  44021. }
  44022. declare module BABYLON {
  44023. /**
  44024. * Configuration options for the WebXR controller creation
  44025. */
  44026. export interface IWebXRControllerOptions {
  44027. /**
  44028. * Force a specific controller type for this controller.
  44029. * This can be used when creating your own profile or when testing different controllers
  44030. */
  44031. forceControllerProfile?: string;
  44032. /**
  44033. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44034. */
  44035. doNotLoadControllerMesh?: boolean;
  44036. /**
  44037. * Should the controller mesh be animated when a user interacts with it
  44038. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44039. */
  44040. disableMotionControllerAnimation?: boolean;
  44041. }
  44042. /**
  44043. * Represents an XR controller
  44044. */
  44045. export class WebXRController {
  44046. private _scene;
  44047. /** The underlying input source for the controller */
  44048. inputSource: XRInputSource;
  44049. private _options;
  44050. /**
  44051. * 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
  44052. */
  44053. grip?: AbstractMesh;
  44054. /**
  44055. * Pointer which can be used to select objects or attach a visible laser to
  44056. */
  44057. pointer: AbstractMesh;
  44058. /**
  44059. * If available, this is the gamepad object related to this controller.
  44060. * Using this object it is possible to get click events and trackpad changes of the
  44061. * webxr controller that is currently being used.
  44062. */
  44063. motionController?: WebXRAbstractMotionController;
  44064. /**
  44065. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44066. */
  44067. onMotionControllerProfileLoaded: Observable<WebXRAbstractMotionController>;
  44068. /**
  44069. * Event that fires when the controller is removed/disposed
  44070. */
  44071. onDisposeObservable: Observable<{}>;
  44072. private _tmpQuaternion;
  44073. private _tmpVector;
  44074. private _uniqueId;
  44075. /**
  44076. * Creates the controller
  44077. * @see https://doc.babylonjs.com/how_to/webxr
  44078. * @param _scene the scene which the controller should be associated to
  44079. * @param inputSource the underlying input source for the controller
  44080. * @param _options options for this controller creation
  44081. */
  44082. constructor(_scene: Scene,
  44083. /** The underlying input source for the controller */
  44084. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44085. /**
  44086. * Get this controllers unique id
  44087. */
  44088. get uniqueId(): string;
  44089. /**
  44090. * Updates the controller pose based on the given XRFrame
  44091. * @param xrFrame xr frame to update the pose with
  44092. * @param referenceSpace reference space to use
  44093. */
  44094. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44095. /**
  44096. * Gets a world space ray coming from the controller
  44097. * @param result the resulting ray
  44098. */
  44099. getWorldPointerRayToRef(result: Ray): void;
  44100. /**
  44101. * Disposes of the object
  44102. */
  44103. dispose(): void;
  44104. }
  44105. }
  44106. declare module BABYLON {
  44107. /**
  44108. * The schema for initialization options of the XR Input class
  44109. */
  44110. export interface IWebXRInputOptions {
  44111. /**
  44112. * If set to true no model will be automatically loaded
  44113. */
  44114. doNotLoadControllerMeshes?: boolean;
  44115. /**
  44116. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44117. * If not found, the xr input profile data will be used.
  44118. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44119. */
  44120. forceInputProfile?: string;
  44121. /**
  44122. * Do not send a request to the controlle repository to load the profile.
  44123. *
  44124. * Instead, use the controllers available in babylon itself.
  44125. */
  44126. disableOnlineControllerRepository?: boolean;
  44127. /**
  44128. * A custom URL for the controllers repository
  44129. */
  44130. customControllersRepositoryURL?: string;
  44131. /**
  44132. * Should the controller model's components not move according to the user input
  44133. */
  44134. disableControllerAnimation?: boolean;
  44135. }
  44136. /**
  44137. * XR input used to track XR inputs such as controllers/rays
  44138. */
  44139. export class WebXRInput implements IDisposable {
  44140. /**
  44141. * the xr session manager for this session
  44142. */
  44143. xrSessionManager: WebXRSessionManager;
  44144. /**
  44145. * the WebXR camera for this session. Mainly used for teleportation
  44146. */
  44147. xrCamera: WebXRCamera;
  44148. private readonly options;
  44149. /**
  44150. * XR controllers being tracked
  44151. */
  44152. controllers: Array<WebXRController>;
  44153. private _frameObserver;
  44154. private _sessionEndedObserver;
  44155. private _sessionInitObserver;
  44156. /**
  44157. * Event when a controller has been connected/added
  44158. */
  44159. onControllerAddedObservable: Observable<WebXRController>;
  44160. /**
  44161. * Event when a controller has been removed/disconnected
  44162. */
  44163. onControllerRemovedObservable: Observable<WebXRController>;
  44164. /**
  44165. * Initializes the WebXRInput
  44166. * @param xrSessionManager the xr session manager for this session
  44167. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44168. * @param options = initialization options for this xr input
  44169. */
  44170. constructor(
  44171. /**
  44172. * the xr session manager for this session
  44173. */
  44174. xrSessionManager: WebXRSessionManager,
  44175. /**
  44176. * the WebXR camera for this session. Mainly used for teleportation
  44177. */
  44178. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44179. private _onInputSourcesChange;
  44180. private _addAndRemoveControllers;
  44181. /**
  44182. * Disposes of the object
  44183. */
  44184. dispose(): void;
  44185. }
  44186. }
  44187. declare module BABYLON {
  44188. /**
  44189. * This is the base class for all WebXR features.
  44190. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44191. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44192. */
  44193. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44194. protected _xrSessionManager: WebXRSessionManager;
  44195. /**
  44196. * Construct a new (abstract) webxr feature
  44197. * @param _xrSessionManager the xr session manager for this feature
  44198. */
  44199. constructor(_xrSessionManager: WebXRSessionManager);
  44200. private _attached;
  44201. private _removeOnDetach;
  44202. /**
  44203. * Is this feature attached
  44204. */
  44205. get attached(): boolean;
  44206. /**
  44207. * Should auto-attach be disabled?
  44208. */
  44209. disableAutoAttach: boolean;
  44210. /**
  44211. * attach this feature
  44212. *
  44213. * @param force should attachment be forced (even when already attached)
  44214. * @returns true if successful, false is failed or already attached
  44215. */
  44216. attach(force?: boolean): boolean;
  44217. /**
  44218. * detach this feature.
  44219. *
  44220. * @returns true if successful, false if failed or already detached
  44221. */
  44222. detach(): boolean;
  44223. /**
  44224. * Dispose this feature and all of the resources attached
  44225. */
  44226. dispose(): void;
  44227. /**
  44228. * Code in this function will be executed on each xrFrame received from the browser.
  44229. * This function will not execute after the feature is detached.
  44230. * @param _xrFrame the current frame
  44231. */
  44232. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44233. /**
  44234. * This is used to register callbacks that will automatically be removed when detach is called.
  44235. * @param observable the observable to which the observer will be attached
  44236. * @param callback the callback to register
  44237. */
  44238. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44239. }
  44240. }
  44241. declare module BABYLON {
  44242. /**
  44243. * Options interface for the pointer selection module
  44244. */
  44245. export interface IWebXRControllerPointerSelectionOptions {
  44246. /**
  44247. * the xr input to use with this pointer selection
  44248. */
  44249. xrInput: WebXRInput;
  44250. /**
  44251. * Different button type to use instead of the main component
  44252. */
  44253. overrideButtonId?: string;
  44254. /**
  44255. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  44256. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44257. * 3000 means 3 seconds between pointing at something and selecting it
  44258. */
  44259. timeToSelect?: number;
  44260. /**
  44261. * 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)
  44262. * If not disabled, the last picked point will be used to execute a pointer up event
  44263. * If disabled, pointer up event will be triggered right after the pointer down event.
  44264. * Used in screen and gaze target ray mode only
  44265. */
  44266. disablePointerUpOnTouchOut: boolean;
  44267. /**
  44268. * For gaze mode (time to select instead of press)
  44269. */
  44270. forceGazeMode: boolean;
  44271. /**
  44272. * 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
  44273. * to start a new countdown to the pointer down event.
  44274. * Defaults to 1.
  44275. */
  44276. gazeModePointerMovedFactor?: number;
  44277. }
  44278. /**
  44279. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44280. */
  44281. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44282. private readonly _options;
  44283. /**
  44284. * The module's name
  44285. */
  44286. static readonly Name: string;
  44287. /**
  44288. * The (Babylon) version of this module.
  44289. * This is an integer representing the implementation version.
  44290. * This number does not correspond to the webxr specs version
  44291. */
  44292. static readonly Version: number;
  44293. /**
  44294. * This color will be set to the laser pointer when selection is triggered
  44295. */
  44296. laserPointerPickedColor: Color3;
  44297. /**
  44298. * This color will be applied to the selection ring when selection is triggered
  44299. */
  44300. selectionMeshPickedColor: Color3;
  44301. /**
  44302. * default color of the selection ring
  44303. */
  44304. selectionMeshDefaultColor: Color3;
  44305. /**
  44306. * Default color of the laser pointer
  44307. */
  44308. lasterPointerDefaultColor: Color3;
  44309. /**
  44310. * Should the laser pointer be displayed
  44311. */
  44312. displayLaserPointer: boolean;
  44313. /**
  44314. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44315. */
  44316. displaySelectionMesh: boolean;
  44317. /**
  44318. * Disable lighting on the laser pointer (so it will always be visible)
  44319. */
  44320. disablePointerLighting: boolean;
  44321. /**
  44322. * Disable lighting on the selection mesh (so it will always be visible)
  44323. */
  44324. disableSelectionMeshLighting: boolean;
  44325. private static _idCounter;
  44326. private _tmpRay;
  44327. private _controllers;
  44328. private _scene;
  44329. /**
  44330. * constructs a new background remover module
  44331. * @param _xrSessionManager the session manager for this module
  44332. * @param _options read-only options to be used in this module
  44333. */
  44334. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44335. /**
  44336. * attach this feature
  44337. * Will usually be called by the features manager
  44338. *
  44339. * @returns true if successful.
  44340. */
  44341. attach(): boolean;
  44342. /**
  44343. * detach this feature.
  44344. * Will usually be called by the features manager
  44345. *
  44346. * @returns true if successful.
  44347. */
  44348. detach(): boolean;
  44349. /**
  44350. * Get the xr controller that correlates to the pointer id in the pointer event
  44351. *
  44352. * @param id the pointer id to search for
  44353. * @returns the controller that correlates to this id or null if not found
  44354. */
  44355. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  44356. protected _onXRFrame(_xrFrame: XRFrame): void;
  44357. private _attachController;
  44358. private _attachScreenRayMode;
  44359. private _attachGazeMode;
  44360. private _tmpVectorForPickCompare;
  44361. private _pickingMoved;
  44362. private _attachTrackedPointerRayMode;
  44363. private _detachController;
  44364. private _generateNewMeshPair;
  44365. private _convertNormalToDirectionOfRay;
  44366. private _updatePointerDistance;
  44367. }
  44368. }
  44369. declare module BABYLON {
  44370. /**
  44371. * Button which can be used to enter a different mode of XR
  44372. */
  44373. export class WebXREnterExitUIButton {
  44374. /** button element */
  44375. element: HTMLElement;
  44376. /** XR initialization options for the button */
  44377. sessionMode: XRSessionMode;
  44378. /** Reference space type */
  44379. referenceSpaceType: XRReferenceSpaceType;
  44380. /**
  44381. * Creates a WebXREnterExitUIButton
  44382. * @param element button element
  44383. * @param sessionMode XR initialization session mode
  44384. * @param referenceSpaceType the type of reference space to be used
  44385. */
  44386. constructor(
  44387. /** button element */
  44388. element: HTMLElement,
  44389. /** XR initialization options for the button */
  44390. sessionMode: XRSessionMode,
  44391. /** Reference space type */
  44392. referenceSpaceType: XRReferenceSpaceType);
  44393. /**
  44394. * Overwritable function which can be used to update the button's visuals when the state changes
  44395. * @param activeButton the current active button in the UI
  44396. */
  44397. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44398. }
  44399. /**
  44400. * Options to create the webXR UI
  44401. */
  44402. export class WebXREnterExitUIOptions {
  44403. /**
  44404. * Context to enter xr with
  44405. */
  44406. renderTarget?: Nullable<WebXRRenderTarget>;
  44407. /**
  44408. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44409. */
  44410. customButtons?: Array<WebXREnterExitUIButton>;
  44411. /**
  44412. * A session mode to use when creating the default button.
  44413. * Default is immersive-vr
  44414. */
  44415. sessionMode?: XRSessionMode;
  44416. /**
  44417. * A reference space type to use when creating the default button.
  44418. * Default is local-floor
  44419. */
  44420. referenceSpaceType?: XRReferenceSpaceType;
  44421. }
  44422. /**
  44423. * UI to allow the user to enter/exit XR mode
  44424. */
  44425. export class WebXREnterExitUI implements IDisposable {
  44426. private scene;
  44427. /** version of the options passed to this UI */
  44428. options: WebXREnterExitUIOptions;
  44429. private _overlay;
  44430. private _buttons;
  44431. private _activeButton;
  44432. /**
  44433. * Fired every time the active button is changed.
  44434. *
  44435. * When xr is entered via a button that launches xr that button will be the callback parameter
  44436. *
  44437. * When exiting xr the callback parameter will be null)
  44438. */
  44439. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44440. /**
  44441. * Creates UI to allow the user to enter/exit XR mode
  44442. * @param scene the scene to add the ui to
  44443. * @param helper the xr experience helper to enter/exit xr with
  44444. * @param options options to configure the UI
  44445. * @returns the created ui
  44446. */
  44447. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44448. /**
  44449. *
  44450. * @param scene babylon scene object to use
  44451. * @param options (read-only) version of the options passed to this UI
  44452. */
  44453. private constructor();
  44454. private _updateButtons;
  44455. /**
  44456. * Disposes of the object
  44457. */
  44458. dispose(): void;
  44459. }
  44460. }
  44461. declare module BABYLON {
  44462. /**
  44463. * Class containing static functions to help procedurally build meshes
  44464. */
  44465. export class LinesBuilder {
  44466. /**
  44467. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44468. * * 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
  44469. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44470. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44471. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44472. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44473. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44474. * * 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
  44475. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44477. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44478. * @param name defines the name of the new line system
  44479. * @param options defines the options used to create the line system
  44480. * @param scene defines the hosting scene
  44481. * @returns a new line system mesh
  44482. */
  44483. static CreateLineSystem(name: string, options: {
  44484. lines: Vector3[][];
  44485. updatable?: boolean;
  44486. instance?: Nullable<LinesMesh>;
  44487. colors?: Nullable<Color4[][]>;
  44488. useVertexAlpha?: boolean;
  44489. }, scene: Nullable<Scene>): LinesMesh;
  44490. /**
  44491. * Creates a line mesh
  44492. * 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
  44493. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44494. * * The parameter `points` is an array successive Vector3
  44495. * * 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
  44496. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44497. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44498. * * When updating an instance, remember that only point positions can change, not the number of points
  44499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44500. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44501. * @param name defines the name of the new line system
  44502. * @param options defines the options used to create the line system
  44503. * @param scene defines the hosting scene
  44504. * @returns a new line mesh
  44505. */
  44506. static CreateLines(name: string, options: {
  44507. points: Vector3[];
  44508. updatable?: boolean;
  44509. instance?: Nullable<LinesMesh>;
  44510. colors?: Color4[];
  44511. useVertexAlpha?: boolean;
  44512. }, scene?: Nullable<Scene>): LinesMesh;
  44513. /**
  44514. * Creates a dashed line mesh
  44515. * * 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
  44516. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44517. * * The parameter `points` is an array successive Vector3
  44518. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44519. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44520. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44521. * * 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
  44522. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44523. * * When updating an instance, remember that only point positions can change, not the number of points
  44524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44525. * @param name defines the name of the mesh
  44526. * @param options defines the options used to create the mesh
  44527. * @param scene defines the hosting scene
  44528. * @returns the dashed line mesh
  44529. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44530. */
  44531. static CreateDashedLines(name: string, options: {
  44532. points: Vector3[];
  44533. dashSize?: number;
  44534. gapSize?: number;
  44535. dashNb?: number;
  44536. updatable?: boolean;
  44537. instance?: LinesMesh;
  44538. useVertexAlpha?: boolean;
  44539. }, scene?: Nullable<Scene>): LinesMesh;
  44540. }
  44541. }
  44542. declare module BABYLON {
  44543. /**
  44544. * The options container for the teleportation module
  44545. */
  44546. export interface IWebXRTeleportationOptions {
  44547. /**
  44548. * Babylon XR Input class for controller
  44549. */
  44550. xrInput: WebXRInput;
  44551. /**
  44552. * A list of meshes to use as floor meshes.
  44553. * Meshes can be added and removed after initializing the feature using the
  44554. * addFloorMesh and removeFloorMesh functions
  44555. * If empty, rotation will still work
  44556. */
  44557. floorMeshes?: AbstractMesh[];
  44558. /**
  44559. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44560. * If you want to support rotation, make sure your mesh has a direction indicator.
  44561. *
  44562. * When left untouched, the default mesh will be initialized.
  44563. */
  44564. teleportationTargetMesh?: AbstractMesh;
  44565. /**
  44566. * Values to configure the default target mesh
  44567. */
  44568. defaultTargetMeshOptions?: {
  44569. /**
  44570. * Fill color of the teleportation area
  44571. */
  44572. teleportationFillColor?: string;
  44573. /**
  44574. * Border color for the teleportation area
  44575. */
  44576. teleportationBorderColor?: string;
  44577. /**
  44578. * Disable the mesh's animation sequence
  44579. */
  44580. disableAnimation?: boolean;
  44581. /**
  44582. * Disable lighting on the material or the ring and arrow
  44583. */
  44584. disableLighting?: boolean;
  44585. /**
  44586. * Override the default material of the torus and arrow
  44587. */
  44588. torusArrowMaterial?: Material;
  44589. };
  44590. /**
  44591. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  44592. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  44593. */
  44594. useMainComponentOnly?: boolean;
  44595. /**
  44596. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  44597. */
  44598. timeToTeleport?: number;
  44599. }
  44600. /**
  44601. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  44602. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  44603. * the input of the attached controllers.
  44604. */
  44605. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44606. private _options;
  44607. /**
  44608. * The module's name
  44609. */
  44610. static readonly Name: string;
  44611. /**
  44612. * The (Babylon) version of this module.
  44613. * This is an integer representing the implementation version.
  44614. * This number does not correspond to the webxr specs version
  44615. */
  44616. static readonly Version: number;
  44617. /**
  44618. * Is rotation enabled when moving forward?
  44619. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44620. */
  44621. rotationEnabled: boolean;
  44622. /**
  44623. * Should the module support parabolic ray on top of direct ray
  44624. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44625. * Very helpful when moving between floors / different heights
  44626. */
  44627. parabolicRayEnabled: boolean;
  44628. /**
  44629. * The distance from the user to the inspection point in the direction of the controller
  44630. * A higher number will allow the user to move further
  44631. * defaults to 5 (meters, in xr units)
  44632. */
  44633. parabolicCheckRadius: number;
  44634. /**
  44635. * How much rotation should be applied when rotating right and left
  44636. */
  44637. rotationAngle: number;
  44638. /**
  44639. * Is movement backwards enabled
  44640. */
  44641. backwardsMovementEnabled: boolean;
  44642. /**
  44643. * Distance to travel when moving backwards
  44644. */
  44645. backwardsTeleportationDistance: number;
  44646. /**
  44647. * Add a new mesh to the floor meshes array
  44648. * @param mesh the mesh to use as floor mesh
  44649. */
  44650. addFloorMesh(mesh: AbstractMesh): void;
  44651. /**
  44652. * Remove a mesh from the floor meshes array
  44653. * @param mesh the mesh to remove
  44654. */
  44655. removeFloorMesh(mesh: AbstractMesh): void;
  44656. /**
  44657. * Remove a mesh from the floor meshes array using its name
  44658. * @param name the mesh name to remove
  44659. */
  44660. removeFloorMeshByName(name: string): void;
  44661. private _tmpRay;
  44662. private _tmpVector;
  44663. private _floorMeshes;
  44664. private _controllers;
  44665. /**
  44666. * constructs a new anchor system
  44667. * @param _xrSessionManager an instance of WebXRSessionManager
  44668. * @param _options configuration object for this feature
  44669. */
  44670. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44671. private _selectionFeature;
  44672. /**
  44673. * This function sets a selection feature that will be disabled when
  44674. * the forward ray is shown and will be reattached when hidden.
  44675. * This is used to remove the selection rays when moving.
  44676. * @param selectionFeature the feature to disable when forward movement is enabled
  44677. */
  44678. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44679. attach(): boolean;
  44680. detach(): boolean;
  44681. dispose(): void;
  44682. protected _onXRFrame(_xrFrame: XRFrame): void;
  44683. private _currentTeleportationControllerId;
  44684. private _attachController;
  44685. private _teleportForward;
  44686. private _detachController;
  44687. private createDefaultTargetMesh;
  44688. private setTargetMeshVisibility;
  44689. private setTargetMeshPosition;
  44690. private _quadraticBezierCurve;
  44691. private showParabolicPath;
  44692. }
  44693. }
  44694. declare module BABYLON {
  44695. /**
  44696. * Options for the default xr helper
  44697. */
  44698. export class WebXRDefaultExperienceOptions {
  44699. /**
  44700. * Floor meshes that will be used for teleporting
  44701. */
  44702. floorMeshes?: Array<AbstractMesh>;
  44703. /**
  44704. * Enable or disable default UI to enter XR
  44705. */
  44706. disableDefaultUI?: boolean;
  44707. /**
  44708. * optional configuration for the output canvas
  44709. */
  44710. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44711. /**
  44712. * optional UI options. This can be used among other to change session mode and reference space type
  44713. */
  44714. uiOptions?: WebXREnterExitUIOptions;
  44715. /**
  44716. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  44717. */
  44718. inputOptions?: IWebXRInputOptions;
  44719. /**
  44720. * Should teleportation not initialize. defaults to false.
  44721. */
  44722. disableTeleportation?: boolean;
  44723. /**
  44724. * If set to true, the first frame will not be used to reset position
  44725. * The first frame is mainly used when copying transformation from the old camera
  44726. * Mainly used in AR
  44727. */
  44728. ignoreNativeCameraTransformation?: boolean;
  44729. }
  44730. /**
  44731. * Default experience which provides a similar setup to the previous webVRExperience
  44732. */
  44733. export class WebXRDefaultExperience {
  44734. /**
  44735. * Base experience
  44736. */
  44737. baseExperience: WebXRExperienceHelper;
  44738. /**
  44739. * Input experience extension
  44740. */
  44741. input: WebXRInput;
  44742. /**
  44743. * Enables laser pointer and selection
  44744. */
  44745. pointerSelection: WebXRControllerPointerSelection;
  44746. /**
  44747. * Enables teleportation
  44748. */
  44749. teleportation: WebXRMotionControllerTeleportation;
  44750. /**
  44751. * Enables ui for entering/exiting xr
  44752. */
  44753. enterExitUI: WebXREnterExitUI;
  44754. /**
  44755. * Default target xr should render to
  44756. */
  44757. renderTarget: WebXRRenderTarget;
  44758. /**
  44759. * Creates the default xr experience
  44760. * @param scene scene
  44761. * @param options options for basic configuration
  44762. * @returns resulting WebXRDefaultExperience
  44763. */
  44764. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44765. private constructor();
  44766. /**
  44767. * DIsposes of the experience helper
  44768. */
  44769. dispose(): void;
  44770. }
  44771. }
  44772. declare module BABYLON {
  44773. /**
  44774. * Options to modify the vr teleportation behavior.
  44775. */
  44776. export interface VRTeleportationOptions {
  44777. /**
  44778. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44779. */
  44780. floorMeshName?: string;
  44781. /**
  44782. * A list of meshes to be used as the teleportation floor. (default: empty)
  44783. */
  44784. floorMeshes?: Mesh[];
  44785. /**
  44786. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44787. */
  44788. teleportationMode?: number;
  44789. /**
  44790. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44791. */
  44792. teleportationTime?: number;
  44793. /**
  44794. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44795. */
  44796. teleportationSpeed?: number;
  44797. /**
  44798. * The easing function used in the animation or null for Linear. (default CircleEase)
  44799. */
  44800. easingFunction?: EasingFunction;
  44801. }
  44802. /**
  44803. * Options to modify the vr experience helper's behavior.
  44804. */
  44805. export interface VRExperienceHelperOptions extends WebVROptions {
  44806. /**
  44807. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44808. */
  44809. createDeviceOrientationCamera?: boolean;
  44810. /**
  44811. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44812. */
  44813. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44814. /**
  44815. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44816. */
  44817. laserToggle?: boolean;
  44818. /**
  44819. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44820. */
  44821. floorMeshes?: Mesh[];
  44822. /**
  44823. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44824. */
  44825. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44826. /**
  44827. * Defines if WebXR should be used instead of WebVR (if available)
  44828. */
  44829. useXR?: boolean;
  44830. }
  44831. /**
  44832. * Event containing information after VR has been entered
  44833. */
  44834. export class OnAfterEnteringVRObservableEvent {
  44835. /**
  44836. * If entering vr was successful
  44837. */
  44838. success: boolean;
  44839. }
  44840. /**
  44841. * Helps to quickly add VR support to an existing scene.
  44842. * See http://doc.babylonjs.com/how_to/webvr_helper
  44843. */
  44844. export class VRExperienceHelper {
  44845. /** Options to modify the vr experience helper's behavior. */
  44846. webVROptions: VRExperienceHelperOptions;
  44847. private _scene;
  44848. private _position;
  44849. private _btnVR;
  44850. private _btnVRDisplayed;
  44851. private _webVRsupported;
  44852. private _webVRready;
  44853. private _webVRrequesting;
  44854. private _webVRpresenting;
  44855. private _hasEnteredVR;
  44856. private _fullscreenVRpresenting;
  44857. private _inputElement;
  44858. private _webVRCamera;
  44859. private _vrDeviceOrientationCamera;
  44860. private _deviceOrientationCamera;
  44861. private _existingCamera;
  44862. private _onKeyDown;
  44863. private _onVrDisplayPresentChange;
  44864. private _onVRDisplayChanged;
  44865. private _onVRRequestPresentStart;
  44866. private _onVRRequestPresentComplete;
  44867. /**
  44868. * 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)
  44869. */
  44870. enableGazeEvenWhenNoPointerLock: boolean;
  44871. /**
  44872. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44873. */
  44874. exitVROnDoubleTap: boolean;
  44875. /**
  44876. * Observable raised right before entering VR.
  44877. */
  44878. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44879. /**
  44880. * Observable raised when entering VR has completed.
  44881. */
  44882. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44883. /**
  44884. * Observable raised when exiting VR.
  44885. */
  44886. onExitingVRObservable: Observable<VRExperienceHelper>;
  44887. /**
  44888. * Observable raised when controller mesh is loaded.
  44889. */
  44890. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44891. /** Return this.onEnteringVRObservable
  44892. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44893. */
  44894. get onEnteringVR(): Observable<VRExperienceHelper>;
  44895. /** Return this.onExitingVRObservable
  44896. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44897. */
  44898. get onExitingVR(): Observable<VRExperienceHelper>;
  44899. /** Return this.onControllerMeshLoadedObservable
  44900. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44901. */
  44902. get onControllerMeshLoaded(): Observable<WebVRController>;
  44903. private _rayLength;
  44904. private _useCustomVRButton;
  44905. private _teleportationRequested;
  44906. private _teleportActive;
  44907. private _floorMeshName;
  44908. private _floorMeshesCollection;
  44909. private _teleportationMode;
  44910. private _teleportationTime;
  44911. private _teleportationSpeed;
  44912. private _teleportationEasing;
  44913. private _rotationAllowed;
  44914. private _teleportBackwardsVector;
  44915. private _teleportationTarget;
  44916. private _isDefaultTeleportationTarget;
  44917. private _postProcessMove;
  44918. private _teleportationFillColor;
  44919. private _teleportationBorderColor;
  44920. private _rotationAngle;
  44921. private _haloCenter;
  44922. private _cameraGazer;
  44923. private _padSensibilityUp;
  44924. private _padSensibilityDown;
  44925. private _leftController;
  44926. private _rightController;
  44927. private _gazeColor;
  44928. private _laserColor;
  44929. private _pickedLaserColor;
  44930. private _pickedGazeColor;
  44931. /**
  44932. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44933. */
  44934. onNewMeshSelected: Observable<AbstractMesh>;
  44935. /**
  44936. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44937. * This observable will provide the mesh and the controller used to select the mesh
  44938. */
  44939. onMeshSelectedWithController: Observable<{
  44940. mesh: AbstractMesh;
  44941. controller: WebVRController;
  44942. }>;
  44943. /**
  44944. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44945. */
  44946. onNewMeshPicked: Observable<PickingInfo>;
  44947. private _circleEase;
  44948. /**
  44949. * Observable raised before camera teleportation
  44950. */
  44951. onBeforeCameraTeleport: Observable<Vector3>;
  44952. /**
  44953. * Observable raised after camera teleportation
  44954. */
  44955. onAfterCameraTeleport: Observable<Vector3>;
  44956. /**
  44957. * Observable raised when current selected mesh gets unselected
  44958. */
  44959. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44960. private _raySelectionPredicate;
  44961. /**
  44962. * To be optionaly changed by user to define custom ray selection
  44963. */
  44964. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44965. /**
  44966. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44967. */
  44968. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44969. /**
  44970. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44971. */
  44972. teleportationEnabled: boolean;
  44973. private _defaultHeight;
  44974. private _teleportationInitialized;
  44975. private _interactionsEnabled;
  44976. private _interactionsRequested;
  44977. private _displayGaze;
  44978. private _displayLaserPointer;
  44979. /**
  44980. * The mesh used to display where the user is going to teleport.
  44981. */
  44982. get teleportationTarget(): Mesh;
  44983. /**
  44984. * Sets the mesh to be used to display where the user is going to teleport.
  44985. */
  44986. set teleportationTarget(value: Mesh);
  44987. /**
  44988. * 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
  44989. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44990. * See http://doc.babylonjs.com/resources/baking_transformations
  44991. */
  44992. get gazeTrackerMesh(): Mesh;
  44993. set gazeTrackerMesh(value: Mesh);
  44994. /**
  44995. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44996. */
  44997. updateGazeTrackerScale: boolean;
  44998. /**
  44999. * If the gaze trackers color should be updated when selecting meshes
  45000. */
  45001. updateGazeTrackerColor: boolean;
  45002. /**
  45003. * If the controller laser color should be updated when selecting meshes
  45004. */
  45005. updateControllerLaserColor: boolean;
  45006. /**
  45007. * The gaze tracking mesh corresponding to the left controller
  45008. */
  45009. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45010. /**
  45011. * The gaze tracking mesh corresponding to the right controller
  45012. */
  45013. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45014. /**
  45015. * If the ray of the gaze should be displayed.
  45016. */
  45017. get displayGaze(): boolean;
  45018. /**
  45019. * Sets if the ray of the gaze should be displayed.
  45020. */
  45021. set displayGaze(value: boolean);
  45022. /**
  45023. * If the ray of the LaserPointer should be displayed.
  45024. */
  45025. get displayLaserPointer(): boolean;
  45026. /**
  45027. * Sets if the ray of the LaserPointer should be displayed.
  45028. */
  45029. set displayLaserPointer(value: boolean);
  45030. /**
  45031. * The deviceOrientationCamera used as the camera when not in VR.
  45032. */
  45033. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45034. /**
  45035. * Based on the current WebVR support, returns the current VR camera used.
  45036. */
  45037. get currentVRCamera(): Nullable<Camera>;
  45038. /**
  45039. * The webVRCamera which is used when in VR.
  45040. */
  45041. get webVRCamera(): WebVRFreeCamera;
  45042. /**
  45043. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45044. */
  45045. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45046. /**
  45047. * The html button that is used to trigger entering into VR.
  45048. */
  45049. get vrButton(): Nullable<HTMLButtonElement>;
  45050. private get _teleportationRequestInitiated();
  45051. /**
  45052. * Defines wether or not Pointer lock should be requested when switching to
  45053. * full screen.
  45054. */
  45055. requestPointerLockOnFullScreen: boolean;
  45056. /**
  45057. * If asking to force XR, this will be populated with the default xr experience
  45058. */
  45059. xr: WebXRDefaultExperience;
  45060. /**
  45061. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45062. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45063. */
  45064. xrTestDone: boolean;
  45065. /**
  45066. * Instantiates a VRExperienceHelper.
  45067. * Helps to quickly add VR support to an existing scene.
  45068. * @param scene The scene the VRExperienceHelper belongs to.
  45069. * @param webVROptions Options to modify the vr experience helper's behavior.
  45070. */
  45071. constructor(scene: Scene,
  45072. /** Options to modify the vr experience helper's behavior. */
  45073. webVROptions?: VRExperienceHelperOptions);
  45074. private completeVRInit;
  45075. private _onDefaultMeshLoaded;
  45076. private _onResize;
  45077. private _onFullscreenChange;
  45078. /**
  45079. * Gets a value indicating if we are currently in VR mode.
  45080. */
  45081. get isInVRMode(): boolean;
  45082. private onVrDisplayPresentChange;
  45083. private onVRDisplayChanged;
  45084. private moveButtonToBottomRight;
  45085. private displayVRButton;
  45086. private updateButtonVisibility;
  45087. private _cachedAngularSensibility;
  45088. /**
  45089. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45090. * Otherwise, will use the fullscreen API.
  45091. */
  45092. enterVR(): void;
  45093. /**
  45094. * Attempt to exit VR, or fullscreen.
  45095. */
  45096. exitVR(): void;
  45097. /**
  45098. * The position of the vr experience helper.
  45099. */
  45100. get position(): Vector3;
  45101. /**
  45102. * Sets the position of the vr experience helper.
  45103. */
  45104. set position(value: Vector3);
  45105. /**
  45106. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45107. */
  45108. enableInteractions(): void;
  45109. private get _noControllerIsActive();
  45110. private beforeRender;
  45111. private _isTeleportationFloor;
  45112. /**
  45113. * Adds a floor mesh to be used for teleportation.
  45114. * @param floorMesh the mesh to be used for teleportation.
  45115. */
  45116. addFloorMesh(floorMesh: Mesh): void;
  45117. /**
  45118. * Removes a floor mesh from being used for teleportation.
  45119. * @param floorMesh the mesh to be removed.
  45120. */
  45121. removeFloorMesh(floorMesh: Mesh): void;
  45122. /**
  45123. * Enables interactions and teleportation using the VR controllers and gaze.
  45124. * @param vrTeleportationOptions options to modify teleportation behavior.
  45125. */
  45126. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45127. private _onNewGamepadConnected;
  45128. private _tryEnableInteractionOnController;
  45129. private _onNewGamepadDisconnected;
  45130. private _enableInteractionOnController;
  45131. private _checkTeleportWithRay;
  45132. private _checkRotate;
  45133. private _checkTeleportBackwards;
  45134. private _enableTeleportationOnController;
  45135. private _createTeleportationCircles;
  45136. private _displayTeleportationTarget;
  45137. private _hideTeleportationTarget;
  45138. private _rotateCamera;
  45139. private _moveTeleportationSelectorTo;
  45140. private _workingVector;
  45141. private _workingQuaternion;
  45142. private _workingMatrix;
  45143. /**
  45144. * Time Constant Teleportation Mode
  45145. */
  45146. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45147. /**
  45148. * Speed Constant Teleportation Mode
  45149. */
  45150. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45151. /**
  45152. * Teleports the users feet to the desired location
  45153. * @param location The location where the user's feet should be placed
  45154. */
  45155. teleportCamera(location: Vector3): void;
  45156. private _convertNormalToDirectionOfRay;
  45157. private _castRayAndSelectObject;
  45158. private _notifySelectedMeshUnselected;
  45159. /**
  45160. * Permanently set new colors for the laser pointer
  45161. * @param color the new laser color
  45162. * @param pickedColor the new laser color when picked mesh detected
  45163. */
  45164. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45165. /**
  45166. * Set lighting enabled / disabled on the laser pointer of both controllers
  45167. * @param enabled should the lighting be enabled on the laser pointer
  45168. */
  45169. setLaserLightingState(enabled?: boolean): void;
  45170. /**
  45171. * Permanently set new colors for the gaze pointer
  45172. * @param color the new gaze color
  45173. * @param pickedColor the new gaze color when picked mesh detected
  45174. */
  45175. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45176. /**
  45177. * Sets the color of the laser ray from the vr controllers.
  45178. * @param color new color for the ray.
  45179. */
  45180. changeLaserColor(color: Color3): void;
  45181. /**
  45182. * Sets the color of the ray from the vr headsets gaze.
  45183. * @param color new color for the ray.
  45184. */
  45185. changeGazeColor(color: Color3): void;
  45186. /**
  45187. * Exits VR and disposes of the vr experience helper
  45188. */
  45189. dispose(): void;
  45190. /**
  45191. * Gets the name of the VRExperienceHelper class
  45192. * @returns "VRExperienceHelper"
  45193. */
  45194. getClassName(): string;
  45195. }
  45196. }
  45197. declare module BABYLON {
  45198. /**
  45199. * Options used for hit testing
  45200. */
  45201. export interface IWebXRHitTestOptions {
  45202. /**
  45203. * Only test when user interacted with the scene. Default - hit test every frame
  45204. */
  45205. testOnPointerDownOnly?: boolean;
  45206. /**
  45207. * The node to use to transform the local results to world coordinates
  45208. */
  45209. worldParentNode?: TransformNode;
  45210. }
  45211. /**
  45212. * Interface defining the babylon result of raycasting/hit-test
  45213. */
  45214. export interface IWebXRHitResult {
  45215. /**
  45216. * The native hit test result
  45217. */
  45218. xrHitResult: XRHitResult;
  45219. /**
  45220. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45221. */
  45222. transformationMatrix: Matrix;
  45223. }
  45224. /**
  45225. * The currently-working hit-test module.
  45226. * Hit test (or raycasting) is used to interact with the real world.
  45227. * For further information read here - https://github.com/immersive-web/hit-test
  45228. */
  45229. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  45230. /**
  45231. * options to use when constructing this feature
  45232. */
  45233. readonly options: IWebXRHitTestOptions;
  45234. /**
  45235. * The module's name
  45236. */
  45237. static readonly Name: string;
  45238. /**
  45239. * The (Babylon) version of this module.
  45240. * This is an integer representing the implementation version.
  45241. * This number does not correspond to the webxr specs version
  45242. */
  45243. static readonly Version: number;
  45244. /**
  45245. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  45246. * @param event the (select) event to use to select with
  45247. * @param referenceSpace the reference space to use for this hit test
  45248. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45249. */
  45250. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  45251. /**
  45252. * execute a hit test with an XR Ray
  45253. *
  45254. * @param xrSession a native xrSession that will execute this hit test
  45255. * @param xrRay the ray (position and direction) to use for raycasting
  45256. * @param referenceSpace native XR reference space to use for the hit-test
  45257. * @param filter filter function that will filter the results
  45258. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45259. */
  45260. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  45261. /**
  45262. * Triggered when new babylon (transformed) hit test results are available
  45263. */
  45264. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  45265. private _onSelectEnabled;
  45266. /**
  45267. * Creates a new instance of the (legacy version) hit test feature
  45268. * @param _xrSessionManager an instance of WebXRSessionManager
  45269. * @param options options to use when constructing this feature
  45270. */
  45271. constructor(_xrSessionManager: WebXRSessionManager,
  45272. /**
  45273. * options to use when constructing this feature
  45274. */
  45275. options?: IWebXRHitTestOptions);
  45276. /**
  45277. * Populated with the last native XR Hit Results
  45278. */
  45279. lastNativeXRHitResults: XRHitResult[];
  45280. /**
  45281. * attach this feature
  45282. * Will usually be called by the features manager
  45283. *
  45284. * @returns true if successful.
  45285. */
  45286. attach(): boolean;
  45287. /**
  45288. * detach this feature.
  45289. * Will usually be called by the features manager
  45290. *
  45291. * @returns true if successful.
  45292. */
  45293. detach(): boolean;
  45294. private _onHitTestResults;
  45295. private _origin;
  45296. private _direction;
  45297. private _mat;
  45298. protected _onXRFrame(frame: XRFrame): void;
  45299. private _onSelect;
  45300. /**
  45301. * Dispose this feature and all of the resources attached
  45302. */
  45303. dispose(): void;
  45304. }
  45305. }
  45306. declare module BABYLON {
  45307. /**
  45308. * Options used in the plane detector module
  45309. */
  45310. export interface IWebXRPlaneDetectorOptions {
  45311. /**
  45312. * The node to use to transform the local results to world coordinates
  45313. */
  45314. worldParentNode?: TransformNode;
  45315. }
  45316. /**
  45317. * A babylon interface for a webxr plane.
  45318. * A Plane is actually a polygon, built from N points in space
  45319. *
  45320. * Supported in chrome 79, not supported in canary 81 ATM
  45321. */
  45322. export interface IWebXRPlane {
  45323. /**
  45324. * a babylon-assigned ID for this polygon
  45325. */
  45326. id: number;
  45327. /**
  45328. * the native xr-plane object
  45329. */
  45330. xrPlane: XRPlane;
  45331. /**
  45332. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  45333. */
  45334. polygonDefinition: Array<Vector3>;
  45335. /**
  45336. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  45337. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  45338. */
  45339. transformationMatrix: Matrix;
  45340. }
  45341. /**
  45342. * The plane detector is used to detect planes in the real world when in AR
  45343. * For more information see https://github.com/immersive-web/real-world-geometry/
  45344. */
  45345. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  45346. private _options;
  45347. /**
  45348. * The module's name
  45349. */
  45350. static readonly Name: string;
  45351. /**
  45352. * The (Babylon) version of this module.
  45353. * This is an integer representing the implementation version.
  45354. * This number does not correspond to the webxr specs version
  45355. */
  45356. static readonly Version: number;
  45357. /**
  45358. * Observers registered here will be executed when a new plane was added to the session
  45359. */
  45360. onPlaneAddedObservable: Observable<IWebXRPlane>;
  45361. /**
  45362. * Observers registered here will be executed when a plane is no longer detected in the session
  45363. */
  45364. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  45365. /**
  45366. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  45367. * This can execute N times every frame
  45368. */
  45369. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  45370. private _enabled;
  45371. private _detectedPlanes;
  45372. private _lastFrameDetected;
  45373. /**
  45374. * construct a new Plane Detector
  45375. * @param _xrSessionManager an instance of xr Session manager
  45376. * @param _options configuration to use when constructing this feature
  45377. */
  45378. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  45379. private _init;
  45380. protected _onXRFrame(frame: XRFrame): void;
  45381. /**
  45382. * Dispose this feature and all of the resources attached
  45383. */
  45384. dispose(): void;
  45385. private _updatePlaneWithXRPlane;
  45386. /**
  45387. * avoiding using Array.find for global support.
  45388. * @param xrPlane the plane to find in the array
  45389. */
  45390. private findIndexInPlaneArray;
  45391. }
  45392. }
  45393. declare module BABYLON {
  45394. /**
  45395. * Configuration options of the anchor system
  45396. */
  45397. export interface IWebXRAnchorSystemOptions {
  45398. /**
  45399. * a node that will be used to convert local to world coordinates
  45400. */
  45401. worldParentNode?: TransformNode;
  45402. /**
  45403. * should the anchor system use plane detection.
  45404. * If set to true, the plane-detection feature should be set using setPlaneDetector
  45405. */
  45406. usePlaneDetection?: boolean;
  45407. /**
  45408. * Should a new anchor be added every time a select event is triggered
  45409. */
  45410. addAnchorOnSelect?: boolean;
  45411. }
  45412. /**
  45413. * A babylon container for an XR Anchor
  45414. */
  45415. export interface IWebXRAnchor {
  45416. /**
  45417. * A babylon-assigned ID for this anchor
  45418. */
  45419. id: number;
  45420. /**
  45421. * The native anchor object
  45422. */
  45423. xrAnchor: XRAnchor;
  45424. /**
  45425. * Transformation matrix to apply to an object attached to this anchor
  45426. */
  45427. transformationMatrix: Matrix;
  45428. }
  45429. /**
  45430. * An implementation of the anchor system of WebXR.
  45431. * Note that the current documented implementation is not available in any browser. Future implementations
  45432. * will use the frame to create an anchor and not the session or a detected plane
  45433. * For further information see https://github.com/immersive-web/anchors/
  45434. */
  45435. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  45436. private _options;
  45437. /**
  45438. * The module's name
  45439. */
  45440. static readonly Name: string;
  45441. /**
  45442. * The (Babylon) version of this module.
  45443. * This is an integer representing the implementation version.
  45444. * This number does not correspond to the webxr specs version
  45445. */
  45446. static readonly Version: number;
  45447. /**
  45448. * Observers registered here will be executed when a new anchor was added to the session
  45449. */
  45450. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  45451. /**
  45452. * Observers registered here will be executed when an existing anchor updates
  45453. * This can execute N times every frame
  45454. */
  45455. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  45456. /**
  45457. * Observers registered here will be executed when an anchor was removed from the session
  45458. */
  45459. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  45460. private _planeDetector;
  45461. private _hitTestModule;
  45462. private _enabled;
  45463. private _trackedAnchors;
  45464. private _lastFrameDetected;
  45465. /**
  45466. * constructs a new anchor system
  45467. * @param _xrSessionManager an instance of WebXRSessionManager
  45468. * @param _options configuration object for this feature
  45469. */
  45470. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  45471. /**
  45472. * set the plane detector to use in order to create anchors from frames
  45473. * @param planeDetector the plane-detector module to use
  45474. * @param enable enable plane-anchors. default is true
  45475. */
  45476. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  45477. /**
  45478. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  45479. * @param hitTestModule the hit-test module to use.
  45480. */
  45481. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  45482. /**
  45483. * attach this feature
  45484. * Will usually be called by the features manager
  45485. *
  45486. * @returns true if successful.
  45487. */
  45488. attach(): boolean;
  45489. /**
  45490. * detach this feature.
  45491. * Will usually be called by the features manager
  45492. *
  45493. * @returns true if successful.
  45494. */
  45495. detach(): boolean;
  45496. /**
  45497. * Dispose this feature and all of the resources attached
  45498. */
  45499. dispose(): void;
  45500. protected _onXRFrame(frame: XRFrame): void;
  45501. private _onSelect;
  45502. /**
  45503. * Add anchor at a specific XR point.
  45504. *
  45505. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  45506. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  45507. * @returns a promise the fulfills when the anchor was created
  45508. */
  45509. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  45510. private _updateAnchorWithXRFrame;
  45511. /**
  45512. * avoiding using Array.find for global support.
  45513. * @param xrAnchor the plane to find in the array
  45514. */
  45515. private _findIndexInAnchorArray;
  45516. }
  45517. }
  45518. declare module BABYLON {
  45519. /**
  45520. * Options interface for the background remover plugin
  45521. */
  45522. export interface IWebXRBackgroundRemoverOptions {
  45523. /**
  45524. * don't disable the environment helper
  45525. */
  45526. ignoreEnvironmentHelper?: boolean;
  45527. /**
  45528. * flags to configure the removal of the environment helper.
  45529. * If not set, the entire background will be removed. If set, flags should be set as well.
  45530. */
  45531. environmentHelperRemovalFlags?: {
  45532. /**
  45533. * Should the skybox be removed (default false)
  45534. */
  45535. skyBox?: boolean;
  45536. /**
  45537. * Should the ground be removed (default false)
  45538. */
  45539. ground?: boolean;
  45540. };
  45541. /**
  45542. * Further background meshes to disable when entering AR
  45543. */
  45544. backgroundMeshes?: AbstractMesh[];
  45545. }
  45546. /**
  45547. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  45548. */
  45549. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  45550. /**
  45551. * read-only options to be used in this module
  45552. */
  45553. readonly options: IWebXRBackgroundRemoverOptions;
  45554. /**
  45555. * The module's name
  45556. */
  45557. static readonly Name: string;
  45558. /**
  45559. * The (Babylon) version of this module.
  45560. * This is an integer representing the implementation version.
  45561. * This number does not correspond to the webxr specs version
  45562. */
  45563. static readonly Version: number;
  45564. /**
  45565. * registered observers will be triggered when the background state changes
  45566. */
  45567. onBackgroundStateChangedObservable: Observable<boolean>;
  45568. /**
  45569. * constructs a new background remover module
  45570. * @param _xrSessionManager the session manager for this module
  45571. * @param options read-only options to be used in this module
  45572. */
  45573. constructor(_xrSessionManager: WebXRSessionManager,
  45574. /**
  45575. * read-only options to be used in this module
  45576. */
  45577. options?: IWebXRBackgroundRemoverOptions);
  45578. /**
  45579. * attach this feature
  45580. * Will usually be called by the features manager
  45581. *
  45582. * @returns true if successful.
  45583. */
  45584. attach(): boolean;
  45585. /**
  45586. * detach this feature.
  45587. * Will usually be called by the features manager
  45588. *
  45589. * @returns true if successful.
  45590. */
  45591. detach(): boolean;
  45592. private _setBackgroundState;
  45593. /**
  45594. * Dispose this feature and all of the resources attached
  45595. */
  45596. dispose(): void;
  45597. protected _onXRFrame(_xrFrame: XRFrame): void;
  45598. }
  45599. }
  45600. declare module BABYLON {
  45601. /**
  45602. * The motion controller class for all microsoft mixed reality controllers
  45603. */
  45604. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  45605. /**
  45606. * The base url used to load the left and right controller models
  45607. */
  45608. static MODEL_BASE_URL: string;
  45609. /**
  45610. * The name of the left controller model file
  45611. */
  45612. static MODEL_LEFT_FILENAME: string;
  45613. /**
  45614. * The name of the right controller model file
  45615. */
  45616. static MODEL_RIGHT_FILENAME: string;
  45617. profileId: string;
  45618. protected readonly _mapping: {
  45619. defaultButton: {
  45620. "valueNodeName": string;
  45621. "unpressedNodeName": string;
  45622. "pressedNodeName": string;
  45623. };
  45624. defaultAxis: {
  45625. "valueNodeName": string;
  45626. "minNodeName": string;
  45627. "maxNodeName": string;
  45628. };
  45629. buttons: {
  45630. "xr-standard-trigger": {
  45631. "rootNodeName": string;
  45632. "componentProperty": string;
  45633. "states": string[];
  45634. };
  45635. "xr-standard-squeeze": {
  45636. "rootNodeName": string;
  45637. "componentProperty": string;
  45638. "states": string[];
  45639. };
  45640. "xr-standard-touchpad": {
  45641. "rootNodeName": string;
  45642. "labelAnchorNodeName": string;
  45643. "touchPointNodeName": string;
  45644. };
  45645. "xr-standard-thumbstick": {
  45646. "rootNodeName": string;
  45647. "componentProperty": string;
  45648. "states": string[];
  45649. };
  45650. };
  45651. axes: {
  45652. "xr-standard-touchpad": {
  45653. "x-axis": {
  45654. "rootNodeName": string;
  45655. };
  45656. "y-axis": {
  45657. "rootNodeName": string;
  45658. };
  45659. };
  45660. "xr-standard-thumbstick": {
  45661. "x-axis": {
  45662. "rootNodeName": string;
  45663. };
  45664. "y-axis": {
  45665. "rootNodeName": string;
  45666. };
  45667. };
  45668. };
  45669. };
  45670. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45671. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45672. protected _getFilenameAndPath(): {
  45673. filename: string;
  45674. path: string;
  45675. };
  45676. protected _updateModel(): void;
  45677. protected _getModelLoadingConstraints(): boolean;
  45678. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45679. }
  45680. }
  45681. declare module BABYLON {
  45682. /**
  45683. * The motion controller class for oculus touch (quest, rift).
  45684. * This class supports legacy mapping as well the standard xr mapping
  45685. */
  45686. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  45687. private _forceLegacyControllers;
  45688. /**
  45689. * The base url used to load the left and right controller models
  45690. */
  45691. static MODEL_BASE_URL: string;
  45692. /**
  45693. * The name of the left controller model file
  45694. */
  45695. static MODEL_LEFT_FILENAME: string;
  45696. /**
  45697. * The name of the right controller model file
  45698. */
  45699. static MODEL_RIGHT_FILENAME: string;
  45700. /**
  45701. * Base Url for the Quest controller model.
  45702. */
  45703. static QUEST_MODEL_BASE_URL: string;
  45704. profileId: string;
  45705. private _modelRootNode;
  45706. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  45707. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45708. protected _getFilenameAndPath(): {
  45709. filename: string;
  45710. path: string;
  45711. };
  45712. /**
  45713. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  45714. * between the touch and touch 2.
  45715. */
  45716. private _isQuest;
  45717. protected _updateModel(): void;
  45718. protected _getModelLoadingConstraints(): boolean;
  45719. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45720. }
  45721. }
  45722. declare module BABYLON {
  45723. /**
  45724. * The motion controller class for the standard HTC-Vive controllers
  45725. */
  45726. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  45727. /**
  45728. * The base url used to load the left and right controller models
  45729. */
  45730. static MODEL_BASE_URL: string;
  45731. /**
  45732. * File name for the controller model.
  45733. */
  45734. static MODEL_FILENAME: string;
  45735. profileId: string;
  45736. private _modelRootNode;
  45737. /**
  45738. * Create a new Vive motion controller object
  45739. * @param scene the scene to use to create this controller
  45740. * @param gamepadObject the corresponding gamepad object
  45741. * @param handness the handness of the controller
  45742. */
  45743. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45744. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45745. protected _getFilenameAndPath(): {
  45746. filename: string;
  45747. path: string;
  45748. };
  45749. protected _updateModel(): void;
  45750. protected _getModelLoadingConstraints(): boolean;
  45751. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45752. }
  45753. }
  45754. declare module BABYLON {
  45755. /**
  45756. * Contains an array of blocks representing the octree
  45757. */
  45758. export interface IOctreeContainer<T> {
  45759. /**
  45760. * Blocks within the octree
  45761. */
  45762. blocks: Array<OctreeBlock<T>>;
  45763. }
  45764. /**
  45765. * Class used to store a cell in an octree
  45766. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45767. */
  45768. export class OctreeBlock<T> {
  45769. /**
  45770. * Gets the content of the current block
  45771. */
  45772. entries: T[];
  45773. /**
  45774. * Gets the list of block children
  45775. */
  45776. blocks: Array<OctreeBlock<T>>;
  45777. private _depth;
  45778. private _maxDepth;
  45779. private _capacity;
  45780. private _minPoint;
  45781. private _maxPoint;
  45782. private _boundingVectors;
  45783. private _creationFunc;
  45784. /**
  45785. * Creates a new block
  45786. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45787. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45788. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45789. * @param depth defines the current depth of this block in the octree
  45790. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45791. * @param creationFunc defines a callback to call when an element is added to the block
  45792. */
  45793. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45794. /**
  45795. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45796. */
  45797. get capacity(): number;
  45798. /**
  45799. * Gets the minimum vector (in world space) of the block's bounding box
  45800. */
  45801. get minPoint(): Vector3;
  45802. /**
  45803. * Gets the maximum vector (in world space) of the block's bounding box
  45804. */
  45805. get maxPoint(): Vector3;
  45806. /**
  45807. * Add a new element to this block
  45808. * @param entry defines the element to add
  45809. */
  45810. addEntry(entry: T): void;
  45811. /**
  45812. * Remove an element from this block
  45813. * @param entry defines the element to remove
  45814. */
  45815. removeEntry(entry: T): void;
  45816. /**
  45817. * Add an array of elements to this block
  45818. * @param entries defines the array of elements to add
  45819. */
  45820. addEntries(entries: T[]): void;
  45821. /**
  45822. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45823. * @param frustumPlanes defines the frustum planes to test
  45824. * @param selection defines the array to store current content if selection is positive
  45825. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45826. */
  45827. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45828. /**
  45829. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45830. * @param sphereCenter defines the bounding sphere center
  45831. * @param sphereRadius defines the bounding sphere radius
  45832. * @param selection defines the array to store current content if selection is positive
  45833. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45834. */
  45835. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45836. /**
  45837. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45838. * @param ray defines the ray to test with
  45839. * @param selection defines the array to store current content if selection is positive
  45840. */
  45841. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45842. /**
  45843. * Subdivide the content into child blocks (this block will then be empty)
  45844. */
  45845. createInnerBlocks(): void;
  45846. /**
  45847. * @hidden
  45848. */
  45849. 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;
  45850. }
  45851. }
  45852. declare module BABYLON {
  45853. /**
  45854. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45855. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45856. */
  45857. export class Octree<T> {
  45858. /** 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.) */
  45859. maxDepth: number;
  45860. /**
  45861. * Blocks within the octree containing objects
  45862. */
  45863. blocks: Array<OctreeBlock<T>>;
  45864. /**
  45865. * Content stored in the octree
  45866. */
  45867. dynamicContent: T[];
  45868. private _maxBlockCapacity;
  45869. private _selectionContent;
  45870. private _creationFunc;
  45871. /**
  45872. * Creates a octree
  45873. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45874. * @param creationFunc function to be used to instatiate the octree
  45875. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45876. * @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.)
  45877. */
  45878. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45879. /** 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.) */
  45880. maxDepth?: number);
  45881. /**
  45882. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45883. * @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);
  45884. * @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);
  45885. * @param entries meshes to be added to the octree blocks
  45886. */
  45887. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45888. /**
  45889. * Adds a mesh to the octree
  45890. * @param entry Mesh to add to the octree
  45891. */
  45892. addMesh(entry: T): void;
  45893. /**
  45894. * Remove an element from the octree
  45895. * @param entry defines the element to remove
  45896. */
  45897. removeMesh(entry: T): void;
  45898. /**
  45899. * Selects an array of meshes within the frustum
  45900. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45901. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45902. * @returns array of meshes within the frustum
  45903. */
  45904. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45905. /**
  45906. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45907. * @param sphereCenter defines the bounding sphere center
  45908. * @param sphereRadius defines the bounding sphere radius
  45909. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45910. * @returns an array of objects that intersect the sphere
  45911. */
  45912. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45913. /**
  45914. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45915. * @param ray defines the ray to test with
  45916. * @returns array of intersected objects
  45917. */
  45918. intersectsRay(ray: Ray): SmartArray<T>;
  45919. /**
  45920. * Adds a mesh into the octree block if it intersects the block
  45921. */
  45922. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45923. /**
  45924. * Adds a submesh into the octree block if it intersects the block
  45925. */
  45926. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45927. }
  45928. }
  45929. declare module BABYLON {
  45930. interface Scene {
  45931. /**
  45932. * @hidden
  45933. * Backing Filed
  45934. */
  45935. _selectionOctree: Octree<AbstractMesh>;
  45936. /**
  45937. * Gets the octree used to boost mesh selection (picking)
  45938. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45939. */
  45940. selectionOctree: Octree<AbstractMesh>;
  45941. /**
  45942. * Creates or updates the octree used to boost selection (picking)
  45943. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45944. * @param maxCapacity defines the maximum capacity per leaf
  45945. * @param maxDepth defines the maximum depth of the octree
  45946. * @returns an octree of AbstractMesh
  45947. */
  45948. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45949. }
  45950. interface AbstractMesh {
  45951. /**
  45952. * @hidden
  45953. * Backing Field
  45954. */
  45955. _submeshesOctree: Octree<SubMesh>;
  45956. /**
  45957. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45958. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45959. * @param maxCapacity defines the maximum size of each block (64 by default)
  45960. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45961. * @returns the new octree
  45962. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45963. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45964. */
  45965. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45966. }
  45967. /**
  45968. * Defines the octree scene component responsible to manage any octrees
  45969. * in a given scene.
  45970. */
  45971. export class OctreeSceneComponent {
  45972. /**
  45973. * The component name help to identify the component in the list of scene components.
  45974. */
  45975. readonly name: string;
  45976. /**
  45977. * The scene the component belongs to.
  45978. */
  45979. scene: Scene;
  45980. /**
  45981. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45982. */
  45983. readonly checksIsEnabled: boolean;
  45984. /**
  45985. * Creates a new instance of the component for the given scene
  45986. * @param scene Defines the scene to register the component in
  45987. */
  45988. constructor(scene: Scene);
  45989. /**
  45990. * Registers the component in a given scene
  45991. */
  45992. register(): void;
  45993. /**
  45994. * Return the list of active meshes
  45995. * @returns the list of active meshes
  45996. */
  45997. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45998. /**
  45999. * Return the list of active sub meshes
  46000. * @param mesh The mesh to get the candidates sub meshes from
  46001. * @returns the list of active sub meshes
  46002. */
  46003. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46004. private _tempRay;
  46005. /**
  46006. * Return the list of sub meshes intersecting with a given local ray
  46007. * @param mesh defines the mesh to find the submesh for
  46008. * @param localRay defines the ray in local space
  46009. * @returns the list of intersecting sub meshes
  46010. */
  46011. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46012. /**
  46013. * Return the list of sub meshes colliding with a collider
  46014. * @param mesh defines the mesh to find the submesh for
  46015. * @param collider defines the collider to evaluate the collision against
  46016. * @returns the list of colliding sub meshes
  46017. */
  46018. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46019. /**
  46020. * Rebuilds the elements related to this component in case of
  46021. * context lost for instance.
  46022. */
  46023. rebuild(): void;
  46024. /**
  46025. * Disposes the component and the associated ressources.
  46026. */
  46027. dispose(): void;
  46028. }
  46029. }
  46030. declare module BABYLON {
  46031. /**
  46032. * Renders a layer on top of an existing scene
  46033. */
  46034. export class UtilityLayerRenderer implements IDisposable {
  46035. /** the original scene that will be rendered on top of */
  46036. originalScene: Scene;
  46037. private _pointerCaptures;
  46038. private _lastPointerEvents;
  46039. private static _DefaultUtilityLayer;
  46040. private static _DefaultKeepDepthUtilityLayer;
  46041. private _sharedGizmoLight;
  46042. private _renderCamera;
  46043. /**
  46044. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46045. * @returns the camera that is used when rendering the utility layer
  46046. */
  46047. getRenderCamera(): Camera;
  46048. /**
  46049. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46050. * @param cam the camera that should be used when rendering the utility layer
  46051. */
  46052. setRenderCamera(cam: Nullable<Camera>): void;
  46053. /**
  46054. * @hidden
  46055. * Light which used by gizmos to get light shading
  46056. */
  46057. _getSharedGizmoLight(): HemisphericLight;
  46058. /**
  46059. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46060. */
  46061. pickUtilitySceneFirst: boolean;
  46062. /**
  46063. * 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)
  46064. */
  46065. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46066. /**
  46067. * 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)
  46068. */
  46069. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46070. /**
  46071. * The scene that is rendered on top of the original scene
  46072. */
  46073. utilityLayerScene: Scene;
  46074. /**
  46075. * If the utility layer should automatically be rendered on top of existing scene
  46076. */
  46077. shouldRender: boolean;
  46078. /**
  46079. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46080. */
  46081. onlyCheckPointerDownEvents: boolean;
  46082. /**
  46083. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46084. */
  46085. processAllEvents: boolean;
  46086. /**
  46087. * Observable raised when the pointer move from the utility layer scene to the main scene
  46088. */
  46089. onPointerOutObservable: Observable<number>;
  46090. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46091. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46092. private _afterRenderObserver;
  46093. private _sceneDisposeObserver;
  46094. private _originalPointerObserver;
  46095. /**
  46096. * Instantiates a UtilityLayerRenderer
  46097. * @param originalScene the original scene that will be rendered on top of
  46098. * @param handleEvents boolean indicating if the utility layer should handle events
  46099. */
  46100. constructor(
  46101. /** the original scene that will be rendered on top of */
  46102. originalScene: Scene, handleEvents?: boolean);
  46103. private _notifyObservers;
  46104. /**
  46105. * Renders the utility layers scene on top of the original scene
  46106. */
  46107. render(): void;
  46108. /**
  46109. * Disposes of the renderer
  46110. */
  46111. dispose(): void;
  46112. private _updateCamera;
  46113. }
  46114. }
  46115. declare module BABYLON {
  46116. /**
  46117. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46118. */
  46119. export class Gizmo implements IDisposable {
  46120. /** The utility layer the gizmo will be added to */
  46121. gizmoLayer: UtilityLayerRenderer;
  46122. /**
  46123. * The root mesh of the gizmo
  46124. */
  46125. _rootMesh: Mesh;
  46126. private _attachedMesh;
  46127. /**
  46128. * Ratio for the scale of the gizmo (Default: 1)
  46129. */
  46130. scaleRatio: number;
  46131. /**
  46132. * If a custom mesh has been set (Default: false)
  46133. */
  46134. protected _customMeshSet: boolean;
  46135. /**
  46136. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46137. * * When set, interactions will be enabled
  46138. */
  46139. get attachedMesh(): Nullable<AbstractMesh>;
  46140. set attachedMesh(value: Nullable<AbstractMesh>);
  46141. /**
  46142. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46143. * @param mesh The mesh to replace the default mesh of the gizmo
  46144. */
  46145. setCustomMesh(mesh: Mesh): void;
  46146. /**
  46147. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46148. */
  46149. updateGizmoRotationToMatchAttachedMesh: boolean;
  46150. /**
  46151. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46152. */
  46153. updateGizmoPositionToMatchAttachedMesh: boolean;
  46154. /**
  46155. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46156. */
  46157. updateScale: boolean;
  46158. protected _interactionsEnabled: boolean;
  46159. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46160. private _beforeRenderObserver;
  46161. private _tempVector;
  46162. /**
  46163. * Creates a gizmo
  46164. * @param gizmoLayer The utility layer the gizmo will be added to
  46165. */
  46166. constructor(
  46167. /** The utility layer the gizmo will be added to */
  46168. gizmoLayer?: UtilityLayerRenderer);
  46169. /**
  46170. * Updates the gizmo to match the attached mesh's position/rotation
  46171. */
  46172. protected _update(): void;
  46173. /**
  46174. * Disposes of the gizmo
  46175. */
  46176. dispose(): void;
  46177. }
  46178. }
  46179. declare module BABYLON {
  46180. /**
  46181. * Single plane drag gizmo
  46182. */
  46183. export class PlaneDragGizmo extends Gizmo {
  46184. /**
  46185. * Drag behavior responsible for the gizmos dragging interactions
  46186. */
  46187. dragBehavior: PointerDragBehavior;
  46188. private _pointerObserver;
  46189. /**
  46190. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46191. */
  46192. snapDistance: number;
  46193. /**
  46194. * Event that fires each time the gizmo snaps to a new location.
  46195. * * snapDistance is the the change in distance
  46196. */
  46197. onSnapObservable: Observable<{
  46198. snapDistance: number;
  46199. }>;
  46200. private _plane;
  46201. private _coloredMaterial;
  46202. private _hoverMaterial;
  46203. private _isEnabled;
  46204. private _parent;
  46205. /** @hidden */
  46206. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46207. /** @hidden */
  46208. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46209. /**
  46210. * Creates a PlaneDragGizmo
  46211. * @param gizmoLayer The utility layer the gizmo will be added to
  46212. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46213. * @param color The color of the gizmo
  46214. */
  46215. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46216. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46217. /**
  46218. * If the gizmo is enabled
  46219. */
  46220. set isEnabled(value: boolean);
  46221. get isEnabled(): boolean;
  46222. /**
  46223. * Disposes of the gizmo
  46224. */
  46225. dispose(): void;
  46226. }
  46227. }
  46228. declare module BABYLON {
  46229. /**
  46230. * Gizmo that enables dragging a mesh along 3 axis
  46231. */
  46232. export class PositionGizmo extends Gizmo {
  46233. /**
  46234. * Internal gizmo used for interactions on the x axis
  46235. */
  46236. xGizmo: AxisDragGizmo;
  46237. /**
  46238. * Internal gizmo used for interactions on the y axis
  46239. */
  46240. yGizmo: AxisDragGizmo;
  46241. /**
  46242. * Internal gizmo used for interactions on the z axis
  46243. */
  46244. zGizmo: AxisDragGizmo;
  46245. /**
  46246. * Internal gizmo used for interactions on the yz plane
  46247. */
  46248. xPlaneGizmo: PlaneDragGizmo;
  46249. /**
  46250. * Internal gizmo used for interactions on the xz plane
  46251. */
  46252. yPlaneGizmo: PlaneDragGizmo;
  46253. /**
  46254. * Internal gizmo used for interactions on the xy plane
  46255. */
  46256. zPlaneGizmo: PlaneDragGizmo;
  46257. /**
  46258. * private variables
  46259. */
  46260. private _meshAttached;
  46261. private _updateGizmoRotationToMatchAttachedMesh;
  46262. private _snapDistance;
  46263. private _scaleRatio;
  46264. /** Fires an event when any of it's sub gizmos are dragged */
  46265. onDragStartObservable: Observable<unknown>;
  46266. /** Fires an event when any of it's sub gizmos are released from dragging */
  46267. onDragEndObservable: Observable<unknown>;
  46268. /**
  46269. * If set to true, planar drag is enabled
  46270. */
  46271. private _planarGizmoEnabled;
  46272. get attachedMesh(): Nullable<AbstractMesh>;
  46273. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46274. /**
  46275. * Creates a PositionGizmo
  46276. * @param gizmoLayer The utility layer the gizmo will be added to
  46277. */
  46278. constructor(gizmoLayer?: UtilityLayerRenderer);
  46279. /**
  46280. * If the planar drag gizmo is enabled
  46281. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46282. */
  46283. set planarGizmoEnabled(value: boolean);
  46284. get planarGizmoEnabled(): boolean;
  46285. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46286. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46287. /**
  46288. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46289. */
  46290. set snapDistance(value: number);
  46291. get snapDistance(): number;
  46292. /**
  46293. * Ratio for the scale of the gizmo (Default: 1)
  46294. */
  46295. set scaleRatio(value: number);
  46296. get scaleRatio(): number;
  46297. /**
  46298. * Disposes of the gizmo
  46299. */
  46300. dispose(): void;
  46301. /**
  46302. * CustomMeshes are not supported by this gizmo
  46303. * @param mesh The mesh to replace the default mesh of the gizmo
  46304. */
  46305. setCustomMesh(mesh: Mesh): void;
  46306. }
  46307. }
  46308. declare module BABYLON {
  46309. /**
  46310. * Single axis drag gizmo
  46311. */
  46312. export class AxisDragGizmo extends Gizmo {
  46313. /**
  46314. * Drag behavior responsible for the gizmos dragging interactions
  46315. */
  46316. dragBehavior: PointerDragBehavior;
  46317. private _pointerObserver;
  46318. /**
  46319. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46320. */
  46321. snapDistance: number;
  46322. /**
  46323. * Event that fires each time the gizmo snaps to a new location.
  46324. * * snapDistance is the the change in distance
  46325. */
  46326. onSnapObservable: Observable<{
  46327. snapDistance: number;
  46328. }>;
  46329. private _isEnabled;
  46330. private _parent;
  46331. private _arrow;
  46332. private _coloredMaterial;
  46333. private _hoverMaterial;
  46334. /** @hidden */
  46335. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46336. /** @hidden */
  46337. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46338. /**
  46339. * Creates an AxisDragGizmo
  46340. * @param gizmoLayer The utility layer the gizmo will be added to
  46341. * @param dragAxis The axis which the gizmo will be able to drag on
  46342. * @param color The color of the gizmo
  46343. */
  46344. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46345. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46346. /**
  46347. * If the gizmo is enabled
  46348. */
  46349. set isEnabled(value: boolean);
  46350. get isEnabled(): boolean;
  46351. /**
  46352. * Disposes of the gizmo
  46353. */
  46354. dispose(): void;
  46355. }
  46356. }
  46357. declare module BABYLON.Debug {
  46358. /**
  46359. * The Axes viewer will show 3 axes in a specific point in space
  46360. */
  46361. export class AxesViewer {
  46362. private _xAxis;
  46363. private _yAxis;
  46364. private _zAxis;
  46365. private _scaleLinesFactor;
  46366. private _instanced;
  46367. /**
  46368. * Gets the hosting scene
  46369. */
  46370. scene: Scene;
  46371. /**
  46372. * Gets or sets a number used to scale line length
  46373. */
  46374. scaleLines: number;
  46375. /** Gets the node hierarchy used to render x-axis */
  46376. get xAxis(): TransformNode;
  46377. /** Gets the node hierarchy used to render y-axis */
  46378. get yAxis(): TransformNode;
  46379. /** Gets the node hierarchy used to render z-axis */
  46380. get zAxis(): TransformNode;
  46381. /**
  46382. * Creates a new AxesViewer
  46383. * @param scene defines the hosting scene
  46384. * @param scaleLines defines a number used to scale line length (1 by default)
  46385. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46386. * @param xAxis defines the node hierarchy used to render the x-axis
  46387. * @param yAxis defines the node hierarchy used to render the y-axis
  46388. * @param zAxis defines the node hierarchy used to render the z-axis
  46389. */
  46390. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46391. /**
  46392. * Force the viewer to update
  46393. * @param position defines the position of the viewer
  46394. * @param xaxis defines the x axis of the viewer
  46395. * @param yaxis defines the y axis of the viewer
  46396. * @param zaxis defines the z axis of the viewer
  46397. */
  46398. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46399. /**
  46400. * Creates an instance of this axes viewer.
  46401. * @returns a new axes viewer with instanced meshes
  46402. */
  46403. createInstance(): AxesViewer;
  46404. /** Releases resources */
  46405. dispose(): void;
  46406. private static _SetRenderingGroupId;
  46407. }
  46408. }
  46409. declare module BABYLON.Debug {
  46410. /**
  46411. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46412. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46413. */
  46414. export class BoneAxesViewer extends AxesViewer {
  46415. /**
  46416. * Gets or sets the target mesh where to display the axes viewer
  46417. */
  46418. mesh: Nullable<Mesh>;
  46419. /**
  46420. * Gets or sets the target bone where to display the axes viewer
  46421. */
  46422. bone: Nullable<Bone>;
  46423. /** Gets current position */
  46424. pos: Vector3;
  46425. /** Gets direction of X axis */
  46426. xaxis: Vector3;
  46427. /** Gets direction of Y axis */
  46428. yaxis: Vector3;
  46429. /** Gets direction of Z axis */
  46430. zaxis: Vector3;
  46431. /**
  46432. * Creates a new BoneAxesViewer
  46433. * @param scene defines the hosting scene
  46434. * @param bone defines the target bone
  46435. * @param mesh defines the target mesh
  46436. * @param scaleLines defines a scaling factor for line length (1 by default)
  46437. */
  46438. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46439. /**
  46440. * Force the viewer to update
  46441. */
  46442. update(): void;
  46443. /** Releases resources */
  46444. dispose(): void;
  46445. }
  46446. }
  46447. declare module BABYLON {
  46448. /**
  46449. * Interface used to define scene explorer extensibility option
  46450. */
  46451. export interface IExplorerExtensibilityOption {
  46452. /**
  46453. * Define the option label
  46454. */
  46455. label: string;
  46456. /**
  46457. * Defines the action to execute on click
  46458. */
  46459. action: (entity: any) => void;
  46460. }
  46461. /**
  46462. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46463. */
  46464. export interface IExplorerExtensibilityGroup {
  46465. /**
  46466. * Defines a predicate to test if a given type mut be extended
  46467. */
  46468. predicate: (entity: any) => boolean;
  46469. /**
  46470. * Gets the list of options added to a type
  46471. */
  46472. entries: IExplorerExtensibilityOption[];
  46473. }
  46474. /**
  46475. * Interface used to define the options to use to create the Inspector
  46476. */
  46477. export interface IInspectorOptions {
  46478. /**
  46479. * Display in overlay mode (default: false)
  46480. */
  46481. overlay?: boolean;
  46482. /**
  46483. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46484. */
  46485. globalRoot?: HTMLElement;
  46486. /**
  46487. * Display the Scene explorer
  46488. */
  46489. showExplorer?: boolean;
  46490. /**
  46491. * Display the property inspector
  46492. */
  46493. showInspector?: boolean;
  46494. /**
  46495. * Display in embed mode (both panes on the right)
  46496. */
  46497. embedMode?: boolean;
  46498. /**
  46499. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46500. */
  46501. handleResize?: boolean;
  46502. /**
  46503. * Allow the panes to popup (default: true)
  46504. */
  46505. enablePopup?: boolean;
  46506. /**
  46507. * Allow the panes to be closed by users (default: true)
  46508. */
  46509. enableClose?: boolean;
  46510. /**
  46511. * Optional list of extensibility entries
  46512. */
  46513. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46514. /**
  46515. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46516. */
  46517. inspectorURL?: string;
  46518. /**
  46519. * Optional initial tab (default to DebugLayerTab.Properties)
  46520. */
  46521. initialTab?: DebugLayerTab;
  46522. }
  46523. interface Scene {
  46524. /**
  46525. * @hidden
  46526. * Backing field
  46527. */
  46528. _debugLayer: DebugLayer;
  46529. /**
  46530. * Gets the debug layer (aka Inspector) associated with the scene
  46531. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46532. */
  46533. debugLayer: DebugLayer;
  46534. }
  46535. /**
  46536. * Enum of inspector action tab
  46537. */
  46538. export enum DebugLayerTab {
  46539. /**
  46540. * Properties tag (default)
  46541. */
  46542. Properties = 0,
  46543. /**
  46544. * Debug tab
  46545. */
  46546. Debug = 1,
  46547. /**
  46548. * Statistics tab
  46549. */
  46550. Statistics = 2,
  46551. /**
  46552. * Tools tab
  46553. */
  46554. Tools = 3,
  46555. /**
  46556. * Settings tab
  46557. */
  46558. Settings = 4
  46559. }
  46560. /**
  46561. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46562. * what is happening in your scene
  46563. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46564. */
  46565. export class DebugLayer {
  46566. /**
  46567. * Define the url to get the inspector script from.
  46568. * By default it uses the babylonjs CDN.
  46569. * @ignoreNaming
  46570. */
  46571. static InspectorURL: string;
  46572. private _scene;
  46573. private BJSINSPECTOR;
  46574. private _onPropertyChangedObservable?;
  46575. /**
  46576. * Observable triggered when a property is changed through the inspector.
  46577. */
  46578. get onPropertyChangedObservable(): any;
  46579. /**
  46580. * Instantiates a new debug layer.
  46581. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46582. * what is happening in your scene
  46583. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46584. * @param scene Defines the scene to inspect
  46585. */
  46586. constructor(scene: Scene);
  46587. /** Creates the inspector window. */
  46588. private _createInspector;
  46589. /**
  46590. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46591. * @param entity defines the entity to select
  46592. * @param lineContainerTitle defines the specific block to highlight
  46593. */
  46594. select(entity: any, lineContainerTitle?: string): void;
  46595. /** Get the inspector from bundle or global */
  46596. private _getGlobalInspector;
  46597. /**
  46598. * Get if the inspector is visible or not.
  46599. * @returns true if visible otherwise, false
  46600. */
  46601. isVisible(): boolean;
  46602. /**
  46603. * Hide the inspector and close its window.
  46604. */
  46605. hide(): void;
  46606. /**
  46607. * Launch the debugLayer.
  46608. * @param config Define the configuration of the inspector
  46609. * @return a promise fulfilled when the debug layer is visible
  46610. */
  46611. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46612. }
  46613. }
  46614. declare module BABYLON {
  46615. /**
  46616. * Class containing static functions to help procedurally build meshes
  46617. */
  46618. export class BoxBuilder {
  46619. /**
  46620. * Creates a box mesh
  46621. * * The parameter `size` sets the size (float) of each box side (default 1)
  46622. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46623. * * 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)
  46624. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46626. * * 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
  46627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46628. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46629. * @param name defines the name of the mesh
  46630. * @param options defines the options used to create the mesh
  46631. * @param scene defines the hosting scene
  46632. * @returns the box mesh
  46633. */
  46634. static CreateBox(name: string, options: {
  46635. size?: number;
  46636. width?: number;
  46637. height?: number;
  46638. depth?: number;
  46639. faceUV?: Vector4[];
  46640. faceColors?: Color4[];
  46641. sideOrientation?: number;
  46642. frontUVs?: Vector4;
  46643. backUVs?: Vector4;
  46644. wrap?: boolean;
  46645. topBaseAt?: number;
  46646. bottomBaseAt?: number;
  46647. updatable?: boolean;
  46648. }, scene?: Nullable<Scene>): Mesh;
  46649. }
  46650. }
  46651. declare module BABYLON.Debug {
  46652. /**
  46653. * Used to show the physics impostor around the specific mesh
  46654. */
  46655. export class PhysicsViewer {
  46656. /** @hidden */
  46657. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46658. /** @hidden */
  46659. protected _meshes: Array<Nullable<AbstractMesh>>;
  46660. /** @hidden */
  46661. protected _scene: Nullable<Scene>;
  46662. /** @hidden */
  46663. protected _numMeshes: number;
  46664. /** @hidden */
  46665. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46666. private _renderFunction;
  46667. private _utilityLayer;
  46668. private _debugBoxMesh;
  46669. private _debugSphereMesh;
  46670. private _debugCylinderMesh;
  46671. private _debugMaterial;
  46672. private _debugMeshMeshes;
  46673. /**
  46674. * Creates a new PhysicsViewer
  46675. * @param scene defines the hosting scene
  46676. */
  46677. constructor(scene: Scene);
  46678. /** @hidden */
  46679. protected _updateDebugMeshes(): void;
  46680. /**
  46681. * Renders a specified physic impostor
  46682. * @param impostor defines the impostor to render
  46683. * @param targetMesh defines the mesh represented by the impostor
  46684. * @returns the new debug mesh used to render the impostor
  46685. */
  46686. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46687. /**
  46688. * Hides a specified physic impostor
  46689. * @param impostor defines the impostor to hide
  46690. */
  46691. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46692. private _getDebugMaterial;
  46693. private _getDebugBoxMesh;
  46694. private _getDebugSphereMesh;
  46695. private _getDebugCylinderMesh;
  46696. private _getDebugMeshMesh;
  46697. private _getDebugMesh;
  46698. /** Releases all resources */
  46699. dispose(): void;
  46700. }
  46701. }
  46702. declare module BABYLON {
  46703. /**
  46704. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46705. * in order to better appreciate the issue one might have.
  46706. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46707. */
  46708. export class RayHelper {
  46709. /**
  46710. * Defines the ray we are currently tryin to visualize.
  46711. */
  46712. ray: Nullable<Ray>;
  46713. private _renderPoints;
  46714. private _renderLine;
  46715. private _renderFunction;
  46716. private _scene;
  46717. private _updateToMeshFunction;
  46718. private _attachedToMesh;
  46719. private _meshSpaceDirection;
  46720. private _meshSpaceOrigin;
  46721. /**
  46722. * Helper function to create a colored helper in a scene in one line.
  46723. * @param ray Defines the ray we are currently tryin to visualize
  46724. * @param scene Defines the scene the ray is used in
  46725. * @param color Defines the color we want to see the ray in
  46726. * @returns The newly created ray helper.
  46727. */
  46728. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46729. /**
  46730. * Instantiate a new ray helper.
  46731. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46732. * in order to better appreciate the issue one might have.
  46733. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46734. * @param ray Defines the ray we are currently tryin to visualize
  46735. */
  46736. constructor(ray: Ray);
  46737. /**
  46738. * Shows the ray we are willing to debug.
  46739. * @param scene Defines the scene the ray needs to be rendered in
  46740. * @param color Defines the color the ray needs to be rendered in
  46741. */
  46742. show(scene: Scene, color?: Color3): void;
  46743. /**
  46744. * Hides the ray we are debugging.
  46745. */
  46746. hide(): void;
  46747. private _render;
  46748. /**
  46749. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46750. * @param mesh Defines the mesh we want the helper attached to
  46751. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46752. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46753. * @param length Defines the length of the ray
  46754. */
  46755. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46756. /**
  46757. * Detach the ray helper from the mesh it has previously been attached to.
  46758. */
  46759. detachFromMesh(): void;
  46760. private _updateToMesh;
  46761. /**
  46762. * Dispose the helper and release its associated resources.
  46763. */
  46764. dispose(): void;
  46765. }
  46766. }
  46767. declare module BABYLON.Debug {
  46768. /**
  46769. * Class used to render a debug view of a given skeleton
  46770. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46771. */
  46772. export class SkeletonViewer {
  46773. /** defines the skeleton to render */
  46774. skeleton: Skeleton;
  46775. /** defines the mesh attached to the skeleton */
  46776. mesh: AbstractMesh;
  46777. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46778. autoUpdateBonesMatrices: boolean;
  46779. /** defines the rendering group id to use with the viewer */
  46780. renderingGroupId: number;
  46781. /** Gets or sets the color used to render the skeleton */
  46782. color: Color3;
  46783. private _scene;
  46784. private _debugLines;
  46785. private _debugMesh;
  46786. private _isEnabled;
  46787. private _renderFunction;
  46788. private _utilityLayer;
  46789. /**
  46790. * Returns the mesh used to render the bones
  46791. */
  46792. get debugMesh(): Nullable<LinesMesh>;
  46793. /**
  46794. * Creates a new SkeletonViewer
  46795. * @param skeleton defines the skeleton to render
  46796. * @param mesh defines the mesh attached to the skeleton
  46797. * @param scene defines the hosting scene
  46798. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46799. * @param renderingGroupId defines the rendering group id to use with the viewer
  46800. */
  46801. constructor(
  46802. /** defines the skeleton to render */
  46803. skeleton: Skeleton,
  46804. /** defines the mesh attached to the skeleton */
  46805. mesh: AbstractMesh, scene: Scene,
  46806. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46807. autoUpdateBonesMatrices?: boolean,
  46808. /** defines the rendering group id to use with the viewer */
  46809. renderingGroupId?: number);
  46810. /** Gets or sets a boolean indicating if the viewer is enabled */
  46811. set isEnabled(value: boolean);
  46812. get isEnabled(): boolean;
  46813. private _getBonePosition;
  46814. private _getLinesForBonesWithLength;
  46815. private _getLinesForBonesNoLength;
  46816. /** Update the viewer to sync with current skeleton state */
  46817. update(): void;
  46818. /** Release associated resources */
  46819. dispose(): void;
  46820. }
  46821. }
  46822. declare module BABYLON {
  46823. /**
  46824. * Options to create the null engine
  46825. */
  46826. export class NullEngineOptions {
  46827. /**
  46828. * Render width (Default: 512)
  46829. */
  46830. renderWidth: number;
  46831. /**
  46832. * Render height (Default: 256)
  46833. */
  46834. renderHeight: number;
  46835. /**
  46836. * Texture size (Default: 512)
  46837. */
  46838. textureSize: number;
  46839. /**
  46840. * If delta time between frames should be constant
  46841. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46842. */
  46843. deterministicLockstep: boolean;
  46844. /**
  46845. * Maximum about of steps between frames (Default: 4)
  46846. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46847. */
  46848. lockstepMaxSteps: number;
  46849. }
  46850. /**
  46851. * The null engine class provides support for headless version of babylon.js.
  46852. * This can be used in server side scenario or for testing purposes
  46853. */
  46854. export class NullEngine extends Engine {
  46855. private _options;
  46856. /**
  46857. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46858. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46859. * @returns true if engine is in deterministic lock step mode
  46860. */
  46861. isDeterministicLockStep(): boolean;
  46862. /**
  46863. * Gets the max steps when engine is running in deterministic lock step
  46864. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46865. * @returns the max steps
  46866. */
  46867. getLockstepMaxSteps(): number;
  46868. /**
  46869. * Gets the current hardware scaling level.
  46870. * By default the hardware scaling level is computed from the window device ratio.
  46871. * 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.
  46872. * @returns a number indicating the current hardware scaling level
  46873. */
  46874. getHardwareScalingLevel(): number;
  46875. constructor(options?: NullEngineOptions);
  46876. /**
  46877. * Creates a vertex buffer
  46878. * @param vertices the data for the vertex buffer
  46879. * @returns the new WebGL static buffer
  46880. */
  46881. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46882. /**
  46883. * Creates a new index buffer
  46884. * @param indices defines the content of the index buffer
  46885. * @param updatable defines if the index buffer must be updatable
  46886. * @returns a new webGL buffer
  46887. */
  46888. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46889. /**
  46890. * Clear the current render buffer or the current render target (if any is set up)
  46891. * @param color defines the color to use
  46892. * @param backBuffer defines if the back buffer must be cleared
  46893. * @param depth defines if the depth buffer must be cleared
  46894. * @param stencil defines if the stencil buffer must be cleared
  46895. */
  46896. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46897. /**
  46898. * Gets the current render width
  46899. * @param useScreen defines if screen size must be used (or the current render target if any)
  46900. * @returns a number defining the current render width
  46901. */
  46902. getRenderWidth(useScreen?: boolean): number;
  46903. /**
  46904. * Gets the current render height
  46905. * @param useScreen defines if screen size must be used (or the current render target if any)
  46906. * @returns a number defining the current render height
  46907. */
  46908. getRenderHeight(useScreen?: boolean): number;
  46909. /**
  46910. * Set the WebGL's viewport
  46911. * @param viewport defines the viewport element to be used
  46912. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46913. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46914. */
  46915. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46916. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46917. /**
  46918. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46919. * @param pipelineContext defines the pipeline context to use
  46920. * @param uniformsNames defines the list of uniform names
  46921. * @returns an array of webGL uniform locations
  46922. */
  46923. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46924. /**
  46925. * Gets the lsit of active attributes for a given webGL program
  46926. * @param pipelineContext defines the pipeline context to use
  46927. * @param attributesNames defines the list of attribute names to get
  46928. * @returns an array of indices indicating the offset of each attribute
  46929. */
  46930. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46931. /**
  46932. * Binds an effect to the webGL context
  46933. * @param effect defines the effect to bind
  46934. */
  46935. bindSamplers(effect: Effect): void;
  46936. /**
  46937. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46938. * @param effect defines the effect to activate
  46939. */
  46940. enableEffect(effect: Effect): void;
  46941. /**
  46942. * Set various states to the webGL context
  46943. * @param culling defines backface culling state
  46944. * @param zOffset defines the value to apply to zOffset (0 by default)
  46945. * @param force defines if states must be applied even if cache is up to date
  46946. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46947. */
  46948. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46949. /**
  46950. * Set the value of an uniform to an array of int32
  46951. * @param uniform defines the webGL uniform location where to store the value
  46952. * @param array defines the array of int32 to store
  46953. */
  46954. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46955. /**
  46956. * Set the value of an uniform to an array of int32 (stored as vec2)
  46957. * @param uniform defines the webGL uniform location where to store the value
  46958. * @param array defines the array of int32 to store
  46959. */
  46960. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46961. /**
  46962. * Set the value of an uniform to an array of int32 (stored as vec3)
  46963. * @param uniform defines the webGL uniform location where to store the value
  46964. * @param array defines the array of int32 to store
  46965. */
  46966. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46967. /**
  46968. * Set the value of an uniform to an array of int32 (stored as vec4)
  46969. * @param uniform defines the webGL uniform location where to store the value
  46970. * @param array defines the array of int32 to store
  46971. */
  46972. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46973. /**
  46974. * Set the value of an uniform to an array of float32
  46975. * @param uniform defines the webGL uniform location where to store the value
  46976. * @param array defines the array of float32 to store
  46977. */
  46978. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46979. /**
  46980. * Set the value of an uniform to an array of float32 (stored as vec2)
  46981. * @param uniform defines the webGL uniform location where to store the value
  46982. * @param array defines the array of float32 to store
  46983. */
  46984. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46985. /**
  46986. * Set the value of an uniform to an array of float32 (stored as vec3)
  46987. * @param uniform defines the webGL uniform location where to store the value
  46988. * @param array defines the array of float32 to store
  46989. */
  46990. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46991. /**
  46992. * Set the value of an uniform to an array of float32 (stored as vec4)
  46993. * @param uniform defines the webGL uniform location where to store the value
  46994. * @param array defines the array of float32 to store
  46995. */
  46996. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46997. /**
  46998. * Set the value of an uniform to an array of number
  46999. * @param uniform defines the webGL uniform location where to store the value
  47000. * @param array defines the array of number to store
  47001. */
  47002. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47003. /**
  47004. * Set the value of an uniform to an array of number (stored as vec2)
  47005. * @param uniform defines the webGL uniform location where to store the value
  47006. * @param array defines the array of number to store
  47007. */
  47008. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47009. /**
  47010. * Set the value of an uniform to an array of number (stored as vec3)
  47011. * @param uniform defines the webGL uniform location where to store the value
  47012. * @param array defines the array of number to store
  47013. */
  47014. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47015. /**
  47016. * Set the value of an uniform to an array of number (stored as vec4)
  47017. * @param uniform defines the webGL uniform location where to store the value
  47018. * @param array defines the array of number to store
  47019. */
  47020. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47021. /**
  47022. * Set the value of an uniform to an array of float32 (stored as matrices)
  47023. * @param uniform defines the webGL uniform location where to store the value
  47024. * @param matrices defines the array of float32 to store
  47025. */
  47026. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47027. /**
  47028. * Set the value of an uniform to a matrix (3x3)
  47029. * @param uniform defines the webGL uniform location where to store the value
  47030. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47031. */
  47032. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47033. /**
  47034. * Set the value of an uniform to a matrix (2x2)
  47035. * @param uniform defines the webGL uniform location where to store the value
  47036. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47037. */
  47038. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47039. /**
  47040. * Set the value of an uniform to a number (float)
  47041. * @param uniform defines the webGL uniform location where to store the value
  47042. * @param value defines the float number to store
  47043. */
  47044. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47045. /**
  47046. * Set the value of an uniform to a vec2
  47047. * @param uniform defines the webGL uniform location where to store the value
  47048. * @param x defines the 1st component of the value
  47049. * @param y defines the 2nd component of the value
  47050. */
  47051. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47052. /**
  47053. * Set the value of an uniform to a vec3
  47054. * @param uniform defines the webGL uniform location where to store the value
  47055. * @param x defines the 1st component of the value
  47056. * @param y defines the 2nd component of the value
  47057. * @param z defines the 3rd component of the value
  47058. */
  47059. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47060. /**
  47061. * Set the value of an uniform to a boolean
  47062. * @param uniform defines the webGL uniform location where to store the value
  47063. * @param bool defines the boolean to store
  47064. */
  47065. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47066. /**
  47067. * Set the value of an uniform to a vec4
  47068. * @param uniform defines the webGL uniform location where to store the value
  47069. * @param x defines the 1st component of the value
  47070. * @param y defines the 2nd component of the value
  47071. * @param z defines the 3rd component of the value
  47072. * @param w defines the 4th component of the value
  47073. */
  47074. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47075. /**
  47076. * Sets the current alpha mode
  47077. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47078. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47079. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47080. */
  47081. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47082. /**
  47083. * Bind webGl buffers directly to the webGL context
  47084. * @param vertexBuffers defines the vertex buffer to bind
  47085. * @param indexBuffer defines the index buffer to bind
  47086. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47087. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47088. * @param effect defines the effect associated with the vertex buffer
  47089. */
  47090. bindBuffers(vertexBuffers: {
  47091. [key: string]: VertexBuffer;
  47092. }, indexBuffer: DataBuffer, effect: Effect): void;
  47093. /**
  47094. * Force the entire cache to be cleared
  47095. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47096. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47097. */
  47098. wipeCaches(bruteForce?: boolean): void;
  47099. /**
  47100. * Send a draw order
  47101. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47102. * @param indexStart defines the starting index
  47103. * @param indexCount defines the number of index to draw
  47104. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47105. */
  47106. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47107. /**
  47108. * Draw a list of indexed primitives
  47109. * @param fillMode defines the primitive to use
  47110. * @param indexStart defines the starting index
  47111. * @param indexCount defines the number of index to draw
  47112. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47113. */
  47114. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47115. /**
  47116. * Draw a list of unindexed primitives
  47117. * @param fillMode defines the primitive to use
  47118. * @param verticesStart defines the index of first vertex to draw
  47119. * @param verticesCount defines the count of vertices to draw
  47120. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47121. */
  47122. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47123. /** @hidden */
  47124. _createTexture(): WebGLTexture;
  47125. /** @hidden */
  47126. _releaseTexture(texture: InternalTexture): void;
  47127. /**
  47128. * Usually called from Texture.ts.
  47129. * Passed information to create a WebGLTexture
  47130. * @param urlArg defines a value which contains one of the following:
  47131. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47132. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47133. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47134. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47135. * @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)
  47136. * @param scene needed for loading to the correct scene
  47137. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47138. * @param onLoad optional callback to be called upon successful completion
  47139. * @param onError optional callback to be called upon failure
  47140. * @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
  47141. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47142. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47143. * @param forcedExtension defines the extension to use to pick the right loader
  47144. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  47145. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47146. */
  47147. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  47148. /**
  47149. * Creates a new render target texture
  47150. * @param size defines the size of the texture
  47151. * @param options defines the options used to create the texture
  47152. * @returns a new render target texture stored in an InternalTexture
  47153. */
  47154. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47155. /**
  47156. * Update the sampling mode of a given texture
  47157. * @param samplingMode defines the required sampling mode
  47158. * @param texture defines the texture to update
  47159. */
  47160. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47161. /**
  47162. * Binds the frame buffer to the specified texture.
  47163. * @param texture The texture to render to or null for the default canvas
  47164. * @param faceIndex The face of the texture to render to in case of cube texture
  47165. * @param requiredWidth The width of the target to render to
  47166. * @param requiredHeight The height of the target to render to
  47167. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47168. * @param lodLevel defines le lod level to bind to the frame buffer
  47169. */
  47170. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47171. /**
  47172. * Unbind the current render target texture from the webGL context
  47173. * @param texture defines the render target texture to unbind
  47174. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47175. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47176. */
  47177. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47178. /**
  47179. * Creates a dynamic vertex buffer
  47180. * @param vertices the data for the dynamic vertex buffer
  47181. * @returns the new WebGL dynamic buffer
  47182. */
  47183. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47184. /**
  47185. * Update the content of a dynamic texture
  47186. * @param texture defines the texture to update
  47187. * @param canvas defines the canvas containing the source
  47188. * @param invertY defines if data must be stored with Y axis inverted
  47189. * @param premulAlpha defines if alpha is stored as premultiplied
  47190. * @param format defines the format of the data
  47191. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47192. */
  47193. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47194. /**
  47195. * Gets a boolean indicating if all created effects are ready
  47196. * @returns true if all effects are ready
  47197. */
  47198. areAllEffectsReady(): boolean;
  47199. /**
  47200. * @hidden
  47201. * Get the current error code of the webGL context
  47202. * @returns the error code
  47203. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47204. */
  47205. getError(): number;
  47206. /** @hidden */
  47207. _getUnpackAlignement(): number;
  47208. /** @hidden */
  47209. _unpackFlipY(value: boolean): void;
  47210. /**
  47211. * Update a dynamic index buffer
  47212. * @param indexBuffer defines the target index buffer
  47213. * @param indices defines the data to update
  47214. * @param offset defines the offset in the target index buffer where update should start
  47215. */
  47216. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47217. /**
  47218. * Updates a dynamic vertex buffer.
  47219. * @param vertexBuffer the vertex buffer to update
  47220. * @param vertices the data used to update the vertex buffer
  47221. * @param byteOffset the byte offset of the data (optional)
  47222. * @param byteLength the byte length of the data (optional)
  47223. */
  47224. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47225. /** @hidden */
  47226. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47227. /** @hidden */
  47228. _bindTexture(channel: number, texture: InternalTexture): void;
  47229. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47230. /**
  47231. * 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
  47232. */
  47233. releaseEffects(): void;
  47234. displayLoadingUI(): void;
  47235. hideLoadingUI(): void;
  47236. /** @hidden */
  47237. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47238. /** @hidden */
  47239. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47240. /** @hidden */
  47241. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47242. /** @hidden */
  47243. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47244. }
  47245. }
  47246. declare module BABYLON {
  47247. /** @hidden */
  47248. export class _OcclusionDataStorage {
  47249. /** @hidden */
  47250. occlusionInternalRetryCounter: number;
  47251. /** @hidden */
  47252. isOcclusionQueryInProgress: boolean;
  47253. /** @hidden */
  47254. isOccluded: boolean;
  47255. /** @hidden */
  47256. occlusionRetryCount: number;
  47257. /** @hidden */
  47258. occlusionType: number;
  47259. /** @hidden */
  47260. occlusionQueryAlgorithmType: number;
  47261. }
  47262. interface Engine {
  47263. /**
  47264. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47265. * @return the new query
  47266. */
  47267. createQuery(): WebGLQuery;
  47268. /**
  47269. * Delete and release a webGL query
  47270. * @param query defines the query to delete
  47271. * @return the current engine
  47272. */
  47273. deleteQuery(query: WebGLQuery): Engine;
  47274. /**
  47275. * Check if a given query has resolved and got its value
  47276. * @param query defines the query to check
  47277. * @returns true if the query got its value
  47278. */
  47279. isQueryResultAvailable(query: WebGLQuery): boolean;
  47280. /**
  47281. * Gets the value of a given query
  47282. * @param query defines the query to check
  47283. * @returns the value of the query
  47284. */
  47285. getQueryResult(query: WebGLQuery): number;
  47286. /**
  47287. * Initiates an occlusion query
  47288. * @param algorithmType defines the algorithm to use
  47289. * @param query defines the query to use
  47290. * @returns the current engine
  47291. * @see http://doc.babylonjs.com/features/occlusionquery
  47292. */
  47293. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47294. /**
  47295. * Ends an occlusion query
  47296. * @see http://doc.babylonjs.com/features/occlusionquery
  47297. * @param algorithmType defines the algorithm to use
  47298. * @returns the current engine
  47299. */
  47300. endOcclusionQuery(algorithmType: number): Engine;
  47301. /**
  47302. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47303. * Please note that only one query can be issued at a time
  47304. * @returns a time token used to track the time span
  47305. */
  47306. startTimeQuery(): Nullable<_TimeToken>;
  47307. /**
  47308. * Ends a time query
  47309. * @param token defines the token used to measure the time span
  47310. * @returns the time spent (in ns)
  47311. */
  47312. endTimeQuery(token: _TimeToken): int;
  47313. /** @hidden */
  47314. _currentNonTimestampToken: Nullable<_TimeToken>;
  47315. /** @hidden */
  47316. _createTimeQuery(): WebGLQuery;
  47317. /** @hidden */
  47318. _deleteTimeQuery(query: WebGLQuery): void;
  47319. /** @hidden */
  47320. _getGlAlgorithmType(algorithmType: number): number;
  47321. /** @hidden */
  47322. _getTimeQueryResult(query: WebGLQuery): any;
  47323. /** @hidden */
  47324. _getTimeQueryAvailability(query: WebGLQuery): any;
  47325. }
  47326. interface AbstractMesh {
  47327. /**
  47328. * Backing filed
  47329. * @hidden
  47330. */
  47331. __occlusionDataStorage: _OcclusionDataStorage;
  47332. /**
  47333. * Access property
  47334. * @hidden
  47335. */
  47336. _occlusionDataStorage: _OcclusionDataStorage;
  47337. /**
  47338. * 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.
  47339. * The default value is -1 which means don't break the query and wait till the result
  47340. * @see http://doc.babylonjs.com/features/occlusionquery
  47341. */
  47342. occlusionRetryCount: number;
  47343. /**
  47344. * 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:
  47345. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47346. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47347. * * 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.
  47348. * @see http://doc.babylonjs.com/features/occlusionquery
  47349. */
  47350. occlusionType: number;
  47351. /**
  47352. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47353. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47354. * * 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.
  47355. * @see http://doc.babylonjs.com/features/occlusionquery
  47356. */
  47357. occlusionQueryAlgorithmType: number;
  47358. /**
  47359. * 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
  47360. * @see http://doc.babylonjs.com/features/occlusionquery
  47361. */
  47362. isOccluded: boolean;
  47363. /**
  47364. * Flag to check the progress status of the query
  47365. * @see http://doc.babylonjs.com/features/occlusionquery
  47366. */
  47367. isOcclusionQueryInProgress: boolean;
  47368. }
  47369. }
  47370. declare module BABYLON {
  47371. /** @hidden */
  47372. export var _forceTransformFeedbackToBundle: boolean;
  47373. interface Engine {
  47374. /**
  47375. * Creates a webGL transform feedback object
  47376. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47377. * @returns the webGL transform feedback object
  47378. */
  47379. createTransformFeedback(): WebGLTransformFeedback;
  47380. /**
  47381. * Delete a webGL transform feedback object
  47382. * @param value defines the webGL transform feedback object to delete
  47383. */
  47384. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47385. /**
  47386. * Bind a webGL transform feedback object to the webgl context
  47387. * @param value defines the webGL transform feedback object to bind
  47388. */
  47389. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47390. /**
  47391. * Begins a transform feedback operation
  47392. * @param usePoints defines if points or triangles must be used
  47393. */
  47394. beginTransformFeedback(usePoints: boolean): void;
  47395. /**
  47396. * Ends a transform feedback operation
  47397. */
  47398. endTransformFeedback(): void;
  47399. /**
  47400. * Specify the varyings to use with transform feedback
  47401. * @param program defines the associated webGL program
  47402. * @param value defines the list of strings representing the varying names
  47403. */
  47404. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47405. /**
  47406. * Bind a webGL buffer for a transform feedback operation
  47407. * @param value defines the webGL buffer to bind
  47408. */
  47409. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47410. }
  47411. }
  47412. declare module BABYLON {
  47413. /**
  47414. * Creation options of the multi render target texture.
  47415. */
  47416. export interface IMultiRenderTargetOptions {
  47417. /**
  47418. * Define if the texture needs to create mip maps after render.
  47419. */
  47420. generateMipMaps?: boolean;
  47421. /**
  47422. * Define the types of all the draw buffers we want to create
  47423. */
  47424. types?: number[];
  47425. /**
  47426. * Define the sampling modes of all the draw buffers we want to create
  47427. */
  47428. samplingModes?: number[];
  47429. /**
  47430. * Define if a depth buffer is required
  47431. */
  47432. generateDepthBuffer?: boolean;
  47433. /**
  47434. * Define if a stencil buffer is required
  47435. */
  47436. generateStencilBuffer?: boolean;
  47437. /**
  47438. * Define if a depth texture is required instead of a depth buffer
  47439. */
  47440. generateDepthTexture?: boolean;
  47441. /**
  47442. * Define the number of desired draw buffers
  47443. */
  47444. textureCount?: number;
  47445. /**
  47446. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47447. */
  47448. doNotChangeAspectRatio?: boolean;
  47449. /**
  47450. * Define the default type of the buffers we are creating
  47451. */
  47452. defaultType?: number;
  47453. }
  47454. /**
  47455. * A multi render target, like a render target provides the ability to render to a texture.
  47456. * Unlike the render target, it can render to several draw buffers in one draw.
  47457. * This is specially interesting in deferred rendering or for any effects requiring more than
  47458. * just one color from a single pass.
  47459. */
  47460. export class MultiRenderTarget extends RenderTargetTexture {
  47461. private _internalTextures;
  47462. private _textures;
  47463. private _multiRenderTargetOptions;
  47464. /**
  47465. * Get if draw buffers are currently supported by the used hardware and browser.
  47466. */
  47467. get isSupported(): boolean;
  47468. /**
  47469. * Get the list of textures generated by the multi render target.
  47470. */
  47471. get textures(): Texture[];
  47472. /**
  47473. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47474. */
  47475. get depthTexture(): Texture;
  47476. /**
  47477. * Set the wrapping mode on U of all the textures we are rendering to.
  47478. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47479. */
  47480. set wrapU(wrap: number);
  47481. /**
  47482. * Set the wrapping mode on V of all the textures we are rendering to.
  47483. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47484. */
  47485. set wrapV(wrap: number);
  47486. /**
  47487. * Instantiate a new multi render target texture.
  47488. * A multi render target, like a render target provides the ability to render to a texture.
  47489. * Unlike the render target, it can render to several draw buffers in one draw.
  47490. * This is specially interesting in deferred rendering or for any effects requiring more than
  47491. * just one color from a single pass.
  47492. * @param name Define the name of the texture
  47493. * @param size Define the size of the buffers to render to
  47494. * @param count Define the number of target we are rendering into
  47495. * @param scene Define the scene the texture belongs to
  47496. * @param options Define the options used to create the multi render target
  47497. */
  47498. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47499. /** @hidden */
  47500. _rebuild(): void;
  47501. private _createInternalTextures;
  47502. private _createTextures;
  47503. /**
  47504. * Define the number of samples used if MSAA is enabled.
  47505. */
  47506. get samples(): number;
  47507. set samples(value: number);
  47508. /**
  47509. * Resize all the textures in the multi render target.
  47510. * Be carrefull as it will recreate all the data in the new texture.
  47511. * @param size Define the new size
  47512. */
  47513. resize(size: any): void;
  47514. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47515. /**
  47516. * Dispose the render targets and their associated resources
  47517. */
  47518. dispose(): void;
  47519. /**
  47520. * Release all the underlying texture used as draw buffers.
  47521. */
  47522. releaseInternalTextures(): void;
  47523. }
  47524. }
  47525. declare module BABYLON {
  47526. interface ThinEngine {
  47527. /**
  47528. * Unbind a list of render target textures from the webGL context
  47529. * This is used only when drawBuffer extension or webGL2 are active
  47530. * @param textures defines the render target textures to unbind
  47531. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47532. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47533. */
  47534. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47535. /**
  47536. * Create a multi render target texture
  47537. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47538. * @param size defines the size of the texture
  47539. * @param options defines the creation options
  47540. * @returns the cube texture as an InternalTexture
  47541. */
  47542. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47543. /**
  47544. * Update the sample count for a given multiple render target texture
  47545. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47546. * @param textures defines the textures to update
  47547. * @param samples defines the sample count to set
  47548. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47549. */
  47550. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47551. }
  47552. }
  47553. declare module BABYLON {
  47554. /**
  47555. * Class used to define an additional view for the engine
  47556. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47557. */
  47558. export class EngineView {
  47559. /** Defines the canvas where to render the view */
  47560. target: HTMLCanvasElement;
  47561. /** Defines an optional camera used to render the view (will use active camera else) */
  47562. camera?: Camera;
  47563. }
  47564. interface Engine {
  47565. /**
  47566. * Gets or sets the HTML element to use for attaching events
  47567. */
  47568. inputElement: Nullable<HTMLElement>;
  47569. /**
  47570. * Gets the current engine view
  47571. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47572. */
  47573. activeView: Nullable<EngineView>;
  47574. /** Gets or sets the list of views */
  47575. views: EngineView[];
  47576. /**
  47577. * Register a new child canvas
  47578. * @param canvas defines the canvas to register
  47579. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47580. * @returns the associated view
  47581. */
  47582. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47583. /**
  47584. * Remove a registered child canvas
  47585. * @param canvas defines the canvas to remove
  47586. * @returns the current engine
  47587. */
  47588. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47589. }
  47590. }
  47591. declare module BABYLON {
  47592. /**
  47593. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47594. */
  47595. export interface CubeMapInfo {
  47596. /**
  47597. * The pixel array for the front face.
  47598. * This is stored in format, left to right, up to down format.
  47599. */
  47600. front: Nullable<ArrayBufferView>;
  47601. /**
  47602. * The pixel array for the back face.
  47603. * This is stored in format, left to right, up to down format.
  47604. */
  47605. back: Nullable<ArrayBufferView>;
  47606. /**
  47607. * The pixel array for the left face.
  47608. * This is stored in format, left to right, up to down format.
  47609. */
  47610. left: Nullable<ArrayBufferView>;
  47611. /**
  47612. * The pixel array for the right face.
  47613. * This is stored in format, left to right, up to down format.
  47614. */
  47615. right: Nullable<ArrayBufferView>;
  47616. /**
  47617. * The pixel array for the up face.
  47618. * This is stored in format, left to right, up to down format.
  47619. */
  47620. up: Nullable<ArrayBufferView>;
  47621. /**
  47622. * The pixel array for the down face.
  47623. * This is stored in format, left to right, up to down format.
  47624. */
  47625. down: Nullable<ArrayBufferView>;
  47626. /**
  47627. * The size of the cubemap stored.
  47628. *
  47629. * Each faces will be size * size pixels.
  47630. */
  47631. size: number;
  47632. /**
  47633. * The format of the texture.
  47634. *
  47635. * RGBA, RGB.
  47636. */
  47637. format: number;
  47638. /**
  47639. * The type of the texture data.
  47640. *
  47641. * UNSIGNED_INT, FLOAT.
  47642. */
  47643. type: number;
  47644. /**
  47645. * Specifies whether the texture is in gamma space.
  47646. */
  47647. gammaSpace: boolean;
  47648. }
  47649. /**
  47650. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47651. */
  47652. export class PanoramaToCubeMapTools {
  47653. private static FACE_FRONT;
  47654. private static FACE_BACK;
  47655. private static FACE_RIGHT;
  47656. private static FACE_LEFT;
  47657. private static FACE_DOWN;
  47658. private static FACE_UP;
  47659. /**
  47660. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47661. *
  47662. * @param float32Array The source data.
  47663. * @param inputWidth The width of the input panorama.
  47664. * @param inputHeight The height of the input panorama.
  47665. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47666. * @return The cubemap data
  47667. */
  47668. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47669. private static CreateCubemapTexture;
  47670. private static CalcProjectionSpherical;
  47671. }
  47672. }
  47673. declare module BABYLON {
  47674. /**
  47675. * Helper class dealing with the extraction of spherical polynomial dataArray
  47676. * from a cube map.
  47677. */
  47678. export class CubeMapToSphericalPolynomialTools {
  47679. private static FileFaces;
  47680. /**
  47681. * Converts a texture to the according Spherical Polynomial data.
  47682. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47683. *
  47684. * @param texture The texture to extract the information from.
  47685. * @return The Spherical Polynomial data.
  47686. */
  47687. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47688. /**
  47689. * Converts a cubemap to the according Spherical Polynomial data.
  47690. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47691. *
  47692. * @param cubeInfo The Cube map to extract the information from.
  47693. * @return The Spherical Polynomial data.
  47694. */
  47695. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47696. }
  47697. }
  47698. declare module BABYLON {
  47699. interface BaseTexture {
  47700. /**
  47701. * Get the polynomial representation of the texture data.
  47702. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47703. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47704. */
  47705. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47706. }
  47707. }
  47708. declare module BABYLON {
  47709. /** @hidden */
  47710. export var rgbdEncodePixelShader: {
  47711. name: string;
  47712. shader: string;
  47713. };
  47714. }
  47715. declare module BABYLON {
  47716. /** @hidden */
  47717. export var rgbdDecodePixelShader: {
  47718. name: string;
  47719. shader: string;
  47720. };
  47721. }
  47722. declare module BABYLON {
  47723. /**
  47724. * Raw texture data and descriptor sufficient for WebGL texture upload
  47725. */
  47726. export interface EnvironmentTextureInfo {
  47727. /**
  47728. * Version of the environment map
  47729. */
  47730. version: number;
  47731. /**
  47732. * Width of image
  47733. */
  47734. width: number;
  47735. /**
  47736. * Irradiance information stored in the file.
  47737. */
  47738. irradiance: any;
  47739. /**
  47740. * Specular information stored in the file.
  47741. */
  47742. specular: any;
  47743. }
  47744. /**
  47745. * Defines One Image in the file. It requires only the position in the file
  47746. * as well as the length.
  47747. */
  47748. interface BufferImageData {
  47749. /**
  47750. * Length of the image data.
  47751. */
  47752. length: number;
  47753. /**
  47754. * Position of the data from the null terminator delimiting the end of the JSON.
  47755. */
  47756. position: number;
  47757. }
  47758. /**
  47759. * Defines the specular data enclosed in the file.
  47760. * This corresponds to the version 1 of the data.
  47761. */
  47762. export interface EnvironmentTextureSpecularInfoV1 {
  47763. /**
  47764. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47765. */
  47766. specularDataPosition?: number;
  47767. /**
  47768. * This contains all the images data needed to reconstruct the cubemap.
  47769. */
  47770. mipmaps: Array<BufferImageData>;
  47771. /**
  47772. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47773. */
  47774. lodGenerationScale: number;
  47775. }
  47776. /**
  47777. * Sets of helpers addressing the serialization and deserialization of environment texture
  47778. * stored in a BabylonJS env file.
  47779. * Those files are usually stored as .env files.
  47780. */
  47781. export class EnvironmentTextureTools {
  47782. /**
  47783. * Magic number identifying the env file.
  47784. */
  47785. private static _MagicBytes;
  47786. /**
  47787. * Gets the environment info from an env file.
  47788. * @param data The array buffer containing the .env bytes.
  47789. * @returns the environment file info (the json header) if successfully parsed.
  47790. */
  47791. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47792. /**
  47793. * Creates an environment texture from a loaded cube texture.
  47794. * @param texture defines the cube texture to convert in env file
  47795. * @return a promise containing the environment data if succesfull.
  47796. */
  47797. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47798. /**
  47799. * Creates a JSON representation of the spherical data.
  47800. * @param texture defines the texture containing the polynomials
  47801. * @return the JSON representation of the spherical info
  47802. */
  47803. private static _CreateEnvTextureIrradiance;
  47804. /**
  47805. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47806. * @param data the image data
  47807. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47808. * @return the views described by info providing access to the underlying buffer
  47809. */
  47810. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47811. /**
  47812. * Uploads the texture info contained in the env file to the GPU.
  47813. * @param texture defines the internal texture to upload to
  47814. * @param data defines the data to load
  47815. * @param info defines the texture info retrieved through the GetEnvInfo method
  47816. * @returns a promise
  47817. */
  47818. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47819. private static _OnImageReadyAsync;
  47820. /**
  47821. * Uploads the levels of image data to the GPU.
  47822. * @param texture defines the internal texture to upload to
  47823. * @param imageData defines the array buffer views of image data [mipmap][face]
  47824. * @returns a promise
  47825. */
  47826. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47827. /**
  47828. * Uploads spherical polynomials information to the texture.
  47829. * @param texture defines the texture we are trying to upload the information to
  47830. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47831. */
  47832. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47833. /** @hidden */
  47834. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47835. }
  47836. }
  47837. declare module BABYLON {
  47838. /**
  47839. * Contains position and normal vectors for a vertex
  47840. */
  47841. export class PositionNormalVertex {
  47842. /** the position of the vertex (defaut: 0,0,0) */
  47843. position: Vector3;
  47844. /** the normal of the vertex (defaut: 0,1,0) */
  47845. normal: Vector3;
  47846. /**
  47847. * Creates a PositionNormalVertex
  47848. * @param position the position of the vertex (defaut: 0,0,0)
  47849. * @param normal the normal of the vertex (defaut: 0,1,0)
  47850. */
  47851. constructor(
  47852. /** the position of the vertex (defaut: 0,0,0) */
  47853. position?: Vector3,
  47854. /** the normal of the vertex (defaut: 0,1,0) */
  47855. normal?: Vector3);
  47856. /**
  47857. * Clones the PositionNormalVertex
  47858. * @returns the cloned PositionNormalVertex
  47859. */
  47860. clone(): PositionNormalVertex;
  47861. }
  47862. /**
  47863. * Contains position, normal and uv vectors for a vertex
  47864. */
  47865. export class PositionNormalTextureVertex {
  47866. /** the position of the vertex (defaut: 0,0,0) */
  47867. position: Vector3;
  47868. /** the normal of the vertex (defaut: 0,1,0) */
  47869. normal: Vector3;
  47870. /** the uv of the vertex (default: 0,0) */
  47871. uv: Vector2;
  47872. /**
  47873. * Creates a PositionNormalTextureVertex
  47874. * @param position the position of the vertex (defaut: 0,0,0)
  47875. * @param normal the normal of the vertex (defaut: 0,1,0)
  47876. * @param uv the uv of the vertex (default: 0,0)
  47877. */
  47878. constructor(
  47879. /** the position of the vertex (defaut: 0,0,0) */
  47880. position?: Vector3,
  47881. /** the normal of the vertex (defaut: 0,1,0) */
  47882. normal?: Vector3,
  47883. /** the uv of the vertex (default: 0,0) */
  47884. uv?: Vector2);
  47885. /**
  47886. * Clones the PositionNormalTextureVertex
  47887. * @returns the cloned PositionNormalTextureVertex
  47888. */
  47889. clone(): PositionNormalTextureVertex;
  47890. }
  47891. }
  47892. declare module BABYLON {
  47893. /** @hidden */
  47894. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47895. private _genericAttributeLocation;
  47896. private _varyingLocationCount;
  47897. private _varyingLocationMap;
  47898. private _replacements;
  47899. private _textureCount;
  47900. private _uniforms;
  47901. lineProcessor(line: string): string;
  47902. attributeProcessor(attribute: string): string;
  47903. varyingProcessor(varying: string, isFragment: boolean): string;
  47904. uniformProcessor(uniform: string): string;
  47905. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47906. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47907. }
  47908. }
  47909. declare module BABYLON {
  47910. /**
  47911. * Container for accessors for natively-stored mesh data buffers.
  47912. */
  47913. class NativeDataBuffer extends DataBuffer {
  47914. /**
  47915. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47916. */
  47917. nativeIndexBuffer?: any;
  47918. /**
  47919. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47920. */
  47921. nativeVertexBuffer?: any;
  47922. }
  47923. /** @hidden */
  47924. class NativeTexture extends InternalTexture {
  47925. getInternalTexture(): InternalTexture;
  47926. getViewCount(): number;
  47927. }
  47928. /** @hidden */
  47929. export class NativeEngine extends Engine {
  47930. private readonly _native;
  47931. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47932. private readonly INVALID_HANDLE;
  47933. getHardwareScalingLevel(): number;
  47934. constructor();
  47935. /**
  47936. * Can be used to override the current requestAnimationFrame requester.
  47937. * @hidden
  47938. */
  47939. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47940. /**
  47941. * Override default engine behavior.
  47942. * @param color
  47943. * @param backBuffer
  47944. * @param depth
  47945. * @param stencil
  47946. */
  47947. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47948. /**
  47949. * Gets host document
  47950. * @returns the host document object
  47951. */
  47952. getHostDocument(): Nullable<Document>;
  47953. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47954. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47955. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47956. recordVertexArrayObject(vertexBuffers: {
  47957. [key: string]: VertexBuffer;
  47958. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47959. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47960. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47961. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47962. /**
  47963. * Draw a list of indexed primitives
  47964. * @param fillMode defines the primitive to use
  47965. * @param indexStart defines the starting index
  47966. * @param indexCount defines the number of index to draw
  47967. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47968. */
  47969. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47970. /**
  47971. * Draw a list of unindexed primitives
  47972. * @param fillMode defines the primitive to use
  47973. * @param verticesStart defines the index of first vertex to draw
  47974. * @param verticesCount defines the count of vertices to draw
  47975. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47976. */
  47977. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47978. createPipelineContext(): IPipelineContext;
  47979. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47980. /** @hidden */
  47981. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47982. /** @hidden */
  47983. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47984. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47985. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47986. protected _setProgram(program: WebGLProgram): void;
  47987. _releaseEffect(effect: Effect): void;
  47988. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47989. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47990. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47991. bindSamplers(effect: Effect): void;
  47992. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47993. getRenderWidth(useScreen?: boolean): number;
  47994. getRenderHeight(useScreen?: boolean): number;
  47995. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47996. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47997. /**
  47998. * Set the z offset to apply to current rendering
  47999. * @param value defines the offset to apply
  48000. */
  48001. setZOffset(value: number): void;
  48002. /**
  48003. * Gets the current value of the zOffset
  48004. * @returns the current zOffset state
  48005. */
  48006. getZOffset(): number;
  48007. /**
  48008. * Enable or disable depth buffering
  48009. * @param enable defines the state to set
  48010. */
  48011. setDepthBuffer(enable: boolean): void;
  48012. /**
  48013. * Gets a boolean indicating if depth writing is enabled
  48014. * @returns the current depth writing state
  48015. */
  48016. getDepthWrite(): boolean;
  48017. /**
  48018. * Enable or disable depth writing
  48019. * @param enable defines the state to set
  48020. */
  48021. setDepthWrite(enable: boolean): void;
  48022. /**
  48023. * Enable or disable color writing
  48024. * @param enable defines the state to set
  48025. */
  48026. setColorWrite(enable: boolean): void;
  48027. /**
  48028. * Gets a boolean indicating if color writing is enabled
  48029. * @returns the current color writing state
  48030. */
  48031. getColorWrite(): boolean;
  48032. /**
  48033. * Sets alpha constants used by some alpha blending modes
  48034. * @param r defines the red component
  48035. * @param g defines the green component
  48036. * @param b defines the blue component
  48037. * @param a defines the alpha component
  48038. */
  48039. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48040. /**
  48041. * Sets the current alpha mode
  48042. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48043. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48044. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48045. */
  48046. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48047. /**
  48048. * Gets the current alpha mode
  48049. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48050. * @returns the current alpha mode
  48051. */
  48052. getAlphaMode(): number;
  48053. setInt(uniform: WebGLUniformLocation, int: number): void;
  48054. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48055. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48056. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48057. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48058. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48059. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48060. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48061. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48062. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48063. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48064. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48065. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48066. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48067. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48068. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48069. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48070. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48071. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48072. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48073. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48074. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48075. wipeCaches(bruteForce?: boolean): void;
  48076. _createTexture(): WebGLTexture;
  48077. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48078. /**
  48079. * Usually called from BABYLON.Texture.ts.
  48080. * Passed information to create a WebGLTexture
  48081. * @param urlArg defines a value which contains one of the following:
  48082. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48083. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48084. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48085. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48086. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  48087. * @param scene needed for loading to the correct scene
  48088. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  48089. * @param onLoad optional callback to be called upon successful completion
  48090. * @param onError optional callback to be called upon failure
  48091. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  48092. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48093. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48094. * @param forcedExtension defines the extension to use to pick the right loader
  48095. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48096. */
  48097. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  48098. /**
  48099. * Creates a cube texture
  48100. * @param rootUrl defines the url where the files to load is located
  48101. * @param scene defines the current scene
  48102. * @param files defines the list of files to load (1 per face)
  48103. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48104. * @param onLoad defines an optional callback raised when the texture is loaded
  48105. * @param onError defines an optional callback raised if there is an issue to load the texture
  48106. * @param format defines the format of the data
  48107. * @param forcedExtension defines the extension to use to pick the right loader
  48108. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48109. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48110. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48111. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48112. * @returns the cube texture as an InternalTexture
  48113. */
  48114. 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;
  48115. private _getSamplingFilter;
  48116. private static _GetNativeTextureFormat;
  48117. createRenderTargetTexture(size: number | {
  48118. width: number;
  48119. height: number;
  48120. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48121. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48122. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48123. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48124. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48125. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48126. /**
  48127. * Updates a dynamic vertex buffer.
  48128. * @param vertexBuffer the vertex buffer to update
  48129. * @param data the data used to update the vertex buffer
  48130. * @param byteOffset the byte offset of the data (optional)
  48131. * @param byteLength the byte length of the data (optional)
  48132. */
  48133. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48134. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48135. private _updateAnisotropicLevel;
  48136. private _getAddressMode;
  48137. /** @hidden */
  48138. _bindTexture(channel: number, texture: InternalTexture): void;
  48139. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48140. releaseEffects(): void;
  48141. /** @hidden */
  48142. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48143. /** @hidden */
  48144. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48145. /** @hidden */
  48146. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48147. /** @hidden */
  48148. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48149. }
  48150. }
  48151. declare module BABYLON {
  48152. /**
  48153. * Gather the list of clipboard event types as constants.
  48154. */
  48155. export class ClipboardEventTypes {
  48156. /**
  48157. * The clipboard event is fired when a copy command is active (pressed).
  48158. */
  48159. static readonly COPY: number;
  48160. /**
  48161. * The clipboard event is fired when a cut command is active (pressed).
  48162. */
  48163. static readonly CUT: number;
  48164. /**
  48165. * The clipboard event is fired when a paste command is active (pressed).
  48166. */
  48167. static readonly PASTE: number;
  48168. }
  48169. /**
  48170. * This class is used to store clipboard related info for the onClipboardObservable event.
  48171. */
  48172. export class ClipboardInfo {
  48173. /**
  48174. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48175. */
  48176. type: number;
  48177. /**
  48178. * Defines the related dom event
  48179. */
  48180. event: ClipboardEvent;
  48181. /**
  48182. *Creates an instance of ClipboardInfo.
  48183. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48184. * @param event Defines the related dom event
  48185. */
  48186. constructor(
  48187. /**
  48188. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48189. */
  48190. type: number,
  48191. /**
  48192. * Defines the related dom event
  48193. */
  48194. event: ClipboardEvent);
  48195. /**
  48196. * Get the clipboard event's type from the keycode.
  48197. * @param keyCode Defines the keyCode for the current keyboard event.
  48198. * @return {number}
  48199. */
  48200. static GetTypeFromCharacter(keyCode: number): number;
  48201. }
  48202. }
  48203. declare module BABYLON {
  48204. /**
  48205. * Google Daydream controller
  48206. */
  48207. export class DaydreamController extends WebVRController {
  48208. /**
  48209. * Base Url for the controller model.
  48210. */
  48211. static MODEL_BASE_URL: string;
  48212. /**
  48213. * File name for the controller model.
  48214. */
  48215. static MODEL_FILENAME: string;
  48216. /**
  48217. * Gamepad Id prefix used to identify Daydream Controller.
  48218. */
  48219. static readonly GAMEPAD_ID_PREFIX: string;
  48220. /**
  48221. * Creates a new DaydreamController from a gamepad
  48222. * @param vrGamepad the gamepad that the controller should be created from
  48223. */
  48224. constructor(vrGamepad: any);
  48225. /**
  48226. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48227. * @param scene scene in which to add meshes
  48228. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48229. */
  48230. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48231. /**
  48232. * Called once for each button that changed state since the last frame
  48233. * @param buttonIdx Which button index changed
  48234. * @param state New state of the button
  48235. * @param changes Which properties on the state changed since last frame
  48236. */
  48237. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48238. }
  48239. }
  48240. declare module BABYLON {
  48241. /**
  48242. * Gear VR Controller
  48243. */
  48244. export class GearVRController extends WebVRController {
  48245. /**
  48246. * Base Url for the controller model.
  48247. */
  48248. static MODEL_BASE_URL: string;
  48249. /**
  48250. * File name for the controller model.
  48251. */
  48252. static MODEL_FILENAME: string;
  48253. /**
  48254. * Gamepad Id prefix used to identify this controller.
  48255. */
  48256. static readonly GAMEPAD_ID_PREFIX: string;
  48257. private readonly _buttonIndexToObservableNameMap;
  48258. /**
  48259. * Creates a new GearVRController from a gamepad
  48260. * @param vrGamepad the gamepad that the controller should be created from
  48261. */
  48262. constructor(vrGamepad: any);
  48263. /**
  48264. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48265. * @param scene scene in which to add meshes
  48266. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48267. */
  48268. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48269. /**
  48270. * Called once for each button that changed state since the last frame
  48271. * @param buttonIdx Which button index changed
  48272. * @param state New state of the button
  48273. * @param changes Which properties on the state changed since last frame
  48274. */
  48275. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48276. }
  48277. }
  48278. declare module BABYLON {
  48279. /**
  48280. * Generic Controller
  48281. */
  48282. export class GenericController extends WebVRController {
  48283. /**
  48284. * Base Url for the controller model.
  48285. */
  48286. static readonly MODEL_BASE_URL: string;
  48287. /**
  48288. * File name for the controller model.
  48289. */
  48290. static readonly MODEL_FILENAME: string;
  48291. /**
  48292. * Creates a new GenericController from a gamepad
  48293. * @param vrGamepad the gamepad that the controller should be created from
  48294. */
  48295. constructor(vrGamepad: any);
  48296. /**
  48297. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48298. * @param scene scene in which to add meshes
  48299. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48300. */
  48301. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48302. /**
  48303. * Called once for each button that changed state since the last frame
  48304. * @param buttonIdx Which button index changed
  48305. * @param state New state of the button
  48306. * @param changes Which properties on the state changed since last frame
  48307. */
  48308. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48309. }
  48310. }
  48311. declare module BABYLON {
  48312. /**
  48313. * Oculus Touch Controller
  48314. */
  48315. export class OculusTouchController extends WebVRController {
  48316. /**
  48317. * Base Url for the controller model.
  48318. */
  48319. static MODEL_BASE_URL: string;
  48320. /**
  48321. * File name for the left controller model.
  48322. */
  48323. static MODEL_LEFT_FILENAME: string;
  48324. /**
  48325. * File name for the right controller model.
  48326. */
  48327. static MODEL_RIGHT_FILENAME: string;
  48328. /**
  48329. * Base Url for the Quest controller model.
  48330. */
  48331. static QUEST_MODEL_BASE_URL: string;
  48332. /**
  48333. * @hidden
  48334. * If the controllers are running on a device that needs the updated Quest controller models
  48335. */
  48336. static _IsQuest: boolean;
  48337. /**
  48338. * Fired when the secondary trigger on this controller is modified
  48339. */
  48340. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48341. /**
  48342. * Fired when the thumb rest on this controller is modified
  48343. */
  48344. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48345. /**
  48346. * Creates a new OculusTouchController from a gamepad
  48347. * @param vrGamepad the gamepad that the controller should be created from
  48348. */
  48349. constructor(vrGamepad: any);
  48350. /**
  48351. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48352. * @param scene scene in which to add meshes
  48353. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48354. */
  48355. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48356. /**
  48357. * Fired when the A button on this controller is modified
  48358. */
  48359. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48360. /**
  48361. * Fired when the B button on this controller is modified
  48362. */
  48363. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48364. /**
  48365. * Fired when the X button on this controller is modified
  48366. */
  48367. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48368. /**
  48369. * Fired when the Y button on this controller is modified
  48370. */
  48371. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48372. /**
  48373. * Called once for each button that changed state since the last frame
  48374. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48375. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48376. * 2) secondary trigger (same)
  48377. * 3) A (right) X (left), touch, pressed = value
  48378. * 4) B / Y
  48379. * 5) thumb rest
  48380. * @param buttonIdx Which button index changed
  48381. * @param state New state of the button
  48382. * @param changes Which properties on the state changed since last frame
  48383. */
  48384. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48385. }
  48386. }
  48387. declare module BABYLON {
  48388. /**
  48389. * Vive Controller
  48390. */
  48391. export class ViveController extends WebVRController {
  48392. /**
  48393. * Base Url for the controller model.
  48394. */
  48395. static MODEL_BASE_URL: string;
  48396. /**
  48397. * File name for the controller model.
  48398. */
  48399. static MODEL_FILENAME: string;
  48400. /**
  48401. * Creates a new ViveController from a gamepad
  48402. * @param vrGamepad the gamepad that the controller should be created from
  48403. */
  48404. constructor(vrGamepad: any);
  48405. /**
  48406. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48407. * @param scene scene in which to add meshes
  48408. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48409. */
  48410. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48411. /**
  48412. * Fired when the left button on this controller is modified
  48413. */
  48414. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48415. /**
  48416. * Fired when the right button on this controller is modified
  48417. */
  48418. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48419. /**
  48420. * Fired when the menu button on this controller is modified
  48421. */
  48422. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48423. /**
  48424. * Called once for each button that changed state since the last frame
  48425. * Vive mapping:
  48426. * 0: touchpad
  48427. * 1: trigger
  48428. * 2: left AND right buttons
  48429. * 3: menu button
  48430. * @param buttonIdx Which button index changed
  48431. * @param state New state of the button
  48432. * @param changes Which properties on the state changed since last frame
  48433. */
  48434. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48435. }
  48436. }
  48437. declare module BABYLON {
  48438. /**
  48439. * Defines the WindowsMotionController object that the state of the windows motion controller
  48440. */
  48441. export class WindowsMotionController extends WebVRController {
  48442. /**
  48443. * The base url used to load the left and right controller models
  48444. */
  48445. static MODEL_BASE_URL: string;
  48446. /**
  48447. * The name of the left controller model file
  48448. */
  48449. static MODEL_LEFT_FILENAME: string;
  48450. /**
  48451. * The name of the right controller model file
  48452. */
  48453. static MODEL_RIGHT_FILENAME: string;
  48454. /**
  48455. * The controller name prefix for this controller type
  48456. */
  48457. static readonly GAMEPAD_ID_PREFIX: string;
  48458. /**
  48459. * The controller id pattern for this controller type
  48460. */
  48461. private static readonly GAMEPAD_ID_PATTERN;
  48462. private _loadedMeshInfo;
  48463. protected readonly _mapping: {
  48464. buttons: string[];
  48465. buttonMeshNames: {
  48466. 'trigger': string;
  48467. 'menu': string;
  48468. 'grip': string;
  48469. 'thumbstick': string;
  48470. 'trackpad': string;
  48471. };
  48472. buttonObservableNames: {
  48473. 'trigger': string;
  48474. 'menu': string;
  48475. 'grip': string;
  48476. 'thumbstick': string;
  48477. 'trackpad': string;
  48478. };
  48479. axisMeshNames: string[];
  48480. pointingPoseMeshName: string;
  48481. };
  48482. /**
  48483. * Fired when the trackpad on this controller is clicked
  48484. */
  48485. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48486. /**
  48487. * Fired when the trackpad on this controller is modified
  48488. */
  48489. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48490. /**
  48491. * The current x and y values of this controller's trackpad
  48492. */
  48493. trackpad: StickValues;
  48494. /**
  48495. * Creates a new WindowsMotionController from a gamepad
  48496. * @param vrGamepad the gamepad that the controller should be created from
  48497. */
  48498. constructor(vrGamepad: any);
  48499. /**
  48500. * Fired when the trigger on this controller is modified
  48501. */
  48502. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48503. /**
  48504. * Fired when the menu button on this controller is modified
  48505. */
  48506. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48507. /**
  48508. * Fired when the grip button on this controller is modified
  48509. */
  48510. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48511. /**
  48512. * Fired when the thumbstick button on this controller is modified
  48513. */
  48514. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48515. /**
  48516. * Fired when the touchpad button on this controller is modified
  48517. */
  48518. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48519. /**
  48520. * Fired when the touchpad values on this controller are modified
  48521. */
  48522. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48523. protected _updateTrackpad(): void;
  48524. /**
  48525. * Called once per frame by the engine.
  48526. */
  48527. update(): void;
  48528. /**
  48529. * Called once for each button that changed state since the last frame
  48530. * @param buttonIdx Which button index changed
  48531. * @param state New state of the button
  48532. * @param changes Which properties on the state changed since last frame
  48533. */
  48534. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48535. /**
  48536. * Moves the buttons on the controller mesh based on their current state
  48537. * @param buttonName the name of the button to move
  48538. * @param buttonValue the value of the button which determines the buttons new position
  48539. */
  48540. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48541. /**
  48542. * Moves the axis on the controller mesh based on its current state
  48543. * @param axis the index of the axis
  48544. * @param axisValue the value of the axis which determines the meshes new position
  48545. * @hidden
  48546. */
  48547. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48548. /**
  48549. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48550. * @param scene scene in which to add meshes
  48551. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48552. */
  48553. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48554. /**
  48555. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48556. * can be transformed by button presses and axes values, based on this._mapping.
  48557. *
  48558. * @param scene scene in which the meshes exist
  48559. * @param meshes list of meshes that make up the controller model to process
  48560. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48561. */
  48562. private processModel;
  48563. private createMeshInfo;
  48564. /**
  48565. * Gets the ray of the controller in the direction the controller is pointing
  48566. * @param length the length the resulting ray should be
  48567. * @returns a ray in the direction the controller is pointing
  48568. */
  48569. getForwardRay(length?: number): Ray;
  48570. /**
  48571. * Disposes of the controller
  48572. */
  48573. dispose(): void;
  48574. }
  48575. /**
  48576. * This class represents a new windows motion controller in XR.
  48577. */
  48578. export class XRWindowsMotionController extends WindowsMotionController {
  48579. /**
  48580. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48581. */
  48582. protected readonly _mapping: {
  48583. buttons: string[];
  48584. buttonMeshNames: {
  48585. 'trigger': string;
  48586. 'menu': string;
  48587. 'grip': string;
  48588. 'thumbstick': string;
  48589. 'trackpad': string;
  48590. };
  48591. buttonObservableNames: {
  48592. 'trigger': string;
  48593. 'menu': string;
  48594. 'grip': string;
  48595. 'thumbstick': string;
  48596. 'trackpad': string;
  48597. };
  48598. axisMeshNames: string[];
  48599. pointingPoseMeshName: string;
  48600. };
  48601. /**
  48602. * Construct a new XR-Based windows motion controller
  48603. *
  48604. * @param gamepadInfo the gamepad object from the browser
  48605. */
  48606. constructor(gamepadInfo: any);
  48607. /**
  48608. * holds the thumbstick values (X,Y)
  48609. */
  48610. thumbstickValues: StickValues;
  48611. /**
  48612. * Fired when the thumbstick on this controller is clicked
  48613. */
  48614. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48615. /**
  48616. * Fired when the thumbstick on this controller is modified
  48617. */
  48618. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48619. /**
  48620. * Fired when the touchpad button on this controller is modified
  48621. */
  48622. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48623. /**
  48624. * Fired when the touchpad values on this controller are modified
  48625. */
  48626. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48627. /**
  48628. * Fired when the thumbstick button on this controller is modified
  48629. * here to prevent breaking changes
  48630. */
  48631. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48632. /**
  48633. * updating the thumbstick(!) and not the trackpad.
  48634. * This is named this way due to the difference between WebVR and XR and to avoid
  48635. * changing the parent class.
  48636. */
  48637. protected _updateTrackpad(): void;
  48638. /**
  48639. * Disposes the class with joy
  48640. */
  48641. dispose(): void;
  48642. }
  48643. }
  48644. declare module BABYLON {
  48645. /**
  48646. * Class containing static functions to help procedurally build meshes
  48647. */
  48648. export class PolyhedronBuilder {
  48649. /**
  48650. * Creates a polyhedron mesh
  48651. * * 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
  48652. * * The parameter `size` (positive float, default 1) sets the polygon size
  48653. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48654. * * 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`
  48655. * * 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
  48656. * * 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)`)
  48657. * * 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
  48658. * * 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
  48659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48660. * * 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
  48661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48662. * @param name defines the name of the mesh
  48663. * @param options defines the options used to create the mesh
  48664. * @param scene defines the hosting scene
  48665. * @returns the polyhedron mesh
  48666. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48667. */
  48668. static CreatePolyhedron(name: string, options: {
  48669. type?: number;
  48670. size?: number;
  48671. sizeX?: number;
  48672. sizeY?: number;
  48673. sizeZ?: number;
  48674. custom?: any;
  48675. faceUV?: Vector4[];
  48676. faceColors?: Color4[];
  48677. flat?: boolean;
  48678. updatable?: boolean;
  48679. sideOrientation?: number;
  48680. frontUVs?: Vector4;
  48681. backUVs?: Vector4;
  48682. }, scene?: Nullable<Scene>): Mesh;
  48683. }
  48684. }
  48685. declare module BABYLON {
  48686. /**
  48687. * Gizmo that enables scaling a mesh along 3 axis
  48688. */
  48689. export class ScaleGizmo extends Gizmo {
  48690. /**
  48691. * Internal gizmo used for interactions on the x axis
  48692. */
  48693. xGizmo: AxisScaleGizmo;
  48694. /**
  48695. * Internal gizmo used for interactions on the y axis
  48696. */
  48697. yGizmo: AxisScaleGizmo;
  48698. /**
  48699. * Internal gizmo used for interactions on the z axis
  48700. */
  48701. zGizmo: AxisScaleGizmo;
  48702. /**
  48703. * Internal gizmo used to scale all axis equally
  48704. */
  48705. uniformScaleGizmo: AxisScaleGizmo;
  48706. private _meshAttached;
  48707. private _updateGizmoRotationToMatchAttachedMesh;
  48708. private _snapDistance;
  48709. private _scaleRatio;
  48710. private _uniformScalingMesh;
  48711. private _octahedron;
  48712. private _sensitivity;
  48713. /** Fires an event when any of it's sub gizmos are dragged */
  48714. onDragStartObservable: Observable<unknown>;
  48715. /** Fires an event when any of it's sub gizmos are released from dragging */
  48716. onDragEndObservable: Observable<unknown>;
  48717. get attachedMesh(): Nullable<AbstractMesh>;
  48718. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48719. /**
  48720. * Creates a ScaleGizmo
  48721. * @param gizmoLayer The utility layer the gizmo will be added to
  48722. */
  48723. constructor(gizmoLayer?: UtilityLayerRenderer);
  48724. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48725. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48726. /**
  48727. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48728. */
  48729. set snapDistance(value: number);
  48730. get snapDistance(): number;
  48731. /**
  48732. * Ratio for the scale of the gizmo (Default: 1)
  48733. */
  48734. set scaleRatio(value: number);
  48735. get scaleRatio(): number;
  48736. /**
  48737. * Sensitivity factor for dragging (Default: 1)
  48738. */
  48739. set sensitivity(value: number);
  48740. get sensitivity(): number;
  48741. /**
  48742. * Disposes of the gizmo
  48743. */
  48744. dispose(): void;
  48745. }
  48746. }
  48747. declare module BABYLON {
  48748. /**
  48749. * Single axis scale gizmo
  48750. */
  48751. export class AxisScaleGizmo extends Gizmo {
  48752. /**
  48753. * Drag behavior responsible for the gizmos dragging interactions
  48754. */
  48755. dragBehavior: PointerDragBehavior;
  48756. private _pointerObserver;
  48757. /**
  48758. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48759. */
  48760. snapDistance: number;
  48761. /**
  48762. * Event that fires each time the gizmo snaps to a new location.
  48763. * * snapDistance is the the change in distance
  48764. */
  48765. onSnapObservable: Observable<{
  48766. snapDistance: number;
  48767. }>;
  48768. /**
  48769. * If the scaling operation should be done on all axis (default: false)
  48770. */
  48771. uniformScaling: boolean;
  48772. /**
  48773. * Custom sensitivity value for the drag strength
  48774. */
  48775. sensitivity: number;
  48776. private _isEnabled;
  48777. private _parent;
  48778. private _arrow;
  48779. private _coloredMaterial;
  48780. private _hoverMaterial;
  48781. /**
  48782. * Creates an AxisScaleGizmo
  48783. * @param gizmoLayer The utility layer the gizmo will be added to
  48784. * @param dragAxis The axis which the gizmo will be able to scale on
  48785. * @param color The color of the gizmo
  48786. */
  48787. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48788. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48789. /**
  48790. * If the gizmo is enabled
  48791. */
  48792. set isEnabled(value: boolean);
  48793. get isEnabled(): boolean;
  48794. /**
  48795. * Disposes of the gizmo
  48796. */
  48797. dispose(): void;
  48798. /**
  48799. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48800. * @param mesh The mesh to replace the default mesh of the gizmo
  48801. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48802. */
  48803. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48804. }
  48805. }
  48806. declare module BABYLON {
  48807. /**
  48808. * Bounding box gizmo
  48809. */
  48810. export class BoundingBoxGizmo extends Gizmo {
  48811. private _lineBoundingBox;
  48812. private _rotateSpheresParent;
  48813. private _scaleBoxesParent;
  48814. private _boundingDimensions;
  48815. private _renderObserver;
  48816. private _pointerObserver;
  48817. private _scaleDragSpeed;
  48818. private _tmpQuaternion;
  48819. private _tmpVector;
  48820. private _tmpRotationMatrix;
  48821. /**
  48822. * 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)
  48823. */
  48824. ignoreChildren: boolean;
  48825. /**
  48826. * 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)
  48827. */
  48828. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48829. /**
  48830. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48831. */
  48832. rotationSphereSize: number;
  48833. /**
  48834. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48835. */
  48836. scaleBoxSize: number;
  48837. /**
  48838. * 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)
  48839. */
  48840. fixedDragMeshScreenSize: boolean;
  48841. /**
  48842. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48843. */
  48844. fixedDragMeshScreenSizeDistanceFactor: number;
  48845. /**
  48846. * Fired when a rotation sphere or scale box is dragged
  48847. */
  48848. onDragStartObservable: Observable<{}>;
  48849. /**
  48850. * Fired when a scale box is dragged
  48851. */
  48852. onScaleBoxDragObservable: Observable<{}>;
  48853. /**
  48854. * Fired when a scale box drag is ended
  48855. */
  48856. onScaleBoxDragEndObservable: Observable<{}>;
  48857. /**
  48858. * Fired when a rotation sphere is dragged
  48859. */
  48860. onRotationSphereDragObservable: Observable<{}>;
  48861. /**
  48862. * Fired when a rotation sphere drag is ended
  48863. */
  48864. onRotationSphereDragEndObservable: Observable<{}>;
  48865. /**
  48866. * 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)
  48867. */
  48868. scalePivot: Nullable<Vector3>;
  48869. /**
  48870. * Mesh used as a pivot to rotate the attached mesh
  48871. */
  48872. private _anchorMesh;
  48873. private _existingMeshScale;
  48874. private _dragMesh;
  48875. private pointerDragBehavior;
  48876. private coloredMaterial;
  48877. private hoverColoredMaterial;
  48878. /**
  48879. * Sets the color of the bounding box gizmo
  48880. * @param color the color to set
  48881. */
  48882. setColor(color: Color3): void;
  48883. /**
  48884. * Creates an BoundingBoxGizmo
  48885. * @param gizmoLayer The utility layer the gizmo will be added to
  48886. * @param color The color of the gizmo
  48887. */
  48888. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48889. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48890. private _selectNode;
  48891. /**
  48892. * Updates the bounding box information for the Gizmo
  48893. */
  48894. updateBoundingBox(): void;
  48895. private _updateRotationSpheres;
  48896. private _updateScaleBoxes;
  48897. /**
  48898. * Enables rotation on the specified axis and disables rotation on the others
  48899. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48900. */
  48901. setEnabledRotationAxis(axis: string): void;
  48902. /**
  48903. * Enables/disables scaling
  48904. * @param enable if scaling should be enabled
  48905. */
  48906. setEnabledScaling(enable: boolean): void;
  48907. private _updateDummy;
  48908. /**
  48909. * Enables a pointer drag behavior on the bounding box of the gizmo
  48910. */
  48911. enableDragBehavior(): void;
  48912. /**
  48913. * Disposes of the gizmo
  48914. */
  48915. dispose(): void;
  48916. /**
  48917. * 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)
  48918. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48919. * @returns the bounding box mesh with the passed in mesh as a child
  48920. */
  48921. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48922. /**
  48923. * CustomMeshes are not supported by this gizmo
  48924. * @param mesh The mesh to replace the default mesh of the gizmo
  48925. */
  48926. setCustomMesh(mesh: Mesh): void;
  48927. }
  48928. }
  48929. declare module BABYLON {
  48930. /**
  48931. * Single plane rotation gizmo
  48932. */
  48933. export class PlaneRotationGizmo extends Gizmo {
  48934. /**
  48935. * Drag behavior responsible for the gizmos dragging interactions
  48936. */
  48937. dragBehavior: PointerDragBehavior;
  48938. private _pointerObserver;
  48939. /**
  48940. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48941. */
  48942. snapDistance: number;
  48943. /**
  48944. * Event that fires each time the gizmo snaps to a new location.
  48945. * * snapDistance is the the change in distance
  48946. */
  48947. onSnapObservable: Observable<{
  48948. snapDistance: number;
  48949. }>;
  48950. private _isEnabled;
  48951. private _parent;
  48952. /**
  48953. * Creates a PlaneRotationGizmo
  48954. * @param gizmoLayer The utility layer the gizmo will be added to
  48955. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48956. * @param color The color of the gizmo
  48957. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48958. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48959. */
  48960. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48961. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48962. /**
  48963. * If the gizmo is enabled
  48964. */
  48965. set isEnabled(value: boolean);
  48966. get isEnabled(): boolean;
  48967. /**
  48968. * Disposes of the gizmo
  48969. */
  48970. dispose(): void;
  48971. }
  48972. }
  48973. declare module BABYLON {
  48974. /**
  48975. * Gizmo that enables rotating a mesh along 3 axis
  48976. */
  48977. export class RotationGizmo extends Gizmo {
  48978. /**
  48979. * Internal gizmo used for interactions on the x axis
  48980. */
  48981. xGizmo: PlaneRotationGizmo;
  48982. /**
  48983. * Internal gizmo used for interactions on the y axis
  48984. */
  48985. yGizmo: PlaneRotationGizmo;
  48986. /**
  48987. * Internal gizmo used for interactions on the z axis
  48988. */
  48989. zGizmo: PlaneRotationGizmo;
  48990. /** Fires an event when any of it's sub gizmos are dragged */
  48991. onDragStartObservable: Observable<unknown>;
  48992. /** Fires an event when any of it's sub gizmos are released from dragging */
  48993. onDragEndObservable: Observable<unknown>;
  48994. private _meshAttached;
  48995. get attachedMesh(): Nullable<AbstractMesh>;
  48996. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48997. /**
  48998. * Creates a RotationGizmo
  48999. * @param gizmoLayer The utility layer the gizmo will be added to
  49000. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49001. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49002. */
  49003. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49004. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49005. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49006. /**
  49007. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49008. */
  49009. set snapDistance(value: number);
  49010. get snapDistance(): number;
  49011. /**
  49012. * Ratio for the scale of the gizmo (Default: 1)
  49013. */
  49014. set scaleRatio(value: number);
  49015. get scaleRatio(): number;
  49016. /**
  49017. * Disposes of the gizmo
  49018. */
  49019. dispose(): void;
  49020. /**
  49021. * CustomMeshes are not supported by this gizmo
  49022. * @param mesh The mesh to replace the default mesh of the gizmo
  49023. */
  49024. setCustomMesh(mesh: Mesh): void;
  49025. }
  49026. }
  49027. declare module BABYLON {
  49028. /**
  49029. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49030. */
  49031. export class GizmoManager implements IDisposable {
  49032. private scene;
  49033. /**
  49034. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49035. */
  49036. gizmos: {
  49037. positionGizmo: Nullable<PositionGizmo>;
  49038. rotationGizmo: Nullable<RotationGizmo>;
  49039. scaleGizmo: Nullable<ScaleGizmo>;
  49040. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49041. };
  49042. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49043. clearGizmoOnEmptyPointerEvent: boolean;
  49044. /** Fires an event when the manager is attached to a mesh */
  49045. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49046. private _gizmosEnabled;
  49047. private _pointerObserver;
  49048. private _attachedMesh;
  49049. private _boundingBoxColor;
  49050. private _defaultUtilityLayer;
  49051. private _defaultKeepDepthUtilityLayer;
  49052. /**
  49053. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49054. */
  49055. boundingBoxDragBehavior: SixDofDragBehavior;
  49056. /**
  49057. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49058. */
  49059. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49060. /**
  49061. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49062. */
  49063. usePointerToAttachGizmos: boolean;
  49064. /**
  49065. * Utility layer that the bounding box gizmo belongs to
  49066. */
  49067. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49068. /**
  49069. * Utility layer that all gizmos besides bounding box belong to
  49070. */
  49071. get utilityLayer(): UtilityLayerRenderer;
  49072. /**
  49073. * Instatiates a gizmo manager
  49074. * @param scene the scene to overlay the gizmos on top of
  49075. */
  49076. constructor(scene: Scene);
  49077. /**
  49078. * Attaches a set of gizmos to the specified mesh
  49079. * @param mesh The mesh the gizmo's should be attached to
  49080. */
  49081. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49082. /**
  49083. * If the position gizmo is enabled
  49084. */
  49085. set positionGizmoEnabled(value: boolean);
  49086. get positionGizmoEnabled(): boolean;
  49087. /**
  49088. * If the rotation gizmo is enabled
  49089. */
  49090. set rotationGizmoEnabled(value: boolean);
  49091. get rotationGizmoEnabled(): boolean;
  49092. /**
  49093. * If the scale gizmo is enabled
  49094. */
  49095. set scaleGizmoEnabled(value: boolean);
  49096. get scaleGizmoEnabled(): boolean;
  49097. /**
  49098. * If the boundingBox gizmo is enabled
  49099. */
  49100. set boundingBoxGizmoEnabled(value: boolean);
  49101. get boundingBoxGizmoEnabled(): boolean;
  49102. /**
  49103. * Disposes of the gizmo manager
  49104. */
  49105. dispose(): void;
  49106. }
  49107. }
  49108. declare module BABYLON {
  49109. /**
  49110. * A directional light is defined by a direction (what a surprise!).
  49111. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49112. * 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.
  49113. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49114. */
  49115. export class DirectionalLight extends ShadowLight {
  49116. private _shadowFrustumSize;
  49117. /**
  49118. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49119. */
  49120. get shadowFrustumSize(): number;
  49121. /**
  49122. * Specifies a fix frustum size for the shadow generation.
  49123. */
  49124. set shadowFrustumSize(value: number);
  49125. private _shadowOrthoScale;
  49126. /**
  49127. * Gets the shadow projection scale against the optimal computed one.
  49128. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49129. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49130. */
  49131. get shadowOrthoScale(): number;
  49132. /**
  49133. * Sets the shadow projection scale against the optimal computed one.
  49134. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49135. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49136. */
  49137. set shadowOrthoScale(value: number);
  49138. /**
  49139. * Automatically compute the projection matrix to best fit (including all the casters)
  49140. * on each frame.
  49141. */
  49142. autoUpdateExtends: boolean;
  49143. /**
  49144. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49145. * on each frame. autoUpdateExtends must be set to true for this to work
  49146. */
  49147. autoCalcShadowZBounds: boolean;
  49148. private _orthoLeft;
  49149. private _orthoRight;
  49150. private _orthoTop;
  49151. private _orthoBottom;
  49152. /**
  49153. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49154. * The directional light is emitted from everywhere in the given direction.
  49155. * It can cast shadows.
  49156. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49157. * @param name The friendly name of the light
  49158. * @param direction The direction of the light
  49159. * @param scene The scene the light belongs to
  49160. */
  49161. constructor(name: string, direction: Vector3, scene: Scene);
  49162. /**
  49163. * Returns the string "DirectionalLight".
  49164. * @return The class name
  49165. */
  49166. getClassName(): string;
  49167. /**
  49168. * Returns the integer 1.
  49169. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49170. */
  49171. getTypeID(): number;
  49172. /**
  49173. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49174. * Returns the DirectionalLight Shadow projection matrix.
  49175. */
  49176. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49177. /**
  49178. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49179. * Returns the DirectionalLight Shadow projection matrix.
  49180. */
  49181. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49182. /**
  49183. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49184. * Returns the DirectionalLight Shadow projection matrix.
  49185. */
  49186. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49187. protected _buildUniformLayout(): void;
  49188. /**
  49189. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49190. * @param effect The effect to update
  49191. * @param lightIndex The index of the light in the effect to update
  49192. * @returns The directional light
  49193. */
  49194. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49195. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49196. /**
  49197. * Gets the minZ used for shadow according to both the scene and the light.
  49198. *
  49199. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49200. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49201. * @param activeCamera The camera we are returning the min for
  49202. * @returns the depth min z
  49203. */
  49204. getDepthMinZ(activeCamera: Camera): number;
  49205. /**
  49206. * Gets the maxZ used for shadow according to both the scene and the light.
  49207. *
  49208. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49209. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49210. * @param activeCamera The camera we are returning the max for
  49211. * @returns the depth max z
  49212. */
  49213. getDepthMaxZ(activeCamera: Camera): number;
  49214. /**
  49215. * Prepares the list of defines specific to the light type.
  49216. * @param defines the list of defines
  49217. * @param lightIndex defines the index of the light for the effect
  49218. */
  49219. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49220. }
  49221. }
  49222. declare module BABYLON {
  49223. /**
  49224. * Class containing static functions to help procedurally build meshes
  49225. */
  49226. export class HemisphereBuilder {
  49227. /**
  49228. * Creates a hemisphere mesh
  49229. * @param name defines the name of the mesh
  49230. * @param options defines the options used to create the mesh
  49231. * @param scene defines the hosting scene
  49232. * @returns the hemisphere mesh
  49233. */
  49234. static CreateHemisphere(name: string, options: {
  49235. segments?: number;
  49236. diameter?: number;
  49237. sideOrientation?: number;
  49238. }, scene: any): Mesh;
  49239. }
  49240. }
  49241. declare module BABYLON {
  49242. /**
  49243. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49244. * These values define a cone of light starting from the position, emitting toward the direction.
  49245. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49246. * and the exponent defines the speed of the decay of the light with distance (reach).
  49247. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49248. */
  49249. export class SpotLight extends ShadowLight {
  49250. private _angle;
  49251. private _innerAngle;
  49252. private _cosHalfAngle;
  49253. private _lightAngleScale;
  49254. private _lightAngleOffset;
  49255. /**
  49256. * Gets the cone angle of the spot light in Radians.
  49257. */
  49258. get angle(): number;
  49259. /**
  49260. * Sets the cone angle of the spot light in Radians.
  49261. */
  49262. set angle(value: number);
  49263. /**
  49264. * Only used in gltf falloff mode, this defines the angle where
  49265. * the directional falloff will start before cutting at angle which could be seen
  49266. * as outer angle.
  49267. */
  49268. get innerAngle(): number;
  49269. /**
  49270. * Only used in gltf falloff mode, this defines the angle where
  49271. * the directional falloff will start before cutting at angle which could be seen
  49272. * as outer angle.
  49273. */
  49274. set innerAngle(value: number);
  49275. private _shadowAngleScale;
  49276. /**
  49277. * Allows scaling the angle of the light for shadow generation only.
  49278. */
  49279. get shadowAngleScale(): number;
  49280. /**
  49281. * Allows scaling the angle of the light for shadow generation only.
  49282. */
  49283. set shadowAngleScale(value: number);
  49284. /**
  49285. * The light decay speed with the distance from the emission spot.
  49286. */
  49287. exponent: number;
  49288. private _projectionTextureMatrix;
  49289. /**
  49290. * Allows reading the projecton texture
  49291. */
  49292. get projectionTextureMatrix(): Matrix;
  49293. protected _projectionTextureLightNear: number;
  49294. /**
  49295. * Gets the near clip of the Spotlight for texture projection.
  49296. */
  49297. get projectionTextureLightNear(): number;
  49298. /**
  49299. * Sets the near clip of the Spotlight for texture projection.
  49300. */
  49301. set projectionTextureLightNear(value: number);
  49302. protected _projectionTextureLightFar: number;
  49303. /**
  49304. * Gets the far clip of the Spotlight for texture projection.
  49305. */
  49306. get projectionTextureLightFar(): number;
  49307. /**
  49308. * Sets the far clip of the Spotlight for texture projection.
  49309. */
  49310. set projectionTextureLightFar(value: number);
  49311. protected _projectionTextureUpDirection: Vector3;
  49312. /**
  49313. * Gets the Up vector of the Spotlight for texture projection.
  49314. */
  49315. get projectionTextureUpDirection(): Vector3;
  49316. /**
  49317. * Sets the Up vector of the Spotlight for texture projection.
  49318. */
  49319. set projectionTextureUpDirection(value: Vector3);
  49320. private _projectionTexture;
  49321. /**
  49322. * Gets the projection texture of the light.
  49323. */
  49324. get projectionTexture(): Nullable<BaseTexture>;
  49325. /**
  49326. * Sets the projection texture of the light.
  49327. */
  49328. set projectionTexture(value: Nullable<BaseTexture>);
  49329. private _projectionTextureViewLightDirty;
  49330. private _projectionTextureProjectionLightDirty;
  49331. private _projectionTextureDirty;
  49332. private _projectionTextureViewTargetVector;
  49333. private _projectionTextureViewLightMatrix;
  49334. private _projectionTextureProjectionLightMatrix;
  49335. private _projectionTextureScalingMatrix;
  49336. /**
  49337. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49338. * It can cast shadows.
  49339. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49340. * @param name The light friendly name
  49341. * @param position The position of the spot light in the scene
  49342. * @param direction The direction of the light in the scene
  49343. * @param angle The cone angle of the light in Radians
  49344. * @param exponent The light decay speed with the distance from the emission spot
  49345. * @param scene The scene the lights belongs to
  49346. */
  49347. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49348. /**
  49349. * Returns the string "SpotLight".
  49350. * @returns the class name
  49351. */
  49352. getClassName(): string;
  49353. /**
  49354. * Returns the integer 2.
  49355. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49356. */
  49357. getTypeID(): number;
  49358. /**
  49359. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49360. */
  49361. protected _setDirection(value: Vector3): void;
  49362. /**
  49363. * Overrides the position setter to recompute the projection texture view light Matrix.
  49364. */
  49365. protected _setPosition(value: Vector3): void;
  49366. /**
  49367. * 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.
  49368. * Returns the SpotLight.
  49369. */
  49370. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49371. protected _computeProjectionTextureViewLightMatrix(): void;
  49372. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49373. /**
  49374. * Main function for light texture projection matrix computing.
  49375. */
  49376. protected _computeProjectionTextureMatrix(): void;
  49377. protected _buildUniformLayout(): void;
  49378. private _computeAngleValues;
  49379. /**
  49380. * Sets the passed Effect "effect" with the Light textures.
  49381. * @param effect The effect to update
  49382. * @param lightIndex The index of the light in the effect to update
  49383. * @returns The light
  49384. */
  49385. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49386. /**
  49387. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49388. * @param effect The effect to update
  49389. * @param lightIndex The index of the light in the effect to update
  49390. * @returns The spot light
  49391. */
  49392. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49393. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49394. /**
  49395. * Disposes the light and the associated resources.
  49396. */
  49397. dispose(): void;
  49398. /**
  49399. * Prepares the list of defines specific to the light type.
  49400. * @param defines the list of defines
  49401. * @param lightIndex defines the index of the light for the effect
  49402. */
  49403. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49404. }
  49405. }
  49406. declare module BABYLON {
  49407. /**
  49408. * Gizmo that enables viewing a light
  49409. */
  49410. export class LightGizmo extends Gizmo {
  49411. private _lightMesh;
  49412. private _material;
  49413. private _cachedPosition;
  49414. private _cachedForward;
  49415. private _attachedMeshParent;
  49416. /**
  49417. * Creates a LightGizmo
  49418. * @param gizmoLayer The utility layer the gizmo will be added to
  49419. */
  49420. constructor(gizmoLayer?: UtilityLayerRenderer);
  49421. private _light;
  49422. /**
  49423. * The light that the gizmo is attached to
  49424. */
  49425. set light(light: Nullable<Light>);
  49426. get light(): Nullable<Light>;
  49427. /**
  49428. * Gets the material used to render the light gizmo
  49429. */
  49430. get material(): StandardMaterial;
  49431. /**
  49432. * @hidden
  49433. * Updates the gizmo to match the attached mesh's position/rotation
  49434. */
  49435. protected _update(): void;
  49436. private static _Scale;
  49437. /**
  49438. * Creates the lines for a light mesh
  49439. */
  49440. private static _CreateLightLines;
  49441. /**
  49442. * Disposes of the light gizmo
  49443. */
  49444. dispose(): void;
  49445. private static _CreateHemisphericLightMesh;
  49446. private static _CreatePointLightMesh;
  49447. private static _CreateSpotLightMesh;
  49448. private static _CreateDirectionalLightMesh;
  49449. }
  49450. }
  49451. declare module BABYLON {
  49452. /** @hidden */
  49453. export var backgroundFragmentDeclaration: {
  49454. name: string;
  49455. shader: string;
  49456. };
  49457. }
  49458. declare module BABYLON {
  49459. /** @hidden */
  49460. export var backgroundUboDeclaration: {
  49461. name: string;
  49462. shader: string;
  49463. };
  49464. }
  49465. declare module BABYLON {
  49466. /** @hidden */
  49467. export var backgroundPixelShader: {
  49468. name: string;
  49469. shader: string;
  49470. };
  49471. }
  49472. declare module BABYLON {
  49473. /** @hidden */
  49474. export var backgroundVertexDeclaration: {
  49475. name: string;
  49476. shader: string;
  49477. };
  49478. }
  49479. declare module BABYLON {
  49480. /** @hidden */
  49481. export var backgroundVertexShader: {
  49482. name: string;
  49483. shader: string;
  49484. };
  49485. }
  49486. declare module BABYLON {
  49487. /**
  49488. * Background material used to create an efficient environement around your scene.
  49489. */
  49490. export class BackgroundMaterial extends PushMaterial {
  49491. /**
  49492. * Standard reflectance value at parallel view angle.
  49493. */
  49494. static StandardReflectance0: number;
  49495. /**
  49496. * Standard reflectance value at grazing angle.
  49497. */
  49498. static StandardReflectance90: number;
  49499. protected _primaryColor: Color3;
  49500. /**
  49501. * Key light Color (multiply against the environement texture)
  49502. */
  49503. primaryColor: Color3;
  49504. protected __perceptualColor: Nullable<Color3>;
  49505. /**
  49506. * Experimental Internal Use Only.
  49507. *
  49508. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49509. * This acts as a helper to set the primary color to a more "human friendly" value.
  49510. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49511. * output color as close as possible from the chosen value.
  49512. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49513. * part of lighting setup.)
  49514. */
  49515. get _perceptualColor(): Nullable<Color3>;
  49516. set _perceptualColor(value: Nullable<Color3>);
  49517. protected _primaryColorShadowLevel: float;
  49518. /**
  49519. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49520. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49521. */
  49522. get primaryColorShadowLevel(): float;
  49523. set primaryColorShadowLevel(value: float);
  49524. protected _primaryColorHighlightLevel: float;
  49525. /**
  49526. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49527. * The primary color is used at the level chosen to define what the white area would look.
  49528. */
  49529. get primaryColorHighlightLevel(): float;
  49530. set primaryColorHighlightLevel(value: float);
  49531. protected _reflectionTexture: Nullable<BaseTexture>;
  49532. /**
  49533. * Reflection Texture used in the material.
  49534. * Should be author in a specific way for the best result (refer to the documentation).
  49535. */
  49536. reflectionTexture: Nullable<BaseTexture>;
  49537. protected _reflectionBlur: float;
  49538. /**
  49539. * Reflection Texture level of blur.
  49540. *
  49541. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49542. * texture twice.
  49543. */
  49544. reflectionBlur: float;
  49545. protected _diffuseTexture: Nullable<BaseTexture>;
  49546. /**
  49547. * Diffuse Texture used in the material.
  49548. * Should be author in a specific way for the best result (refer to the documentation).
  49549. */
  49550. diffuseTexture: Nullable<BaseTexture>;
  49551. protected _shadowLights: Nullable<IShadowLight[]>;
  49552. /**
  49553. * Specify the list of lights casting shadow on the material.
  49554. * All scene shadow lights will be included if null.
  49555. */
  49556. shadowLights: Nullable<IShadowLight[]>;
  49557. protected _shadowLevel: float;
  49558. /**
  49559. * Helps adjusting the shadow to a softer level if required.
  49560. * 0 means black shadows and 1 means no shadows.
  49561. */
  49562. shadowLevel: float;
  49563. protected _sceneCenter: Vector3;
  49564. /**
  49565. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49566. * It is usually zero but might be interesting to modify according to your setup.
  49567. */
  49568. sceneCenter: Vector3;
  49569. protected _opacityFresnel: boolean;
  49570. /**
  49571. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49572. * This helps ensuring a nice transition when the camera goes under the ground.
  49573. */
  49574. opacityFresnel: boolean;
  49575. protected _reflectionFresnel: boolean;
  49576. /**
  49577. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49578. * This helps adding a mirror texture on the ground.
  49579. */
  49580. reflectionFresnel: boolean;
  49581. protected _reflectionFalloffDistance: number;
  49582. /**
  49583. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49584. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49585. */
  49586. reflectionFalloffDistance: number;
  49587. protected _reflectionAmount: number;
  49588. /**
  49589. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49590. */
  49591. reflectionAmount: number;
  49592. protected _reflectionReflectance0: number;
  49593. /**
  49594. * This specifies the weight of the reflection at grazing angle.
  49595. */
  49596. reflectionReflectance0: number;
  49597. protected _reflectionReflectance90: number;
  49598. /**
  49599. * This specifies the weight of the reflection at a perpendicular point of view.
  49600. */
  49601. reflectionReflectance90: number;
  49602. /**
  49603. * Sets the reflection reflectance fresnel values according to the default standard
  49604. * empirically know to work well :-)
  49605. */
  49606. set reflectionStandardFresnelWeight(value: number);
  49607. protected _useRGBColor: boolean;
  49608. /**
  49609. * Helps to directly use the maps channels instead of their level.
  49610. */
  49611. useRGBColor: boolean;
  49612. protected _enableNoise: boolean;
  49613. /**
  49614. * This helps reducing the banding effect that could occur on the background.
  49615. */
  49616. enableNoise: boolean;
  49617. /**
  49618. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49619. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49620. * Recommended to be keep at 1.0 except for special cases.
  49621. */
  49622. get fovMultiplier(): number;
  49623. set fovMultiplier(value: number);
  49624. private _fovMultiplier;
  49625. /**
  49626. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49627. */
  49628. useEquirectangularFOV: boolean;
  49629. private _maxSimultaneousLights;
  49630. /**
  49631. * Number of Simultaneous lights allowed on the material.
  49632. */
  49633. maxSimultaneousLights: int;
  49634. /**
  49635. * Default configuration related to image processing available in the Background Material.
  49636. */
  49637. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49638. /**
  49639. * Keep track of the image processing observer to allow dispose and replace.
  49640. */
  49641. private _imageProcessingObserver;
  49642. /**
  49643. * Attaches a new image processing configuration to the PBR Material.
  49644. * @param configuration (if null the scene configuration will be use)
  49645. */
  49646. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49647. /**
  49648. * Gets the image processing configuration used either in this material.
  49649. */
  49650. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49651. /**
  49652. * Sets the Default image processing configuration used either in the this material.
  49653. *
  49654. * If sets to null, the scene one is in use.
  49655. */
  49656. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49657. /**
  49658. * Gets wether the color curves effect is enabled.
  49659. */
  49660. get cameraColorCurvesEnabled(): boolean;
  49661. /**
  49662. * Sets wether the color curves effect is enabled.
  49663. */
  49664. set cameraColorCurvesEnabled(value: boolean);
  49665. /**
  49666. * Gets wether the color grading effect is enabled.
  49667. */
  49668. get cameraColorGradingEnabled(): boolean;
  49669. /**
  49670. * Gets wether the color grading effect is enabled.
  49671. */
  49672. set cameraColorGradingEnabled(value: boolean);
  49673. /**
  49674. * Gets wether tonemapping is enabled or not.
  49675. */
  49676. get cameraToneMappingEnabled(): boolean;
  49677. /**
  49678. * Sets wether tonemapping is enabled or not
  49679. */
  49680. set cameraToneMappingEnabled(value: boolean);
  49681. /**
  49682. * The camera exposure used on this material.
  49683. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49684. * This corresponds to a photographic exposure.
  49685. */
  49686. get cameraExposure(): float;
  49687. /**
  49688. * The camera exposure used on this material.
  49689. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49690. * This corresponds to a photographic exposure.
  49691. */
  49692. set cameraExposure(value: float);
  49693. /**
  49694. * Gets The camera contrast used on this material.
  49695. */
  49696. get cameraContrast(): float;
  49697. /**
  49698. * Sets The camera contrast used on this material.
  49699. */
  49700. set cameraContrast(value: float);
  49701. /**
  49702. * Gets the Color Grading 2D Lookup Texture.
  49703. */
  49704. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49705. /**
  49706. * Sets the Color Grading 2D Lookup Texture.
  49707. */
  49708. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49709. /**
  49710. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49711. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49712. * 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;
  49713. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49714. */
  49715. get cameraColorCurves(): Nullable<ColorCurves>;
  49716. /**
  49717. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49718. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49719. * 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;
  49720. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49721. */
  49722. set cameraColorCurves(value: Nullable<ColorCurves>);
  49723. /**
  49724. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49725. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49726. */
  49727. switchToBGR: boolean;
  49728. private _renderTargets;
  49729. private _reflectionControls;
  49730. private _white;
  49731. private _primaryShadowColor;
  49732. private _primaryHighlightColor;
  49733. /**
  49734. * Instantiates a Background Material in the given scene
  49735. * @param name The friendly name of the material
  49736. * @param scene The scene to add the material to
  49737. */
  49738. constructor(name: string, scene: Scene);
  49739. /**
  49740. * Gets a boolean indicating that current material needs to register RTT
  49741. */
  49742. get hasRenderTargetTextures(): boolean;
  49743. /**
  49744. * The entire material has been created in order to prevent overdraw.
  49745. * @returns false
  49746. */
  49747. needAlphaTesting(): boolean;
  49748. /**
  49749. * The entire material has been created in order to prevent overdraw.
  49750. * @returns true if blending is enable
  49751. */
  49752. needAlphaBlending(): boolean;
  49753. /**
  49754. * Checks wether the material is ready to be rendered for a given mesh.
  49755. * @param mesh The mesh to render
  49756. * @param subMesh The submesh to check against
  49757. * @param useInstances Specify wether or not the material is used with instances
  49758. * @returns true if all the dependencies are ready (Textures, Effects...)
  49759. */
  49760. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49761. /**
  49762. * Compute the primary color according to the chosen perceptual color.
  49763. */
  49764. private _computePrimaryColorFromPerceptualColor;
  49765. /**
  49766. * Compute the highlights and shadow colors according to their chosen levels.
  49767. */
  49768. private _computePrimaryColors;
  49769. /**
  49770. * Build the uniform buffer used in the material.
  49771. */
  49772. buildUniformLayout(): void;
  49773. /**
  49774. * Unbind the material.
  49775. */
  49776. unbind(): void;
  49777. /**
  49778. * Bind only the world matrix to the material.
  49779. * @param world The world matrix to bind.
  49780. */
  49781. bindOnlyWorldMatrix(world: Matrix): void;
  49782. /**
  49783. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49784. * @param world The world matrix to bind.
  49785. * @param subMesh The submesh to bind for.
  49786. */
  49787. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49788. /**
  49789. * Checks to see if a texture is used in the material.
  49790. * @param texture - Base texture to use.
  49791. * @returns - Boolean specifying if a texture is used in the material.
  49792. */
  49793. hasTexture(texture: BaseTexture): boolean;
  49794. /**
  49795. * Dispose the material.
  49796. * @param forceDisposeEffect Force disposal of the associated effect.
  49797. * @param forceDisposeTextures Force disposal of the associated textures.
  49798. */
  49799. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49800. /**
  49801. * Clones the material.
  49802. * @param name The cloned name.
  49803. * @returns The cloned material.
  49804. */
  49805. clone(name: string): BackgroundMaterial;
  49806. /**
  49807. * Serializes the current material to its JSON representation.
  49808. * @returns The JSON representation.
  49809. */
  49810. serialize(): any;
  49811. /**
  49812. * Gets the class name of the material
  49813. * @returns "BackgroundMaterial"
  49814. */
  49815. getClassName(): string;
  49816. /**
  49817. * Parse a JSON input to create back a background material.
  49818. * @param source The JSON data to parse
  49819. * @param scene The scene to create the parsed material in
  49820. * @param rootUrl The root url of the assets the material depends upon
  49821. * @returns the instantiated BackgroundMaterial.
  49822. */
  49823. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49824. }
  49825. }
  49826. declare module BABYLON {
  49827. /**
  49828. * Represents the different options available during the creation of
  49829. * a Environment helper.
  49830. *
  49831. * This can control the default ground, skybox and image processing setup of your scene.
  49832. */
  49833. export interface IEnvironmentHelperOptions {
  49834. /**
  49835. * Specifies wether or not to create a ground.
  49836. * True by default.
  49837. */
  49838. createGround: boolean;
  49839. /**
  49840. * Specifies the ground size.
  49841. * 15 by default.
  49842. */
  49843. groundSize: number;
  49844. /**
  49845. * The texture used on the ground for the main color.
  49846. * Comes from the BabylonJS CDN by default.
  49847. *
  49848. * Remarks: Can be either a texture or a url.
  49849. */
  49850. groundTexture: string | BaseTexture;
  49851. /**
  49852. * The color mixed in the ground texture by default.
  49853. * BabylonJS clearColor by default.
  49854. */
  49855. groundColor: Color3;
  49856. /**
  49857. * Specifies the ground opacity.
  49858. * 1 by default.
  49859. */
  49860. groundOpacity: number;
  49861. /**
  49862. * Enables the ground to receive shadows.
  49863. * True by default.
  49864. */
  49865. enableGroundShadow: boolean;
  49866. /**
  49867. * Helps preventing the shadow to be fully black on the ground.
  49868. * 0.5 by default.
  49869. */
  49870. groundShadowLevel: number;
  49871. /**
  49872. * Creates a mirror texture attach to the ground.
  49873. * false by default.
  49874. */
  49875. enableGroundMirror: boolean;
  49876. /**
  49877. * Specifies the ground mirror size ratio.
  49878. * 0.3 by default as the default kernel is 64.
  49879. */
  49880. groundMirrorSizeRatio: number;
  49881. /**
  49882. * Specifies the ground mirror blur kernel size.
  49883. * 64 by default.
  49884. */
  49885. groundMirrorBlurKernel: number;
  49886. /**
  49887. * Specifies the ground mirror visibility amount.
  49888. * 1 by default
  49889. */
  49890. groundMirrorAmount: number;
  49891. /**
  49892. * Specifies the ground mirror reflectance weight.
  49893. * This uses the standard weight of the background material to setup the fresnel effect
  49894. * of the mirror.
  49895. * 1 by default.
  49896. */
  49897. groundMirrorFresnelWeight: number;
  49898. /**
  49899. * Specifies the ground mirror Falloff distance.
  49900. * This can helps reducing the size of the reflection.
  49901. * 0 by Default.
  49902. */
  49903. groundMirrorFallOffDistance: number;
  49904. /**
  49905. * Specifies the ground mirror texture type.
  49906. * Unsigned Int by Default.
  49907. */
  49908. groundMirrorTextureType: number;
  49909. /**
  49910. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49911. * the shown objects.
  49912. */
  49913. groundYBias: number;
  49914. /**
  49915. * Specifies wether or not to create a skybox.
  49916. * True by default.
  49917. */
  49918. createSkybox: boolean;
  49919. /**
  49920. * Specifies the skybox size.
  49921. * 20 by default.
  49922. */
  49923. skyboxSize: number;
  49924. /**
  49925. * The texture used on the skybox for the main color.
  49926. * Comes from the BabylonJS CDN by default.
  49927. *
  49928. * Remarks: Can be either a texture or a url.
  49929. */
  49930. skyboxTexture: string | BaseTexture;
  49931. /**
  49932. * The color mixed in the skybox texture by default.
  49933. * BabylonJS clearColor by default.
  49934. */
  49935. skyboxColor: Color3;
  49936. /**
  49937. * The background rotation around the Y axis of the scene.
  49938. * This helps aligning the key lights of your scene with the background.
  49939. * 0 by default.
  49940. */
  49941. backgroundYRotation: number;
  49942. /**
  49943. * Compute automatically the size of the elements to best fit with the scene.
  49944. */
  49945. sizeAuto: boolean;
  49946. /**
  49947. * Default position of the rootMesh if autoSize is not true.
  49948. */
  49949. rootPosition: Vector3;
  49950. /**
  49951. * Sets up the image processing in the scene.
  49952. * true by default.
  49953. */
  49954. setupImageProcessing: boolean;
  49955. /**
  49956. * The texture used as your environment texture in the scene.
  49957. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49958. *
  49959. * Remarks: Can be either a texture or a url.
  49960. */
  49961. environmentTexture: string | BaseTexture;
  49962. /**
  49963. * The value of the exposure to apply to the scene.
  49964. * 0.6 by default if setupImageProcessing is true.
  49965. */
  49966. cameraExposure: number;
  49967. /**
  49968. * The value of the contrast to apply to the scene.
  49969. * 1.6 by default if setupImageProcessing is true.
  49970. */
  49971. cameraContrast: number;
  49972. /**
  49973. * Specifies wether or not tonemapping should be enabled in the scene.
  49974. * true by default if setupImageProcessing is true.
  49975. */
  49976. toneMappingEnabled: boolean;
  49977. }
  49978. /**
  49979. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49980. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49981. * It also helps with the default setup of your imageProcessing configuration.
  49982. */
  49983. export class EnvironmentHelper {
  49984. /**
  49985. * Default ground texture URL.
  49986. */
  49987. private static _groundTextureCDNUrl;
  49988. /**
  49989. * Default skybox texture URL.
  49990. */
  49991. private static _skyboxTextureCDNUrl;
  49992. /**
  49993. * Default environment texture URL.
  49994. */
  49995. private static _environmentTextureCDNUrl;
  49996. /**
  49997. * Creates the default options for the helper.
  49998. */
  49999. private static _getDefaultOptions;
  50000. private _rootMesh;
  50001. /**
  50002. * Gets the root mesh created by the helper.
  50003. */
  50004. get rootMesh(): Mesh;
  50005. private _skybox;
  50006. /**
  50007. * Gets the skybox created by the helper.
  50008. */
  50009. get skybox(): Nullable<Mesh>;
  50010. private _skyboxTexture;
  50011. /**
  50012. * Gets the skybox texture created by the helper.
  50013. */
  50014. get skyboxTexture(): Nullable<BaseTexture>;
  50015. private _skyboxMaterial;
  50016. /**
  50017. * Gets the skybox material created by the helper.
  50018. */
  50019. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50020. private _ground;
  50021. /**
  50022. * Gets the ground mesh created by the helper.
  50023. */
  50024. get ground(): Nullable<Mesh>;
  50025. private _groundTexture;
  50026. /**
  50027. * Gets the ground texture created by the helper.
  50028. */
  50029. get groundTexture(): Nullable<BaseTexture>;
  50030. private _groundMirror;
  50031. /**
  50032. * Gets the ground mirror created by the helper.
  50033. */
  50034. get groundMirror(): Nullable<MirrorTexture>;
  50035. /**
  50036. * Gets the ground mirror render list to helps pushing the meshes
  50037. * you wish in the ground reflection.
  50038. */
  50039. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50040. private _groundMaterial;
  50041. /**
  50042. * Gets the ground material created by the helper.
  50043. */
  50044. get groundMaterial(): Nullable<BackgroundMaterial>;
  50045. /**
  50046. * Stores the creation options.
  50047. */
  50048. private readonly _scene;
  50049. private _options;
  50050. /**
  50051. * This observable will be notified with any error during the creation of the environment,
  50052. * mainly texture creation errors.
  50053. */
  50054. onErrorObservable: Observable<{
  50055. message?: string;
  50056. exception?: any;
  50057. }>;
  50058. /**
  50059. * constructor
  50060. * @param options Defines the options we want to customize the helper
  50061. * @param scene The scene to add the material to
  50062. */
  50063. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50064. /**
  50065. * Updates the background according to the new options
  50066. * @param options
  50067. */
  50068. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50069. /**
  50070. * Sets the primary color of all the available elements.
  50071. * @param color the main color to affect to the ground and the background
  50072. */
  50073. setMainColor(color: Color3): void;
  50074. /**
  50075. * Setup the image processing according to the specified options.
  50076. */
  50077. private _setupImageProcessing;
  50078. /**
  50079. * Setup the environment texture according to the specified options.
  50080. */
  50081. private _setupEnvironmentTexture;
  50082. /**
  50083. * Setup the background according to the specified options.
  50084. */
  50085. private _setupBackground;
  50086. /**
  50087. * Get the scene sizes according to the setup.
  50088. */
  50089. private _getSceneSize;
  50090. /**
  50091. * Setup the ground according to the specified options.
  50092. */
  50093. private _setupGround;
  50094. /**
  50095. * Setup the ground material according to the specified options.
  50096. */
  50097. private _setupGroundMaterial;
  50098. /**
  50099. * Setup the ground diffuse texture according to the specified options.
  50100. */
  50101. private _setupGroundDiffuseTexture;
  50102. /**
  50103. * Setup the ground mirror texture according to the specified options.
  50104. */
  50105. private _setupGroundMirrorTexture;
  50106. /**
  50107. * Setup the ground to receive the mirror texture.
  50108. */
  50109. private _setupMirrorInGroundMaterial;
  50110. /**
  50111. * Setup the skybox according to the specified options.
  50112. */
  50113. private _setupSkybox;
  50114. /**
  50115. * Setup the skybox material according to the specified options.
  50116. */
  50117. private _setupSkyboxMaterial;
  50118. /**
  50119. * Setup the skybox reflection texture according to the specified options.
  50120. */
  50121. private _setupSkyboxReflectionTexture;
  50122. private _errorHandler;
  50123. /**
  50124. * Dispose all the elements created by the Helper.
  50125. */
  50126. dispose(): void;
  50127. }
  50128. }
  50129. declare module BABYLON {
  50130. /**
  50131. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50132. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50133. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50134. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50135. */
  50136. export class PhotoDome extends TransformNode {
  50137. /**
  50138. * Define the image as a Monoscopic panoramic 360 image.
  50139. */
  50140. static readonly MODE_MONOSCOPIC: number;
  50141. /**
  50142. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50143. */
  50144. static readonly MODE_TOPBOTTOM: number;
  50145. /**
  50146. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50147. */
  50148. static readonly MODE_SIDEBYSIDE: number;
  50149. private _useDirectMapping;
  50150. /**
  50151. * The texture being displayed on the sphere
  50152. */
  50153. protected _photoTexture: Texture;
  50154. /**
  50155. * Gets or sets the texture being displayed on the sphere
  50156. */
  50157. get photoTexture(): Texture;
  50158. set photoTexture(value: Texture);
  50159. /**
  50160. * Observable raised when an error occured while loading the 360 image
  50161. */
  50162. onLoadErrorObservable: Observable<string>;
  50163. /**
  50164. * The skybox material
  50165. */
  50166. protected _material: BackgroundMaterial;
  50167. /**
  50168. * The surface used for the skybox
  50169. */
  50170. protected _mesh: Mesh;
  50171. /**
  50172. * Gets the mesh used for the skybox.
  50173. */
  50174. get mesh(): Mesh;
  50175. /**
  50176. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50177. * Also see the options.resolution property.
  50178. */
  50179. get fovMultiplier(): number;
  50180. set fovMultiplier(value: number);
  50181. private _imageMode;
  50182. /**
  50183. * Gets or set the current video mode for the video. It can be:
  50184. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50185. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50186. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50187. */
  50188. get imageMode(): number;
  50189. set imageMode(value: number);
  50190. /**
  50191. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50192. * @param name Element's name, child elements will append suffixes for their own names.
  50193. * @param urlsOfPhoto defines the url of the photo to display
  50194. * @param options defines an object containing optional or exposed sub element properties
  50195. * @param onError defines a callback called when an error occured while loading the texture
  50196. */
  50197. constructor(name: string, urlOfPhoto: string, options: {
  50198. resolution?: number;
  50199. size?: number;
  50200. useDirectMapping?: boolean;
  50201. faceForward?: boolean;
  50202. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50203. private _onBeforeCameraRenderObserver;
  50204. private _changeImageMode;
  50205. /**
  50206. * Releases resources associated with this node.
  50207. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50208. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50209. */
  50210. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50211. }
  50212. }
  50213. declare module BABYLON {
  50214. /**
  50215. * Class used to host RGBD texture specific utilities
  50216. */
  50217. export class RGBDTextureTools {
  50218. /**
  50219. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50220. * @param texture the texture to expand.
  50221. */
  50222. static ExpandRGBDTexture(texture: Texture): void;
  50223. }
  50224. }
  50225. declare module BABYLON {
  50226. /**
  50227. * Class used to host texture specific utilities
  50228. */
  50229. export class BRDFTextureTools {
  50230. /**
  50231. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50232. * @param scene defines the hosting scene
  50233. * @returns the environment BRDF texture
  50234. */
  50235. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50236. private static _environmentBRDFBase64Texture;
  50237. }
  50238. }
  50239. declare module BABYLON {
  50240. /**
  50241. * @hidden
  50242. */
  50243. export interface IMaterialClearCoatDefines {
  50244. CLEARCOAT: boolean;
  50245. CLEARCOAT_DEFAULTIOR: boolean;
  50246. CLEARCOAT_TEXTURE: boolean;
  50247. CLEARCOAT_TEXTUREDIRECTUV: number;
  50248. CLEARCOAT_BUMP: boolean;
  50249. CLEARCOAT_BUMPDIRECTUV: number;
  50250. CLEARCOAT_TINT: boolean;
  50251. CLEARCOAT_TINT_TEXTURE: boolean;
  50252. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50253. /** @hidden */
  50254. _areTexturesDirty: boolean;
  50255. }
  50256. /**
  50257. * Define the code related to the clear coat parameters of the pbr material.
  50258. */
  50259. export class PBRClearCoatConfiguration {
  50260. /**
  50261. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50262. * The default fits with a polyurethane material.
  50263. */
  50264. private static readonly _DefaultIndexOfRefraction;
  50265. private _isEnabled;
  50266. /**
  50267. * Defines if the clear coat is enabled in the material.
  50268. */
  50269. isEnabled: boolean;
  50270. /**
  50271. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50272. */
  50273. intensity: number;
  50274. /**
  50275. * Defines the clear coat layer roughness.
  50276. */
  50277. roughness: number;
  50278. private _indexOfRefraction;
  50279. /**
  50280. * Defines the index of refraction of the clear coat.
  50281. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50282. * The default fits with a polyurethane material.
  50283. * Changing the default value is more performance intensive.
  50284. */
  50285. indexOfRefraction: number;
  50286. private _texture;
  50287. /**
  50288. * Stores the clear coat values in a texture.
  50289. */
  50290. texture: Nullable<BaseTexture>;
  50291. private _bumpTexture;
  50292. /**
  50293. * Define the clear coat specific bump texture.
  50294. */
  50295. bumpTexture: Nullable<BaseTexture>;
  50296. private _isTintEnabled;
  50297. /**
  50298. * Defines if the clear coat tint is enabled in the material.
  50299. */
  50300. isTintEnabled: boolean;
  50301. /**
  50302. * Defines the clear coat tint of the material.
  50303. * This is only use if tint is enabled
  50304. */
  50305. tintColor: Color3;
  50306. /**
  50307. * Defines the distance at which the tint color should be found in the
  50308. * clear coat media.
  50309. * This is only use if tint is enabled
  50310. */
  50311. tintColorAtDistance: number;
  50312. /**
  50313. * Defines the clear coat layer thickness.
  50314. * This is only use if tint is enabled
  50315. */
  50316. tintThickness: number;
  50317. private _tintTexture;
  50318. /**
  50319. * Stores the clear tint values in a texture.
  50320. * rgb is tint
  50321. * a is a thickness factor
  50322. */
  50323. tintTexture: Nullable<BaseTexture>;
  50324. /** @hidden */
  50325. private _internalMarkAllSubMeshesAsTexturesDirty;
  50326. /** @hidden */
  50327. _markAllSubMeshesAsTexturesDirty(): void;
  50328. /**
  50329. * Instantiate a new istance of clear coat configuration.
  50330. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50331. */
  50332. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50333. /**
  50334. * Gets wehter the submesh is ready to be used or not.
  50335. * @param defines the list of "defines" to update.
  50336. * @param scene defines the scene the material belongs to.
  50337. * @param engine defines the engine the material belongs to.
  50338. * @param disableBumpMap defines wether the material disables bump or not.
  50339. * @returns - boolean indicating that the submesh is ready or not.
  50340. */
  50341. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50342. /**
  50343. * Checks to see if a texture is used in the material.
  50344. * @param defines the list of "defines" to update.
  50345. * @param scene defines the scene to the material belongs to.
  50346. */
  50347. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50348. /**
  50349. * Binds the material data.
  50350. * @param uniformBuffer defines the Uniform buffer to fill in.
  50351. * @param scene defines the scene the material belongs to.
  50352. * @param engine defines the engine the material belongs to.
  50353. * @param disableBumpMap defines wether the material disables bump or not.
  50354. * @param isFrozen defines wether the material is frozen or not.
  50355. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50356. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50357. */
  50358. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50359. /**
  50360. * Checks to see if a texture is used in the material.
  50361. * @param texture - Base texture to use.
  50362. * @returns - Boolean specifying if a texture is used in the material.
  50363. */
  50364. hasTexture(texture: BaseTexture): boolean;
  50365. /**
  50366. * Returns an array of the actively used textures.
  50367. * @param activeTextures Array of BaseTextures
  50368. */
  50369. getActiveTextures(activeTextures: BaseTexture[]): void;
  50370. /**
  50371. * Returns the animatable textures.
  50372. * @param animatables Array of animatable textures.
  50373. */
  50374. getAnimatables(animatables: IAnimatable[]): void;
  50375. /**
  50376. * Disposes the resources of the material.
  50377. * @param forceDisposeTextures - Forces the disposal of all textures.
  50378. */
  50379. dispose(forceDisposeTextures?: boolean): void;
  50380. /**
  50381. * Get the current class name of the texture useful for serialization or dynamic coding.
  50382. * @returns "PBRClearCoatConfiguration"
  50383. */
  50384. getClassName(): string;
  50385. /**
  50386. * Add fallbacks to the effect fallbacks list.
  50387. * @param defines defines the Base texture to use.
  50388. * @param fallbacks defines the current fallback list.
  50389. * @param currentRank defines the current fallback rank.
  50390. * @returns the new fallback rank.
  50391. */
  50392. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50393. /**
  50394. * Add the required uniforms to the current list.
  50395. * @param uniforms defines the current uniform list.
  50396. */
  50397. static AddUniforms(uniforms: string[]): void;
  50398. /**
  50399. * Add the required samplers to the current list.
  50400. * @param samplers defines the current sampler list.
  50401. */
  50402. static AddSamplers(samplers: string[]): void;
  50403. /**
  50404. * Add the required uniforms to the current buffer.
  50405. * @param uniformBuffer defines the current uniform buffer.
  50406. */
  50407. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50408. /**
  50409. * Makes a duplicate of the current configuration into another one.
  50410. * @param clearCoatConfiguration define the config where to copy the info
  50411. */
  50412. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50413. /**
  50414. * Serializes this clear coat configuration.
  50415. * @returns - An object with the serialized config.
  50416. */
  50417. serialize(): any;
  50418. /**
  50419. * Parses a anisotropy Configuration from a serialized object.
  50420. * @param source - Serialized object.
  50421. * @param scene Defines the scene we are parsing for
  50422. * @param rootUrl Defines the rootUrl to load from
  50423. */
  50424. parse(source: any, scene: Scene, rootUrl: string): void;
  50425. }
  50426. }
  50427. declare module BABYLON {
  50428. /**
  50429. * @hidden
  50430. */
  50431. export interface IMaterialAnisotropicDefines {
  50432. ANISOTROPIC: boolean;
  50433. ANISOTROPIC_TEXTURE: boolean;
  50434. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50435. MAINUV1: boolean;
  50436. _areTexturesDirty: boolean;
  50437. _needUVs: boolean;
  50438. }
  50439. /**
  50440. * Define the code related to the anisotropic parameters of the pbr material.
  50441. */
  50442. export class PBRAnisotropicConfiguration {
  50443. private _isEnabled;
  50444. /**
  50445. * Defines if the anisotropy is enabled in the material.
  50446. */
  50447. isEnabled: boolean;
  50448. /**
  50449. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50450. */
  50451. intensity: number;
  50452. /**
  50453. * Defines if the effect is along the tangents, bitangents or in between.
  50454. * By default, the effect is "strectching" the highlights along the tangents.
  50455. */
  50456. direction: Vector2;
  50457. private _texture;
  50458. /**
  50459. * Stores the anisotropy values in a texture.
  50460. * rg is direction (like normal from -1 to 1)
  50461. * b is a intensity
  50462. */
  50463. texture: Nullable<BaseTexture>;
  50464. /** @hidden */
  50465. private _internalMarkAllSubMeshesAsTexturesDirty;
  50466. /** @hidden */
  50467. _markAllSubMeshesAsTexturesDirty(): void;
  50468. /**
  50469. * Instantiate a new istance of anisotropy configuration.
  50470. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50471. */
  50472. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50473. /**
  50474. * Specifies that the submesh is ready to be used.
  50475. * @param defines the list of "defines" to update.
  50476. * @param scene defines the scene the material belongs to.
  50477. * @returns - boolean indicating that the submesh is ready or not.
  50478. */
  50479. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50480. /**
  50481. * Checks to see if a texture is used in the material.
  50482. * @param defines the list of "defines" to update.
  50483. * @param mesh the mesh we are preparing the defines for.
  50484. * @param scene defines the scene the material belongs to.
  50485. */
  50486. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50487. /**
  50488. * Binds the material data.
  50489. * @param uniformBuffer defines the Uniform buffer to fill in.
  50490. * @param scene defines the scene the material belongs to.
  50491. * @param isFrozen defines wether the material is frozen or not.
  50492. */
  50493. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50494. /**
  50495. * Checks to see if a texture is used in the material.
  50496. * @param texture - Base texture to use.
  50497. * @returns - Boolean specifying if a texture is used in the material.
  50498. */
  50499. hasTexture(texture: BaseTexture): boolean;
  50500. /**
  50501. * Returns an array of the actively used textures.
  50502. * @param activeTextures Array of BaseTextures
  50503. */
  50504. getActiveTextures(activeTextures: BaseTexture[]): void;
  50505. /**
  50506. * Returns the animatable textures.
  50507. * @param animatables Array of animatable textures.
  50508. */
  50509. getAnimatables(animatables: IAnimatable[]): void;
  50510. /**
  50511. * Disposes the resources of the material.
  50512. * @param forceDisposeTextures - Forces the disposal of all textures.
  50513. */
  50514. dispose(forceDisposeTextures?: boolean): void;
  50515. /**
  50516. * Get the current class name of the texture useful for serialization or dynamic coding.
  50517. * @returns "PBRAnisotropicConfiguration"
  50518. */
  50519. getClassName(): string;
  50520. /**
  50521. * Add fallbacks to the effect fallbacks list.
  50522. * @param defines defines the Base texture to use.
  50523. * @param fallbacks defines the current fallback list.
  50524. * @param currentRank defines the current fallback rank.
  50525. * @returns the new fallback rank.
  50526. */
  50527. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50528. /**
  50529. * Add the required uniforms to the current list.
  50530. * @param uniforms defines the current uniform list.
  50531. */
  50532. static AddUniforms(uniforms: string[]): void;
  50533. /**
  50534. * Add the required uniforms to the current buffer.
  50535. * @param uniformBuffer defines the current uniform buffer.
  50536. */
  50537. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50538. /**
  50539. * Add the required samplers to the current list.
  50540. * @param samplers defines the current sampler list.
  50541. */
  50542. static AddSamplers(samplers: string[]): void;
  50543. /**
  50544. * Makes a duplicate of the current configuration into another one.
  50545. * @param anisotropicConfiguration define the config where to copy the info
  50546. */
  50547. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50548. /**
  50549. * Serializes this anisotropy configuration.
  50550. * @returns - An object with the serialized config.
  50551. */
  50552. serialize(): any;
  50553. /**
  50554. * Parses a anisotropy Configuration from a serialized object.
  50555. * @param source - Serialized object.
  50556. * @param scene Defines the scene we are parsing for
  50557. * @param rootUrl Defines the rootUrl to load from
  50558. */
  50559. parse(source: any, scene: Scene, rootUrl: string): void;
  50560. }
  50561. }
  50562. declare module BABYLON {
  50563. /**
  50564. * @hidden
  50565. */
  50566. export interface IMaterialBRDFDefines {
  50567. BRDF_V_HEIGHT_CORRELATED: boolean;
  50568. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50569. SPHERICAL_HARMONICS: boolean;
  50570. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50571. /** @hidden */
  50572. _areMiscDirty: boolean;
  50573. }
  50574. /**
  50575. * Define the code related to the BRDF parameters of the pbr material.
  50576. */
  50577. export class PBRBRDFConfiguration {
  50578. /**
  50579. * Default value used for the energy conservation.
  50580. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50581. */
  50582. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50583. /**
  50584. * Default value used for the Smith Visibility Height Correlated mode.
  50585. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50586. */
  50587. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50588. /**
  50589. * Default value used for the IBL diffuse part.
  50590. * This can help switching back to the polynomials mode globally which is a tiny bit
  50591. * less GPU intensive at the drawback of a lower quality.
  50592. */
  50593. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50594. /**
  50595. * Default value used for activating energy conservation for the specular workflow.
  50596. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50597. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50598. */
  50599. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50600. private _useEnergyConservation;
  50601. /**
  50602. * Defines if the material uses energy conservation.
  50603. */
  50604. useEnergyConservation: boolean;
  50605. private _useSmithVisibilityHeightCorrelated;
  50606. /**
  50607. * LEGACY Mode set to false
  50608. * Defines if the material uses height smith correlated visibility term.
  50609. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50610. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50611. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50612. * Not relying on height correlated will also disable energy conservation.
  50613. */
  50614. useSmithVisibilityHeightCorrelated: boolean;
  50615. private _useSphericalHarmonics;
  50616. /**
  50617. * LEGACY Mode set to false
  50618. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50619. * diffuse part of the IBL.
  50620. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50621. * to the ground truth.
  50622. */
  50623. useSphericalHarmonics: boolean;
  50624. private _useSpecularGlossinessInputEnergyConservation;
  50625. /**
  50626. * Defines if the material uses energy conservation, when the specular workflow is active.
  50627. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50628. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50629. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50630. */
  50631. useSpecularGlossinessInputEnergyConservation: boolean;
  50632. /** @hidden */
  50633. private _internalMarkAllSubMeshesAsMiscDirty;
  50634. /** @hidden */
  50635. _markAllSubMeshesAsMiscDirty(): void;
  50636. /**
  50637. * Instantiate a new istance of clear coat configuration.
  50638. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50639. */
  50640. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50641. /**
  50642. * Checks to see if a texture is used in the material.
  50643. * @param defines the list of "defines" to update.
  50644. */
  50645. prepareDefines(defines: IMaterialBRDFDefines): void;
  50646. /**
  50647. * Get the current class name of the texture useful for serialization or dynamic coding.
  50648. * @returns "PBRClearCoatConfiguration"
  50649. */
  50650. getClassName(): string;
  50651. /**
  50652. * Makes a duplicate of the current configuration into another one.
  50653. * @param brdfConfiguration define the config where to copy the info
  50654. */
  50655. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50656. /**
  50657. * Serializes this BRDF configuration.
  50658. * @returns - An object with the serialized config.
  50659. */
  50660. serialize(): any;
  50661. /**
  50662. * Parses a anisotropy Configuration from a serialized object.
  50663. * @param source - Serialized object.
  50664. * @param scene Defines the scene we are parsing for
  50665. * @param rootUrl Defines the rootUrl to load from
  50666. */
  50667. parse(source: any, scene: Scene, rootUrl: string): void;
  50668. }
  50669. }
  50670. declare module BABYLON {
  50671. /**
  50672. * @hidden
  50673. */
  50674. export interface IMaterialSheenDefines {
  50675. SHEEN: boolean;
  50676. SHEEN_TEXTURE: boolean;
  50677. SHEEN_TEXTUREDIRECTUV: number;
  50678. SHEEN_LINKWITHALBEDO: boolean;
  50679. /** @hidden */
  50680. _areTexturesDirty: boolean;
  50681. }
  50682. /**
  50683. * Define the code related to the Sheen parameters of the pbr material.
  50684. */
  50685. export class PBRSheenConfiguration {
  50686. private _isEnabled;
  50687. /**
  50688. * Defines if the material uses sheen.
  50689. */
  50690. isEnabled: boolean;
  50691. private _linkSheenWithAlbedo;
  50692. /**
  50693. * Defines if the sheen is linked to the sheen color.
  50694. */
  50695. linkSheenWithAlbedo: boolean;
  50696. /**
  50697. * Defines the sheen intensity.
  50698. */
  50699. intensity: number;
  50700. /**
  50701. * Defines the sheen color.
  50702. */
  50703. color: Color3;
  50704. private _texture;
  50705. /**
  50706. * Stores the sheen tint values in a texture.
  50707. * rgb is tint
  50708. * a is a intensity
  50709. */
  50710. texture: Nullable<BaseTexture>;
  50711. /** @hidden */
  50712. private _internalMarkAllSubMeshesAsTexturesDirty;
  50713. /** @hidden */
  50714. _markAllSubMeshesAsTexturesDirty(): void;
  50715. /**
  50716. * Instantiate a new istance of clear coat configuration.
  50717. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50718. */
  50719. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50720. /**
  50721. * Specifies that the submesh is ready to be used.
  50722. * @param defines the list of "defines" to update.
  50723. * @param scene defines the scene the material belongs to.
  50724. * @returns - boolean indicating that the submesh is ready or not.
  50725. */
  50726. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50727. /**
  50728. * Checks to see if a texture is used in the material.
  50729. * @param defines the list of "defines" to update.
  50730. * @param scene defines the scene the material belongs to.
  50731. */
  50732. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50733. /**
  50734. * Binds the material data.
  50735. * @param uniformBuffer defines the Uniform buffer to fill in.
  50736. * @param scene defines the scene the material belongs to.
  50737. * @param isFrozen defines wether the material is frozen or not.
  50738. */
  50739. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50740. /**
  50741. * Checks to see if a texture is used in the material.
  50742. * @param texture - Base texture to use.
  50743. * @returns - Boolean specifying if a texture is used in the material.
  50744. */
  50745. hasTexture(texture: BaseTexture): boolean;
  50746. /**
  50747. * Returns an array of the actively used textures.
  50748. * @param activeTextures Array of BaseTextures
  50749. */
  50750. getActiveTextures(activeTextures: BaseTexture[]): void;
  50751. /**
  50752. * Returns the animatable textures.
  50753. * @param animatables Array of animatable textures.
  50754. */
  50755. getAnimatables(animatables: IAnimatable[]): void;
  50756. /**
  50757. * Disposes the resources of the material.
  50758. * @param forceDisposeTextures - Forces the disposal of all textures.
  50759. */
  50760. dispose(forceDisposeTextures?: boolean): void;
  50761. /**
  50762. * Get the current class name of the texture useful for serialization or dynamic coding.
  50763. * @returns "PBRSheenConfiguration"
  50764. */
  50765. getClassName(): string;
  50766. /**
  50767. * Add fallbacks to the effect fallbacks list.
  50768. * @param defines defines the Base texture to use.
  50769. * @param fallbacks defines the current fallback list.
  50770. * @param currentRank defines the current fallback rank.
  50771. * @returns the new fallback rank.
  50772. */
  50773. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50774. /**
  50775. * Add the required uniforms to the current list.
  50776. * @param uniforms defines the current uniform list.
  50777. */
  50778. static AddUniforms(uniforms: string[]): void;
  50779. /**
  50780. * Add the required uniforms to the current buffer.
  50781. * @param uniformBuffer defines the current uniform buffer.
  50782. */
  50783. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50784. /**
  50785. * Add the required samplers to the current list.
  50786. * @param samplers defines the current sampler list.
  50787. */
  50788. static AddSamplers(samplers: string[]): void;
  50789. /**
  50790. * Makes a duplicate of the current configuration into another one.
  50791. * @param sheenConfiguration define the config where to copy the info
  50792. */
  50793. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50794. /**
  50795. * Serializes this BRDF configuration.
  50796. * @returns - An object with the serialized config.
  50797. */
  50798. serialize(): any;
  50799. /**
  50800. * Parses a anisotropy Configuration from a serialized object.
  50801. * @param source - Serialized object.
  50802. * @param scene Defines the scene we are parsing for
  50803. * @param rootUrl Defines the rootUrl to load from
  50804. */
  50805. parse(source: any, scene: Scene, rootUrl: string): void;
  50806. }
  50807. }
  50808. declare module BABYLON {
  50809. /**
  50810. * @hidden
  50811. */
  50812. export interface IMaterialSubSurfaceDefines {
  50813. SUBSURFACE: boolean;
  50814. SS_REFRACTION: boolean;
  50815. SS_TRANSLUCENCY: boolean;
  50816. SS_SCATERRING: boolean;
  50817. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50818. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50819. SS_REFRACTIONMAP_3D: boolean;
  50820. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50821. SS_LODINREFRACTIONALPHA: boolean;
  50822. SS_GAMMAREFRACTION: boolean;
  50823. SS_RGBDREFRACTION: boolean;
  50824. SS_LINEARSPECULARREFRACTION: boolean;
  50825. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50826. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50827. /** @hidden */
  50828. _areTexturesDirty: boolean;
  50829. }
  50830. /**
  50831. * Define the code related to the sub surface parameters of the pbr material.
  50832. */
  50833. export class PBRSubSurfaceConfiguration {
  50834. private _isRefractionEnabled;
  50835. /**
  50836. * Defines if the refraction is enabled in the material.
  50837. */
  50838. isRefractionEnabled: boolean;
  50839. private _isTranslucencyEnabled;
  50840. /**
  50841. * Defines if the translucency is enabled in the material.
  50842. */
  50843. isTranslucencyEnabled: boolean;
  50844. private _isScatteringEnabled;
  50845. /**
  50846. * Defines the refraction intensity of the material.
  50847. * The refraction when enabled replaces the Diffuse part of the material.
  50848. * The intensity helps transitionning between diffuse and refraction.
  50849. */
  50850. refractionIntensity: number;
  50851. /**
  50852. * Defines the translucency intensity of the material.
  50853. * When translucency has been enabled, this defines how much of the "translucency"
  50854. * is addded to the diffuse part of the material.
  50855. */
  50856. translucencyIntensity: number;
  50857. /**
  50858. * Defines the scattering intensity of the material.
  50859. * When scattering has been enabled, this defines how much of the "scattered light"
  50860. * is addded to the diffuse part of the material.
  50861. */
  50862. scatteringIntensity: number;
  50863. private _thicknessTexture;
  50864. /**
  50865. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50866. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50867. * 0 would mean minimumThickness
  50868. * 1 would mean maximumThickness
  50869. * The other channels might be use as a mask to vary the different effects intensity.
  50870. */
  50871. thicknessTexture: Nullable<BaseTexture>;
  50872. private _refractionTexture;
  50873. /**
  50874. * Defines the texture to use for refraction.
  50875. */
  50876. refractionTexture: Nullable<BaseTexture>;
  50877. private _indexOfRefraction;
  50878. /**
  50879. * Defines the index of refraction used in the material.
  50880. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50881. */
  50882. indexOfRefraction: number;
  50883. private _invertRefractionY;
  50884. /**
  50885. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50886. */
  50887. invertRefractionY: boolean;
  50888. private _linkRefractionWithTransparency;
  50889. /**
  50890. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50891. * Materials half opaque for instance using refraction could benefit from this control.
  50892. */
  50893. linkRefractionWithTransparency: boolean;
  50894. /**
  50895. * Defines the minimum thickness stored in the thickness map.
  50896. * If no thickness map is defined, this value will be used to simulate thickness.
  50897. */
  50898. minimumThickness: number;
  50899. /**
  50900. * Defines the maximum thickness stored in the thickness map.
  50901. */
  50902. maximumThickness: number;
  50903. /**
  50904. * Defines the volume tint of the material.
  50905. * This is used for both translucency and scattering.
  50906. */
  50907. tintColor: Color3;
  50908. /**
  50909. * Defines the distance at which the tint color should be found in the media.
  50910. * This is used for refraction only.
  50911. */
  50912. tintColorAtDistance: number;
  50913. /**
  50914. * Defines how far each channel transmit through the media.
  50915. * It is defined as a color to simplify it selection.
  50916. */
  50917. diffusionDistance: Color3;
  50918. private _useMaskFromThicknessTexture;
  50919. /**
  50920. * Stores the intensity of the different subsurface effects in the thickness texture.
  50921. * * the green channel is the translucency intensity.
  50922. * * the blue channel is the scattering intensity.
  50923. * * the alpha channel is the refraction intensity.
  50924. */
  50925. useMaskFromThicknessTexture: boolean;
  50926. /** @hidden */
  50927. private _internalMarkAllSubMeshesAsTexturesDirty;
  50928. /** @hidden */
  50929. _markAllSubMeshesAsTexturesDirty(): void;
  50930. /**
  50931. * Instantiate a new istance of sub surface configuration.
  50932. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50933. */
  50934. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50935. /**
  50936. * Gets wehter the submesh is ready to be used or not.
  50937. * @param defines the list of "defines" to update.
  50938. * @param scene defines the scene the material belongs to.
  50939. * @returns - boolean indicating that the submesh is ready or not.
  50940. */
  50941. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50942. /**
  50943. * Checks to see if a texture is used in the material.
  50944. * @param defines the list of "defines" to update.
  50945. * @param scene defines the scene to the material belongs to.
  50946. */
  50947. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50948. /**
  50949. * Binds the material data.
  50950. * @param uniformBuffer defines the Uniform buffer to fill in.
  50951. * @param scene defines the scene the material belongs to.
  50952. * @param engine defines the engine the material belongs to.
  50953. * @param isFrozen defines wether the material is frozen or not.
  50954. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50955. */
  50956. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50957. /**
  50958. * Unbinds the material from the mesh.
  50959. * @param activeEffect defines the effect that should be unbound from.
  50960. * @returns true if unbound, otherwise false
  50961. */
  50962. unbind(activeEffect: Effect): boolean;
  50963. /**
  50964. * Returns the texture used for refraction or null if none is used.
  50965. * @param scene defines the scene the material belongs to.
  50966. * @returns - Refraction texture if present. If no refraction texture and refraction
  50967. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50968. */
  50969. private _getRefractionTexture;
  50970. /**
  50971. * Returns true if alpha blending should be disabled.
  50972. */
  50973. get disableAlphaBlending(): boolean;
  50974. /**
  50975. * Fills the list of render target textures.
  50976. * @param renderTargets the list of render targets to update
  50977. */
  50978. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50979. /**
  50980. * Checks to see if a texture is used in the material.
  50981. * @param texture - Base texture to use.
  50982. * @returns - Boolean specifying if a texture is used in the material.
  50983. */
  50984. hasTexture(texture: BaseTexture): boolean;
  50985. /**
  50986. * Gets a boolean indicating that current material needs to register RTT
  50987. * @returns true if this uses a render target otherwise false.
  50988. */
  50989. hasRenderTargetTextures(): boolean;
  50990. /**
  50991. * Returns an array of the actively used textures.
  50992. * @param activeTextures Array of BaseTextures
  50993. */
  50994. getActiveTextures(activeTextures: BaseTexture[]): void;
  50995. /**
  50996. * Returns the animatable textures.
  50997. * @param animatables Array of animatable textures.
  50998. */
  50999. getAnimatables(animatables: IAnimatable[]): void;
  51000. /**
  51001. * Disposes the resources of the material.
  51002. * @param forceDisposeTextures - Forces the disposal of all textures.
  51003. */
  51004. dispose(forceDisposeTextures?: boolean): void;
  51005. /**
  51006. * Get the current class name of the texture useful for serialization or dynamic coding.
  51007. * @returns "PBRSubSurfaceConfiguration"
  51008. */
  51009. getClassName(): string;
  51010. /**
  51011. * Add fallbacks to the effect fallbacks list.
  51012. * @param defines defines the Base texture to use.
  51013. * @param fallbacks defines the current fallback list.
  51014. * @param currentRank defines the current fallback rank.
  51015. * @returns the new fallback rank.
  51016. */
  51017. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51018. /**
  51019. * Add the required uniforms to the current list.
  51020. * @param uniforms defines the current uniform list.
  51021. */
  51022. static AddUniforms(uniforms: string[]): void;
  51023. /**
  51024. * Add the required samplers to the current list.
  51025. * @param samplers defines the current sampler list.
  51026. */
  51027. static AddSamplers(samplers: string[]): void;
  51028. /**
  51029. * Add the required uniforms to the current buffer.
  51030. * @param uniformBuffer defines the current uniform buffer.
  51031. */
  51032. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51033. /**
  51034. * Makes a duplicate of the current configuration into another one.
  51035. * @param configuration define the config where to copy the info
  51036. */
  51037. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51038. /**
  51039. * Serializes this Sub Surface configuration.
  51040. * @returns - An object with the serialized config.
  51041. */
  51042. serialize(): any;
  51043. /**
  51044. * Parses a anisotropy Configuration from a serialized object.
  51045. * @param source - Serialized object.
  51046. * @param scene Defines the scene we are parsing for
  51047. * @param rootUrl Defines the rootUrl to load from
  51048. */
  51049. parse(source: any, scene: Scene, rootUrl: string): void;
  51050. }
  51051. }
  51052. declare module BABYLON {
  51053. /** @hidden */
  51054. export var pbrFragmentDeclaration: {
  51055. name: string;
  51056. shader: string;
  51057. };
  51058. }
  51059. declare module BABYLON {
  51060. /** @hidden */
  51061. export var pbrUboDeclaration: {
  51062. name: string;
  51063. shader: string;
  51064. };
  51065. }
  51066. declare module BABYLON {
  51067. /** @hidden */
  51068. export var pbrFragmentExtraDeclaration: {
  51069. name: string;
  51070. shader: string;
  51071. };
  51072. }
  51073. declare module BABYLON {
  51074. /** @hidden */
  51075. export var pbrFragmentSamplersDeclaration: {
  51076. name: string;
  51077. shader: string;
  51078. };
  51079. }
  51080. declare module BABYLON {
  51081. /** @hidden */
  51082. export var pbrHelperFunctions: {
  51083. name: string;
  51084. shader: string;
  51085. };
  51086. }
  51087. declare module BABYLON {
  51088. /** @hidden */
  51089. export var harmonicsFunctions: {
  51090. name: string;
  51091. shader: string;
  51092. };
  51093. }
  51094. declare module BABYLON {
  51095. /** @hidden */
  51096. export var pbrDirectLightingSetupFunctions: {
  51097. name: string;
  51098. shader: string;
  51099. };
  51100. }
  51101. declare module BABYLON {
  51102. /** @hidden */
  51103. export var pbrDirectLightingFalloffFunctions: {
  51104. name: string;
  51105. shader: string;
  51106. };
  51107. }
  51108. declare module BABYLON {
  51109. /** @hidden */
  51110. export var pbrBRDFFunctions: {
  51111. name: string;
  51112. shader: string;
  51113. };
  51114. }
  51115. declare module BABYLON {
  51116. /** @hidden */
  51117. export var pbrDirectLightingFunctions: {
  51118. name: string;
  51119. shader: string;
  51120. };
  51121. }
  51122. declare module BABYLON {
  51123. /** @hidden */
  51124. export var pbrIBLFunctions: {
  51125. name: string;
  51126. shader: string;
  51127. };
  51128. }
  51129. declare module BABYLON {
  51130. /** @hidden */
  51131. export var pbrDebug: {
  51132. name: string;
  51133. shader: string;
  51134. };
  51135. }
  51136. declare module BABYLON {
  51137. /** @hidden */
  51138. export var pbrPixelShader: {
  51139. name: string;
  51140. shader: string;
  51141. };
  51142. }
  51143. declare module BABYLON {
  51144. /** @hidden */
  51145. export var pbrVertexDeclaration: {
  51146. name: string;
  51147. shader: string;
  51148. };
  51149. }
  51150. declare module BABYLON {
  51151. /** @hidden */
  51152. export var pbrVertexShader: {
  51153. name: string;
  51154. shader: string;
  51155. };
  51156. }
  51157. declare module BABYLON {
  51158. /**
  51159. * Manages the defines for the PBR Material.
  51160. * @hidden
  51161. */
  51162. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51163. PBR: boolean;
  51164. MAINUV1: boolean;
  51165. MAINUV2: boolean;
  51166. UV1: boolean;
  51167. UV2: boolean;
  51168. ALBEDO: boolean;
  51169. ALBEDODIRECTUV: number;
  51170. VERTEXCOLOR: boolean;
  51171. AMBIENT: boolean;
  51172. AMBIENTDIRECTUV: number;
  51173. AMBIENTINGRAYSCALE: boolean;
  51174. OPACITY: boolean;
  51175. VERTEXALPHA: boolean;
  51176. OPACITYDIRECTUV: number;
  51177. OPACITYRGB: boolean;
  51178. ALPHATEST: boolean;
  51179. DEPTHPREPASS: boolean;
  51180. ALPHABLEND: boolean;
  51181. ALPHAFROMALBEDO: boolean;
  51182. ALPHATESTVALUE: string;
  51183. SPECULAROVERALPHA: boolean;
  51184. RADIANCEOVERALPHA: boolean;
  51185. ALPHAFRESNEL: boolean;
  51186. LINEARALPHAFRESNEL: boolean;
  51187. PREMULTIPLYALPHA: boolean;
  51188. EMISSIVE: boolean;
  51189. EMISSIVEDIRECTUV: number;
  51190. REFLECTIVITY: boolean;
  51191. REFLECTIVITYDIRECTUV: number;
  51192. SPECULARTERM: boolean;
  51193. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51194. MICROSURFACEAUTOMATIC: boolean;
  51195. LODBASEDMICROSFURACE: boolean;
  51196. MICROSURFACEMAP: boolean;
  51197. MICROSURFACEMAPDIRECTUV: number;
  51198. METALLICWORKFLOW: boolean;
  51199. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51200. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51201. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51202. AOSTOREINMETALMAPRED: boolean;
  51203. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51204. ENVIRONMENTBRDF: boolean;
  51205. ENVIRONMENTBRDF_RGBD: boolean;
  51206. NORMAL: boolean;
  51207. TANGENT: boolean;
  51208. BUMP: boolean;
  51209. BUMPDIRECTUV: number;
  51210. OBJECTSPACE_NORMALMAP: boolean;
  51211. PARALLAX: boolean;
  51212. PARALLAXOCCLUSION: boolean;
  51213. NORMALXYSCALE: boolean;
  51214. LIGHTMAP: boolean;
  51215. LIGHTMAPDIRECTUV: number;
  51216. USELIGHTMAPASSHADOWMAP: boolean;
  51217. GAMMALIGHTMAP: boolean;
  51218. RGBDLIGHTMAP: boolean;
  51219. REFLECTION: boolean;
  51220. REFLECTIONMAP_3D: boolean;
  51221. REFLECTIONMAP_SPHERICAL: boolean;
  51222. REFLECTIONMAP_PLANAR: boolean;
  51223. REFLECTIONMAP_CUBIC: boolean;
  51224. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51225. REFLECTIONMAP_PROJECTION: boolean;
  51226. REFLECTIONMAP_SKYBOX: boolean;
  51227. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  51228. REFLECTIONMAP_EXPLICIT: boolean;
  51229. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51230. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51231. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51232. INVERTCUBICMAP: boolean;
  51233. USESPHERICALFROMREFLECTIONMAP: boolean;
  51234. USEIRRADIANCEMAP: boolean;
  51235. SPHERICAL_HARMONICS: boolean;
  51236. USESPHERICALINVERTEX: boolean;
  51237. REFLECTIONMAP_OPPOSITEZ: boolean;
  51238. LODINREFLECTIONALPHA: boolean;
  51239. GAMMAREFLECTION: boolean;
  51240. RGBDREFLECTION: boolean;
  51241. LINEARSPECULARREFLECTION: boolean;
  51242. RADIANCEOCCLUSION: boolean;
  51243. HORIZONOCCLUSION: boolean;
  51244. INSTANCES: boolean;
  51245. NUM_BONE_INFLUENCERS: number;
  51246. BonesPerMesh: number;
  51247. BONETEXTURE: boolean;
  51248. NONUNIFORMSCALING: boolean;
  51249. MORPHTARGETS: boolean;
  51250. MORPHTARGETS_NORMAL: boolean;
  51251. MORPHTARGETS_TANGENT: boolean;
  51252. MORPHTARGETS_UV: boolean;
  51253. NUM_MORPH_INFLUENCERS: number;
  51254. IMAGEPROCESSING: boolean;
  51255. VIGNETTE: boolean;
  51256. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51257. VIGNETTEBLENDMODEOPAQUE: boolean;
  51258. TONEMAPPING: boolean;
  51259. TONEMAPPING_ACES: boolean;
  51260. CONTRAST: boolean;
  51261. COLORCURVES: boolean;
  51262. COLORGRADING: boolean;
  51263. COLORGRADING3D: boolean;
  51264. SAMPLER3DGREENDEPTH: boolean;
  51265. SAMPLER3DBGRMAP: boolean;
  51266. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51267. EXPOSURE: boolean;
  51268. MULTIVIEW: boolean;
  51269. USEPHYSICALLIGHTFALLOFF: boolean;
  51270. USEGLTFLIGHTFALLOFF: boolean;
  51271. TWOSIDEDLIGHTING: boolean;
  51272. SHADOWFLOAT: boolean;
  51273. CLIPPLANE: boolean;
  51274. CLIPPLANE2: boolean;
  51275. CLIPPLANE3: boolean;
  51276. CLIPPLANE4: boolean;
  51277. CLIPPLANE5: boolean;
  51278. CLIPPLANE6: boolean;
  51279. POINTSIZE: boolean;
  51280. FOG: boolean;
  51281. LOGARITHMICDEPTH: boolean;
  51282. FORCENORMALFORWARD: boolean;
  51283. SPECULARAA: boolean;
  51284. CLEARCOAT: boolean;
  51285. CLEARCOAT_DEFAULTIOR: boolean;
  51286. CLEARCOAT_TEXTURE: boolean;
  51287. CLEARCOAT_TEXTUREDIRECTUV: number;
  51288. CLEARCOAT_BUMP: boolean;
  51289. CLEARCOAT_BUMPDIRECTUV: number;
  51290. CLEARCOAT_TINT: boolean;
  51291. CLEARCOAT_TINT_TEXTURE: boolean;
  51292. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51293. ANISOTROPIC: boolean;
  51294. ANISOTROPIC_TEXTURE: boolean;
  51295. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51296. BRDF_V_HEIGHT_CORRELATED: boolean;
  51297. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51298. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51299. SHEEN: boolean;
  51300. SHEEN_TEXTURE: boolean;
  51301. SHEEN_TEXTUREDIRECTUV: number;
  51302. SHEEN_LINKWITHALBEDO: boolean;
  51303. SUBSURFACE: boolean;
  51304. SS_REFRACTION: boolean;
  51305. SS_TRANSLUCENCY: boolean;
  51306. SS_SCATERRING: boolean;
  51307. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51308. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51309. SS_REFRACTIONMAP_3D: boolean;
  51310. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51311. SS_LODINREFRACTIONALPHA: boolean;
  51312. SS_GAMMAREFRACTION: boolean;
  51313. SS_RGBDREFRACTION: boolean;
  51314. SS_LINEARSPECULARREFRACTION: boolean;
  51315. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51316. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51317. UNLIT: boolean;
  51318. DEBUGMODE: number;
  51319. /**
  51320. * Initializes the PBR Material defines.
  51321. */
  51322. constructor();
  51323. /**
  51324. * Resets the PBR Material defines.
  51325. */
  51326. reset(): void;
  51327. }
  51328. /**
  51329. * The Physically based material base class of BJS.
  51330. *
  51331. * This offers the main features of a standard PBR material.
  51332. * For more information, please refer to the documentation :
  51333. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51334. */
  51335. export abstract class PBRBaseMaterial extends PushMaterial {
  51336. /**
  51337. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51338. */
  51339. static readonly PBRMATERIAL_OPAQUE: number;
  51340. /**
  51341. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51342. */
  51343. static readonly PBRMATERIAL_ALPHATEST: number;
  51344. /**
  51345. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51346. */
  51347. static readonly PBRMATERIAL_ALPHABLEND: number;
  51348. /**
  51349. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51350. * They are also discarded below the alpha cutoff threshold to improve performances.
  51351. */
  51352. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51353. /**
  51354. * Defines the default value of how much AO map is occluding the analytical lights
  51355. * (point spot...).
  51356. */
  51357. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51358. /**
  51359. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51360. */
  51361. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51362. /**
  51363. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51364. * to enhance interoperability with other engines.
  51365. */
  51366. static readonly LIGHTFALLOFF_GLTF: number;
  51367. /**
  51368. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51369. * to enhance interoperability with other materials.
  51370. */
  51371. static readonly LIGHTFALLOFF_STANDARD: number;
  51372. /**
  51373. * Intensity of the direct lights e.g. the four lights available in your scene.
  51374. * This impacts both the direct diffuse and specular highlights.
  51375. */
  51376. protected _directIntensity: number;
  51377. /**
  51378. * Intensity of the emissive part of the material.
  51379. * This helps controlling the emissive effect without modifying the emissive color.
  51380. */
  51381. protected _emissiveIntensity: number;
  51382. /**
  51383. * Intensity of the environment e.g. how much the environment will light the object
  51384. * either through harmonics for rough material or through the refelction for shiny ones.
  51385. */
  51386. protected _environmentIntensity: number;
  51387. /**
  51388. * This is a special control allowing the reduction of the specular highlights coming from the
  51389. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51390. */
  51391. protected _specularIntensity: number;
  51392. /**
  51393. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51394. */
  51395. private _lightingInfos;
  51396. /**
  51397. * Debug Control allowing disabling the bump map on this material.
  51398. */
  51399. protected _disableBumpMap: boolean;
  51400. /**
  51401. * AKA Diffuse Texture in standard nomenclature.
  51402. */
  51403. protected _albedoTexture: Nullable<BaseTexture>;
  51404. /**
  51405. * AKA Occlusion Texture in other nomenclature.
  51406. */
  51407. protected _ambientTexture: Nullable<BaseTexture>;
  51408. /**
  51409. * AKA Occlusion Texture Intensity in other nomenclature.
  51410. */
  51411. protected _ambientTextureStrength: number;
  51412. /**
  51413. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51414. * 1 means it completely occludes it
  51415. * 0 mean it has no impact
  51416. */
  51417. protected _ambientTextureImpactOnAnalyticalLights: number;
  51418. /**
  51419. * Stores the alpha values in a texture.
  51420. */
  51421. protected _opacityTexture: Nullable<BaseTexture>;
  51422. /**
  51423. * Stores the reflection values in a texture.
  51424. */
  51425. protected _reflectionTexture: Nullable<BaseTexture>;
  51426. /**
  51427. * Stores the emissive values in a texture.
  51428. */
  51429. protected _emissiveTexture: Nullable<BaseTexture>;
  51430. /**
  51431. * AKA Specular texture in other nomenclature.
  51432. */
  51433. protected _reflectivityTexture: Nullable<BaseTexture>;
  51434. /**
  51435. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51436. */
  51437. protected _metallicTexture: Nullable<BaseTexture>;
  51438. /**
  51439. * Specifies the metallic scalar of the metallic/roughness workflow.
  51440. * Can also be used to scale the metalness values of the metallic texture.
  51441. */
  51442. protected _metallic: Nullable<number>;
  51443. /**
  51444. * Specifies the roughness scalar of the metallic/roughness workflow.
  51445. * Can also be used to scale the roughness values of the metallic texture.
  51446. */
  51447. protected _roughness: Nullable<number>;
  51448. /**
  51449. * Specifies the an F0 factor to help configuring the material F0.
  51450. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51451. * to 0.5 the previously hard coded value stays the same.
  51452. * Can also be used to scale the F0 values of the metallic texture.
  51453. */
  51454. protected _metallicF0Factor: number;
  51455. /**
  51456. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51457. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51458. * your expectation as it multiplies with the texture data.
  51459. */
  51460. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51461. /**
  51462. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51463. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51464. */
  51465. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51466. /**
  51467. * Stores surface normal data used to displace a mesh in a texture.
  51468. */
  51469. protected _bumpTexture: Nullable<BaseTexture>;
  51470. /**
  51471. * Stores the pre-calculated light information of a mesh in a texture.
  51472. */
  51473. protected _lightmapTexture: Nullable<BaseTexture>;
  51474. /**
  51475. * The color of a material in ambient lighting.
  51476. */
  51477. protected _ambientColor: Color3;
  51478. /**
  51479. * AKA Diffuse Color in other nomenclature.
  51480. */
  51481. protected _albedoColor: Color3;
  51482. /**
  51483. * AKA Specular Color in other nomenclature.
  51484. */
  51485. protected _reflectivityColor: Color3;
  51486. /**
  51487. * The color applied when light is reflected from a material.
  51488. */
  51489. protected _reflectionColor: Color3;
  51490. /**
  51491. * The color applied when light is emitted from a material.
  51492. */
  51493. protected _emissiveColor: Color3;
  51494. /**
  51495. * AKA Glossiness in other nomenclature.
  51496. */
  51497. protected _microSurface: number;
  51498. /**
  51499. * Specifies that the material will use the light map as a show map.
  51500. */
  51501. protected _useLightmapAsShadowmap: boolean;
  51502. /**
  51503. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51504. * makes the reflect vector face the model (under horizon).
  51505. */
  51506. protected _useHorizonOcclusion: boolean;
  51507. /**
  51508. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51509. * too much the area relying on ambient texture to define their ambient occlusion.
  51510. */
  51511. protected _useRadianceOcclusion: boolean;
  51512. /**
  51513. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51514. */
  51515. protected _useAlphaFromAlbedoTexture: boolean;
  51516. /**
  51517. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51518. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51519. */
  51520. protected _useSpecularOverAlpha: boolean;
  51521. /**
  51522. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51523. */
  51524. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51525. /**
  51526. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51527. */
  51528. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51529. /**
  51530. * Specifies if the metallic texture contains the roughness information in its green channel.
  51531. */
  51532. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51533. /**
  51534. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51535. */
  51536. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51537. /**
  51538. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51539. */
  51540. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51541. /**
  51542. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51543. */
  51544. protected _useAmbientInGrayScale: boolean;
  51545. /**
  51546. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51547. * The material will try to infer what glossiness each pixel should be.
  51548. */
  51549. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51550. /**
  51551. * Defines the falloff type used in this material.
  51552. * It by default is Physical.
  51553. */
  51554. protected _lightFalloff: number;
  51555. /**
  51556. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51557. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51558. */
  51559. protected _useRadianceOverAlpha: boolean;
  51560. /**
  51561. * Allows using an object space normal map (instead of tangent space).
  51562. */
  51563. protected _useObjectSpaceNormalMap: boolean;
  51564. /**
  51565. * Allows using the bump map in parallax mode.
  51566. */
  51567. protected _useParallax: boolean;
  51568. /**
  51569. * Allows using the bump map in parallax occlusion mode.
  51570. */
  51571. protected _useParallaxOcclusion: boolean;
  51572. /**
  51573. * Controls the scale bias of the parallax mode.
  51574. */
  51575. protected _parallaxScaleBias: number;
  51576. /**
  51577. * If sets to true, disables all the lights affecting the material.
  51578. */
  51579. protected _disableLighting: boolean;
  51580. /**
  51581. * Number of Simultaneous lights allowed on the material.
  51582. */
  51583. protected _maxSimultaneousLights: number;
  51584. /**
  51585. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51586. */
  51587. protected _invertNormalMapX: boolean;
  51588. /**
  51589. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51590. */
  51591. protected _invertNormalMapY: boolean;
  51592. /**
  51593. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51594. */
  51595. protected _twoSidedLighting: boolean;
  51596. /**
  51597. * Defines the alpha limits in alpha test mode.
  51598. */
  51599. protected _alphaCutOff: number;
  51600. /**
  51601. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51602. */
  51603. protected _forceAlphaTest: boolean;
  51604. /**
  51605. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51606. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51607. */
  51608. protected _useAlphaFresnel: boolean;
  51609. /**
  51610. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51611. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51612. */
  51613. protected _useLinearAlphaFresnel: boolean;
  51614. /**
  51615. * The transparency mode of the material.
  51616. */
  51617. protected _transparencyMode: Nullable<number>;
  51618. /**
  51619. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51620. * from cos thetav and roughness:
  51621. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51622. */
  51623. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51624. /**
  51625. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51626. */
  51627. protected _forceIrradianceInFragment: boolean;
  51628. /**
  51629. * Force normal to face away from face.
  51630. */
  51631. protected _forceNormalForward: boolean;
  51632. /**
  51633. * Enables specular anti aliasing in the PBR shader.
  51634. * It will both interacts on the Geometry for analytical and IBL lighting.
  51635. * It also prefilter the roughness map based on the bump values.
  51636. */
  51637. protected _enableSpecularAntiAliasing: boolean;
  51638. /**
  51639. * Default configuration related to image processing available in the PBR Material.
  51640. */
  51641. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51642. /**
  51643. * Keep track of the image processing observer to allow dispose and replace.
  51644. */
  51645. private _imageProcessingObserver;
  51646. /**
  51647. * Attaches a new image processing configuration to the PBR Material.
  51648. * @param configuration
  51649. */
  51650. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51651. /**
  51652. * Stores the available render targets.
  51653. */
  51654. private _renderTargets;
  51655. /**
  51656. * Sets the global ambient color for the material used in lighting calculations.
  51657. */
  51658. private _globalAmbientColor;
  51659. /**
  51660. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51661. */
  51662. private _useLogarithmicDepth;
  51663. /**
  51664. * If set to true, no lighting calculations will be applied.
  51665. */
  51666. private _unlit;
  51667. private _debugMode;
  51668. /**
  51669. * @hidden
  51670. * This is reserved for the inspector.
  51671. * Defines the material debug mode.
  51672. * It helps seeing only some components of the material while troubleshooting.
  51673. */
  51674. debugMode: number;
  51675. /**
  51676. * @hidden
  51677. * This is reserved for the inspector.
  51678. * Specify from where on screen the debug mode should start.
  51679. * The value goes from -1 (full screen) to 1 (not visible)
  51680. * It helps with side by side comparison against the final render
  51681. * This defaults to -1
  51682. */
  51683. private debugLimit;
  51684. /**
  51685. * @hidden
  51686. * This is reserved for the inspector.
  51687. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51688. * You can use the factor to better multiply the final value.
  51689. */
  51690. private debugFactor;
  51691. /**
  51692. * Defines the clear coat layer parameters for the material.
  51693. */
  51694. readonly clearCoat: PBRClearCoatConfiguration;
  51695. /**
  51696. * Defines the anisotropic parameters for the material.
  51697. */
  51698. readonly anisotropy: PBRAnisotropicConfiguration;
  51699. /**
  51700. * Defines the BRDF parameters for the material.
  51701. */
  51702. readonly brdf: PBRBRDFConfiguration;
  51703. /**
  51704. * Defines the Sheen parameters for the material.
  51705. */
  51706. readonly sheen: PBRSheenConfiguration;
  51707. /**
  51708. * Defines the SubSurface parameters for the material.
  51709. */
  51710. readonly subSurface: PBRSubSurfaceConfiguration;
  51711. /**
  51712. * Custom callback helping to override the default shader used in the material.
  51713. */
  51714. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51715. protected _rebuildInParallel: boolean;
  51716. /**
  51717. * Instantiates a new PBRMaterial instance.
  51718. *
  51719. * @param name The material name
  51720. * @param scene The scene the material will be use in.
  51721. */
  51722. constructor(name: string, scene: Scene);
  51723. /**
  51724. * Gets a boolean indicating that current material needs to register RTT
  51725. */
  51726. get hasRenderTargetTextures(): boolean;
  51727. /**
  51728. * Gets the name of the material class.
  51729. */
  51730. getClassName(): string;
  51731. /**
  51732. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51733. */
  51734. get useLogarithmicDepth(): boolean;
  51735. /**
  51736. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51737. */
  51738. set useLogarithmicDepth(value: boolean);
  51739. /**
  51740. * Gets the current transparency mode.
  51741. */
  51742. get transparencyMode(): Nullable<number>;
  51743. /**
  51744. * Sets the transparency mode of the material.
  51745. *
  51746. * | Value | Type | Description |
  51747. * | ----- | ----------------------------------- | ----------- |
  51748. * | 0 | OPAQUE | |
  51749. * | 1 | ALPHATEST | |
  51750. * | 2 | ALPHABLEND | |
  51751. * | 3 | ALPHATESTANDBLEND | |
  51752. *
  51753. */
  51754. set transparencyMode(value: Nullable<number>);
  51755. /**
  51756. * Returns true if alpha blending should be disabled.
  51757. */
  51758. private get _disableAlphaBlending();
  51759. /**
  51760. * Specifies whether or not this material should be rendered in alpha blend mode.
  51761. */
  51762. needAlphaBlending(): boolean;
  51763. /**
  51764. * Specifies if the mesh will require alpha blending.
  51765. * @param mesh - BJS mesh.
  51766. */
  51767. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51768. /**
  51769. * Specifies whether or not this material should be rendered in alpha test mode.
  51770. */
  51771. needAlphaTesting(): boolean;
  51772. /**
  51773. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51774. */
  51775. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51776. /**
  51777. * Gets the texture used for the alpha test.
  51778. */
  51779. getAlphaTestTexture(): Nullable<BaseTexture>;
  51780. /**
  51781. * Specifies that the submesh is ready to be used.
  51782. * @param mesh - BJS mesh.
  51783. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51784. * @param useInstances - Specifies that instances should be used.
  51785. * @returns - boolean indicating that the submesh is ready or not.
  51786. */
  51787. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51788. /**
  51789. * Specifies if the material uses metallic roughness workflow.
  51790. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51791. */
  51792. isMetallicWorkflow(): boolean;
  51793. private _prepareEffect;
  51794. private _prepareDefines;
  51795. /**
  51796. * Force shader compilation
  51797. */
  51798. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51799. /**
  51800. * Initializes the uniform buffer layout for the shader.
  51801. */
  51802. buildUniformLayout(): void;
  51803. /**
  51804. * Unbinds the material from the mesh
  51805. */
  51806. unbind(): void;
  51807. /**
  51808. * Binds the submesh data.
  51809. * @param world - The world matrix.
  51810. * @param mesh - The BJS mesh.
  51811. * @param subMesh - A submesh of the BJS mesh.
  51812. */
  51813. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51814. /**
  51815. * Returns the animatable textures.
  51816. * @returns - Array of animatable textures.
  51817. */
  51818. getAnimatables(): IAnimatable[];
  51819. /**
  51820. * Returns the texture used for reflections.
  51821. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51822. */
  51823. private _getReflectionTexture;
  51824. /**
  51825. * Returns an array of the actively used textures.
  51826. * @returns - Array of BaseTextures
  51827. */
  51828. getActiveTextures(): BaseTexture[];
  51829. /**
  51830. * Checks to see if a texture is used in the material.
  51831. * @param texture - Base texture to use.
  51832. * @returns - Boolean specifying if a texture is used in the material.
  51833. */
  51834. hasTexture(texture: BaseTexture): boolean;
  51835. /**
  51836. * Disposes the resources of the material.
  51837. * @param forceDisposeEffect - Forces the disposal of effects.
  51838. * @param forceDisposeTextures - Forces the disposal of all textures.
  51839. */
  51840. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51841. }
  51842. }
  51843. declare module BABYLON {
  51844. /**
  51845. * The Physically based material of BJS.
  51846. *
  51847. * This offers the main features of a standard PBR material.
  51848. * For more information, please refer to the documentation :
  51849. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51850. */
  51851. export class PBRMaterial extends PBRBaseMaterial {
  51852. /**
  51853. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51854. */
  51855. static readonly PBRMATERIAL_OPAQUE: number;
  51856. /**
  51857. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51858. */
  51859. static readonly PBRMATERIAL_ALPHATEST: number;
  51860. /**
  51861. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51862. */
  51863. static readonly PBRMATERIAL_ALPHABLEND: number;
  51864. /**
  51865. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51866. * They are also discarded below the alpha cutoff threshold to improve performances.
  51867. */
  51868. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51869. /**
  51870. * Defines the default value of how much AO map is occluding the analytical lights
  51871. * (point spot...).
  51872. */
  51873. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51874. /**
  51875. * Intensity of the direct lights e.g. the four lights available in your scene.
  51876. * This impacts both the direct diffuse and specular highlights.
  51877. */
  51878. directIntensity: number;
  51879. /**
  51880. * Intensity of the emissive part of the material.
  51881. * This helps controlling the emissive effect without modifying the emissive color.
  51882. */
  51883. emissiveIntensity: number;
  51884. /**
  51885. * Intensity of the environment e.g. how much the environment will light the object
  51886. * either through harmonics for rough material or through the refelction for shiny ones.
  51887. */
  51888. environmentIntensity: number;
  51889. /**
  51890. * This is a special control allowing the reduction of the specular highlights coming from the
  51891. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51892. */
  51893. specularIntensity: number;
  51894. /**
  51895. * Debug Control allowing disabling the bump map on this material.
  51896. */
  51897. disableBumpMap: boolean;
  51898. /**
  51899. * AKA Diffuse Texture in standard nomenclature.
  51900. */
  51901. albedoTexture: BaseTexture;
  51902. /**
  51903. * AKA Occlusion Texture in other nomenclature.
  51904. */
  51905. ambientTexture: BaseTexture;
  51906. /**
  51907. * AKA Occlusion Texture Intensity in other nomenclature.
  51908. */
  51909. ambientTextureStrength: number;
  51910. /**
  51911. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51912. * 1 means it completely occludes it
  51913. * 0 mean it has no impact
  51914. */
  51915. ambientTextureImpactOnAnalyticalLights: number;
  51916. /**
  51917. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51918. */
  51919. opacityTexture: BaseTexture;
  51920. /**
  51921. * Stores the reflection values in a texture.
  51922. */
  51923. reflectionTexture: Nullable<BaseTexture>;
  51924. /**
  51925. * Stores the emissive values in a texture.
  51926. */
  51927. emissiveTexture: BaseTexture;
  51928. /**
  51929. * AKA Specular texture in other nomenclature.
  51930. */
  51931. reflectivityTexture: BaseTexture;
  51932. /**
  51933. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51934. */
  51935. metallicTexture: BaseTexture;
  51936. /**
  51937. * Specifies the metallic scalar of the metallic/roughness workflow.
  51938. * Can also be used to scale the metalness values of the metallic texture.
  51939. */
  51940. metallic: Nullable<number>;
  51941. /**
  51942. * Specifies the roughness scalar of the metallic/roughness workflow.
  51943. * Can also be used to scale the roughness values of the metallic texture.
  51944. */
  51945. roughness: Nullable<number>;
  51946. /**
  51947. * Specifies the an F0 factor to help configuring the material F0.
  51948. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51949. * to 0.5 the previously hard coded value stays the same.
  51950. * Can also be used to scale the F0 values of the metallic texture.
  51951. */
  51952. metallicF0Factor: number;
  51953. /**
  51954. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51955. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51956. * your expectation as it multiplies with the texture data.
  51957. */
  51958. useMetallicF0FactorFromMetallicTexture: boolean;
  51959. /**
  51960. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51961. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51962. */
  51963. microSurfaceTexture: BaseTexture;
  51964. /**
  51965. * Stores surface normal data used to displace a mesh in a texture.
  51966. */
  51967. bumpTexture: BaseTexture;
  51968. /**
  51969. * Stores the pre-calculated light information of a mesh in a texture.
  51970. */
  51971. lightmapTexture: BaseTexture;
  51972. /**
  51973. * Stores the refracted light information in a texture.
  51974. */
  51975. get refractionTexture(): Nullable<BaseTexture>;
  51976. set refractionTexture(value: Nullable<BaseTexture>);
  51977. /**
  51978. * The color of a material in ambient lighting.
  51979. */
  51980. ambientColor: Color3;
  51981. /**
  51982. * AKA Diffuse Color in other nomenclature.
  51983. */
  51984. albedoColor: Color3;
  51985. /**
  51986. * AKA Specular Color in other nomenclature.
  51987. */
  51988. reflectivityColor: Color3;
  51989. /**
  51990. * The color reflected from the material.
  51991. */
  51992. reflectionColor: Color3;
  51993. /**
  51994. * The color emitted from the material.
  51995. */
  51996. emissiveColor: Color3;
  51997. /**
  51998. * AKA Glossiness in other nomenclature.
  51999. */
  52000. microSurface: number;
  52001. /**
  52002. * source material index of refraction (IOR)' / 'destination material IOR.
  52003. */
  52004. get indexOfRefraction(): number;
  52005. set indexOfRefraction(value: number);
  52006. /**
  52007. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52008. */
  52009. get invertRefractionY(): boolean;
  52010. set invertRefractionY(value: boolean);
  52011. /**
  52012. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52013. * Materials half opaque for instance using refraction could benefit from this control.
  52014. */
  52015. get linkRefractionWithTransparency(): boolean;
  52016. set linkRefractionWithTransparency(value: boolean);
  52017. /**
  52018. * If true, the light map contains occlusion information instead of lighting info.
  52019. */
  52020. useLightmapAsShadowmap: boolean;
  52021. /**
  52022. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52023. */
  52024. useAlphaFromAlbedoTexture: boolean;
  52025. /**
  52026. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52027. */
  52028. forceAlphaTest: boolean;
  52029. /**
  52030. * Defines the alpha limits in alpha test mode.
  52031. */
  52032. alphaCutOff: number;
  52033. /**
  52034. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52035. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52036. */
  52037. useSpecularOverAlpha: boolean;
  52038. /**
  52039. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52040. */
  52041. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52042. /**
  52043. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52044. */
  52045. useRoughnessFromMetallicTextureAlpha: boolean;
  52046. /**
  52047. * Specifies if the metallic texture contains the roughness information in its green channel.
  52048. */
  52049. useRoughnessFromMetallicTextureGreen: boolean;
  52050. /**
  52051. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52052. */
  52053. useMetallnessFromMetallicTextureBlue: boolean;
  52054. /**
  52055. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52056. */
  52057. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52058. /**
  52059. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52060. */
  52061. useAmbientInGrayScale: boolean;
  52062. /**
  52063. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52064. * The material will try to infer what glossiness each pixel should be.
  52065. */
  52066. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52067. /**
  52068. * BJS is using an harcoded light falloff based on a manually sets up range.
  52069. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52070. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52071. */
  52072. get usePhysicalLightFalloff(): boolean;
  52073. /**
  52074. * BJS is using an harcoded light falloff based on a manually sets up range.
  52075. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52076. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52077. */
  52078. set usePhysicalLightFalloff(value: boolean);
  52079. /**
  52080. * In order to support the falloff compatibility with gltf, a special mode has been added
  52081. * to reproduce the gltf light falloff.
  52082. */
  52083. get useGLTFLightFalloff(): boolean;
  52084. /**
  52085. * In order to support the falloff compatibility with gltf, a special mode has been added
  52086. * to reproduce the gltf light falloff.
  52087. */
  52088. set useGLTFLightFalloff(value: boolean);
  52089. /**
  52090. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52091. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52092. */
  52093. useRadianceOverAlpha: boolean;
  52094. /**
  52095. * Allows using an object space normal map (instead of tangent space).
  52096. */
  52097. useObjectSpaceNormalMap: boolean;
  52098. /**
  52099. * Allows using the bump map in parallax mode.
  52100. */
  52101. useParallax: boolean;
  52102. /**
  52103. * Allows using the bump map in parallax occlusion mode.
  52104. */
  52105. useParallaxOcclusion: boolean;
  52106. /**
  52107. * Controls the scale bias of the parallax mode.
  52108. */
  52109. parallaxScaleBias: number;
  52110. /**
  52111. * If sets to true, disables all the lights affecting the material.
  52112. */
  52113. disableLighting: boolean;
  52114. /**
  52115. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52116. */
  52117. forceIrradianceInFragment: boolean;
  52118. /**
  52119. * Number of Simultaneous lights allowed on the material.
  52120. */
  52121. maxSimultaneousLights: number;
  52122. /**
  52123. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52124. */
  52125. invertNormalMapX: boolean;
  52126. /**
  52127. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52128. */
  52129. invertNormalMapY: boolean;
  52130. /**
  52131. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52132. */
  52133. twoSidedLighting: boolean;
  52134. /**
  52135. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52136. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52137. */
  52138. useAlphaFresnel: boolean;
  52139. /**
  52140. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52141. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52142. */
  52143. useLinearAlphaFresnel: boolean;
  52144. /**
  52145. * Let user defines the brdf lookup texture used for IBL.
  52146. * A default 8bit version is embedded but you could point at :
  52147. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52148. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52149. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52150. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52151. */
  52152. environmentBRDFTexture: Nullable<BaseTexture>;
  52153. /**
  52154. * Force normal to face away from face.
  52155. */
  52156. forceNormalForward: boolean;
  52157. /**
  52158. * Enables specular anti aliasing in the PBR shader.
  52159. * It will both interacts on the Geometry for analytical and IBL lighting.
  52160. * It also prefilter the roughness map based on the bump values.
  52161. */
  52162. enableSpecularAntiAliasing: boolean;
  52163. /**
  52164. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52165. * makes the reflect vector face the model (under horizon).
  52166. */
  52167. useHorizonOcclusion: boolean;
  52168. /**
  52169. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52170. * too much the area relying on ambient texture to define their ambient occlusion.
  52171. */
  52172. useRadianceOcclusion: boolean;
  52173. /**
  52174. * If set to true, no lighting calculations will be applied.
  52175. */
  52176. unlit: boolean;
  52177. /**
  52178. * Gets the image processing configuration used either in this material.
  52179. */
  52180. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52181. /**
  52182. * Sets the Default image processing configuration used either in the this material.
  52183. *
  52184. * If sets to null, the scene one is in use.
  52185. */
  52186. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52187. /**
  52188. * Gets wether the color curves effect is enabled.
  52189. */
  52190. get cameraColorCurvesEnabled(): boolean;
  52191. /**
  52192. * Sets wether the color curves effect is enabled.
  52193. */
  52194. set cameraColorCurvesEnabled(value: boolean);
  52195. /**
  52196. * Gets wether the color grading effect is enabled.
  52197. */
  52198. get cameraColorGradingEnabled(): boolean;
  52199. /**
  52200. * Gets wether the color grading effect is enabled.
  52201. */
  52202. set cameraColorGradingEnabled(value: boolean);
  52203. /**
  52204. * Gets wether tonemapping is enabled or not.
  52205. */
  52206. get cameraToneMappingEnabled(): boolean;
  52207. /**
  52208. * Sets wether tonemapping is enabled or not
  52209. */
  52210. set cameraToneMappingEnabled(value: boolean);
  52211. /**
  52212. * The camera exposure used on this material.
  52213. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52214. * This corresponds to a photographic exposure.
  52215. */
  52216. get cameraExposure(): number;
  52217. /**
  52218. * The camera exposure used on this material.
  52219. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52220. * This corresponds to a photographic exposure.
  52221. */
  52222. set cameraExposure(value: number);
  52223. /**
  52224. * Gets The camera contrast used on this material.
  52225. */
  52226. get cameraContrast(): number;
  52227. /**
  52228. * Sets The camera contrast used on this material.
  52229. */
  52230. set cameraContrast(value: number);
  52231. /**
  52232. * Gets the Color Grading 2D Lookup Texture.
  52233. */
  52234. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52235. /**
  52236. * Sets the Color Grading 2D Lookup Texture.
  52237. */
  52238. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52239. /**
  52240. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52241. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52242. * 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;
  52243. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52244. */
  52245. get cameraColorCurves(): Nullable<ColorCurves>;
  52246. /**
  52247. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52248. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52249. * 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;
  52250. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52251. */
  52252. set cameraColorCurves(value: Nullable<ColorCurves>);
  52253. /**
  52254. * Instantiates a new PBRMaterial instance.
  52255. *
  52256. * @param name The material name
  52257. * @param scene The scene the material will be use in.
  52258. */
  52259. constructor(name: string, scene: Scene);
  52260. /**
  52261. * Returns the name of this material class.
  52262. */
  52263. getClassName(): string;
  52264. /**
  52265. * Makes a duplicate of the current material.
  52266. * @param name - name to use for the new material.
  52267. */
  52268. clone(name: string): PBRMaterial;
  52269. /**
  52270. * Serializes this PBR Material.
  52271. * @returns - An object with the serialized material.
  52272. */
  52273. serialize(): any;
  52274. /**
  52275. * Parses a PBR Material from a serialized object.
  52276. * @param source - Serialized object.
  52277. * @param scene - BJS scene instance.
  52278. * @param rootUrl - url for the scene object
  52279. * @returns - PBRMaterial
  52280. */
  52281. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52282. }
  52283. }
  52284. declare module BABYLON {
  52285. /**
  52286. * Direct draw surface info
  52287. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52288. */
  52289. export interface DDSInfo {
  52290. /**
  52291. * Width of the texture
  52292. */
  52293. width: number;
  52294. /**
  52295. * Width of the texture
  52296. */
  52297. height: number;
  52298. /**
  52299. * Number of Mipmaps for the texture
  52300. * @see https://en.wikipedia.org/wiki/Mipmap
  52301. */
  52302. mipmapCount: number;
  52303. /**
  52304. * If the textures format is a known fourCC format
  52305. * @see https://www.fourcc.org/
  52306. */
  52307. isFourCC: boolean;
  52308. /**
  52309. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52310. */
  52311. isRGB: boolean;
  52312. /**
  52313. * If the texture is a lumincance format
  52314. */
  52315. isLuminance: boolean;
  52316. /**
  52317. * If this is a cube texture
  52318. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52319. */
  52320. isCube: boolean;
  52321. /**
  52322. * If the texture is a compressed format eg. FOURCC_DXT1
  52323. */
  52324. isCompressed: boolean;
  52325. /**
  52326. * The dxgiFormat of the texture
  52327. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52328. */
  52329. dxgiFormat: number;
  52330. /**
  52331. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52332. */
  52333. textureType: number;
  52334. /**
  52335. * Sphericle polynomial created for the dds texture
  52336. */
  52337. sphericalPolynomial?: SphericalPolynomial;
  52338. }
  52339. /**
  52340. * Class used to provide DDS decompression tools
  52341. */
  52342. export class DDSTools {
  52343. /**
  52344. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52345. */
  52346. static StoreLODInAlphaChannel: boolean;
  52347. /**
  52348. * Gets DDS information from an array buffer
  52349. * @param data defines the array buffer view to read data from
  52350. * @returns the DDS information
  52351. */
  52352. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52353. private static _FloatView;
  52354. private static _Int32View;
  52355. private static _ToHalfFloat;
  52356. private static _FromHalfFloat;
  52357. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52358. private static _GetHalfFloatRGBAArrayBuffer;
  52359. private static _GetFloatRGBAArrayBuffer;
  52360. private static _GetFloatAsUIntRGBAArrayBuffer;
  52361. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52362. private static _GetRGBAArrayBuffer;
  52363. private static _ExtractLongWordOrder;
  52364. private static _GetRGBArrayBuffer;
  52365. private static _GetLuminanceArrayBuffer;
  52366. /**
  52367. * Uploads DDS Levels to a Babylon Texture
  52368. * @hidden
  52369. */
  52370. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52371. }
  52372. interface ThinEngine {
  52373. /**
  52374. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52375. * @param rootUrl defines the url where the file to load is located
  52376. * @param scene defines the current scene
  52377. * @param lodScale defines scale to apply to the mip map selection
  52378. * @param lodOffset defines offset to apply to the mip map selection
  52379. * @param onLoad defines an optional callback raised when the texture is loaded
  52380. * @param onError defines an optional callback raised if there is an issue to load the texture
  52381. * @param format defines the format of the data
  52382. * @param forcedExtension defines the extension to use to pick the right loader
  52383. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52384. * @returns the cube texture as an InternalTexture
  52385. */
  52386. 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;
  52387. }
  52388. }
  52389. declare module BABYLON {
  52390. /**
  52391. * Implementation of the DDS Texture Loader.
  52392. * @hidden
  52393. */
  52394. export class _DDSTextureLoader implements IInternalTextureLoader {
  52395. /**
  52396. * Defines wether the loader supports cascade loading the different faces.
  52397. */
  52398. readonly supportCascades: boolean;
  52399. /**
  52400. * This returns if the loader support the current file information.
  52401. * @param extension defines the file extension of the file being loaded
  52402. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52403. * @param fallback defines the fallback internal texture if any
  52404. * @param isBase64 defines whether the texture is encoded as a base64
  52405. * @param isBuffer defines whether the texture data are stored as a buffer
  52406. * @returns true if the loader can load the specified file
  52407. */
  52408. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52409. /**
  52410. * Transform the url before loading if required.
  52411. * @param rootUrl the url of the texture
  52412. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52413. * @returns the transformed texture
  52414. */
  52415. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52416. /**
  52417. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52418. * @param rootUrl the url of the texture
  52419. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52420. * @returns the fallback texture
  52421. */
  52422. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52423. /**
  52424. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52425. * @param data contains the texture data
  52426. * @param texture defines the BabylonJS internal texture
  52427. * @param createPolynomials will be true if polynomials have been requested
  52428. * @param onLoad defines the callback to trigger once the texture is ready
  52429. * @param onError defines the callback to trigger in case of error
  52430. */
  52431. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52432. /**
  52433. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52434. * @param data contains the texture data
  52435. * @param texture defines the BabylonJS internal texture
  52436. * @param callback defines the method to call once ready to upload
  52437. */
  52438. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52439. }
  52440. }
  52441. declare module BABYLON {
  52442. /**
  52443. * Implementation of the ENV Texture Loader.
  52444. * @hidden
  52445. */
  52446. export class _ENVTextureLoader implements IInternalTextureLoader {
  52447. /**
  52448. * Defines wether the loader supports cascade loading the different faces.
  52449. */
  52450. readonly supportCascades: boolean;
  52451. /**
  52452. * This returns if the loader support the current file information.
  52453. * @param extension defines the file extension of the file being loaded
  52454. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52455. * @param fallback defines the fallback internal texture if any
  52456. * @param isBase64 defines whether the texture is encoded as a base64
  52457. * @param isBuffer defines whether the texture data are stored as a buffer
  52458. * @returns true if the loader can load the specified file
  52459. */
  52460. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52461. /**
  52462. * Transform the url before loading if required.
  52463. * @param rootUrl the url of the texture
  52464. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52465. * @returns the transformed texture
  52466. */
  52467. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52468. /**
  52469. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52470. * @param rootUrl the url of the texture
  52471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52472. * @returns the fallback texture
  52473. */
  52474. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52475. /**
  52476. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52477. * @param data contains the texture data
  52478. * @param texture defines the BabylonJS internal texture
  52479. * @param createPolynomials will be true if polynomials have been requested
  52480. * @param onLoad defines the callback to trigger once the texture is ready
  52481. * @param onError defines the callback to trigger in case of error
  52482. */
  52483. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52484. /**
  52485. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52486. * @param data contains the texture data
  52487. * @param texture defines the BabylonJS internal texture
  52488. * @param callback defines the method to call once ready to upload
  52489. */
  52490. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52491. }
  52492. }
  52493. declare module BABYLON {
  52494. /**
  52495. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52496. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52497. */
  52498. export class KhronosTextureContainer {
  52499. /** contents of the KTX container file */
  52500. data: ArrayBufferView;
  52501. private static HEADER_LEN;
  52502. private static COMPRESSED_2D;
  52503. private static COMPRESSED_3D;
  52504. private static TEX_2D;
  52505. private static TEX_3D;
  52506. /**
  52507. * Gets the openGL type
  52508. */
  52509. glType: number;
  52510. /**
  52511. * Gets the openGL type size
  52512. */
  52513. glTypeSize: number;
  52514. /**
  52515. * Gets the openGL format
  52516. */
  52517. glFormat: number;
  52518. /**
  52519. * Gets the openGL internal format
  52520. */
  52521. glInternalFormat: number;
  52522. /**
  52523. * Gets the base internal format
  52524. */
  52525. glBaseInternalFormat: number;
  52526. /**
  52527. * Gets image width in pixel
  52528. */
  52529. pixelWidth: number;
  52530. /**
  52531. * Gets image height in pixel
  52532. */
  52533. pixelHeight: number;
  52534. /**
  52535. * Gets image depth in pixels
  52536. */
  52537. pixelDepth: number;
  52538. /**
  52539. * Gets the number of array elements
  52540. */
  52541. numberOfArrayElements: number;
  52542. /**
  52543. * Gets the number of faces
  52544. */
  52545. numberOfFaces: number;
  52546. /**
  52547. * Gets the number of mipmap levels
  52548. */
  52549. numberOfMipmapLevels: number;
  52550. /**
  52551. * Gets the bytes of key value data
  52552. */
  52553. bytesOfKeyValueData: number;
  52554. /**
  52555. * Gets the load type
  52556. */
  52557. loadType: number;
  52558. /**
  52559. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52560. */
  52561. isInvalid: boolean;
  52562. /**
  52563. * Creates a new KhronosTextureContainer
  52564. * @param data contents of the KTX container file
  52565. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52566. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52567. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52568. */
  52569. constructor(
  52570. /** contents of the KTX container file */
  52571. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52572. /**
  52573. * Uploads KTX content to a Babylon Texture.
  52574. * It is assumed that the texture has already been created & is currently bound
  52575. * @hidden
  52576. */
  52577. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52578. private _upload2DCompressedLevels;
  52579. }
  52580. }
  52581. declare module BABYLON {
  52582. /**
  52583. * Implementation of the KTX Texture Loader.
  52584. * @hidden
  52585. */
  52586. export class _KTXTextureLoader implements IInternalTextureLoader {
  52587. /**
  52588. * Defines wether the loader supports cascade loading the different faces.
  52589. */
  52590. readonly supportCascades: boolean;
  52591. /**
  52592. * This returns if the loader support the current file information.
  52593. * @param extension defines the file extension of the file being loaded
  52594. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52595. * @param fallback defines the fallback internal texture if any
  52596. * @param isBase64 defines whether the texture is encoded as a base64
  52597. * @param isBuffer defines whether the texture data are stored as a buffer
  52598. * @returns true if the loader can load the specified file
  52599. */
  52600. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52601. /**
  52602. * Transform the url before loading if required.
  52603. * @param rootUrl the url of the texture
  52604. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52605. * @returns the transformed texture
  52606. */
  52607. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52608. /**
  52609. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52610. * @param rootUrl the url of the texture
  52611. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52612. * @returns the fallback texture
  52613. */
  52614. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52615. /**
  52616. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52617. * @param data contains the texture data
  52618. * @param texture defines the BabylonJS internal texture
  52619. * @param createPolynomials will be true if polynomials have been requested
  52620. * @param onLoad defines the callback to trigger once the texture is ready
  52621. * @param onError defines the callback to trigger in case of error
  52622. */
  52623. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52624. /**
  52625. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52626. * @param data contains the texture data
  52627. * @param texture defines the BabylonJS internal texture
  52628. * @param callback defines the method to call once ready to upload
  52629. */
  52630. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52631. }
  52632. }
  52633. declare module BABYLON {
  52634. /** @hidden */
  52635. export var _forceSceneHelpersToBundle: boolean;
  52636. interface Scene {
  52637. /**
  52638. * Creates a default light for the scene.
  52639. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52640. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52641. */
  52642. createDefaultLight(replace?: boolean): void;
  52643. /**
  52644. * Creates a default camera for the scene.
  52645. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52646. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52647. * @param replace has default false, when true replaces the active camera in the scene
  52648. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52649. */
  52650. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52651. /**
  52652. * Creates a default camera and a default light.
  52653. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52654. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52655. * @param replace has the default false, when true replaces the active camera/light in the scene
  52656. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52657. */
  52658. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52659. /**
  52660. * Creates a new sky box
  52661. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52662. * @param environmentTexture defines the texture to use as environment texture
  52663. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52664. * @param scale defines the overall scale of the skybox
  52665. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52666. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52667. * @returns a new mesh holding the sky box
  52668. */
  52669. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52670. /**
  52671. * Creates a new environment
  52672. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52673. * @param options defines the options you can use to configure the environment
  52674. * @returns the new EnvironmentHelper
  52675. */
  52676. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52677. /**
  52678. * Creates a new VREXperienceHelper
  52679. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52680. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52681. * @returns a new VREXperienceHelper
  52682. */
  52683. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52684. /**
  52685. * Creates a new WebXRDefaultExperience
  52686. * @see http://doc.babylonjs.com/how_to/webxr
  52687. * @param options experience options
  52688. * @returns a promise for a new WebXRDefaultExperience
  52689. */
  52690. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52691. }
  52692. }
  52693. declare module BABYLON {
  52694. /**
  52695. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52696. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52697. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52698. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52699. */
  52700. export class VideoDome extends TransformNode {
  52701. /**
  52702. * Define the video source as a Monoscopic panoramic 360 video.
  52703. */
  52704. static readonly MODE_MONOSCOPIC: number;
  52705. /**
  52706. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52707. */
  52708. static readonly MODE_TOPBOTTOM: number;
  52709. /**
  52710. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52711. */
  52712. static readonly MODE_SIDEBYSIDE: number;
  52713. private _halfDome;
  52714. private _useDirectMapping;
  52715. /**
  52716. * The video texture being displayed on the sphere
  52717. */
  52718. protected _videoTexture: VideoTexture;
  52719. /**
  52720. * Gets the video texture being displayed on the sphere
  52721. */
  52722. get videoTexture(): VideoTexture;
  52723. /**
  52724. * The skybox material
  52725. */
  52726. protected _material: BackgroundMaterial;
  52727. /**
  52728. * The surface used for the skybox
  52729. */
  52730. protected _mesh: Mesh;
  52731. /**
  52732. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52733. */
  52734. private _halfDomeMask;
  52735. /**
  52736. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52737. * Also see the options.resolution property.
  52738. */
  52739. get fovMultiplier(): number;
  52740. set fovMultiplier(value: number);
  52741. private _videoMode;
  52742. /**
  52743. * Gets or set the current video mode for the video. It can be:
  52744. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52745. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52746. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52747. */
  52748. get videoMode(): number;
  52749. set videoMode(value: number);
  52750. /**
  52751. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52752. *
  52753. */
  52754. get halfDome(): boolean;
  52755. /**
  52756. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52757. */
  52758. set halfDome(enabled: boolean);
  52759. /**
  52760. * Oberserver used in Stereoscopic VR Mode.
  52761. */
  52762. private _onBeforeCameraRenderObserver;
  52763. /**
  52764. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52765. * @param name Element's name, child elements will append suffixes for their own names.
  52766. * @param urlsOrVideo defines the url(s) or the video element to use
  52767. * @param options An object containing optional or exposed sub element properties
  52768. */
  52769. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52770. resolution?: number;
  52771. clickToPlay?: boolean;
  52772. autoPlay?: boolean;
  52773. loop?: boolean;
  52774. size?: number;
  52775. poster?: string;
  52776. faceForward?: boolean;
  52777. useDirectMapping?: boolean;
  52778. halfDomeMode?: boolean;
  52779. }, scene: Scene);
  52780. private _changeVideoMode;
  52781. /**
  52782. * Releases resources associated with this node.
  52783. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52784. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52785. */
  52786. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52787. }
  52788. }
  52789. declare module BABYLON {
  52790. /**
  52791. * This class can be used to get instrumentation data from a Babylon engine
  52792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52793. */
  52794. export class EngineInstrumentation implements IDisposable {
  52795. /**
  52796. * Define the instrumented engine.
  52797. */
  52798. engine: Engine;
  52799. private _captureGPUFrameTime;
  52800. private _gpuFrameTimeToken;
  52801. private _gpuFrameTime;
  52802. private _captureShaderCompilationTime;
  52803. private _shaderCompilationTime;
  52804. private _onBeginFrameObserver;
  52805. private _onEndFrameObserver;
  52806. private _onBeforeShaderCompilationObserver;
  52807. private _onAfterShaderCompilationObserver;
  52808. /**
  52809. * Gets the perf counter used for GPU frame time
  52810. */
  52811. get gpuFrameTimeCounter(): PerfCounter;
  52812. /**
  52813. * Gets the GPU frame time capture status
  52814. */
  52815. get captureGPUFrameTime(): boolean;
  52816. /**
  52817. * Enable or disable the GPU frame time capture
  52818. */
  52819. set captureGPUFrameTime(value: boolean);
  52820. /**
  52821. * Gets the perf counter used for shader compilation time
  52822. */
  52823. get shaderCompilationTimeCounter(): PerfCounter;
  52824. /**
  52825. * Gets the shader compilation time capture status
  52826. */
  52827. get captureShaderCompilationTime(): boolean;
  52828. /**
  52829. * Enable or disable the shader compilation time capture
  52830. */
  52831. set captureShaderCompilationTime(value: boolean);
  52832. /**
  52833. * Instantiates a new engine instrumentation.
  52834. * This class can be used to get instrumentation data from a Babylon engine
  52835. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52836. * @param engine Defines the engine to instrument
  52837. */
  52838. constructor(
  52839. /**
  52840. * Define the instrumented engine.
  52841. */
  52842. engine: Engine);
  52843. /**
  52844. * Dispose and release associated resources.
  52845. */
  52846. dispose(): void;
  52847. }
  52848. }
  52849. declare module BABYLON {
  52850. /**
  52851. * This class can be used to get instrumentation data from a Babylon engine
  52852. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52853. */
  52854. export class SceneInstrumentation implements IDisposable {
  52855. /**
  52856. * Defines the scene to instrument
  52857. */
  52858. scene: Scene;
  52859. private _captureActiveMeshesEvaluationTime;
  52860. private _activeMeshesEvaluationTime;
  52861. private _captureRenderTargetsRenderTime;
  52862. private _renderTargetsRenderTime;
  52863. private _captureFrameTime;
  52864. private _frameTime;
  52865. private _captureRenderTime;
  52866. private _renderTime;
  52867. private _captureInterFrameTime;
  52868. private _interFrameTime;
  52869. private _captureParticlesRenderTime;
  52870. private _particlesRenderTime;
  52871. private _captureSpritesRenderTime;
  52872. private _spritesRenderTime;
  52873. private _capturePhysicsTime;
  52874. private _physicsTime;
  52875. private _captureAnimationsTime;
  52876. private _animationsTime;
  52877. private _captureCameraRenderTime;
  52878. private _cameraRenderTime;
  52879. private _onBeforeActiveMeshesEvaluationObserver;
  52880. private _onAfterActiveMeshesEvaluationObserver;
  52881. private _onBeforeRenderTargetsRenderObserver;
  52882. private _onAfterRenderTargetsRenderObserver;
  52883. private _onAfterRenderObserver;
  52884. private _onBeforeDrawPhaseObserver;
  52885. private _onAfterDrawPhaseObserver;
  52886. private _onBeforeAnimationsObserver;
  52887. private _onBeforeParticlesRenderingObserver;
  52888. private _onAfterParticlesRenderingObserver;
  52889. private _onBeforeSpritesRenderingObserver;
  52890. private _onAfterSpritesRenderingObserver;
  52891. private _onBeforePhysicsObserver;
  52892. private _onAfterPhysicsObserver;
  52893. private _onAfterAnimationsObserver;
  52894. private _onBeforeCameraRenderObserver;
  52895. private _onAfterCameraRenderObserver;
  52896. /**
  52897. * Gets the perf counter used for active meshes evaluation time
  52898. */
  52899. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52900. /**
  52901. * Gets the active meshes evaluation time capture status
  52902. */
  52903. get captureActiveMeshesEvaluationTime(): boolean;
  52904. /**
  52905. * Enable or disable the active meshes evaluation time capture
  52906. */
  52907. set captureActiveMeshesEvaluationTime(value: boolean);
  52908. /**
  52909. * Gets the perf counter used for render targets render time
  52910. */
  52911. get renderTargetsRenderTimeCounter(): PerfCounter;
  52912. /**
  52913. * Gets the render targets render time capture status
  52914. */
  52915. get captureRenderTargetsRenderTime(): boolean;
  52916. /**
  52917. * Enable or disable the render targets render time capture
  52918. */
  52919. set captureRenderTargetsRenderTime(value: boolean);
  52920. /**
  52921. * Gets the perf counter used for particles render time
  52922. */
  52923. get particlesRenderTimeCounter(): PerfCounter;
  52924. /**
  52925. * Gets the particles render time capture status
  52926. */
  52927. get captureParticlesRenderTime(): boolean;
  52928. /**
  52929. * Enable or disable the particles render time capture
  52930. */
  52931. set captureParticlesRenderTime(value: boolean);
  52932. /**
  52933. * Gets the perf counter used for sprites render time
  52934. */
  52935. get spritesRenderTimeCounter(): PerfCounter;
  52936. /**
  52937. * Gets the sprites render time capture status
  52938. */
  52939. get captureSpritesRenderTime(): boolean;
  52940. /**
  52941. * Enable or disable the sprites render time capture
  52942. */
  52943. set captureSpritesRenderTime(value: boolean);
  52944. /**
  52945. * Gets the perf counter used for physics time
  52946. */
  52947. get physicsTimeCounter(): PerfCounter;
  52948. /**
  52949. * Gets the physics time capture status
  52950. */
  52951. get capturePhysicsTime(): boolean;
  52952. /**
  52953. * Enable or disable the physics time capture
  52954. */
  52955. set capturePhysicsTime(value: boolean);
  52956. /**
  52957. * Gets the perf counter used for animations time
  52958. */
  52959. get animationsTimeCounter(): PerfCounter;
  52960. /**
  52961. * Gets the animations time capture status
  52962. */
  52963. get captureAnimationsTime(): boolean;
  52964. /**
  52965. * Enable or disable the animations time capture
  52966. */
  52967. set captureAnimationsTime(value: boolean);
  52968. /**
  52969. * Gets the perf counter used for frame time capture
  52970. */
  52971. get frameTimeCounter(): PerfCounter;
  52972. /**
  52973. * Gets the frame time capture status
  52974. */
  52975. get captureFrameTime(): boolean;
  52976. /**
  52977. * Enable or disable the frame time capture
  52978. */
  52979. set captureFrameTime(value: boolean);
  52980. /**
  52981. * Gets the perf counter used for inter-frames time capture
  52982. */
  52983. get interFrameTimeCounter(): PerfCounter;
  52984. /**
  52985. * Gets the inter-frames time capture status
  52986. */
  52987. get captureInterFrameTime(): boolean;
  52988. /**
  52989. * Enable or disable the inter-frames time capture
  52990. */
  52991. set captureInterFrameTime(value: boolean);
  52992. /**
  52993. * Gets the perf counter used for render time capture
  52994. */
  52995. get renderTimeCounter(): PerfCounter;
  52996. /**
  52997. * Gets the render time capture status
  52998. */
  52999. get captureRenderTime(): boolean;
  53000. /**
  53001. * Enable or disable the render time capture
  53002. */
  53003. set captureRenderTime(value: boolean);
  53004. /**
  53005. * Gets the perf counter used for camera render time capture
  53006. */
  53007. get cameraRenderTimeCounter(): PerfCounter;
  53008. /**
  53009. * Gets the camera render time capture status
  53010. */
  53011. get captureCameraRenderTime(): boolean;
  53012. /**
  53013. * Enable or disable the camera render time capture
  53014. */
  53015. set captureCameraRenderTime(value: boolean);
  53016. /**
  53017. * Gets the perf counter used for draw calls
  53018. */
  53019. get drawCallsCounter(): PerfCounter;
  53020. /**
  53021. * Instantiates a new scene instrumentation.
  53022. * This class can be used to get instrumentation data from a Babylon engine
  53023. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53024. * @param scene Defines the scene to instrument
  53025. */
  53026. constructor(
  53027. /**
  53028. * Defines the scene to instrument
  53029. */
  53030. scene: Scene);
  53031. /**
  53032. * Dispose and release associated resources.
  53033. */
  53034. dispose(): void;
  53035. }
  53036. }
  53037. declare module BABYLON {
  53038. /** @hidden */
  53039. export var glowMapGenerationPixelShader: {
  53040. name: string;
  53041. shader: string;
  53042. };
  53043. }
  53044. declare module BABYLON {
  53045. /** @hidden */
  53046. export var glowMapGenerationVertexShader: {
  53047. name: string;
  53048. shader: string;
  53049. };
  53050. }
  53051. declare module BABYLON {
  53052. /**
  53053. * Effect layer options. This helps customizing the behaviour
  53054. * of the effect layer.
  53055. */
  53056. export interface IEffectLayerOptions {
  53057. /**
  53058. * Multiplication factor apply to the canvas size to compute the render target size
  53059. * used to generated the objects (the smaller the faster).
  53060. */
  53061. mainTextureRatio: number;
  53062. /**
  53063. * Enforces a fixed size texture to ensure effect stability across devices.
  53064. */
  53065. mainTextureFixedSize?: number;
  53066. /**
  53067. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53068. */
  53069. alphaBlendingMode: number;
  53070. /**
  53071. * The camera attached to the layer.
  53072. */
  53073. camera: Nullable<Camera>;
  53074. /**
  53075. * The rendering group to draw the layer in.
  53076. */
  53077. renderingGroupId: number;
  53078. }
  53079. /**
  53080. * The effect layer Helps adding post process effect blended with the main pass.
  53081. *
  53082. * This can be for instance use to generate glow or higlight effects on the scene.
  53083. *
  53084. * The effect layer class can not be used directly and is intented to inherited from to be
  53085. * customized per effects.
  53086. */
  53087. export abstract class EffectLayer {
  53088. private _vertexBuffers;
  53089. private _indexBuffer;
  53090. private _cachedDefines;
  53091. private _effectLayerMapGenerationEffect;
  53092. private _effectLayerOptions;
  53093. private _mergeEffect;
  53094. protected _scene: Scene;
  53095. protected _engine: Engine;
  53096. protected _maxSize: number;
  53097. protected _mainTextureDesiredSize: ISize;
  53098. protected _mainTexture: RenderTargetTexture;
  53099. protected _shouldRender: boolean;
  53100. protected _postProcesses: PostProcess[];
  53101. protected _textures: BaseTexture[];
  53102. protected _emissiveTextureAndColor: {
  53103. texture: Nullable<BaseTexture>;
  53104. color: Color4;
  53105. };
  53106. /**
  53107. * The name of the layer
  53108. */
  53109. name: string;
  53110. /**
  53111. * The clear color of the texture used to generate the glow map.
  53112. */
  53113. neutralColor: Color4;
  53114. /**
  53115. * Specifies wether the highlight layer is enabled or not.
  53116. */
  53117. isEnabled: boolean;
  53118. /**
  53119. * Gets the camera attached to the layer.
  53120. */
  53121. get camera(): Nullable<Camera>;
  53122. /**
  53123. * Gets the rendering group id the layer should render in.
  53124. */
  53125. get renderingGroupId(): number;
  53126. set renderingGroupId(renderingGroupId: number);
  53127. /**
  53128. * An event triggered when the effect layer has been disposed.
  53129. */
  53130. onDisposeObservable: Observable<EffectLayer>;
  53131. /**
  53132. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53133. */
  53134. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53135. /**
  53136. * An event triggered when the generated texture is being merged in the scene.
  53137. */
  53138. onBeforeComposeObservable: Observable<EffectLayer>;
  53139. /**
  53140. * An event triggered when the mesh is rendered into the effect render target.
  53141. */
  53142. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53143. /**
  53144. * An event triggered after the mesh has been rendered into the effect render target.
  53145. */
  53146. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53147. /**
  53148. * An event triggered when the generated texture has been merged in the scene.
  53149. */
  53150. onAfterComposeObservable: Observable<EffectLayer>;
  53151. /**
  53152. * An event triggered when the efffect layer changes its size.
  53153. */
  53154. onSizeChangedObservable: Observable<EffectLayer>;
  53155. /** @hidden */
  53156. static _SceneComponentInitialization: (scene: Scene) => void;
  53157. /**
  53158. * Instantiates a new effect Layer and references it in the scene.
  53159. * @param name The name of the layer
  53160. * @param scene The scene to use the layer in
  53161. */
  53162. constructor(
  53163. /** The Friendly of the effect in the scene */
  53164. name: string, scene: Scene);
  53165. /**
  53166. * Get the effect name of the layer.
  53167. * @return The effect name
  53168. */
  53169. abstract getEffectName(): string;
  53170. /**
  53171. * Checks for the readiness of the element composing the layer.
  53172. * @param subMesh the mesh to check for
  53173. * @param useInstances specify wether or not to use instances to render the mesh
  53174. * @return true if ready otherwise, false
  53175. */
  53176. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53177. /**
  53178. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53179. * @returns true if the effect requires stencil during the main canvas render pass.
  53180. */
  53181. abstract needStencil(): boolean;
  53182. /**
  53183. * Create the merge effect. This is the shader use to blit the information back
  53184. * to the main canvas at the end of the scene rendering.
  53185. * @returns The effect containing the shader used to merge the effect on the main canvas
  53186. */
  53187. protected abstract _createMergeEffect(): Effect;
  53188. /**
  53189. * Creates the render target textures and post processes used in the effect layer.
  53190. */
  53191. protected abstract _createTextureAndPostProcesses(): void;
  53192. /**
  53193. * Implementation specific of rendering the generating effect on the main canvas.
  53194. * @param effect The effect used to render through
  53195. */
  53196. protected abstract _internalRender(effect: Effect): void;
  53197. /**
  53198. * Sets the required values for both the emissive texture and and the main color.
  53199. */
  53200. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53201. /**
  53202. * Free any resources and references associated to a mesh.
  53203. * Internal use
  53204. * @param mesh The mesh to free.
  53205. */
  53206. abstract _disposeMesh(mesh: Mesh): void;
  53207. /**
  53208. * Serializes this layer (Glow or Highlight for example)
  53209. * @returns a serialized layer object
  53210. */
  53211. abstract serialize?(): any;
  53212. /**
  53213. * Initializes the effect layer with the required options.
  53214. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53215. */
  53216. protected _init(options: Partial<IEffectLayerOptions>): void;
  53217. /**
  53218. * Generates the index buffer of the full screen quad blending to the main canvas.
  53219. */
  53220. private _generateIndexBuffer;
  53221. /**
  53222. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53223. */
  53224. private _generateVertexBuffer;
  53225. /**
  53226. * Sets the main texture desired size which is the closest power of two
  53227. * of the engine canvas size.
  53228. */
  53229. private _setMainTextureSize;
  53230. /**
  53231. * Creates the main texture for the effect layer.
  53232. */
  53233. protected _createMainTexture(): void;
  53234. /**
  53235. * Adds specific effects defines.
  53236. * @param defines The defines to add specifics to.
  53237. */
  53238. protected _addCustomEffectDefines(defines: string[]): void;
  53239. /**
  53240. * Checks for the readiness of the element composing the layer.
  53241. * @param subMesh the mesh to check for
  53242. * @param useInstances specify wether or not to use instances to render the mesh
  53243. * @param emissiveTexture the associated emissive texture used to generate the glow
  53244. * @return true if ready otherwise, false
  53245. */
  53246. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53247. /**
  53248. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53249. */
  53250. render(): void;
  53251. /**
  53252. * Determine if a given mesh will be used in the current effect.
  53253. * @param mesh mesh to test
  53254. * @returns true if the mesh will be used
  53255. */
  53256. hasMesh(mesh: AbstractMesh): boolean;
  53257. /**
  53258. * Returns true if the layer contains information to display, otherwise false.
  53259. * @returns true if the glow layer should be rendered
  53260. */
  53261. shouldRender(): boolean;
  53262. /**
  53263. * Returns true if the mesh should render, otherwise false.
  53264. * @param mesh The mesh to render
  53265. * @returns true if it should render otherwise false
  53266. */
  53267. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53268. /**
  53269. * Returns true if the mesh can be rendered, otherwise false.
  53270. * @param mesh The mesh to render
  53271. * @param material The material used on the mesh
  53272. * @returns true if it can be rendered otherwise false
  53273. */
  53274. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53275. /**
  53276. * Returns true if the mesh should render, otherwise false.
  53277. * @param mesh The mesh to render
  53278. * @returns true if it should render otherwise false
  53279. */
  53280. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53281. /**
  53282. * Renders the submesh passed in parameter to the generation map.
  53283. */
  53284. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53285. /**
  53286. * Defines wether the current material of the mesh should be use to render the effect.
  53287. * @param mesh defines the current mesh to render
  53288. */
  53289. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53290. /**
  53291. * Rebuild the required buffers.
  53292. * @hidden Internal use only.
  53293. */
  53294. _rebuild(): void;
  53295. /**
  53296. * Dispose only the render target textures and post process.
  53297. */
  53298. private _disposeTextureAndPostProcesses;
  53299. /**
  53300. * Dispose the highlight layer and free resources.
  53301. */
  53302. dispose(): void;
  53303. /**
  53304. * Gets the class name of the effect layer
  53305. * @returns the string with the class name of the effect layer
  53306. */
  53307. getClassName(): string;
  53308. /**
  53309. * Creates an effect layer from parsed effect layer data
  53310. * @param parsedEffectLayer defines effect layer data
  53311. * @param scene defines the current scene
  53312. * @param rootUrl defines the root URL containing the effect layer information
  53313. * @returns a parsed effect Layer
  53314. */
  53315. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53316. }
  53317. }
  53318. declare module BABYLON {
  53319. interface AbstractScene {
  53320. /**
  53321. * The list of effect layers (highlights/glow) added to the scene
  53322. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53323. * @see http://doc.babylonjs.com/how_to/glow_layer
  53324. */
  53325. effectLayers: Array<EffectLayer>;
  53326. /**
  53327. * Removes the given effect layer from this scene.
  53328. * @param toRemove defines the effect layer to remove
  53329. * @returns the index of the removed effect layer
  53330. */
  53331. removeEffectLayer(toRemove: EffectLayer): number;
  53332. /**
  53333. * Adds the given effect layer to this scene
  53334. * @param newEffectLayer defines the effect layer to add
  53335. */
  53336. addEffectLayer(newEffectLayer: EffectLayer): void;
  53337. }
  53338. /**
  53339. * Defines the layer scene component responsible to manage any effect layers
  53340. * in a given scene.
  53341. */
  53342. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53343. /**
  53344. * The component name helpfull to identify the component in the list of scene components.
  53345. */
  53346. readonly name: string;
  53347. /**
  53348. * The scene the component belongs to.
  53349. */
  53350. scene: Scene;
  53351. private _engine;
  53352. private _renderEffects;
  53353. private _needStencil;
  53354. private _previousStencilState;
  53355. /**
  53356. * Creates a new instance of the component for the given scene
  53357. * @param scene Defines the scene to register the component in
  53358. */
  53359. constructor(scene: Scene);
  53360. /**
  53361. * Registers the component in a given scene
  53362. */
  53363. register(): void;
  53364. /**
  53365. * Rebuilds the elements related to this component in case of
  53366. * context lost for instance.
  53367. */
  53368. rebuild(): void;
  53369. /**
  53370. * Serializes the component data to the specified json object
  53371. * @param serializationObject The object to serialize to
  53372. */
  53373. serialize(serializationObject: any): void;
  53374. /**
  53375. * Adds all the elements from the container to the scene
  53376. * @param container the container holding the elements
  53377. */
  53378. addFromContainer(container: AbstractScene): void;
  53379. /**
  53380. * Removes all the elements in the container from the scene
  53381. * @param container contains the elements to remove
  53382. * @param dispose if the removed element should be disposed (default: false)
  53383. */
  53384. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53385. /**
  53386. * Disposes the component and the associated ressources.
  53387. */
  53388. dispose(): void;
  53389. private _isReadyForMesh;
  53390. private _renderMainTexture;
  53391. private _setStencil;
  53392. private _setStencilBack;
  53393. private _draw;
  53394. private _drawCamera;
  53395. private _drawRenderingGroup;
  53396. }
  53397. }
  53398. declare module BABYLON {
  53399. /** @hidden */
  53400. export var glowMapMergePixelShader: {
  53401. name: string;
  53402. shader: string;
  53403. };
  53404. }
  53405. declare module BABYLON {
  53406. /** @hidden */
  53407. export var glowMapMergeVertexShader: {
  53408. name: string;
  53409. shader: string;
  53410. };
  53411. }
  53412. declare module BABYLON {
  53413. interface AbstractScene {
  53414. /**
  53415. * Return a the first highlight layer of the scene with a given name.
  53416. * @param name The name of the highlight layer to look for.
  53417. * @return The highlight layer if found otherwise null.
  53418. */
  53419. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53420. }
  53421. /**
  53422. * Glow layer options. This helps customizing the behaviour
  53423. * of the glow layer.
  53424. */
  53425. export interface IGlowLayerOptions {
  53426. /**
  53427. * Multiplication factor apply to the canvas size to compute the render target size
  53428. * used to generated the glowing objects (the smaller the faster).
  53429. */
  53430. mainTextureRatio: number;
  53431. /**
  53432. * Enforces a fixed size texture to ensure resize independant blur.
  53433. */
  53434. mainTextureFixedSize?: number;
  53435. /**
  53436. * How big is the kernel of the blur texture.
  53437. */
  53438. blurKernelSize: number;
  53439. /**
  53440. * The camera attached to the layer.
  53441. */
  53442. camera: Nullable<Camera>;
  53443. /**
  53444. * Enable MSAA by chosing the number of samples.
  53445. */
  53446. mainTextureSamples?: number;
  53447. /**
  53448. * The rendering group to draw the layer in.
  53449. */
  53450. renderingGroupId: number;
  53451. }
  53452. /**
  53453. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53454. *
  53455. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53456. *
  53457. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53458. */
  53459. export class GlowLayer extends EffectLayer {
  53460. /**
  53461. * Effect Name of the layer.
  53462. */
  53463. static readonly EffectName: string;
  53464. /**
  53465. * The default blur kernel size used for the glow.
  53466. */
  53467. static DefaultBlurKernelSize: number;
  53468. /**
  53469. * The default texture size ratio used for the glow.
  53470. */
  53471. static DefaultTextureRatio: number;
  53472. /**
  53473. * Sets the kernel size of the blur.
  53474. */
  53475. set blurKernelSize(value: number);
  53476. /**
  53477. * Gets the kernel size of the blur.
  53478. */
  53479. get blurKernelSize(): number;
  53480. /**
  53481. * Sets the glow intensity.
  53482. */
  53483. set intensity(value: number);
  53484. /**
  53485. * Gets the glow intensity.
  53486. */
  53487. get intensity(): number;
  53488. private _options;
  53489. private _intensity;
  53490. private _horizontalBlurPostprocess1;
  53491. private _verticalBlurPostprocess1;
  53492. private _horizontalBlurPostprocess2;
  53493. private _verticalBlurPostprocess2;
  53494. private _blurTexture1;
  53495. private _blurTexture2;
  53496. private _postProcesses1;
  53497. private _postProcesses2;
  53498. private _includedOnlyMeshes;
  53499. private _excludedMeshes;
  53500. private _meshesUsingTheirOwnMaterials;
  53501. /**
  53502. * Callback used to let the user override the color selection on a per mesh basis
  53503. */
  53504. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53505. /**
  53506. * Callback used to let the user override the texture selection on a per mesh basis
  53507. */
  53508. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53509. /**
  53510. * Instantiates a new glow Layer and references it to the scene.
  53511. * @param name The name of the layer
  53512. * @param scene The scene to use the layer in
  53513. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53514. */
  53515. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53516. /**
  53517. * Get the effect name of the layer.
  53518. * @return The effect name
  53519. */
  53520. getEffectName(): string;
  53521. /**
  53522. * Create the merge effect. This is the shader use to blit the information back
  53523. * to the main canvas at the end of the scene rendering.
  53524. */
  53525. protected _createMergeEffect(): Effect;
  53526. /**
  53527. * Creates the render target textures and post processes used in the glow layer.
  53528. */
  53529. protected _createTextureAndPostProcesses(): void;
  53530. /**
  53531. * Checks for the readiness of the element composing the layer.
  53532. * @param subMesh the mesh to check for
  53533. * @param useInstances specify wether or not to use instances to render the mesh
  53534. * @param emissiveTexture the associated emissive texture used to generate the glow
  53535. * @return true if ready otherwise, false
  53536. */
  53537. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53538. /**
  53539. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53540. */
  53541. needStencil(): boolean;
  53542. /**
  53543. * Returns true if the mesh can be rendered, otherwise false.
  53544. * @param mesh The mesh to render
  53545. * @param material The material used on the mesh
  53546. * @returns true if it can be rendered otherwise false
  53547. */
  53548. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53549. /**
  53550. * Implementation specific of rendering the generating effect on the main canvas.
  53551. * @param effect The effect used to render through
  53552. */
  53553. protected _internalRender(effect: Effect): void;
  53554. /**
  53555. * Sets the required values for both the emissive texture and and the main color.
  53556. */
  53557. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53558. /**
  53559. * Returns true if the mesh should render, otherwise false.
  53560. * @param mesh The mesh to render
  53561. * @returns true if it should render otherwise false
  53562. */
  53563. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53564. /**
  53565. * Adds specific effects defines.
  53566. * @param defines The defines to add specifics to.
  53567. */
  53568. protected _addCustomEffectDefines(defines: string[]): void;
  53569. /**
  53570. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53571. * @param mesh The mesh to exclude from the glow layer
  53572. */
  53573. addExcludedMesh(mesh: Mesh): void;
  53574. /**
  53575. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53576. * @param mesh The mesh to remove
  53577. */
  53578. removeExcludedMesh(mesh: Mesh): void;
  53579. /**
  53580. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53581. * @param mesh The mesh to include in the glow layer
  53582. */
  53583. addIncludedOnlyMesh(mesh: Mesh): void;
  53584. /**
  53585. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53586. * @param mesh The mesh to remove
  53587. */
  53588. removeIncludedOnlyMesh(mesh: Mesh): void;
  53589. /**
  53590. * Determine if a given mesh will be used in the glow layer
  53591. * @param mesh The mesh to test
  53592. * @returns true if the mesh will be highlighted by the current glow layer
  53593. */
  53594. hasMesh(mesh: AbstractMesh): boolean;
  53595. /**
  53596. * Defines wether the current material of the mesh should be use to render the effect.
  53597. * @param mesh defines the current mesh to render
  53598. */
  53599. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53600. /**
  53601. * Add a mesh to be rendered through its own material and not with emissive only.
  53602. * @param mesh The mesh for which we need to use its material
  53603. */
  53604. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53605. /**
  53606. * Remove a mesh from being rendered through its own material and not with emissive only.
  53607. * @param mesh The mesh for which we need to not use its material
  53608. */
  53609. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53610. /**
  53611. * Free any resources and references associated to a mesh.
  53612. * Internal use
  53613. * @param mesh The mesh to free.
  53614. * @hidden
  53615. */
  53616. _disposeMesh(mesh: Mesh): void;
  53617. /**
  53618. * Gets the class name of the effect layer
  53619. * @returns the string with the class name of the effect layer
  53620. */
  53621. getClassName(): string;
  53622. /**
  53623. * Serializes this glow layer
  53624. * @returns a serialized glow layer object
  53625. */
  53626. serialize(): any;
  53627. /**
  53628. * Creates a Glow Layer from parsed glow layer data
  53629. * @param parsedGlowLayer defines glow layer data
  53630. * @param scene defines the current scene
  53631. * @param rootUrl defines the root URL containing the glow layer information
  53632. * @returns a parsed Glow Layer
  53633. */
  53634. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53635. }
  53636. }
  53637. declare module BABYLON {
  53638. /** @hidden */
  53639. export var glowBlurPostProcessPixelShader: {
  53640. name: string;
  53641. shader: string;
  53642. };
  53643. }
  53644. declare module BABYLON {
  53645. interface AbstractScene {
  53646. /**
  53647. * Return a the first highlight layer of the scene with a given name.
  53648. * @param name The name of the highlight layer to look for.
  53649. * @return The highlight layer if found otherwise null.
  53650. */
  53651. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53652. }
  53653. /**
  53654. * Highlight layer options. This helps customizing the behaviour
  53655. * of the highlight layer.
  53656. */
  53657. export interface IHighlightLayerOptions {
  53658. /**
  53659. * Multiplication factor apply to the canvas size to compute the render target size
  53660. * used to generated the glowing objects (the smaller the faster).
  53661. */
  53662. mainTextureRatio: number;
  53663. /**
  53664. * Enforces a fixed size texture to ensure resize independant blur.
  53665. */
  53666. mainTextureFixedSize?: number;
  53667. /**
  53668. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53669. * of the picture to blur (the smaller the faster).
  53670. */
  53671. blurTextureSizeRatio: number;
  53672. /**
  53673. * How big in texel of the blur texture is the vertical blur.
  53674. */
  53675. blurVerticalSize: number;
  53676. /**
  53677. * How big in texel of the blur texture is the horizontal blur.
  53678. */
  53679. blurHorizontalSize: number;
  53680. /**
  53681. * Alpha blending mode used to apply the blur. Default is combine.
  53682. */
  53683. alphaBlendingMode: number;
  53684. /**
  53685. * The camera attached to the layer.
  53686. */
  53687. camera: Nullable<Camera>;
  53688. /**
  53689. * Should we display highlight as a solid stroke?
  53690. */
  53691. isStroke?: boolean;
  53692. /**
  53693. * The rendering group to draw the layer in.
  53694. */
  53695. renderingGroupId: number;
  53696. }
  53697. /**
  53698. * The highlight layer Helps adding a glow effect around a mesh.
  53699. *
  53700. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53701. * glowy meshes to your scene.
  53702. *
  53703. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53704. */
  53705. export class HighlightLayer extends EffectLayer {
  53706. name: string;
  53707. /**
  53708. * Effect Name of the highlight layer.
  53709. */
  53710. static readonly EffectName: string;
  53711. /**
  53712. * The neutral color used during the preparation of the glow effect.
  53713. * This is black by default as the blend operation is a blend operation.
  53714. */
  53715. static NeutralColor: Color4;
  53716. /**
  53717. * Stencil value used for glowing meshes.
  53718. */
  53719. static GlowingMeshStencilReference: number;
  53720. /**
  53721. * Stencil value used for the other meshes in the scene.
  53722. */
  53723. static NormalMeshStencilReference: number;
  53724. /**
  53725. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53726. */
  53727. innerGlow: boolean;
  53728. /**
  53729. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53730. */
  53731. outerGlow: boolean;
  53732. /**
  53733. * Specifies the horizontal size of the blur.
  53734. */
  53735. set blurHorizontalSize(value: number);
  53736. /**
  53737. * Specifies the vertical size of the blur.
  53738. */
  53739. set blurVerticalSize(value: number);
  53740. /**
  53741. * Gets the horizontal size of the blur.
  53742. */
  53743. get blurHorizontalSize(): number;
  53744. /**
  53745. * Gets the vertical size of the blur.
  53746. */
  53747. get blurVerticalSize(): number;
  53748. /**
  53749. * An event triggered when the highlight layer is being blurred.
  53750. */
  53751. onBeforeBlurObservable: Observable<HighlightLayer>;
  53752. /**
  53753. * An event triggered when the highlight layer has been blurred.
  53754. */
  53755. onAfterBlurObservable: Observable<HighlightLayer>;
  53756. private _instanceGlowingMeshStencilReference;
  53757. private _options;
  53758. private _downSamplePostprocess;
  53759. private _horizontalBlurPostprocess;
  53760. private _verticalBlurPostprocess;
  53761. private _blurTexture;
  53762. private _meshes;
  53763. private _excludedMeshes;
  53764. /**
  53765. * Instantiates a new highlight Layer and references it to the scene..
  53766. * @param name The name of the layer
  53767. * @param scene The scene to use the layer in
  53768. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53769. */
  53770. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53771. /**
  53772. * Get the effect name of the layer.
  53773. * @return The effect name
  53774. */
  53775. getEffectName(): string;
  53776. /**
  53777. * Create the merge effect. This is the shader use to blit the information back
  53778. * to the main canvas at the end of the scene rendering.
  53779. */
  53780. protected _createMergeEffect(): Effect;
  53781. /**
  53782. * Creates the render target textures and post processes used in the highlight layer.
  53783. */
  53784. protected _createTextureAndPostProcesses(): void;
  53785. /**
  53786. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53787. */
  53788. needStencil(): boolean;
  53789. /**
  53790. * Checks for the readiness of the element composing the layer.
  53791. * @param subMesh the mesh to check for
  53792. * @param useInstances specify wether or not to use instances to render the mesh
  53793. * @param emissiveTexture the associated emissive texture used to generate the glow
  53794. * @return true if ready otherwise, false
  53795. */
  53796. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53797. /**
  53798. * Implementation specific of rendering the generating effect on the main canvas.
  53799. * @param effect The effect used to render through
  53800. */
  53801. protected _internalRender(effect: Effect): void;
  53802. /**
  53803. * Returns true if the layer contains information to display, otherwise false.
  53804. */
  53805. shouldRender(): boolean;
  53806. /**
  53807. * Returns true if the mesh should render, otherwise false.
  53808. * @param mesh The mesh to render
  53809. * @returns true if it should render otherwise false
  53810. */
  53811. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53812. /**
  53813. * Sets the required values for both the emissive texture and and the main color.
  53814. */
  53815. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53816. /**
  53817. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53818. * @param mesh The mesh to exclude from the highlight layer
  53819. */
  53820. addExcludedMesh(mesh: Mesh): void;
  53821. /**
  53822. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53823. * @param mesh The mesh to highlight
  53824. */
  53825. removeExcludedMesh(mesh: Mesh): void;
  53826. /**
  53827. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53828. * @param mesh mesh to test
  53829. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53830. */
  53831. hasMesh(mesh: AbstractMesh): boolean;
  53832. /**
  53833. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53834. * @param mesh The mesh to highlight
  53835. * @param color The color of the highlight
  53836. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53837. */
  53838. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53839. /**
  53840. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53841. * @param mesh The mesh to highlight
  53842. */
  53843. removeMesh(mesh: Mesh): void;
  53844. /**
  53845. * Force the stencil to the normal expected value for none glowing parts
  53846. */
  53847. private _defaultStencilReference;
  53848. /**
  53849. * Free any resources and references associated to a mesh.
  53850. * Internal use
  53851. * @param mesh The mesh to free.
  53852. * @hidden
  53853. */
  53854. _disposeMesh(mesh: Mesh): void;
  53855. /**
  53856. * Dispose the highlight layer and free resources.
  53857. */
  53858. dispose(): void;
  53859. /**
  53860. * Gets the class name of the effect layer
  53861. * @returns the string with the class name of the effect layer
  53862. */
  53863. getClassName(): string;
  53864. /**
  53865. * Serializes this Highlight layer
  53866. * @returns a serialized Highlight layer object
  53867. */
  53868. serialize(): any;
  53869. /**
  53870. * Creates a Highlight layer from parsed Highlight layer data
  53871. * @param parsedHightlightLayer defines the Highlight layer data
  53872. * @param scene defines the current scene
  53873. * @param rootUrl defines the root URL containing the Highlight layer information
  53874. * @returns a parsed Highlight layer
  53875. */
  53876. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53877. }
  53878. }
  53879. declare module BABYLON {
  53880. interface AbstractScene {
  53881. /**
  53882. * The list of layers (background and foreground) of the scene
  53883. */
  53884. layers: Array<Layer>;
  53885. }
  53886. /**
  53887. * Defines the layer scene component responsible to manage any layers
  53888. * in a given scene.
  53889. */
  53890. export class LayerSceneComponent implements ISceneComponent {
  53891. /**
  53892. * The component name helpfull to identify the component in the list of scene components.
  53893. */
  53894. readonly name: string;
  53895. /**
  53896. * The scene the component belongs to.
  53897. */
  53898. scene: Scene;
  53899. private _engine;
  53900. /**
  53901. * Creates a new instance of the component for the given scene
  53902. * @param scene Defines the scene to register the component in
  53903. */
  53904. constructor(scene: Scene);
  53905. /**
  53906. * Registers the component in a given scene
  53907. */
  53908. register(): void;
  53909. /**
  53910. * Rebuilds the elements related to this component in case of
  53911. * context lost for instance.
  53912. */
  53913. rebuild(): void;
  53914. /**
  53915. * Disposes the component and the associated ressources.
  53916. */
  53917. dispose(): void;
  53918. private _draw;
  53919. private _drawCameraPredicate;
  53920. private _drawCameraBackground;
  53921. private _drawCameraForeground;
  53922. private _drawRenderTargetPredicate;
  53923. private _drawRenderTargetBackground;
  53924. private _drawRenderTargetForeground;
  53925. /**
  53926. * Adds all the elements from the container to the scene
  53927. * @param container the container holding the elements
  53928. */
  53929. addFromContainer(container: AbstractScene): void;
  53930. /**
  53931. * Removes all the elements in the container from the scene
  53932. * @param container contains the elements to remove
  53933. * @param dispose if the removed element should be disposed (default: false)
  53934. */
  53935. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53936. }
  53937. }
  53938. declare module BABYLON {
  53939. /** @hidden */
  53940. export var layerPixelShader: {
  53941. name: string;
  53942. shader: string;
  53943. };
  53944. }
  53945. declare module BABYLON {
  53946. /** @hidden */
  53947. export var layerVertexShader: {
  53948. name: string;
  53949. shader: string;
  53950. };
  53951. }
  53952. declare module BABYLON {
  53953. /**
  53954. * This represents a full screen 2d layer.
  53955. * This can be useful to display a picture in the background of your scene for instance.
  53956. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53957. */
  53958. export class Layer {
  53959. /**
  53960. * Define the name of the layer.
  53961. */
  53962. name: string;
  53963. /**
  53964. * Define the texture the layer should display.
  53965. */
  53966. texture: Nullable<Texture>;
  53967. /**
  53968. * Is the layer in background or foreground.
  53969. */
  53970. isBackground: boolean;
  53971. /**
  53972. * Define the color of the layer (instead of texture).
  53973. */
  53974. color: Color4;
  53975. /**
  53976. * Define the scale of the layer in order to zoom in out of the texture.
  53977. */
  53978. scale: Vector2;
  53979. /**
  53980. * Define an offset for the layer in order to shift the texture.
  53981. */
  53982. offset: Vector2;
  53983. /**
  53984. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53985. */
  53986. alphaBlendingMode: number;
  53987. /**
  53988. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53989. * Alpha test will not mix with the background color in case of transparency.
  53990. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53991. */
  53992. alphaTest: boolean;
  53993. /**
  53994. * Define a mask to restrict the layer to only some of the scene cameras.
  53995. */
  53996. layerMask: number;
  53997. /**
  53998. * Define the list of render target the layer is visible into.
  53999. */
  54000. renderTargetTextures: RenderTargetTexture[];
  54001. /**
  54002. * Define if the layer is only used in renderTarget or if it also
  54003. * renders in the main frame buffer of the canvas.
  54004. */
  54005. renderOnlyInRenderTargetTextures: boolean;
  54006. private _scene;
  54007. private _vertexBuffers;
  54008. private _indexBuffer;
  54009. private _effect;
  54010. private _previousDefines;
  54011. /**
  54012. * An event triggered when the layer is disposed.
  54013. */
  54014. onDisposeObservable: Observable<Layer>;
  54015. private _onDisposeObserver;
  54016. /**
  54017. * Back compatibility with callback before the onDisposeObservable existed.
  54018. * The set callback will be triggered when the layer has been disposed.
  54019. */
  54020. set onDispose(callback: () => void);
  54021. /**
  54022. * An event triggered before rendering the scene
  54023. */
  54024. onBeforeRenderObservable: Observable<Layer>;
  54025. private _onBeforeRenderObserver;
  54026. /**
  54027. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54028. * The set callback will be triggered just before rendering the layer.
  54029. */
  54030. set onBeforeRender(callback: () => void);
  54031. /**
  54032. * An event triggered after rendering the scene
  54033. */
  54034. onAfterRenderObservable: Observable<Layer>;
  54035. private _onAfterRenderObserver;
  54036. /**
  54037. * Back compatibility with callback before the onAfterRenderObservable existed.
  54038. * The set callback will be triggered just after rendering the layer.
  54039. */
  54040. set onAfterRender(callback: () => void);
  54041. /**
  54042. * Instantiates a new layer.
  54043. * This represents a full screen 2d layer.
  54044. * This can be useful to display a picture in the background of your scene for instance.
  54045. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54046. * @param name Define the name of the layer in the scene
  54047. * @param imgUrl Define the url of the texture to display in the layer
  54048. * @param scene Define the scene the layer belongs to
  54049. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54050. * @param color Defines a color for the layer
  54051. */
  54052. constructor(
  54053. /**
  54054. * Define the name of the layer.
  54055. */
  54056. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54057. private _createIndexBuffer;
  54058. /** @hidden */
  54059. _rebuild(): void;
  54060. /**
  54061. * Renders the layer in the scene.
  54062. */
  54063. render(): void;
  54064. /**
  54065. * Disposes and releases the associated ressources.
  54066. */
  54067. dispose(): void;
  54068. }
  54069. }
  54070. declare module BABYLON {
  54071. /** @hidden */
  54072. export var lensFlarePixelShader: {
  54073. name: string;
  54074. shader: string;
  54075. };
  54076. }
  54077. declare module BABYLON {
  54078. /** @hidden */
  54079. export var lensFlareVertexShader: {
  54080. name: string;
  54081. shader: string;
  54082. };
  54083. }
  54084. declare module BABYLON {
  54085. /**
  54086. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54087. * It is usually composed of several `lensFlare`.
  54088. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54089. */
  54090. export class LensFlareSystem {
  54091. /**
  54092. * Define the name of the lens flare system
  54093. */
  54094. name: string;
  54095. /**
  54096. * List of lens flares used in this system.
  54097. */
  54098. lensFlares: LensFlare[];
  54099. /**
  54100. * Define a limit from the border the lens flare can be visible.
  54101. */
  54102. borderLimit: number;
  54103. /**
  54104. * Define a viewport border we do not want to see the lens flare in.
  54105. */
  54106. viewportBorder: number;
  54107. /**
  54108. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54109. */
  54110. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54111. /**
  54112. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54113. */
  54114. layerMask: number;
  54115. /**
  54116. * Define the id of the lens flare system in the scene.
  54117. * (equal to name by default)
  54118. */
  54119. id: string;
  54120. private _scene;
  54121. private _emitter;
  54122. private _vertexBuffers;
  54123. private _indexBuffer;
  54124. private _effect;
  54125. private _positionX;
  54126. private _positionY;
  54127. private _isEnabled;
  54128. /** @hidden */
  54129. static _SceneComponentInitialization: (scene: Scene) => void;
  54130. /**
  54131. * Instantiates a lens flare system.
  54132. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54133. * It is usually composed of several `lensFlare`.
  54134. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54135. * @param name Define the name of the lens flare system in the scene
  54136. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54137. * @param scene Define the scene the lens flare system belongs to
  54138. */
  54139. constructor(
  54140. /**
  54141. * Define the name of the lens flare system
  54142. */
  54143. name: string, emitter: any, scene: Scene);
  54144. /**
  54145. * Define if the lens flare system is enabled.
  54146. */
  54147. get isEnabled(): boolean;
  54148. set isEnabled(value: boolean);
  54149. /**
  54150. * Get the scene the effects belongs to.
  54151. * @returns the scene holding the lens flare system
  54152. */
  54153. getScene(): Scene;
  54154. /**
  54155. * Get the emitter of the lens flare system.
  54156. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54157. * @returns the emitter of the lens flare system
  54158. */
  54159. getEmitter(): any;
  54160. /**
  54161. * Set the emitter of the lens flare system.
  54162. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54163. * @param newEmitter Define the new emitter of the system
  54164. */
  54165. setEmitter(newEmitter: any): void;
  54166. /**
  54167. * Get the lens flare system emitter position.
  54168. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54169. * @returns the position
  54170. */
  54171. getEmitterPosition(): Vector3;
  54172. /**
  54173. * @hidden
  54174. */
  54175. computeEffectivePosition(globalViewport: Viewport): boolean;
  54176. /** @hidden */
  54177. _isVisible(): boolean;
  54178. /**
  54179. * @hidden
  54180. */
  54181. render(): boolean;
  54182. /**
  54183. * Dispose and release the lens flare with its associated resources.
  54184. */
  54185. dispose(): void;
  54186. /**
  54187. * Parse a lens flare system from a JSON repressentation
  54188. * @param parsedLensFlareSystem Define the JSON to parse
  54189. * @param scene Define the scene the parsed system should be instantiated in
  54190. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54191. * @returns the parsed system
  54192. */
  54193. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54194. /**
  54195. * Serialize the current Lens Flare System into a JSON representation.
  54196. * @returns the serialized JSON
  54197. */
  54198. serialize(): any;
  54199. }
  54200. }
  54201. declare module BABYLON {
  54202. /**
  54203. * This represents one of the lens effect in a `lensFlareSystem`.
  54204. * It controls one of the indiviual texture used in the effect.
  54205. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54206. */
  54207. export class LensFlare {
  54208. /**
  54209. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54210. */
  54211. size: number;
  54212. /**
  54213. * 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.
  54214. */
  54215. position: number;
  54216. /**
  54217. * Define the lens color.
  54218. */
  54219. color: Color3;
  54220. /**
  54221. * Define the lens texture.
  54222. */
  54223. texture: Nullable<Texture>;
  54224. /**
  54225. * Define the alpha mode to render this particular lens.
  54226. */
  54227. alphaMode: number;
  54228. private _system;
  54229. /**
  54230. * Creates a new Lens Flare.
  54231. * This represents one of the lens effect in a `lensFlareSystem`.
  54232. * It controls one of the indiviual texture used in the effect.
  54233. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54234. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54235. * @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.
  54236. * @param color Define the lens color
  54237. * @param imgUrl Define the lens texture url
  54238. * @param system Define the `lensFlareSystem` this flare is part of
  54239. * @returns The newly created Lens Flare
  54240. */
  54241. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54242. /**
  54243. * Instantiates a new Lens Flare.
  54244. * This represents one of the lens effect in a `lensFlareSystem`.
  54245. * It controls one of the indiviual texture used in the effect.
  54246. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54247. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54248. * @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.
  54249. * @param color Define the lens color
  54250. * @param imgUrl Define the lens texture url
  54251. * @param system Define the `lensFlareSystem` this flare is part of
  54252. */
  54253. constructor(
  54254. /**
  54255. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54256. */
  54257. size: number,
  54258. /**
  54259. * 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.
  54260. */
  54261. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54262. /**
  54263. * Dispose and release the lens flare with its associated resources.
  54264. */
  54265. dispose(): void;
  54266. }
  54267. }
  54268. declare module BABYLON {
  54269. interface AbstractScene {
  54270. /**
  54271. * The list of lens flare system added to the scene
  54272. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54273. */
  54274. lensFlareSystems: Array<LensFlareSystem>;
  54275. /**
  54276. * Removes the given lens flare system from this scene.
  54277. * @param toRemove The lens flare system to remove
  54278. * @returns The index of the removed lens flare system
  54279. */
  54280. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54281. /**
  54282. * Adds the given lens flare system to this scene
  54283. * @param newLensFlareSystem The lens flare system to add
  54284. */
  54285. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54286. /**
  54287. * Gets a lens flare system using its name
  54288. * @param name defines the name to look for
  54289. * @returns the lens flare system or null if not found
  54290. */
  54291. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54292. /**
  54293. * Gets a lens flare system using its id
  54294. * @param id defines the id to look for
  54295. * @returns the lens flare system or null if not found
  54296. */
  54297. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54298. }
  54299. /**
  54300. * Defines the lens flare scene component responsible to manage any lens flares
  54301. * in a given scene.
  54302. */
  54303. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54304. /**
  54305. * The component name helpfull to identify the component in the list of scene components.
  54306. */
  54307. readonly name: string;
  54308. /**
  54309. * The scene the component belongs to.
  54310. */
  54311. scene: Scene;
  54312. /**
  54313. * Creates a new instance of the component for the given scene
  54314. * @param scene Defines the scene to register the component in
  54315. */
  54316. constructor(scene: Scene);
  54317. /**
  54318. * Registers the component in a given scene
  54319. */
  54320. register(): void;
  54321. /**
  54322. * Rebuilds the elements related to this component in case of
  54323. * context lost for instance.
  54324. */
  54325. rebuild(): void;
  54326. /**
  54327. * Adds all the elements from the container to the scene
  54328. * @param container the container holding the elements
  54329. */
  54330. addFromContainer(container: AbstractScene): void;
  54331. /**
  54332. * Removes all the elements in the container from the scene
  54333. * @param container contains the elements to remove
  54334. * @param dispose if the removed element should be disposed (default: false)
  54335. */
  54336. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54337. /**
  54338. * Serializes the component data to the specified json object
  54339. * @param serializationObject The object to serialize to
  54340. */
  54341. serialize(serializationObject: any): void;
  54342. /**
  54343. * Disposes the component and the associated ressources.
  54344. */
  54345. dispose(): void;
  54346. private _draw;
  54347. }
  54348. }
  54349. declare module BABYLON {
  54350. /** @hidden */
  54351. export var depthPixelShader: {
  54352. name: string;
  54353. shader: string;
  54354. };
  54355. }
  54356. declare module BABYLON {
  54357. /** @hidden */
  54358. export var depthVertexShader: {
  54359. name: string;
  54360. shader: string;
  54361. };
  54362. }
  54363. declare module BABYLON {
  54364. /**
  54365. * This represents a depth renderer in Babylon.
  54366. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54367. */
  54368. export class DepthRenderer {
  54369. private _scene;
  54370. private _depthMap;
  54371. private _effect;
  54372. private readonly _storeNonLinearDepth;
  54373. private readonly _clearColor;
  54374. /** Get if the depth renderer is using packed depth or not */
  54375. readonly isPacked: boolean;
  54376. private _cachedDefines;
  54377. private _camera;
  54378. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54379. enabled: boolean;
  54380. /**
  54381. * Specifiess that the depth renderer will only be used within
  54382. * the camera it is created for.
  54383. * This can help forcing its rendering during the camera processing.
  54384. */
  54385. useOnlyInActiveCamera: boolean;
  54386. /** @hidden */
  54387. static _SceneComponentInitialization: (scene: Scene) => void;
  54388. /**
  54389. * Instantiates a depth renderer
  54390. * @param scene The scene the renderer belongs to
  54391. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54392. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54393. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54394. */
  54395. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54396. /**
  54397. * Creates the depth rendering effect and checks if the effect is ready.
  54398. * @param subMesh The submesh to be used to render the depth map of
  54399. * @param useInstances If multiple world instances should be used
  54400. * @returns if the depth renderer is ready to render the depth map
  54401. */
  54402. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54403. /**
  54404. * Gets the texture which the depth map will be written to.
  54405. * @returns The depth map texture
  54406. */
  54407. getDepthMap(): RenderTargetTexture;
  54408. /**
  54409. * Disposes of the depth renderer.
  54410. */
  54411. dispose(): void;
  54412. }
  54413. }
  54414. declare module BABYLON {
  54415. /** @hidden */
  54416. export var minmaxReduxPixelShader: {
  54417. name: string;
  54418. shader: string;
  54419. };
  54420. }
  54421. declare module BABYLON {
  54422. /**
  54423. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54424. * and maximum values from all values of the texture.
  54425. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54426. * The source values are read from the red channel of the texture.
  54427. */
  54428. export class MinMaxReducer {
  54429. /**
  54430. * Observable triggered when the computation has been performed
  54431. */
  54432. onAfterReductionPerformed: Observable<{
  54433. min: number;
  54434. max: number;
  54435. }>;
  54436. protected _camera: Camera;
  54437. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54438. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54439. protected _postProcessManager: PostProcessManager;
  54440. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54441. protected _forceFullscreenViewport: boolean;
  54442. /**
  54443. * Creates a min/max reducer
  54444. * @param camera The camera to use for the post processes
  54445. */
  54446. constructor(camera: Camera);
  54447. /**
  54448. * Gets the texture used to read the values from.
  54449. */
  54450. get sourceTexture(): Nullable<RenderTargetTexture>;
  54451. /**
  54452. * Sets the source texture to read the values from.
  54453. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54454. * because in such textures '1' value must not be taken into account to compute the maximum
  54455. * as this value is used to clear the texture.
  54456. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54457. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54458. * @param depthRedux Indicates if the texture is a depth texture or not
  54459. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54460. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54461. */
  54462. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54463. /**
  54464. * Defines the refresh rate of the computation.
  54465. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54466. */
  54467. get refreshRate(): number;
  54468. set refreshRate(value: number);
  54469. protected _activated: boolean;
  54470. /**
  54471. * Gets the activation status of the reducer
  54472. */
  54473. get activated(): boolean;
  54474. /**
  54475. * Activates the reduction computation.
  54476. * When activated, the observers registered in onAfterReductionPerformed are
  54477. * called after the compuation is performed
  54478. */
  54479. activate(): void;
  54480. /**
  54481. * Deactivates the reduction computation.
  54482. */
  54483. deactivate(): void;
  54484. /**
  54485. * Disposes the min/max reducer
  54486. * @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.
  54487. */
  54488. dispose(disposeAll?: boolean): void;
  54489. }
  54490. }
  54491. declare module BABYLON {
  54492. /**
  54493. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54494. */
  54495. export class DepthReducer extends MinMaxReducer {
  54496. private _depthRenderer;
  54497. private _depthRendererId;
  54498. /**
  54499. * Gets the depth renderer used for the computation.
  54500. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54501. */
  54502. get depthRenderer(): Nullable<DepthRenderer>;
  54503. /**
  54504. * Creates a depth reducer
  54505. * @param camera The camera used to render the depth texture
  54506. */
  54507. constructor(camera: Camera);
  54508. /**
  54509. * Sets the depth renderer to use to generate the depth map
  54510. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54511. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54512. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54513. */
  54514. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54515. /** @hidden */
  54516. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54517. /**
  54518. * Activates the reduction computation.
  54519. * When activated, the observers registered in onAfterReductionPerformed are
  54520. * called after the compuation is performed
  54521. */
  54522. activate(): void;
  54523. /**
  54524. * Deactivates the reduction computation.
  54525. */
  54526. deactivate(): void;
  54527. /**
  54528. * Disposes the depth reducer
  54529. * @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.
  54530. */
  54531. dispose(disposeAll?: boolean): void;
  54532. }
  54533. }
  54534. declare module BABYLON {
  54535. /**
  54536. * A CSM implementation allowing casting shadows on large scenes.
  54537. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54538. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54539. */
  54540. export class CascadedShadowGenerator extends ShadowGenerator {
  54541. private static readonly frustumCornersNDCSpace;
  54542. /**
  54543. * Name of the CSM class
  54544. */
  54545. static CLASSNAME: string;
  54546. /**
  54547. * Defines the default number of cascades used by the CSM.
  54548. */
  54549. static readonly DEFAULT_CASCADES_COUNT: number;
  54550. /**
  54551. * Defines the minimum number of cascades used by the CSM.
  54552. */
  54553. static readonly MIN_CASCADES_COUNT: number;
  54554. /**
  54555. * Defines the maximum number of cascades used by the CSM.
  54556. */
  54557. static readonly MAX_CASCADES_COUNT: number;
  54558. protected _validateFilter(filter: number): number;
  54559. /**
  54560. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54561. */
  54562. penumbraDarkness: number;
  54563. private _numCascades;
  54564. /**
  54565. * Gets or set the number of cascades used by the CSM.
  54566. */
  54567. get numCascades(): number;
  54568. set numCascades(value: number);
  54569. /**
  54570. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54571. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54572. */
  54573. stabilizeCascades: boolean;
  54574. private _freezeShadowCastersBoundingInfo;
  54575. private _freezeShadowCastersBoundingInfoObservable;
  54576. /**
  54577. * Enables or disables the shadow casters bounding info computation.
  54578. * If your shadow casters don't move, you can disable this feature.
  54579. * If it is enabled, the bounding box computation is done every frame.
  54580. */
  54581. get freezeShadowCastersBoundingInfo(): boolean;
  54582. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54583. private _scbiMin;
  54584. private _scbiMax;
  54585. protected _computeShadowCastersBoundingInfo(): void;
  54586. protected _shadowCastersBoundingInfo: BoundingInfo;
  54587. /**
  54588. * Gets or sets the shadow casters bounding info.
  54589. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54590. * so that the system won't overwrite the bounds you provide
  54591. */
  54592. get shadowCastersBoundingInfo(): BoundingInfo;
  54593. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54594. protected _breaksAreDirty: boolean;
  54595. protected _minDistance: number;
  54596. protected _maxDistance: number;
  54597. /**
  54598. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54599. *
  54600. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54601. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54602. * @param min minimal distance for the breaks (default to 0.)
  54603. * @param max maximal distance for the breaks (default to 1.)
  54604. */
  54605. setMinMaxDistance(min: number, max: number): void;
  54606. /** Gets the minimal distance used in the cascade break computation */
  54607. get minDistance(): number;
  54608. /** Gets the maximal distance used in the cascade break computation */
  54609. get maxDistance(): number;
  54610. /**
  54611. * Gets the class name of that object
  54612. * @returns "CascadedShadowGenerator"
  54613. */
  54614. getClassName(): string;
  54615. private _cascadeMinExtents;
  54616. private _cascadeMaxExtents;
  54617. /**
  54618. * Gets a cascade minimum extents
  54619. * @param cascadeIndex index of the cascade
  54620. * @returns the minimum cascade extents
  54621. */
  54622. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54623. /**
  54624. * Gets a cascade maximum extents
  54625. * @param cascadeIndex index of the cascade
  54626. * @returns the maximum cascade extents
  54627. */
  54628. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54629. private _cascades;
  54630. private _currentLayer;
  54631. private _viewSpaceFrustumsZ;
  54632. private _viewMatrices;
  54633. private _projectionMatrices;
  54634. private _transformMatrices;
  54635. private _transformMatricesAsArray;
  54636. private _frustumLengths;
  54637. private _lightSizeUVCorrection;
  54638. private _depthCorrection;
  54639. private _frustumCornersWorldSpace;
  54640. private _frustumCenter;
  54641. private _shadowCameraPos;
  54642. private _shadowMaxZ;
  54643. /**
  54644. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54645. * It defaults to camera.maxZ
  54646. */
  54647. get shadowMaxZ(): number;
  54648. /**
  54649. * Sets the shadow max z distance.
  54650. */
  54651. set shadowMaxZ(value: number);
  54652. protected _debug: boolean;
  54653. /**
  54654. * Gets or sets the debug flag.
  54655. * When enabled, the cascades are materialized by different colors on the screen.
  54656. */
  54657. get debug(): boolean;
  54658. set debug(dbg: boolean);
  54659. private _depthClamp;
  54660. /**
  54661. * Gets or sets the depth clamping value.
  54662. *
  54663. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54664. * to account for the shadow casters far away.
  54665. *
  54666. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54667. */
  54668. get depthClamp(): boolean;
  54669. set depthClamp(value: boolean);
  54670. private _cascadeBlendPercentage;
  54671. /**
  54672. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54673. * It defaults to 0.1 (10% blending).
  54674. */
  54675. get cascadeBlendPercentage(): number;
  54676. set cascadeBlendPercentage(value: number);
  54677. private _lambda;
  54678. /**
  54679. * Gets or set the lambda parameter.
  54680. * This parameter is used to split the camera frustum and create the cascades.
  54681. * 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.
  54682. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54683. */
  54684. get lambda(): number;
  54685. set lambda(value: number);
  54686. /**
  54687. * Gets the view matrix corresponding to a given cascade
  54688. * @param cascadeNum cascade to retrieve the view matrix from
  54689. * @returns the cascade view matrix
  54690. */
  54691. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54692. /**
  54693. * Gets the projection matrix corresponding to a given cascade
  54694. * @param cascadeNum cascade to retrieve the projection matrix from
  54695. * @returns the cascade projection matrix
  54696. */
  54697. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54698. /**
  54699. * Gets the transformation matrix corresponding to a given cascade
  54700. * @param cascadeNum cascade to retrieve the transformation matrix from
  54701. * @returns the cascade transformation matrix
  54702. */
  54703. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54704. private _depthRenderer;
  54705. /**
  54706. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54707. *
  54708. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54709. *
  54710. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54711. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54712. * @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
  54713. */
  54714. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54715. private _depthReducer;
  54716. private _autoCalcDepthBounds;
  54717. /**
  54718. * Gets or sets the autoCalcDepthBounds property.
  54719. *
  54720. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54721. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54722. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54723. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54724. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54725. */
  54726. get autoCalcDepthBounds(): boolean;
  54727. set autoCalcDepthBounds(value: boolean);
  54728. /**
  54729. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54730. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54731. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54732. * for setting the refresh rate on the renderer yourself!
  54733. */
  54734. get autoCalcDepthBoundsRefreshRate(): number;
  54735. set autoCalcDepthBoundsRefreshRate(value: number);
  54736. /**
  54737. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54738. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54739. * you change the camera near/far planes!
  54740. */
  54741. splitFrustum(): void;
  54742. private _splitFrustum;
  54743. private _computeMatrices;
  54744. private _computeFrustumInWorldSpace;
  54745. private _computeCascadeFrustum;
  54746. /** @hidden */
  54747. static _SceneComponentInitialization: (scene: Scene) => void;
  54748. /**
  54749. * Creates a Cascaded Shadow Generator object.
  54750. * A ShadowGenerator is the required tool to use the shadows.
  54751. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54752. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54753. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54754. * @param light The directional light object generating the shadows.
  54755. * @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.
  54756. */
  54757. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54758. protected _initializeGenerator(): void;
  54759. protected _createTargetRenderTexture(): void;
  54760. protected _initializeShadowMap(): void;
  54761. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54762. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54763. /**
  54764. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54765. * @param defines Defines of the material we want to update
  54766. * @param lightIndex Index of the light in the enabled light list of the material
  54767. */
  54768. prepareDefines(defines: any, lightIndex: number): void;
  54769. /**
  54770. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54771. * defined in the generator but impacting the effect).
  54772. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54773. * @param effect The effect we are binfing the information for
  54774. */
  54775. bindShadowLight(lightIndex: string, effect: Effect): void;
  54776. /**
  54777. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54778. * (eq to view projection * shadow projection matrices)
  54779. * @returns The transform matrix used to create the shadow map
  54780. */
  54781. getTransformMatrix(): Matrix;
  54782. /**
  54783. * Disposes the ShadowGenerator.
  54784. * Returns nothing.
  54785. */
  54786. dispose(): void;
  54787. /**
  54788. * Serializes the shadow generator setup to a json object.
  54789. * @returns The serialized JSON object
  54790. */
  54791. serialize(): any;
  54792. /**
  54793. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54794. * @param parsedShadowGenerator The JSON object to parse
  54795. * @param scene The scene to create the shadow map for
  54796. * @returns The parsed shadow generator
  54797. */
  54798. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54799. }
  54800. }
  54801. declare module BABYLON {
  54802. /**
  54803. * Defines the shadow generator component responsible to manage any shadow generators
  54804. * in a given scene.
  54805. */
  54806. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54807. /**
  54808. * The component name helpfull to identify the component in the list of scene components.
  54809. */
  54810. readonly name: string;
  54811. /**
  54812. * The scene the component belongs to.
  54813. */
  54814. scene: Scene;
  54815. /**
  54816. * Creates a new instance of the component for the given scene
  54817. * @param scene Defines the scene to register the component in
  54818. */
  54819. constructor(scene: Scene);
  54820. /**
  54821. * Registers the component in a given scene
  54822. */
  54823. register(): void;
  54824. /**
  54825. * Rebuilds the elements related to this component in case of
  54826. * context lost for instance.
  54827. */
  54828. rebuild(): void;
  54829. /**
  54830. * Serializes the component data to the specified json object
  54831. * @param serializationObject The object to serialize to
  54832. */
  54833. serialize(serializationObject: any): void;
  54834. /**
  54835. * Adds all the elements from the container to the scene
  54836. * @param container the container holding the elements
  54837. */
  54838. addFromContainer(container: AbstractScene): void;
  54839. /**
  54840. * Removes all the elements in the container from the scene
  54841. * @param container contains the elements to remove
  54842. * @param dispose if the removed element should be disposed (default: false)
  54843. */
  54844. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54845. /**
  54846. * Rebuilds the elements related to this component in case of
  54847. * context lost for instance.
  54848. */
  54849. dispose(): void;
  54850. private _gatherRenderTargets;
  54851. }
  54852. }
  54853. declare module BABYLON {
  54854. /**
  54855. * A point light is a light defined by an unique point in world space.
  54856. * The light is emitted in every direction from this point.
  54857. * A good example of a point light is a standard light bulb.
  54858. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54859. */
  54860. export class PointLight extends ShadowLight {
  54861. private _shadowAngle;
  54862. /**
  54863. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54864. * This specifies what angle the shadow will use to be created.
  54865. *
  54866. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54867. */
  54868. get shadowAngle(): number;
  54869. /**
  54870. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54871. * This specifies what angle the shadow will use to be created.
  54872. *
  54873. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54874. */
  54875. set shadowAngle(value: number);
  54876. /**
  54877. * Gets the direction if it has been set.
  54878. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54879. */
  54880. get direction(): Vector3;
  54881. /**
  54882. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54883. */
  54884. set direction(value: Vector3);
  54885. /**
  54886. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54887. * A PointLight emits the light in every direction.
  54888. * It can cast shadows.
  54889. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54890. * ```javascript
  54891. * var pointLight = new PointLight("pl", camera.position, scene);
  54892. * ```
  54893. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54894. * @param name The light friendly name
  54895. * @param position The position of the point light in the scene
  54896. * @param scene The scene the lights belongs to
  54897. */
  54898. constructor(name: string, position: Vector3, scene: Scene);
  54899. /**
  54900. * Returns the string "PointLight"
  54901. * @returns the class name
  54902. */
  54903. getClassName(): string;
  54904. /**
  54905. * Returns the integer 0.
  54906. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54907. */
  54908. getTypeID(): number;
  54909. /**
  54910. * Specifies wether or not the shadowmap should be a cube texture.
  54911. * @returns true if the shadowmap needs to be a cube texture.
  54912. */
  54913. needCube(): boolean;
  54914. /**
  54915. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54916. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54917. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54918. */
  54919. getShadowDirection(faceIndex?: number): Vector3;
  54920. /**
  54921. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54922. * - fov = PI / 2
  54923. * - aspect ratio : 1.0
  54924. * - z-near and far equal to the active camera minZ and maxZ.
  54925. * Returns the PointLight.
  54926. */
  54927. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54928. protected _buildUniformLayout(): void;
  54929. /**
  54930. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54931. * @param effect The effect to update
  54932. * @param lightIndex The index of the light in the effect to update
  54933. * @returns The point light
  54934. */
  54935. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54936. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54937. /**
  54938. * Prepares the list of defines specific to the light type.
  54939. * @param defines the list of defines
  54940. * @param lightIndex defines the index of the light for the effect
  54941. */
  54942. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54943. }
  54944. }
  54945. declare module BABYLON {
  54946. /**
  54947. * Header information of HDR texture files.
  54948. */
  54949. export interface HDRInfo {
  54950. /**
  54951. * The height of the texture in pixels.
  54952. */
  54953. height: number;
  54954. /**
  54955. * The width of the texture in pixels.
  54956. */
  54957. width: number;
  54958. /**
  54959. * The index of the beginning of the data in the binary file.
  54960. */
  54961. dataPosition: number;
  54962. }
  54963. /**
  54964. * This groups tools to convert HDR texture to native colors array.
  54965. */
  54966. export class HDRTools {
  54967. private static Ldexp;
  54968. private static Rgbe2float;
  54969. private static readStringLine;
  54970. /**
  54971. * Reads header information from an RGBE texture stored in a native array.
  54972. * More information on this format are available here:
  54973. * https://en.wikipedia.org/wiki/RGBE_image_format
  54974. *
  54975. * @param uint8array The binary file stored in native array.
  54976. * @return The header information.
  54977. */
  54978. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54979. /**
  54980. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54981. * This RGBE texture needs to store the information as a panorama.
  54982. *
  54983. * More information on this format are available here:
  54984. * https://en.wikipedia.org/wiki/RGBE_image_format
  54985. *
  54986. * @param buffer The binary file stored in an array buffer.
  54987. * @param size The expected size of the extracted cubemap.
  54988. * @return The Cube Map information.
  54989. */
  54990. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54991. /**
  54992. * Returns the pixels data extracted from an RGBE texture.
  54993. * This pixels will be stored left to right up to down in the R G B order in one array.
  54994. *
  54995. * More information on this format are available here:
  54996. * https://en.wikipedia.org/wiki/RGBE_image_format
  54997. *
  54998. * @param uint8array The binary file stored in an array buffer.
  54999. * @param hdrInfo The header information of the file.
  55000. * @return The pixels data in RGB right to left up to down order.
  55001. */
  55002. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55003. private static RGBE_ReadPixels_RLE;
  55004. }
  55005. }
  55006. declare module BABYLON {
  55007. /**
  55008. * This represents a texture coming from an HDR input.
  55009. *
  55010. * The only supported format is currently panorama picture stored in RGBE format.
  55011. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55012. */
  55013. export class HDRCubeTexture extends BaseTexture {
  55014. private static _facesMapping;
  55015. private _generateHarmonics;
  55016. private _noMipmap;
  55017. private _textureMatrix;
  55018. private _size;
  55019. private _onLoad;
  55020. private _onError;
  55021. /**
  55022. * The texture URL.
  55023. */
  55024. url: string;
  55025. /**
  55026. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55027. */
  55028. coordinatesMode: number;
  55029. protected _isBlocking: boolean;
  55030. /**
  55031. * Sets wether or not the texture is blocking during loading.
  55032. */
  55033. set isBlocking(value: boolean);
  55034. /**
  55035. * Gets wether or not the texture is blocking during loading.
  55036. */
  55037. get isBlocking(): boolean;
  55038. protected _rotationY: number;
  55039. /**
  55040. * Sets texture matrix rotation angle around Y axis in radians.
  55041. */
  55042. set rotationY(value: number);
  55043. /**
  55044. * Gets texture matrix rotation angle around Y axis radians.
  55045. */
  55046. get rotationY(): number;
  55047. /**
  55048. * Gets or sets the center of the bounding box associated with the cube texture
  55049. * It must define where the camera used to render the texture was set
  55050. */
  55051. boundingBoxPosition: Vector3;
  55052. private _boundingBoxSize;
  55053. /**
  55054. * Gets or sets the size of the bounding box associated with the cube texture
  55055. * When defined, the cubemap will switch to local mode
  55056. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55057. * @example https://www.babylonjs-playground.com/#RNASML
  55058. */
  55059. set boundingBoxSize(value: Vector3);
  55060. get boundingBoxSize(): Vector3;
  55061. /**
  55062. * Instantiates an HDRTexture from the following parameters.
  55063. *
  55064. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55065. * @param scene The scene the texture will be used in
  55066. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55067. * @param noMipmap Forces to not generate the mipmap if true
  55068. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55069. * @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)
  55070. * @param reserved Reserved flag for internal use.
  55071. */
  55072. 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>);
  55073. /**
  55074. * Get the current class name of the texture useful for serialization or dynamic coding.
  55075. * @returns "HDRCubeTexture"
  55076. */
  55077. getClassName(): string;
  55078. /**
  55079. * Occurs when the file is raw .hdr file.
  55080. */
  55081. private loadTexture;
  55082. clone(): HDRCubeTexture;
  55083. delayLoad(): void;
  55084. /**
  55085. * Get the texture reflection matrix used to rotate/transform the reflection.
  55086. * @returns the reflection matrix
  55087. */
  55088. getReflectionTextureMatrix(): Matrix;
  55089. /**
  55090. * Set the texture reflection matrix used to rotate/transform the reflection.
  55091. * @param value Define the reflection matrix to set
  55092. */
  55093. setReflectionTextureMatrix(value: Matrix): void;
  55094. /**
  55095. * Parses a JSON representation of an HDR Texture in order to create the texture
  55096. * @param parsedTexture Define the JSON representation
  55097. * @param scene Define the scene the texture should be created in
  55098. * @param rootUrl Define the root url in case we need to load relative dependencies
  55099. * @returns the newly created texture after parsing
  55100. */
  55101. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55102. serialize(): any;
  55103. }
  55104. }
  55105. declare module BABYLON {
  55106. /**
  55107. * Class used to control physics engine
  55108. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55109. */
  55110. export class PhysicsEngine implements IPhysicsEngine {
  55111. private _physicsPlugin;
  55112. /**
  55113. * Global value used to control the smallest number supported by the simulation
  55114. */
  55115. static Epsilon: number;
  55116. private _impostors;
  55117. private _joints;
  55118. private _subTimeStep;
  55119. /**
  55120. * Gets the gravity vector used by the simulation
  55121. */
  55122. gravity: Vector3;
  55123. /**
  55124. * Factory used to create the default physics plugin.
  55125. * @returns The default physics plugin
  55126. */
  55127. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55128. /**
  55129. * Creates a new Physics Engine
  55130. * @param gravity defines the gravity vector used by the simulation
  55131. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55132. */
  55133. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55134. /**
  55135. * Sets the gravity vector used by the simulation
  55136. * @param gravity defines the gravity vector to use
  55137. */
  55138. setGravity(gravity: Vector3): void;
  55139. /**
  55140. * Set the time step of the physics engine.
  55141. * Default is 1/60.
  55142. * To slow it down, enter 1/600 for example.
  55143. * To speed it up, 1/30
  55144. * @param newTimeStep defines the new timestep to apply to this world.
  55145. */
  55146. setTimeStep(newTimeStep?: number): void;
  55147. /**
  55148. * Get the time step of the physics engine.
  55149. * @returns the current time step
  55150. */
  55151. getTimeStep(): number;
  55152. /**
  55153. * Set the sub time step of the physics engine.
  55154. * Default is 0 meaning there is no sub steps
  55155. * To increase physics resolution precision, set a small value (like 1 ms)
  55156. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55157. */
  55158. setSubTimeStep(subTimeStep?: number): void;
  55159. /**
  55160. * Get the sub time step of the physics engine.
  55161. * @returns the current sub time step
  55162. */
  55163. getSubTimeStep(): number;
  55164. /**
  55165. * Release all resources
  55166. */
  55167. dispose(): void;
  55168. /**
  55169. * Gets the name of the current physics plugin
  55170. * @returns the name of the plugin
  55171. */
  55172. getPhysicsPluginName(): string;
  55173. /**
  55174. * Adding a new impostor for the impostor tracking.
  55175. * This will be done by the impostor itself.
  55176. * @param impostor the impostor to add
  55177. */
  55178. addImpostor(impostor: PhysicsImpostor): void;
  55179. /**
  55180. * Remove an impostor from the engine.
  55181. * This impostor and its mesh will not longer be updated by the physics engine.
  55182. * @param impostor the impostor to remove
  55183. */
  55184. removeImpostor(impostor: PhysicsImpostor): void;
  55185. /**
  55186. * Add a joint to the physics engine
  55187. * @param mainImpostor defines the main impostor to which the joint is added.
  55188. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55189. * @param joint defines the joint that will connect both impostors.
  55190. */
  55191. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55192. /**
  55193. * Removes a joint from the simulation
  55194. * @param mainImpostor defines the impostor used with the joint
  55195. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55196. * @param joint defines the joint to remove
  55197. */
  55198. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55199. /**
  55200. * Called by the scene. No need to call it.
  55201. * @param delta defines the timespam between frames
  55202. */
  55203. _step(delta: number): void;
  55204. /**
  55205. * Gets the current plugin used to run the simulation
  55206. * @returns current plugin
  55207. */
  55208. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55209. /**
  55210. * Gets the list of physic impostors
  55211. * @returns an array of PhysicsImpostor
  55212. */
  55213. getImpostors(): Array<PhysicsImpostor>;
  55214. /**
  55215. * Gets the impostor for a physics enabled object
  55216. * @param object defines the object impersonated by the impostor
  55217. * @returns the PhysicsImpostor or null if not found
  55218. */
  55219. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55220. /**
  55221. * Gets the impostor for a physics body object
  55222. * @param body defines physics body used by the impostor
  55223. * @returns the PhysicsImpostor or null if not found
  55224. */
  55225. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55226. /**
  55227. * Does a raycast in the physics world
  55228. * @param from when should the ray start?
  55229. * @param to when should the ray end?
  55230. * @returns PhysicsRaycastResult
  55231. */
  55232. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55233. }
  55234. }
  55235. declare module BABYLON {
  55236. /** @hidden */
  55237. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55238. private _useDeltaForWorldStep;
  55239. world: any;
  55240. name: string;
  55241. private _physicsMaterials;
  55242. private _fixedTimeStep;
  55243. private _cannonRaycastResult;
  55244. private _raycastResult;
  55245. private _physicsBodysToRemoveAfterStep;
  55246. BJSCANNON: any;
  55247. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55248. setGravity(gravity: Vector3): void;
  55249. setTimeStep(timeStep: number): void;
  55250. getTimeStep(): number;
  55251. executeStep(delta: number): void;
  55252. private _removeMarkedPhysicsBodiesFromWorld;
  55253. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55254. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55255. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55256. private _processChildMeshes;
  55257. removePhysicsBody(impostor: PhysicsImpostor): void;
  55258. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55259. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55260. private _addMaterial;
  55261. private _checkWithEpsilon;
  55262. private _createShape;
  55263. private _createHeightmap;
  55264. private _minus90X;
  55265. private _plus90X;
  55266. private _tmpPosition;
  55267. private _tmpDeltaPosition;
  55268. private _tmpUnityRotation;
  55269. private _updatePhysicsBodyTransformation;
  55270. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55271. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55272. isSupported(): boolean;
  55273. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55274. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55275. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55276. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55277. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55278. getBodyMass(impostor: PhysicsImpostor): number;
  55279. getBodyFriction(impostor: PhysicsImpostor): number;
  55280. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55281. getBodyRestitution(impostor: PhysicsImpostor): number;
  55282. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55283. sleepBody(impostor: PhysicsImpostor): void;
  55284. wakeUpBody(impostor: PhysicsImpostor): void;
  55285. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55286. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55287. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55288. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55289. getRadius(impostor: PhysicsImpostor): number;
  55290. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55291. dispose(): void;
  55292. private _extendNamespace;
  55293. /**
  55294. * Does a raycast in the physics world
  55295. * @param from when should the ray start?
  55296. * @param to when should the ray end?
  55297. * @returns PhysicsRaycastResult
  55298. */
  55299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55300. }
  55301. }
  55302. declare module BABYLON {
  55303. /** @hidden */
  55304. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55305. world: any;
  55306. name: string;
  55307. BJSOIMO: any;
  55308. private _raycastResult;
  55309. constructor(iterations?: number, oimoInjection?: any);
  55310. setGravity(gravity: Vector3): void;
  55311. setTimeStep(timeStep: number): void;
  55312. getTimeStep(): number;
  55313. private _tmpImpostorsArray;
  55314. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55315. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55316. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55317. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55318. private _tmpPositionVector;
  55319. removePhysicsBody(impostor: PhysicsImpostor): void;
  55320. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55321. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55322. isSupported(): boolean;
  55323. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55324. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55325. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55326. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55327. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55328. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55329. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55330. getBodyMass(impostor: PhysicsImpostor): number;
  55331. getBodyFriction(impostor: PhysicsImpostor): number;
  55332. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55333. getBodyRestitution(impostor: PhysicsImpostor): number;
  55334. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55335. sleepBody(impostor: PhysicsImpostor): void;
  55336. wakeUpBody(impostor: PhysicsImpostor): void;
  55337. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55338. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55339. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55340. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55341. getRadius(impostor: PhysicsImpostor): number;
  55342. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55343. dispose(): void;
  55344. /**
  55345. * Does a raycast in the physics world
  55346. * @param from when should the ray start?
  55347. * @param to when should the ray end?
  55348. * @returns PhysicsRaycastResult
  55349. */
  55350. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55351. }
  55352. }
  55353. declare module BABYLON {
  55354. /**
  55355. * Class containing static functions to help procedurally build meshes
  55356. */
  55357. export class RibbonBuilder {
  55358. /**
  55359. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55360. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55361. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55362. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55363. * * 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
  55364. * * 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
  55365. * * 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
  55366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55367. * * 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
  55368. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55369. * * 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
  55370. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55371. * * 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
  55372. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55374. * @param name defines the name of the mesh
  55375. * @param options defines the options used to create the mesh
  55376. * @param scene defines the hosting scene
  55377. * @returns the ribbon mesh
  55378. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55379. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55380. */
  55381. static CreateRibbon(name: string, options: {
  55382. pathArray: Vector3[][];
  55383. closeArray?: boolean;
  55384. closePath?: boolean;
  55385. offset?: number;
  55386. updatable?: boolean;
  55387. sideOrientation?: number;
  55388. frontUVs?: Vector4;
  55389. backUVs?: Vector4;
  55390. instance?: Mesh;
  55391. invertUV?: boolean;
  55392. uvs?: Vector2[];
  55393. colors?: Color4[];
  55394. }, scene?: Nullable<Scene>): Mesh;
  55395. }
  55396. }
  55397. declare module BABYLON {
  55398. /**
  55399. * Class containing static functions to help procedurally build meshes
  55400. */
  55401. export class ShapeBuilder {
  55402. /**
  55403. * 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.
  55404. * * 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.
  55405. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55406. * * 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.
  55407. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55408. * * 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
  55409. * * 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
  55410. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55412. * * 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
  55413. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55415. * @param name defines the name of the mesh
  55416. * @param options defines the options used to create the mesh
  55417. * @param scene defines the hosting scene
  55418. * @returns the extruded shape mesh
  55419. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55421. */
  55422. static ExtrudeShape(name: string, options: {
  55423. shape: Vector3[];
  55424. path: Vector3[];
  55425. scale?: number;
  55426. rotation?: number;
  55427. cap?: number;
  55428. updatable?: boolean;
  55429. sideOrientation?: number;
  55430. frontUVs?: Vector4;
  55431. backUVs?: Vector4;
  55432. instance?: Mesh;
  55433. invertUV?: boolean;
  55434. }, scene?: Nullable<Scene>): Mesh;
  55435. /**
  55436. * Creates an custom extruded shape mesh.
  55437. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55438. * * 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.
  55439. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55440. * * 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
  55441. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55442. * * 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
  55443. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55444. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55445. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55446. * * 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
  55447. * * 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
  55448. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55450. * * 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
  55451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55453. * @param name defines the name of the mesh
  55454. * @param options defines the options used to create the mesh
  55455. * @param scene defines the hosting scene
  55456. * @returns the custom extruded shape mesh
  55457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55458. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55460. */
  55461. static ExtrudeShapeCustom(name: string, options: {
  55462. shape: Vector3[];
  55463. path: Vector3[];
  55464. scaleFunction?: any;
  55465. rotationFunction?: any;
  55466. ribbonCloseArray?: boolean;
  55467. ribbonClosePath?: boolean;
  55468. cap?: number;
  55469. updatable?: boolean;
  55470. sideOrientation?: number;
  55471. frontUVs?: Vector4;
  55472. backUVs?: Vector4;
  55473. instance?: Mesh;
  55474. invertUV?: boolean;
  55475. }, scene?: Nullable<Scene>): Mesh;
  55476. private static _ExtrudeShapeGeneric;
  55477. }
  55478. }
  55479. declare module BABYLON {
  55480. /**
  55481. * AmmoJS Physics plugin
  55482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55483. * @see https://github.com/kripken/ammo.js/
  55484. */
  55485. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55486. private _useDeltaForWorldStep;
  55487. /**
  55488. * Reference to the Ammo library
  55489. */
  55490. bjsAMMO: any;
  55491. /**
  55492. * Created ammoJS world which physics bodies are added to
  55493. */
  55494. world: any;
  55495. /**
  55496. * Name of the plugin
  55497. */
  55498. name: string;
  55499. private _timeStep;
  55500. private _fixedTimeStep;
  55501. private _maxSteps;
  55502. private _tmpQuaternion;
  55503. private _tmpAmmoTransform;
  55504. private _tmpAmmoQuaternion;
  55505. private _tmpAmmoConcreteContactResultCallback;
  55506. private _collisionConfiguration;
  55507. private _dispatcher;
  55508. private _overlappingPairCache;
  55509. private _solver;
  55510. private _softBodySolver;
  55511. private _tmpAmmoVectorA;
  55512. private _tmpAmmoVectorB;
  55513. private _tmpAmmoVectorC;
  55514. private _tmpAmmoVectorD;
  55515. private _tmpContactCallbackResult;
  55516. private _tmpAmmoVectorRCA;
  55517. private _tmpAmmoVectorRCB;
  55518. private _raycastResult;
  55519. private static readonly DISABLE_COLLISION_FLAG;
  55520. private static readonly KINEMATIC_FLAG;
  55521. private static readonly DISABLE_DEACTIVATION_FLAG;
  55522. /**
  55523. * Initializes the ammoJS plugin
  55524. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55525. * @param ammoInjection can be used to inject your own ammo reference
  55526. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55527. */
  55528. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55529. /**
  55530. * Sets the gravity of the physics world (m/(s^2))
  55531. * @param gravity Gravity to set
  55532. */
  55533. setGravity(gravity: Vector3): void;
  55534. /**
  55535. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55536. * @param timeStep timestep to use in seconds
  55537. */
  55538. setTimeStep(timeStep: number): void;
  55539. /**
  55540. * 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)
  55541. * @param fixedTimeStep fixedTimeStep to use in seconds
  55542. */
  55543. setFixedTimeStep(fixedTimeStep: number): void;
  55544. /**
  55545. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55546. * @param maxSteps the maximum number of steps by the physics engine per frame
  55547. */
  55548. setMaxSteps(maxSteps: number): void;
  55549. /**
  55550. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55551. * @returns the current timestep in seconds
  55552. */
  55553. getTimeStep(): number;
  55554. /**
  55555. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55556. */
  55557. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55558. private _isImpostorInContact;
  55559. private _isImpostorPairInContact;
  55560. private _stepSimulation;
  55561. /**
  55562. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55563. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55564. * After the step the babylon meshes are set to the position of the physics imposters
  55565. * @param delta amount of time to step forward
  55566. * @param impostors array of imposters to update before/after the step
  55567. */
  55568. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55569. /**
  55570. * Update babylon mesh to match physics world object
  55571. * @param impostor imposter to match
  55572. */
  55573. private _afterSoftStep;
  55574. /**
  55575. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55576. * @param impostor imposter to match
  55577. */
  55578. private _ropeStep;
  55579. /**
  55580. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55581. * @param impostor imposter to match
  55582. */
  55583. private _softbodyOrClothStep;
  55584. private _tmpVector;
  55585. private _tmpMatrix;
  55586. /**
  55587. * Applies an impulse on the imposter
  55588. * @param impostor imposter to apply impulse to
  55589. * @param force amount of force to be applied to the imposter
  55590. * @param contactPoint the location to apply the impulse on the imposter
  55591. */
  55592. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55593. /**
  55594. * Applies a force on the imposter
  55595. * @param impostor imposter to apply force
  55596. * @param force amount of force to be applied to the imposter
  55597. * @param contactPoint the location to apply the force on the imposter
  55598. */
  55599. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55600. /**
  55601. * Creates a physics body using the plugin
  55602. * @param impostor the imposter to create the physics body on
  55603. */
  55604. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55605. /**
  55606. * Removes the physics body from the imposter and disposes of the body's memory
  55607. * @param impostor imposter to remove the physics body from
  55608. */
  55609. removePhysicsBody(impostor: PhysicsImpostor): void;
  55610. /**
  55611. * Generates a joint
  55612. * @param impostorJoint the imposter joint to create the joint with
  55613. */
  55614. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55615. /**
  55616. * Removes a joint
  55617. * @param impostorJoint the imposter joint to remove the joint from
  55618. */
  55619. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55620. private _addMeshVerts;
  55621. /**
  55622. * Initialise the soft body vertices to match its object's (mesh) vertices
  55623. * Softbody vertices (nodes) are in world space and to match this
  55624. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55625. * @param impostor to create the softbody for
  55626. */
  55627. private _softVertexData;
  55628. /**
  55629. * Create an impostor's soft body
  55630. * @param impostor to create the softbody for
  55631. */
  55632. private _createSoftbody;
  55633. /**
  55634. * Create cloth for an impostor
  55635. * @param impostor to create the softbody for
  55636. */
  55637. private _createCloth;
  55638. /**
  55639. * Create rope for an impostor
  55640. * @param impostor to create the softbody for
  55641. */
  55642. private _createRope;
  55643. /**
  55644. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55645. * @param impostor to create the custom physics shape for
  55646. */
  55647. private _createCustom;
  55648. private _addHullVerts;
  55649. private _createShape;
  55650. /**
  55651. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55652. * @param impostor imposter containing the physics body and babylon object
  55653. */
  55654. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55655. /**
  55656. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55657. * @param impostor imposter containing the physics body and babylon object
  55658. * @param newPosition new position
  55659. * @param newRotation new rotation
  55660. */
  55661. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55662. /**
  55663. * If this plugin is supported
  55664. * @returns true if its supported
  55665. */
  55666. isSupported(): boolean;
  55667. /**
  55668. * Sets the linear velocity of the physics body
  55669. * @param impostor imposter to set the velocity on
  55670. * @param velocity velocity to set
  55671. */
  55672. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55673. /**
  55674. * Sets the angular velocity of the physics body
  55675. * @param impostor imposter to set the velocity on
  55676. * @param velocity velocity to set
  55677. */
  55678. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55679. /**
  55680. * gets the linear velocity
  55681. * @param impostor imposter to get linear velocity from
  55682. * @returns linear velocity
  55683. */
  55684. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55685. /**
  55686. * gets the angular velocity
  55687. * @param impostor imposter to get angular velocity from
  55688. * @returns angular velocity
  55689. */
  55690. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55691. /**
  55692. * Sets the mass of physics body
  55693. * @param impostor imposter to set the mass on
  55694. * @param mass mass to set
  55695. */
  55696. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55697. /**
  55698. * Gets the mass of the physics body
  55699. * @param impostor imposter to get the mass from
  55700. * @returns mass
  55701. */
  55702. getBodyMass(impostor: PhysicsImpostor): number;
  55703. /**
  55704. * Gets friction of the impostor
  55705. * @param impostor impostor to get friction from
  55706. * @returns friction value
  55707. */
  55708. getBodyFriction(impostor: PhysicsImpostor): number;
  55709. /**
  55710. * Sets friction of the impostor
  55711. * @param impostor impostor to set friction on
  55712. * @param friction friction value
  55713. */
  55714. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55715. /**
  55716. * Gets restitution of the impostor
  55717. * @param impostor impostor to get restitution from
  55718. * @returns restitution value
  55719. */
  55720. getBodyRestitution(impostor: PhysicsImpostor): number;
  55721. /**
  55722. * Sets resitution of the impostor
  55723. * @param impostor impostor to set resitution on
  55724. * @param restitution resitution value
  55725. */
  55726. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55727. /**
  55728. * Gets pressure inside the impostor
  55729. * @param impostor impostor to get pressure from
  55730. * @returns pressure value
  55731. */
  55732. getBodyPressure(impostor: PhysicsImpostor): number;
  55733. /**
  55734. * Sets pressure inside a soft body impostor
  55735. * Cloth and rope must remain 0 pressure
  55736. * @param impostor impostor to set pressure on
  55737. * @param pressure pressure value
  55738. */
  55739. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55740. /**
  55741. * Gets stiffness of the impostor
  55742. * @param impostor impostor to get stiffness from
  55743. * @returns pressure value
  55744. */
  55745. getBodyStiffness(impostor: PhysicsImpostor): number;
  55746. /**
  55747. * Sets stiffness of the impostor
  55748. * @param impostor impostor to set stiffness on
  55749. * @param stiffness stiffness value from 0 to 1
  55750. */
  55751. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55752. /**
  55753. * Gets velocityIterations of the impostor
  55754. * @param impostor impostor to get velocity iterations from
  55755. * @returns velocityIterations value
  55756. */
  55757. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55758. /**
  55759. * Sets velocityIterations of the impostor
  55760. * @param impostor impostor to set velocity iterations on
  55761. * @param velocityIterations velocityIterations value
  55762. */
  55763. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55764. /**
  55765. * Gets positionIterations of the impostor
  55766. * @param impostor impostor to get position iterations from
  55767. * @returns positionIterations value
  55768. */
  55769. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55770. /**
  55771. * Sets positionIterations of the impostor
  55772. * @param impostor impostor to set position on
  55773. * @param positionIterations positionIterations value
  55774. */
  55775. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55776. /**
  55777. * Append an anchor to a cloth object
  55778. * @param impostor is the cloth impostor to add anchor to
  55779. * @param otherImpostor is the rigid impostor to anchor to
  55780. * @param width ratio across width from 0 to 1
  55781. * @param height ratio up height from 0 to 1
  55782. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55783. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55784. */
  55785. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55786. /**
  55787. * Append an hook to a rope object
  55788. * @param impostor is the rope impostor to add hook to
  55789. * @param otherImpostor is the rigid impostor to hook to
  55790. * @param length ratio along the rope from 0 to 1
  55791. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55792. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55793. */
  55794. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55795. /**
  55796. * Sleeps the physics body and stops it from being active
  55797. * @param impostor impostor to sleep
  55798. */
  55799. sleepBody(impostor: PhysicsImpostor): void;
  55800. /**
  55801. * Activates the physics body
  55802. * @param impostor impostor to activate
  55803. */
  55804. wakeUpBody(impostor: PhysicsImpostor): void;
  55805. /**
  55806. * Updates the distance parameters of the joint
  55807. * @param joint joint to update
  55808. * @param maxDistance maximum distance of the joint
  55809. * @param minDistance minimum distance of the joint
  55810. */
  55811. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55812. /**
  55813. * Sets a motor on the joint
  55814. * @param joint joint to set motor on
  55815. * @param speed speed of the motor
  55816. * @param maxForce maximum force of the motor
  55817. * @param motorIndex index of the motor
  55818. */
  55819. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55820. /**
  55821. * Sets the motors limit
  55822. * @param joint joint to set limit on
  55823. * @param upperLimit upper limit
  55824. * @param lowerLimit lower limit
  55825. */
  55826. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55827. /**
  55828. * Syncs the position and rotation of a mesh with the impostor
  55829. * @param mesh mesh to sync
  55830. * @param impostor impostor to update the mesh with
  55831. */
  55832. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55833. /**
  55834. * Gets the radius of the impostor
  55835. * @param impostor impostor to get radius from
  55836. * @returns the radius
  55837. */
  55838. getRadius(impostor: PhysicsImpostor): number;
  55839. /**
  55840. * Gets the box size of the impostor
  55841. * @param impostor impostor to get box size from
  55842. * @param result the resulting box size
  55843. */
  55844. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55845. /**
  55846. * Disposes of the impostor
  55847. */
  55848. dispose(): void;
  55849. /**
  55850. * Does a raycast in the physics world
  55851. * @param from when should the ray start?
  55852. * @param to when should the ray end?
  55853. * @returns PhysicsRaycastResult
  55854. */
  55855. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55856. }
  55857. }
  55858. declare module BABYLON {
  55859. interface AbstractScene {
  55860. /**
  55861. * The list of reflection probes added to the scene
  55862. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55863. */
  55864. reflectionProbes: Array<ReflectionProbe>;
  55865. /**
  55866. * Removes the given reflection probe from this scene.
  55867. * @param toRemove The reflection probe to remove
  55868. * @returns The index of the removed reflection probe
  55869. */
  55870. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55871. /**
  55872. * Adds the given reflection probe to this scene.
  55873. * @param newReflectionProbe The reflection probe to add
  55874. */
  55875. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55876. }
  55877. /**
  55878. * Class used to generate realtime reflection / refraction cube textures
  55879. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55880. */
  55881. export class ReflectionProbe {
  55882. /** defines the name of the probe */
  55883. name: string;
  55884. private _scene;
  55885. private _renderTargetTexture;
  55886. private _projectionMatrix;
  55887. private _viewMatrix;
  55888. private _target;
  55889. private _add;
  55890. private _attachedMesh;
  55891. private _invertYAxis;
  55892. /** Gets or sets probe position (center of the cube map) */
  55893. position: Vector3;
  55894. /**
  55895. * Creates a new reflection probe
  55896. * @param name defines the name of the probe
  55897. * @param size defines the texture resolution (for each face)
  55898. * @param scene defines the hosting scene
  55899. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55900. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55901. */
  55902. constructor(
  55903. /** defines the name of the probe */
  55904. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55905. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55906. get samples(): number;
  55907. set samples(value: number);
  55908. /** Gets or sets the refresh rate to use (on every frame by default) */
  55909. get refreshRate(): number;
  55910. set refreshRate(value: number);
  55911. /**
  55912. * Gets the hosting scene
  55913. * @returns a Scene
  55914. */
  55915. getScene(): Scene;
  55916. /** Gets the internal CubeTexture used to render to */
  55917. get cubeTexture(): RenderTargetTexture;
  55918. /** Gets the list of meshes to render */
  55919. get renderList(): Nullable<AbstractMesh[]>;
  55920. /**
  55921. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55922. * @param mesh defines the mesh to attach to
  55923. */
  55924. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55925. /**
  55926. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55927. * @param renderingGroupId The rendering group id corresponding to its index
  55928. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55929. */
  55930. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55931. /**
  55932. * Clean all associated resources
  55933. */
  55934. dispose(): void;
  55935. /**
  55936. * Converts the reflection probe information to a readable string for debug purpose.
  55937. * @param fullDetails Supports for multiple levels of logging within scene loading
  55938. * @returns the human readable reflection probe info
  55939. */
  55940. toString(fullDetails?: boolean): string;
  55941. /**
  55942. * Get the class name of the relfection probe.
  55943. * @returns "ReflectionProbe"
  55944. */
  55945. getClassName(): string;
  55946. /**
  55947. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55948. * @returns The JSON representation of the texture
  55949. */
  55950. serialize(): any;
  55951. /**
  55952. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55953. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55954. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55955. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55956. * @returns The parsed reflection probe if successful
  55957. */
  55958. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55959. }
  55960. }
  55961. declare module BABYLON {
  55962. /** @hidden */
  55963. export var _BabylonLoaderRegistered: boolean;
  55964. /**
  55965. * Helps setting up some configuration for the babylon file loader.
  55966. */
  55967. export class BabylonFileLoaderConfiguration {
  55968. /**
  55969. * The loader does not allow injecting custom physix engine into the plugins.
  55970. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55971. * So you could set this variable to your engine import to make it work.
  55972. */
  55973. static LoaderInjectedPhysicsEngine: any;
  55974. }
  55975. }
  55976. declare module BABYLON {
  55977. /**
  55978. * The Physically based simple base material of BJS.
  55979. *
  55980. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55981. * It is used as the base class for both the specGloss and metalRough conventions.
  55982. */
  55983. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55984. /**
  55985. * Number of Simultaneous lights allowed on the material.
  55986. */
  55987. maxSimultaneousLights: number;
  55988. /**
  55989. * If sets to true, disables all the lights affecting the material.
  55990. */
  55991. disableLighting: boolean;
  55992. /**
  55993. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55994. */
  55995. environmentTexture: BaseTexture;
  55996. /**
  55997. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55998. */
  55999. invertNormalMapX: boolean;
  56000. /**
  56001. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56002. */
  56003. invertNormalMapY: boolean;
  56004. /**
  56005. * Normal map used in the model.
  56006. */
  56007. normalTexture: BaseTexture;
  56008. /**
  56009. * Emissivie color used to self-illuminate the model.
  56010. */
  56011. emissiveColor: Color3;
  56012. /**
  56013. * Emissivie texture used to self-illuminate the model.
  56014. */
  56015. emissiveTexture: BaseTexture;
  56016. /**
  56017. * Occlusion Channel Strenght.
  56018. */
  56019. occlusionStrength: number;
  56020. /**
  56021. * Occlusion Texture of the material (adding extra occlusion effects).
  56022. */
  56023. occlusionTexture: BaseTexture;
  56024. /**
  56025. * Defines the alpha limits in alpha test mode.
  56026. */
  56027. alphaCutOff: number;
  56028. /**
  56029. * Gets the current double sided mode.
  56030. */
  56031. get doubleSided(): boolean;
  56032. /**
  56033. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56034. */
  56035. set doubleSided(value: boolean);
  56036. /**
  56037. * Stores the pre-calculated light information of a mesh in a texture.
  56038. */
  56039. lightmapTexture: BaseTexture;
  56040. /**
  56041. * If true, the light map contains occlusion information instead of lighting info.
  56042. */
  56043. useLightmapAsShadowmap: boolean;
  56044. /**
  56045. * Instantiates a new PBRMaterial instance.
  56046. *
  56047. * @param name The material name
  56048. * @param scene The scene the material will be use in.
  56049. */
  56050. constructor(name: string, scene: Scene);
  56051. getClassName(): string;
  56052. }
  56053. }
  56054. declare module BABYLON {
  56055. /**
  56056. * The PBR material of BJS following the metal roughness convention.
  56057. *
  56058. * This fits to the PBR convention in the GLTF definition:
  56059. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56060. */
  56061. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56062. /**
  56063. * The base color has two different interpretations depending on the value of metalness.
  56064. * When the material is a metal, the base color is the specific measured reflectance value
  56065. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56066. * of the material.
  56067. */
  56068. baseColor: Color3;
  56069. /**
  56070. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56071. * well as opacity information in the alpha channel.
  56072. */
  56073. baseTexture: BaseTexture;
  56074. /**
  56075. * Specifies the metallic scalar value of the material.
  56076. * Can also be used to scale the metalness values of the metallic texture.
  56077. */
  56078. metallic: number;
  56079. /**
  56080. * Specifies the roughness scalar value of the material.
  56081. * Can also be used to scale the roughness values of the metallic texture.
  56082. */
  56083. roughness: number;
  56084. /**
  56085. * Texture containing both the metallic value in the B channel and the
  56086. * roughness value in the G channel to keep better precision.
  56087. */
  56088. metallicRoughnessTexture: BaseTexture;
  56089. /**
  56090. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56091. *
  56092. * @param name The material name
  56093. * @param scene The scene the material will be use in.
  56094. */
  56095. constructor(name: string, scene: Scene);
  56096. /**
  56097. * Return the currrent class name of the material.
  56098. */
  56099. getClassName(): string;
  56100. /**
  56101. * Makes a duplicate of the current material.
  56102. * @param name - name to use for the new material.
  56103. */
  56104. clone(name: string): PBRMetallicRoughnessMaterial;
  56105. /**
  56106. * Serialize the material to a parsable JSON object.
  56107. */
  56108. serialize(): any;
  56109. /**
  56110. * Parses a JSON object correponding to the serialize function.
  56111. */
  56112. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56113. }
  56114. }
  56115. declare module BABYLON {
  56116. /**
  56117. * The PBR material of BJS following the specular glossiness convention.
  56118. *
  56119. * This fits to the PBR convention in the GLTF definition:
  56120. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56121. */
  56122. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56123. /**
  56124. * Specifies the diffuse color of the material.
  56125. */
  56126. diffuseColor: Color3;
  56127. /**
  56128. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56129. * channel.
  56130. */
  56131. diffuseTexture: BaseTexture;
  56132. /**
  56133. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56134. */
  56135. specularColor: Color3;
  56136. /**
  56137. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56138. */
  56139. glossiness: number;
  56140. /**
  56141. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56142. */
  56143. specularGlossinessTexture: BaseTexture;
  56144. /**
  56145. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56146. *
  56147. * @param name The material name
  56148. * @param scene The scene the material will be use in.
  56149. */
  56150. constructor(name: string, scene: Scene);
  56151. /**
  56152. * Return the currrent class name of the material.
  56153. */
  56154. getClassName(): string;
  56155. /**
  56156. * Makes a duplicate of the current material.
  56157. * @param name - name to use for the new material.
  56158. */
  56159. clone(name: string): PBRSpecularGlossinessMaterial;
  56160. /**
  56161. * Serialize the material to a parsable JSON object.
  56162. */
  56163. serialize(): any;
  56164. /**
  56165. * Parses a JSON object correponding to the serialize function.
  56166. */
  56167. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56168. }
  56169. }
  56170. declare module BABYLON {
  56171. /**
  56172. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56173. * It can help converting any input color in a desired output one. This can then be used to create effects
  56174. * from sepia, black and white to sixties or futuristic rendering...
  56175. *
  56176. * The only supported format is currently 3dl.
  56177. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56178. */
  56179. export class ColorGradingTexture extends BaseTexture {
  56180. /**
  56181. * The current texture matrix. (will always be identity in color grading texture)
  56182. */
  56183. private _textureMatrix;
  56184. /**
  56185. * The texture URL.
  56186. */
  56187. url: string;
  56188. /**
  56189. * Empty line regex stored for GC.
  56190. */
  56191. private static _noneEmptyLineRegex;
  56192. private _engine;
  56193. /**
  56194. * Instantiates a ColorGradingTexture from the following parameters.
  56195. *
  56196. * @param url The location of the color gradind data (currently only supporting 3dl)
  56197. * @param scene The scene the texture will be used in
  56198. */
  56199. constructor(url: string, scene: Scene);
  56200. /**
  56201. * Returns the texture matrix used in most of the material.
  56202. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56203. */
  56204. getTextureMatrix(): Matrix;
  56205. /**
  56206. * Occurs when the file being loaded is a .3dl LUT file.
  56207. */
  56208. private load3dlTexture;
  56209. /**
  56210. * Starts the loading process of the texture.
  56211. */
  56212. private loadTexture;
  56213. /**
  56214. * Clones the color gradind texture.
  56215. */
  56216. clone(): ColorGradingTexture;
  56217. /**
  56218. * Called during delayed load for textures.
  56219. */
  56220. delayLoad(): void;
  56221. /**
  56222. * Parses a color grading texture serialized by Babylon.
  56223. * @param parsedTexture The texture information being parsedTexture
  56224. * @param scene The scene to load the texture in
  56225. * @param rootUrl The root url of the data assets to load
  56226. * @return A color gradind texture
  56227. */
  56228. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56229. /**
  56230. * Serializes the LUT texture to json format.
  56231. */
  56232. serialize(): any;
  56233. }
  56234. }
  56235. declare module BABYLON {
  56236. /**
  56237. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56238. */
  56239. export class EquiRectangularCubeTexture extends BaseTexture {
  56240. /** The six faces of the cube. */
  56241. private static _FacesMapping;
  56242. private _noMipmap;
  56243. private _onLoad;
  56244. private _onError;
  56245. /** The size of the cubemap. */
  56246. private _size;
  56247. /** The buffer of the image. */
  56248. private _buffer;
  56249. /** The width of the input image. */
  56250. private _width;
  56251. /** The height of the input image. */
  56252. private _height;
  56253. /** The URL to the image. */
  56254. url: string;
  56255. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56256. coordinatesMode: number;
  56257. /**
  56258. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56259. * @param url The location of the image
  56260. * @param scene The scene the texture will be used in
  56261. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56262. * @param noMipmap Forces to not generate the mipmap if true
  56263. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56264. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56265. * @param onLoad — defines a callback called when texture is loaded
  56266. * @param onError — defines a callback called if there is an error
  56267. */
  56268. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56269. /**
  56270. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56271. */
  56272. private loadImage;
  56273. /**
  56274. * Convert the image buffer into a cubemap and create a CubeTexture.
  56275. */
  56276. private loadTexture;
  56277. /**
  56278. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56279. * @param buffer The ArrayBuffer that should be converted.
  56280. * @returns The buffer as Float32Array.
  56281. */
  56282. private getFloat32ArrayFromArrayBuffer;
  56283. /**
  56284. * Get the current class name of the texture useful for serialization or dynamic coding.
  56285. * @returns "EquiRectangularCubeTexture"
  56286. */
  56287. getClassName(): string;
  56288. /**
  56289. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56290. * @returns A clone of the current EquiRectangularCubeTexture.
  56291. */
  56292. clone(): EquiRectangularCubeTexture;
  56293. }
  56294. }
  56295. declare module BABYLON {
  56296. /**
  56297. * Based on jsTGALoader - Javascript loader for TGA file
  56298. * By Vincent Thibault
  56299. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56300. */
  56301. export class TGATools {
  56302. private static _TYPE_INDEXED;
  56303. private static _TYPE_RGB;
  56304. private static _TYPE_GREY;
  56305. private static _TYPE_RLE_INDEXED;
  56306. private static _TYPE_RLE_RGB;
  56307. private static _TYPE_RLE_GREY;
  56308. private static _ORIGIN_MASK;
  56309. private static _ORIGIN_SHIFT;
  56310. private static _ORIGIN_BL;
  56311. private static _ORIGIN_BR;
  56312. private static _ORIGIN_UL;
  56313. private static _ORIGIN_UR;
  56314. /**
  56315. * Gets the header of a TGA file
  56316. * @param data defines the TGA data
  56317. * @returns the header
  56318. */
  56319. static GetTGAHeader(data: Uint8Array): any;
  56320. /**
  56321. * Uploads TGA content to a Babylon Texture
  56322. * @hidden
  56323. */
  56324. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56325. /** @hidden */
  56326. 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;
  56327. /** @hidden */
  56328. 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;
  56329. /** @hidden */
  56330. 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;
  56331. /** @hidden */
  56332. 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;
  56333. /** @hidden */
  56334. 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;
  56335. /** @hidden */
  56336. 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;
  56337. }
  56338. }
  56339. declare module BABYLON {
  56340. /**
  56341. * Implementation of the TGA Texture Loader.
  56342. * @hidden
  56343. */
  56344. export class _TGATextureLoader implements IInternalTextureLoader {
  56345. /**
  56346. * Defines wether the loader supports cascade loading the different faces.
  56347. */
  56348. readonly supportCascades: boolean;
  56349. /**
  56350. * This returns if the loader support the current file information.
  56351. * @param extension defines the file extension of the file being loaded
  56352. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56353. * @param fallback defines the fallback internal texture if any
  56354. * @param isBase64 defines whether the texture is encoded as a base64
  56355. * @param isBuffer defines whether the texture data are stored as a buffer
  56356. * @returns true if the loader can load the specified file
  56357. */
  56358. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56359. /**
  56360. * Transform the url before loading if required.
  56361. * @param rootUrl the url of the texture
  56362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56363. * @returns the transformed texture
  56364. */
  56365. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56366. /**
  56367. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56368. * @param rootUrl the url of the texture
  56369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56370. * @returns the fallback texture
  56371. */
  56372. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56373. /**
  56374. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56375. * @param data contains the texture data
  56376. * @param texture defines the BabylonJS internal texture
  56377. * @param createPolynomials will be true if polynomials have been requested
  56378. * @param onLoad defines the callback to trigger once the texture is ready
  56379. * @param onError defines the callback to trigger in case of error
  56380. */
  56381. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56382. /**
  56383. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56384. * @param data contains the texture data
  56385. * @param texture defines the BabylonJS internal texture
  56386. * @param callback defines the method to call once ready to upload
  56387. */
  56388. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56389. }
  56390. }
  56391. declare module BABYLON {
  56392. /**
  56393. * Info about the .basis files
  56394. */
  56395. class BasisFileInfo {
  56396. /**
  56397. * If the file has alpha
  56398. */
  56399. hasAlpha: boolean;
  56400. /**
  56401. * Info about each image of the basis file
  56402. */
  56403. images: Array<{
  56404. levels: Array<{
  56405. width: number;
  56406. height: number;
  56407. transcodedPixels: ArrayBufferView;
  56408. }>;
  56409. }>;
  56410. }
  56411. /**
  56412. * Result of transcoding a basis file
  56413. */
  56414. class TranscodeResult {
  56415. /**
  56416. * Info about the .basis file
  56417. */
  56418. fileInfo: BasisFileInfo;
  56419. /**
  56420. * Format to use when loading the file
  56421. */
  56422. format: number;
  56423. }
  56424. /**
  56425. * Configuration options for the Basis transcoder
  56426. */
  56427. export class BasisTranscodeConfiguration {
  56428. /**
  56429. * Supported compression formats used to determine the supported output format of the transcoder
  56430. */
  56431. supportedCompressionFormats?: {
  56432. /**
  56433. * etc1 compression format
  56434. */
  56435. etc1?: boolean;
  56436. /**
  56437. * s3tc compression format
  56438. */
  56439. s3tc?: boolean;
  56440. /**
  56441. * pvrtc compression format
  56442. */
  56443. pvrtc?: boolean;
  56444. /**
  56445. * etc2 compression format
  56446. */
  56447. etc2?: boolean;
  56448. };
  56449. /**
  56450. * If mipmap levels should be loaded for transcoded images (Default: true)
  56451. */
  56452. loadMipmapLevels?: boolean;
  56453. /**
  56454. * Index of a single image to load (Default: all images)
  56455. */
  56456. loadSingleImage?: number;
  56457. }
  56458. /**
  56459. * Used to load .Basis files
  56460. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56461. */
  56462. export class BasisTools {
  56463. private static _IgnoreSupportedFormats;
  56464. /**
  56465. * URL to use when loading the basis transcoder
  56466. */
  56467. static JSModuleURL: string;
  56468. /**
  56469. * URL to use when loading the wasm module for the transcoder
  56470. */
  56471. static WasmModuleURL: string;
  56472. /**
  56473. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56474. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56475. * @returns internal format corresponding to the Basis format
  56476. */
  56477. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56478. private static _WorkerPromise;
  56479. private static _Worker;
  56480. private static _actionId;
  56481. private static _CreateWorkerAsync;
  56482. /**
  56483. * Transcodes a loaded image file to compressed pixel data
  56484. * @param data image data to transcode
  56485. * @param config configuration options for the transcoding
  56486. * @returns a promise resulting in the transcoded image
  56487. */
  56488. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56489. /**
  56490. * Loads a texture from the transcode result
  56491. * @param texture texture load to
  56492. * @param transcodeResult the result of transcoding the basis file to load from
  56493. */
  56494. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56495. }
  56496. }
  56497. declare module BABYLON {
  56498. /**
  56499. * Loader for .basis file format
  56500. */
  56501. export class _BasisTextureLoader implements IInternalTextureLoader {
  56502. /**
  56503. * Defines whether the loader supports cascade loading the different faces.
  56504. */
  56505. readonly supportCascades: boolean;
  56506. /**
  56507. * This returns if the loader support the current file information.
  56508. * @param extension defines the file extension of the file being loaded
  56509. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56510. * @param fallback defines the fallback internal texture if any
  56511. * @param isBase64 defines whether the texture is encoded as a base64
  56512. * @param isBuffer defines whether the texture data are stored as a buffer
  56513. * @returns true if the loader can load the specified file
  56514. */
  56515. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56516. /**
  56517. * Transform the url before loading if required.
  56518. * @param rootUrl the url of the texture
  56519. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56520. * @returns the transformed texture
  56521. */
  56522. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56523. /**
  56524. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56525. * @param rootUrl the url of the texture
  56526. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56527. * @returns the fallback texture
  56528. */
  56529. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56530. /**
  56531. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  56532. * @param data contains the texture data
  56533. * @param texture defines the BabylonJS internal texture
  56534. * @param createPolynomials will be true if polynomials have been requested
  56535. * @param onLoad defines the callback to trigger once the texture is ready
  56536. * @param onError defines the callback to trigger in case of error
  56537. */
  56538. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56539. /**
  56540. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56541. * @param data contains the texture data
  56542. * @param texture defines the BabylonJS internal texture
  56543. * @param callback defines the method to call once ready to upload
  56544. */
  56545. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56546. }
  56547. }
  56548. declare module BABYLON {
  56549. /**
  56550. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  56551. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56552. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56553. */
  56554. export class CustomProceduralTexture extends ProceduralTexture {
  56555. private _animate;
  56556. private _time;
  56557. private _config;
  56558. private _texturePath;
  56559. /**
  56560. * Instantiates a new Custom Procedural Texture.
  56561. * 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.
  56562. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56563. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56564. * @param name Define the name of the texture
  56565. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56566. * @param size Define the size of the texture to create
  56567. * @param scene Define the scene the texture belongs to
  56568. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56569. * @param generateMipMaps Define if the texture should creates mip maps or not
  56570. */
  56571. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56572. private _loadJson;
  56573. /**
  56574. * Is the texture ready to be used ? (rendered at least once)
  56575. * @returns true if ready, otherwise, false.
  56576. */
  56577. isReady(): boolean;
  56578. /**
  56579. * Render the texture to its associated render target.
  56580. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56581. */
  56582. render(useCameraPostProcess?: boolean): void;
  56583. /**
  56584. * Update the list of dependant textures samplers in the shader.
  56585. */
  56586. updateTextures(): void;
  56587. /**
  56588. * Update the uniform values of the procedural texture in the shader.
  56589. */
  56590. updateShaderUniforms(): void;
  56591. /**
  56592. * Define if the texture animates or not.
  56593. */
  56594. get animate(): boolean;
  56595. set animate(value: boolean);
  56596. }
  56597. }
  56598. declare module BABYLON {
  56599. /** @hidden */
  56600. export var noisePixelShader: {
  56601. name: string;
  56602. shader: string;
  56603. };
  56604. }
  56605. declare module BABYLON {
  56606. /**
  56607. * Class used to generate noise procedural textures
  56608. */
  56609. export class NoiseProceduralTexture extends ProceduralTexture {
  56610. private _time;
  56611. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56612. brightness: number;
  56613. /** Defines the number of octaves to process */
  56614. octaves: number;
  56615. /** Defines the level of persistence (0.8 by default) */
  56616. persistence: number;
  56617. /** Gets or sets animation speed factor (default is 1) */
  56618. animationSpeedFactor: number;
  56619. /**
  56620. * Creates a new NoiseProceduralTexture
  56621. * @param name defines the name fo the texture
  56622. * @param size defines the size of the texture (default is 256)
  56623. * @param scene defines the hosting scene
  56624. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56625. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56626. */
  56627. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56628. private _updateShaderUniforms;
  56629. protected _getDefines(): string;
  56630. /** Generate the current state of the procedural texture */
  56631. render(useCameraPostProcess?: boolean): void;
  56632. /**
  56633. * Serializes this noise procedural texture
  56634. * @returns a serialized noise procedural texture object
  56635. */
  56636. serialize(): any;
  56637. /**
  56638. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56639. * @param parsedTexture defines parsed texture data
  56640. * @param scene defines the current scene
  56641. * @param rootUrl defines the root URL containing noise procedural texture information
  56642. * @returns a parsed NoiseProceduralTexture
  56643. */
  56644. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56645. }
  56646. }
  56647. declare module BABYLON {
  56648. /**
  56649. * Raw cube texture where the raw buffers are passed in
  56650. */
  56651. export class RawCubeTexture extends CubeTexture {
  56652. /**
  56653. * Creates a cube texture where the raw buffers are passed in.
  56654. * @param scene defines the scene the texture is attached to
  56655. * @param data defines the array of data to use to create each face
  56656. * @param size defines the size of the textures
  56657. * @param format defines the format of the data
  56658. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56659. * @param generateMipMaps defines if the engine should generate the mip levels
  56660. * @param invertY defines if data must be stored with Y axis inverted
  56661. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56662. * @param compression defines the compression used (null by default)
  56663. */
  56664. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56665. /**
  56666. * Updates the raw cube texture.
  56667. * @param data defines the data to store
  56668. * @param format defines the data format
  56669. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56670. * @param invertY defines if data must be stored with Y axis inverted
  56671. * @param compression defines the compression used (null by default)
  56672. * @param level defines which level of the texture to update
  56673. */
  56674. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56675. /**
  56676. * Updates a raw cube texture with RGBD encoded data.
  56677. * @param data defines the array of data [mipmap][face] to use to create each face
  56678. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56679. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56680. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56681. * @returns a promsie that resolves when the operation is complete
  56682. */
  56683. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56684. /**
  56685. * Clones the raw cube texture.
  56686. * @return a new cube texture
  56687. */
  56688. clone(): CubeTexture;
  56689. /** @hidden */
  56690. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56691. }
  56692. }
  56693. declare module BABYLON {
  56694. /**
  56695. * Class used to store 3D textures containing user data
  56696. */
  56697. export class RawTexture3D extends Texture {
  56698. /** Gets or sets the texture format to use */
  56699. format: number;
  56700. private _engine;
  56701. /**
  56702. * Create a new RawTexture3D
  56703. * @param data defines the data of the texture
  56704. * @param width defines the width of the texture
  56705. * @param height defines the height of the texture
  56706. * @param depth defines the depth of the texture
  56707. * @param format defines the texture format to use
  56708. * @param scene defines the hosting scene
  56709. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56710. * @param invertY defines if texture must be stored with Y axis inverted
  56711. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56712. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56713. */
  56714. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56715. /** Gets or sets the texture format to use */
  56716. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56717. /**
  56718. * Update the texture with new data
  56719. * @param data defines the data to store in the texture
  56720. */
  56721. update(data: ArrayBufferView): void;
  56722. }
  56723. }
  56724. declare module BABYLON {
  56725. /**
  56726. * Class used to store 2D array textures containing user data
  56727. */
  56728. export class RawTexture2DArray extends Texture {
  56729. /** Gets or sets the texture format to use */
  56730. format: number;
  56731. private _engine;
  56732. /**
  56733. * Create a new RawTexture2DArray
  56734. * @param data defines the data of the texture
  56735. * @param width defines the width of the texture
  56736. * @param height defines the height of the texture
  56737. * @param depth defines the number of layers of the texture
  56738. * @param format defines the texture format to use
  56739. * @param scene defines the hosting scene
  56740. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56741. * @param invertY defines if texture must be stored with Y axis inverted
  56742. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56743. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56744. */
  56745. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56746. /** Gets or sets the texture format to use */
  56747. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56748. /**
  56749. * Update the texture with new data
  56750. * @param data defines the data to store in the texture
  56751. */
  56752. update(data: ArrayBufferView): void;
  56753. }
  56754. }
  56755. declare module BABYLON {
  56756. /**
  56757. * Creates a refraction texture used by refraction channel of the standard material.
  56758. * It is like a mirror but to see through a material.
  56759. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56760. */
  56761. export class RefractionTexture extends RenderTargetTexture {
  56762. /**
  56763. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56764. * 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.
  56765. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56766. */
  56767. refractionPlane: Plane;
  56768. /**
  56769. * Define how deep under the surface we should see.
  56770. */
  56771. depth: number;
  56772. /**
  56773. * Creates a refraction texture used by refraction channel of the standard material.
  56774. * It is like a mirror but to see through a material.
  56775. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56776. * @param name Define the texture name
  56777. * @param size Define the size of the underlying texture
  56778. * @param scene Define the scene the refraction belongs to
  56779. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56780. */
  56781. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56782. /**
  56783. * Clone the refraction texture.
  56784. * @returns the cloned texture
  56785. */
  56786. clone(): RefractionTexture;
  56787. /**
  56788. * Serialize the texture to a JSON representation you could use in Parse later on
  56789. * @returns the serialized JSON representation
  56790. */
  56791. serialize(): any;
  56792. }
  56793. }
  56794. declare module BABYLON {
  56795. /**
  56796. * Defines the options related to the creation of an HtmlElementTexture
  56797. */
  56798. export interface IHtmlElementTextureOptions {
  56799. /**
  56800. * Defines wether mip maps should be created or not.
  56801. */
  56802. generateMipMaps?: boolean;
  56803. /**
  56804. * Defines the sampling mode of the texture.
  56805. */
  56806. samplingMode?: number;
  56807. /**
  56808. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56809. */
  56810. engine: Nullable<ThinEngine>;
  56811. /**
  56812. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56813. */
  56814. scene: Nullable<Scene>;
  56815. }
  56816. /**
  56817. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56818. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56819. * is automatically managed.
  56820. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56821. * in your application.
  56822. *
  56823. * As the update is not automatic, you need to call them manually.
  56824. */
  56825. export class HtmlElementTexture extends BaseTexture {
  56826. /**
  56827. * The texture URL.
  56828. */
  56829. element: HTMLVideoElement | HTMLCanvasElement;
  56830. private static readonly DefaultOptions;
  56831. private _textureMatrix;
  56832. private _engine;
  56833. private _isVideo;
  56834. private _generateMipMaps;
  56835. private _samplingMode;
  56836. /**
  56837. * Instantiates a HtmlElementTexture from the following parameters.
  56838. *
  56839. * @param name Defines the name of the texture
  56840. * @param element Defines the video or canvas the texture is filled with
  56841. * @param options Defines the other none mandatory texture creation options
  56842. */
  56843. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56844. private _createInternalTexture;
  56845. /**
  56846. * Returns the texture matrix used in most of the material.
  56847. */
  56848. getTextureMatrix(): Matrix;
  56849. /**
  56850. * Updates the content of the texture.
  56851. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56852. */
  56853. update(invertY?: Nullable<boolean>): void;
  56854. }
  56855. }
  56856. declare module BABYLON {
  56857. /**
  56858. * Enum used to define the target of a block
  56859. */
  56860. export enum NodeMaterialBlockTargets {
  56861. /** Vertex shader */
  56862. Vertex = 1,
  56863. /** Fragment shader */
  56864. Fragment = 2,
  56865. /** Neutral */
  56866. Neutral = 4,
  56867. /** Vertex and Fragment */
  56868. VertexAndFragment = 3
  56869. }
  56870. }
  56871. declare module BABYLON {
  56872. /**
  56873. * Defines the kind of connection point for node based material
  56874. */
  56875. export enum NodeMaterialBlockConnectionPointTypes {
  56876. /** Float */
  56877. Float = 1,
  56878. /** Int */
  56879. Int = 2,
  56880. /** Vector2 */
  56881. Vector2 = 4,
  56882. /** Vector3 */
  56883. Vector3 = 8,
  56884. /** Vector4 */
  56885. Vector4 = 16,
  56886. /** Color3 */
  56887. Color3 = 32,
  56888. /** Color4 */
  56889. Color4 = 64,
  56890. /** Matrix */
  56891. Matrix = 128,
  56892. /** Detect type based on connection */
  56893. AutoDetect = 1024,
  56894. /** Output type that will be defined by input type */
  56895. BasedOnInput = 2048
  56896. }
  56897. }
  56898. declare module BABYLON {
  56899. /**
  56900. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56901. */
  56902. export enum NodeMaterialBlockConnectionPointMode {
  56903. /** Value is an uniform */
  56904. Uniform = 0,
  56905. /** Value is a mesh attribute */
  56906. Attribute = 1,
  56907. /** Value is a varying between vertex and fragment shaders */
  56908. Varying = 2,
  56909. /** Mode is undefined */
  56910. Undefined = 3
  56911. }
  56912. }
  56913. declare module BABYLON {
  56914. /**
  56915. * Enum used to define system values e.g. values automatically provided by the system
  56916. */
  56917. export enum NodeMaterialSystemValues {
  56918. /** World */
  56919. World = 1,
  56920. /** View */
  56921. View = 2,
  56922. /** Projection */
  56923. Projection = 3,
  56924. /** ViewProjection */
  56925. ViewProjection = 4,
  56926. /** WorldView */
  56927. WorldView = 5,
  56928. /** WorldViewProjection */
  56929. WorldViewProjection = 6,
  56930. /** CameraPosition */
  56931. CameraPosition = 7,
  56932. /** Fog Color */
  56933. FogColor = 8,
  56934. /** Delta time */
  56935. DeltaTime = 9
  56936. }
  56937. }
  56938. declare module BABYLON {
  56939. /**
  56940. * Root class for all node material optimizers
  56941. */
  56942. export class NodeMaterialOptimizer {
  56943. /**
  56944. * Function used to optimize a NodeMaterial graph
  56945. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56946. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56947. */
  56948. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56949. }
  56950. }
  56951. declare module BABYLON {
  56952. /**
  56953. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56954. */
  56955. export class TransformBlock extends NodeMaterialBlock {
  56956. /**
  56957. * Defines the value to use to complement W value to transform it to a Vector4
  56958. */
  56959. complementW: number;
  56960. /**
  56961. * Defines the value to use to complement z value to transform it to a Vector4
  56962. */
  56963. complementZ: number;
  56964. /**
  56965. * Creates a new TransformBlock
  56966. * @param name defines the block name
  56967. */
  56968. constructor(name: string);
  56969. /**
  56970. * Gets the current class name
  56971. * @returns the class name
  56972. */
  56973. getClassName(): string;
  56974. /**
  56975. * Gets the vector input
  56976. */
  56977. get vector(): NodeMaterialConnectionPoint;
  56978. /**
  56979. * Gets the output component
  56980. */
  56981. get output(): NodeMaterialConnectionPoint;
  56982. /**
  56983. * Gets the matrix transform input
  56984. */
  56985. get transform(): NodeMaterialConnectionPoint;
  56986. protected _buildBlock(state: NodeMaterialBuildState): this;
  56987. serialize(): any;
  56988. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56989. protected _dumpPropertiesCode(): string;
  56990. }
  56991. }
  56992. declare module BABYLON {
  56993. /**
  56994. * Block used to output the vertex position
  56995. */
  56996. export class VertexOutputBlock extends NodeMaterialBlock {
  56997. /**
  56998. * Creates a new VertexOutputBlock
  56999. * @param name defines the block name
  57000. */
  57001. constructor(name: string);
  57002. /**
  57003. * Gets the current class name
  57004. * @returns the class name
  57005. */
  57006. getClassName(): string;
  57007. /**
  57008. * Gets the vector input component
  57009. */
  57010. get vector(): NodeMaterialConnectionPoint;
  57011. protected _buildBlock(state: NodeMaterialBuildState): this;
  57012. }
  57013. }
  57014. declare module BABYLON {
  57015. /**
  57016. * Block used to output the final color
  57017. */
  57018. export class FragmentOutputBlock extends NodeMaterialBlock {
  57019. /**
  57020. * Create a new FragmentOutputBlock
  57021. * @param name defines the block name
  57022. */
  57023. constructor(name: string);
  57024. /**
  57025. * Gets the current class name
  57026. * @returns the class name
  57027. */
  57028. getClassName(): string;
  57029. /**
  57030. * Gets the rgba input component
  57031. */
  57032. get rgba(): NodeMaterialConnectionPoint;
  57033. /**
  57034. * Gets the rgb input component
  57035. */
  57036. get rgb(): NodeMaterialConnectionPoint;
  57037. /**
  57038. * Gets the a input component
  57039. */
  57040. get a(): NodeMaterialConnectionPoint;
  57041. protected _buildBlock(state: NodeMaterialBuildState): this;
  57042. }
  57043. }
  57044. declare module BABYLON {
  57045. /**
  57046. * Block used to read a reflection texture from a sampler
  57047. */
  57048. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57049. private _define3DName;
  57050. private _defineCubicName;
  57051. private _defineExplicitName;
  57052. private _defineProjectionName;
  57053. private _defineLocalCubicName;
  57054. private _defineSphericalName;
  57055. private _definePlanarName;
  57056. private _defineEquirectangularName;
  57057. private _defineMirroredEquirectangularFixedName;
  57058. private _defineEquirectangularFixedName;
  57059. private _defineSkyboxName;
  57060. private _cubeSamplerName;
  57061. private _2DSamplerName;
  57062. private _positionUVWName;
  57063. private _directionWName;
  57064. private _reflectionCoordsName;
  57065. private _reflection2DCoordsName;
  57066. private _reflectionColorName;
  57067. private _reflectionMatrixName;
  57068. /**
  57069. * Gets or sets the texture associated with the node
  57070. */
  57071. texture: Nullable<BaseTexture>;
  57072. /**
  57073. * Create a new TextureBlock
  57074. * @param name defines the block name
  57075. */
  57076. constructor(name: string);
  57077. /**
  57078. * Gets the current class name
  57079. * @returns the class name
  57080. */
  57081. getClassName(): string;
  57082. /**
  57083. * Gets the world position input component
  57084. */
  57085. get position(): NodeMaterialConnectionPoint;
  57086. /**
  57087. * Gets the world position input component
  57088. */
  57089. get worldPosition(): NodeMaterialConnectionPoint;
  57090. /**
  57091. * Gets the world normal input component
  57092. */
  57093. get worldNormal(): NodeMaterialConnectionPoint;
  57094. /**
  57095. * Gets the world input component
  57096. */
  57097. get world(): NodeMaterialConnectionPoint;
  57098. /**
  57099. * Gets the camera (or eye) position component
  57100. */
  57101. get cameraPosition(): NodeMaterialConnectionPoint;
  57102. /**
  57103. * Gets the view input component
  57104. */
  57105. get view(): NodeMaterialConnectionPoint;
  57106. /**
  57107. * Gets the rgb output component
  57108. */
  57109. get rgb(): NodeMaterialConnectionPoint;
  57110. /**
  57111. * Gets the r output component
  57112. */
  57113. get r(): NodeMaterialConnectionPoint;
  57114. /**
  57115. * Gets the g output component
  57116. */
  57117. get g(): NodeMaterialConnectionPoint;
  57118. /**
  57119. * Gets the b output component
  57120. */
  57121. get b(): NodeMaterialConnectionPoint;
  57122. autoConfigure(material: NodeMaterial): void;
  57123. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57124. isReady(): boolean;
  57125. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57126. private _injectVertexCode;
  57127. private _writeOutput;
  57128. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57129. protected _dumpPropertiesCode(): string;
  57130. serialize(): any;
  57131. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57132. }
  57133. }
  57134. declare module BABYLON {
  57135. /**
  57136. * Interface used to configure the node material editor
  57137. */
  57138. export interface INodeMaterialEditorOptions {
  57139. /** Define the URl to load node editor script */
  57140. editorURL?: string;
  57141. }
  57142. /** @hidden */
  57143. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57144. NORMAL: boolean;
  57145. TANGENT: boolean;
  57146. UV1: boolean;
  57147. /** BONES */
  57148. NUM_BONE_INFLUENCERS: number;
  57149. BonesPerMesh: number;
  57150. BONETEXTURE: boolean;
  57151. /** MORPH TARGETS */
  57152. MORPHTARGETS: boolean;
  57153. MORPHTARGETS_NORMAL: boolean;
  57154. MORPHTARGETS_TANGENT: boolean;
  57155. MORPHTARGETS_UV: boolean;
  57156. NUM_MORPH_INFLUENCERS: number;
  57157. /** IMAGE PROCESSING */
  57158. IMAGEPROCESSING: boolean;
  57159. VIGNETTE: boolean;
  57160. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57161. VIGNETTEBLENDMODEOPAQUE: boolean;
  57162. TONEMAPPING: boolean;
  57163. TONEMAPPING_ACES: boolean;
  57164. CONTRAST: boolean;
  57165. EXPOSURE: boolean;
  57166. COLORCURVES: boolean;
  57167. COLORGRADING: boolean;
  57168. COLORGRADING3D: boolean;
  57169. SAMPLER3DGREENDEPTH: boolean;
  57170. SAMPLER3DBGRMAP: boolean;
  57171. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57172. /** MISC. */
  57173. BUMPDIRECTUV: number;
  57174. constructor();
  57175. setValue(name: string, value: boolean): void;
  57176. }
  57177. /**
  57178. * Class used to configure NodeMaterial
  57179. */
  57180. export interface INodeMaterialOptions {
  57181. /**
  57182. * Defines if blocks should emit comments
  57183. */
  57184. emitComments: boolean;
  57185. }
  57186. /**
  57187. * Class used to create a node based material built by assembling shader blocks
  57188. */
  57189. export class NodeMaterial extends PushMaterial {
  57190. private static _BuildIdGenerator;
  57191. private _options;
  57192. private _vertexCompilationState;
  57193. private _fragmentCompilationState;
  57194. private _sharedData;
  57195. private _buildId;
  57196. private _buildWasSuccessful;
  57197. private _cachedWorldViewMatrix;
  57198. private _cachedWorldViewProjectionMatrix;
  57199. private _optimizers;
  57200. private _animationFrame;
  57201. /** Define the Url to load node editor script */
  57202. static EditorURL: string;
  57203. /** Define the Url to load snippets */
  57204. static SnippetUrl: string;
  57205. private BJSNODEMATERIALEDITOR;
  57206. /** Get the inspector from bundle or global */
  57207. private _getGlobalNodeMaterialEditor;
  57208. /**
  57209. * Gets or sets data used by visual editor
  57210. * @see https://nme.babylonjs.com
  57211. */
  57212. editorData: any;
  57213. /**
  57214. * 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)
  57215. */
  57216. ignoreAlpha: boolean;
  57217. /**
  57218. * Defines the maximum number of lights that can be used in the material
  57219. */
  57220. maxSimultaneousLights: number;
  57221. /**
  57222. * Observable raised when the material is built
  57223. */
  57224. onBuildObservable: Observable<NodeMaterial>;
  57225. /**
  57226. * Gets or sets the root nodes of the material vertex shader
  57227. */
  57228. _vertexOutputNodes: NodeMaterialBlock[];
  57229. /**
  57230. * Gets or sets the root nodes of the material fragment (pixel) shader
  57231. */
  57232. _fragmentOutputNodes: NodeMaterialBlock[];
  57233. /** Gets or sets options to control the node material overall behavior */
  57234. get options(): INodeMaterialOptions;
  57235. set options(options: INodeMaterialOptions);
  57236. /**
  57237. * Default configuration related to image processing available in the standard Material.
  57238. */
  57239. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57240. /**
  57241. * Gets the image processing configuration used either in this material.
  57242. */
  57243. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57244. /**
  57245. * Sets the Default image processing configuration used either in the this material.
  57246. *
  57247. * If sets to null, the scene one is in use.
  57248. */
  57249. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57250. /**
  57251. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57252. */
  57253. attachedBlocks: NodeMaterialBlock[];
  57254. /**
  57255. * Create a new node based material
  57256. * @param name defines the material name
  57257. * @param scene defines the hosting scene
  57258. * @param options defines creation option
  57259. */
  57260. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57261. /**
  57262. * Gets the current class name of the material e.g. "NodeMaterial"
  57263. * @returns the class name
  57264. */
  57265. getClassName(): string;
  57266. /**
  57267. * Keep track of the image processing observer to allow dispose and replace.
  57268. */
  57269. private _imageProcessingObserver;
  57270. /**
  57271. * Attaches a new image processing configuration to the Standard Material.
  57272. * @param configuration
  57273. */
  57274. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57275. /**
  57276. * Get a block by its name
  57277. * @param name defines the name of the block to retrieve
  57278. * @returns the required block or null if not found
  57279. */
  57280. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57281. /**
  57282. * Get a block by its name
  57283. * @param predicate defines the predicate used to find the good candidate
  57284. * @returns the required block or null if not found
  57285. */
  57286. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57287. /**
  57288. * Get an input block by its name
  57289. * @param predicate defines the predicate used to find the good candidate
  57290. * @returns the required input block or null if not found
  57291. */
  57292. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57293. /**
  57294. * Gets the list of input blocks attached to this material
  57295. * @returns an array of InputBlocks
  57296. */
  57297. getInputBlocks(): InputBlock[];
  57298. /**
  57299. * Adds a new optimizer to the list of optimizers
  57300. * @param optimizer defines the optimizers to add
  57301. * @returns the current material
  57302. */
  57303. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57304. /**
  57305. * Remove an optimizer from the list of optimizers
  57306. * @param optimizer defines the optimizers to remove
  57307. * @returns the current material
  57308. */
  57309. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57310. /**
  57311. * Add a new block to the list of output nodes
  57312. * @param node defines the node to add
  57313. * @returns the current material
  57314. */
  57315. addOutputNode(node: NodeMaterialBlock): this;
  57316. /**
  57317. * Remove a block from the list of root nodes
  57318. * @param node defines the node to remove
  57319. * @returns the current material
  57320. */
  57321. removeOutputNode(node: NodeMaterialBlock): this;
  57322. private _addVertexOutputNode;
  57323. private _removeVertexOutputNode;
  57324. private _addFragmentOutputNode;
  57325. private _removeFragmentOutputNode;
  57326. /**
  57327. * Specifies if the material will require alpha blending
  57328. * @returns a boolean specifying if alpha blending is needed
  57329. */
  57330. needAlphaBlending(): boolean;
  57331. /**
  57332. * Specifies if this material should be rendered in alpha test mode
  57333. * @returns a boolean specifying if an alpha test is needed.
  57334. */
  57335. needAlphaTesting(): boolean;
  57336. private _initializeBlock;
  57337. private _resetDualBlocks;
  57338. /**
  57339. * Remove a block from the current node material
  57340. * @param block defines the block to remove
  57341. */
  57342. removeBlock(block: NodeMaterialBlock): void;
  57343. /**
  57344. * Build the material and generates the inner effect
  57345. * @param verbose defines if the build should log activity
  57346. */
  57347. build(verbose?: boolean): void;
  57348. /**
  57349. * Runs an otpimization phase to try to improve the shader code
  57350. */
  57351. optimize(): void;
  57352. private _prepareDefinesForAttributes;
  57353. /**
  57354. * Get if the submesh is ready to be used and all its information available.
  57355. * Child classes can use it to update shaders
  57356. * @param mesh defines the mesh to check
  57357. * @param subMesh defines which submesh to check
  57358. * @param useInstances specifies that instances should be used
  57359. * @returns a boolean indicating that the submesh is ready or not
  57360. */
  57361. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57362. /**
  57363. * Get a string representing the shaders built by the current node graph
  57364. */
  57365. get compiledShaders(): string;
  57366. /**
  57367. * Binds the world matrix to the material
  57368. * @param world defines the world transformation matrix
  57369. */
  57370. bindOnlyWorldMatrix(world: Matrix): void;
  57371. /**
  57372. * Binds the submesh to this material by preparing the effect and shader to draw
  57373. * @param world defines the world transformation matrix
  57374. * @param mesh defines the mesh containing the submesh
  57375. * @param subMesh defines the submesh to bind the material to
  57376. */
  57377. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57378. /**
  57379. * Gets the active textures from the material
  57380. * @returns an array of textures
  57381. */
  57382. getActiveTextures(): BaseTexture[];
  57383. /**
  57384. * Gets the list of texture blocks
  57385. * @returns an array of texture blocks
  57386. */
  57387. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57388. /**
  57389. * Specifies if the material uses a texture
  57390. * @param texture defines the texture to check against the material
  57391. * @returns a boolean specifying if the material uses the texture
  57392. */
  57393. hasTexture(texture: BaseTexture): boolean;
  57394. /**
  57395. * Disposes the material
  57396. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57397. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57398. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57399. */
  57400. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57401. /** Creates the node editor window. */
  57402. private _createNodeEditor;
  57403. /**
  57404. * Launch the node material editor
  57405. * @param config Define the configuration of the editor
  57406. * @return a promise fulfilled when the node editor is visible
  57407. */
  57408. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57409. /**
  57410. * Clear the current material
  57411. */
  57412. clear(): void;
  57413. /**
  57414. * Clear the current material and set it to a default state
  57415. */
  57416. setToDefault(): void;
  57417. /**
  57418. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57419. * @param url defines the url to load from
  57420. * @returns a promise that will fullfil when the material is fully loaded
  57421. */
  57422. loadAsync(url: string): Promise<void>;
  57423. private _gatherBlocks;
  57424. /**
  57425. * Generate a string containing the code declaration required to create an equivalent of this material
  57426. * @returns a string
  57427. */
  57428. generateCode(): string;
  57429. /**
  57430. * Serializes this material in a JSON representation
  57431. * @returns the serialized material object
  57432. */
  57433. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57434. private _restoreConnections;
  57435. /**
  57436. * Clear the current graph and load a new one from a serialization object
  57437. * @param source defines the JSON representation of the material
  57438. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57439. */
  57440. loadFromSerialization(source: any, rootUrl?: string): void;
  57441. /**
  57442. * Creates a node material from parsed material data
  57443. * @param source defines the JSON representation of the material
  57444. * @param scene defines the hosting scene
  57445. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57446. * @returns a new node material
  57447. */
  57448. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57449. /**
  57450. * Creates a node material from a snippet saved by the node material editor
  57451. * @param snippetId defines the snippet to load
  57452. * @param scene defines the hosting scene
  57453. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57454. * @returns a promise that will resolve to the new node material
  57455. */
  57456. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57457. /**
  57458. * Creates a new node material set to default basic configuration
  57459. * @param name defines the name of the material
  57460. * @param scene defines the hosting scene
  57461. * @returns a new NodeMaterial
  57462. */
  57463. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57464. }
  57465. }
  57466. declare module BABYLON {
  57467. /**
  57468. * Block used to read a texture from a sampler
  57469. */
  57470. export class TextureBlock extends NodeMaterialBlock {
  57471. private _defineName;
  57472. private _linearDefineName;
  57473. private _tempTextureRead;
  57474. private _samplerName;
  57475. private _transformedUVName;
  57476. private _textureTransformName;
  57477. private _textureInfoName;
  57478. private _mainUVName;
  57479. private _mainUVDefineName;
  57480. /**
  57481. * Gets or sets the texture associated with the node
  57482. */
  57483. texture: Nullable<Texture>;
  57484. /**
  57485. * Create a new TextureBlock
  57486. * @param name defines the block name
  57487. */
  57488. constructor(name: string);
  57489. /**
  57490. * Gets the current class name
  57491. * @returns the class name
  57492. */
  57493. getClassName(): string;
  57494. /**
  57495. * Gets the uv input component
  57496. */
  57497. get uv(): NodeMaterialConnectionPoint;
  57498. /**
  57499. * Gets the rgba output component
  57500. */
  57501. get rgba(): NodeMaterialConnectionPoint;
  57502. /**
  57503. * Gets the rgb output component
  57504. */
  57505. get rgb(): NodeMaterialConnectionPoint;
  57506. /**
  57507. * Gets the r output component
  57508. */
  57509. get r(): NodeMaterialConnectionPoint;
  57510. /**
  57511. * Gets the g output component
  57512. */
  57513. get g(): NodeMaterialConnectionPoint;
  57514. /**
  57515. * Gets the b output component
  57516. */
  57517. get b(): NodeMaterialConnectionPoint;
  57518. /**
  57519. * Gets the a output component
  57520. */
  57521. get a(): NodeMaterialConnectionPoint;
  57522. get target(): NodeMaterialBlockTargets;
  57523. autoConfigure(material: NodeMaterial): void;
  57524. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57526. isReady(): boolean;
  57527. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57528. private get _isMixed();
  57529. private _injectVertexCode;
  57530. private _writeTextureRead;
  57531. private _writeOutput;
  57532. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57533. protected _dumpPropertiesCode(): string;
  57534. serialize(): any;
  57535. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57536. }
  57537. }
  57538. declare module BABYLON {
  57539. /**
  57540. * Class used to store shared data between 2 NodeMaterialBuildState
  57541. */
  57542. export class NodeMaterialBuildStateSharedData {
  57543. /**
  57544. * Gets the list of emitted varyings
  57545. */
  57546. temps: string[];
  57547. /**
  57548. * Gets the list of emitted varyings
  57549. */
  57550. varyings: string[];
  57551. /**
  57552. * Gets the varying declaration string
  57553. */
  57554. varyingDeclaration: string;
  57555. /**
  57556. * Input blocks
  57557. */
  57558. inputBlocks: InputBlock[];
  57559. /**
  57560. * Input blocks
  57561. */
  57562. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57563. /**
  57564. * Bindable blocks (Blocks that need to set data to the effect)
  57565. */
  57566. bindableBlocks: NodeMaterialBlock[];
  57567. /**
  57568. * List of blocks that can provide a compilation fallback
  57569. */
  57570. blocksWithFallbacks: NodeMaterialBlock[];
  57571. /**
  57572. * List of blocks that can provide a define update
  57573. */
  57574. blocksWithDefines: NodeMaterialBlock[];
  57575. /**
  57576. * List of blocks that can provide a repeatable content
  57577. */
  57578. repeatableContentBlocks: NodeMaterialBlock[];
  57579. /**
  57580. * List of blocks that can provide a dynamic list of uniforms
  57581. */
  57582. dynamicUniformBlocks: NodeMaterialBlock[];
  57583. /**
  57584. * List of blocks that can block the isReady function for the material
  57585. */
  57586. blockingBlocks: NodeMaterialBlock[];
  57587. /**
  57588. * Gets the list of animated inputs
  57589. */
  57590. animatedInputs: InputBlock[];
  57591. /**
  57592. * Build Id used to avoid multiple recompilations
  57593. */
  57594. buildId: number;
  57595. /** List of emitted variables */
  57596. variableNames: {
  57597. [key: string]: number;
  57598. };
  57599. /** List of emitted defines */
  57600. defineNames: {
  57601. [key: string]: number;
  57602. };
  57603. /** Should emit comments? */
  57604. emitComments: boolean;
  57605. /** Emit build activity */
  57606. verbose: boolean;
  57607. /** Gets or sets the hosting scene */
  57608. scene: Scene;
  57609. /**
  57610. * Gets the compilation hints emitted at compilation time
  57611. */
  57612. hints: {
  57613. needWorldViewMatrix: boolean;
  57614. needWorldViewProjectionMatrix: boolean;
  57615. needAlphaBlending: boolean;
  57616. needAlphaTesting: boolean;
  57617. };
  57618. /**
  57619. * List of compilation checks
  57620. */
  57621. checks: {
  57622. emitVertex: boolean;
  57623. emitFragment: boolean;
  57624. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57625. };
  57626. /** Creates a new shared data */
  57627. constructor();
  57628. /**
  57629. * Emits console errors and exceptions if there is a failing check
  57630. */
  57631. emitErrors(): void;
  57632. }
  57633. }
  57634. declare module BABYLON {
  57635. /**
  57636. * Class used to store node based material build state
  57637. */
  57638. export class NodeMaterialBuildState {
  57639. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57640. supportUniformBuffers: boolean;
  57641. /**
  57642. * Gets the list of emitted attributes
  57643. */
  57644. attributes: string[];
  57645. /**
  57646. * Gets the list of emitted uniforms
  57647. */
  57648. uniforms: string[];
  57649. /**
  57650. * Gets the list of emitted constants
  57651. */
  57652. constants: string[];
  57653. /**
  57654. * Gets the list of emitted samplers
  57655. */
  57656. samplers: string[];
  57657. /**
  57658. * Gets the list of emitted functions
  57659. */
  57660. functions: {
  57661. [key: string]: string;
  57662. };
  57663. /**
  57664. * Gets the list of emitted extensions
  57665. */
  57666. extensions: {
  57667. [key: string]: string;
  57668. };
  57669. /**
  57670. * Gets the target of the compilation state
  57671. */
  57672. target: NodeMaterialBlockTargets;
  57673. /**
  57674. * Gets the list of emitted counters
  57675. */
  57676. counters: {
  57677. [key: string]: number;
  57678. };
  57679. /**
  57680. * Shared data between multiple NodeMaterialBuildState instances
  57681. */
  57682. sharedData: NodeMaterialBuildStateSharedData;
  57683. /** @hidden */
  57684. _vertexState: NodeMaterialBuildState;
  57685. /** @hidden */
  57686. _attributeDeclaration: string;
  57687. /** @hidden */
  57688. _uniformDeclaration: string;
  57689. /** @hidden */
  57690. _constantDeclaration: string;
  57691. /** @hidden */
  57692. _samplerDeclaration: string;
  57693. /** @hidden */
  57694. _varyingTransfer: string;
  57695. private _repeatableContentAnchorIndex;
  57696. /** @hidden */
  57697. _builtCompilationString: string;
  57698. /**
  57699. * Gets the emitted compilation strings
  57700. */
  57701. compilationString: string;
  57702. /**
  57703. * Finalize the compilation strings
  57704. * @param state defines the current compilation state
  57705. */
  57706. finalize(state: NodeMaterialBuildState): void;
  57707. /** @hidden */
  57708. get _repeatableContentAnchor(): string;
  57709. /** @hidden */
  57710. _getFreeVariableName(prefix: string): string;
  57711. /** @hidden */
  57712. _getFreeDefineName(prefix: string): string;
  57713. /** @hidden */
  57714. _excludeVariableName(name: string): void;
  57715. /** @hidden */
  57716. _emit2DSampler(name: string): void;
  57717. /** @hidden */
  57718. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57719. /** @hidden */
  57720. _emitExtension(name: string, extension: string): void;
  57721. /** @hidden */
  57722. _emitFunction(name: string, code: string, comments: string): void;
  57723. /** @hidden */
  57724. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57725. replaceStrings?: {
  57726. search: RegExp;
  57727. replace: string;
  57728. }[];
  57729. repeatKey?: string;
  57730. }): string;
  57731. /** @hidden */
  57732. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57733. repeatKey?: string;
  57734. removeAttributes?: boolean;
  57735. removeUniforms?: boolean;
  57736. removeVaryings?: boolean;
  57737. removeIfDef?: boolean;
  57738. replaceStrings?: {
  57739. search: RegExp;
  57740. replace: string;
  57741. }[];
  57742. }, storeKey?: string): void;
  57743. /** @hidden */
  57744. _registerTempVariable(name: string): boolean;
  57745. /** @hidden */
  57746. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57747. /** @hidden */
  57748. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57749. /** @hidden */
  57750. _emitFloat(value: number): string;
  57751. }
  57752. }
  57753. declare module BABYLON {
  57754. /**
  57755. * Defines a block that can be used inside a node based material
  57756. */
  57757. export class NodeMaterialBlock {
  57758. private _buildId;
  57759. private _buildTarget;
  57760. private _target;
  57761. private _isFinalMerger;
  57762. private _isInput;
  57763. protected _isUnique: boolean;
  57764. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57765. inputsAreExclusive: boolean;
  57766. /** @hidden */
  57767. _codeVariableName: string;
  57768. /** @hidden */
  57769. _inputs: NodeMaterialConnectionPoint[];
  57770. /** @hidden */
  57771. _outputs: NodeMaterialConnectionPoint[];
  57772. /** @hidden */
  57773. _preparationId: number;
  57774. /**
  57775. * Gets or sets the name of the block
  57776. */
  57777. name: string;
  57778. /**
  57779. * Gets or sets the unique id of the node
  57780. */
  57781. uniqueId: number;
  57782. /**
  57783. * Gets or sets the comments associated with this block
  57784. */
  57785. comments: string;
  57786. /**
  57787. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57788. */
  57789. get isUnique(): boolean;
  57790. /**
  57791. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57792. */
  57793. get isFinalMerger(): boolean;
  57794. /**
  57795. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57796. */
  57797. get isInput(): boolean;
  57798. /**
  57799. * Gets or sets the build Id
  57800. */
  57801. get buildId(): number;
  57802. set buildId(value: number);
  57803. /**
  57804. * Gets or sets the target of the block
  57805. */
  57806. get target(): NodeMaterialBlockTargets;
  57807. set target(value: NodeMaterialBlockTargets);
  57808. /**
  57809. * Gets the list of input points
  57810. */
  57811. get inputs(): NodeMaterialConnectionPoint[];
  57812. /** Gets the list of output points */
  57813. get outputs(): NodeMaterialConnectionPoint[];
  57814. /**
  57815. * Find an input by its name
  57816. * @param name defines the name of the input to look for
  57817. * @returns the input or null if not found
  57818. */
  57819. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57820. /**
  57821. * Find an output by its name
  57822. * @param name defines the name of the outputto look for
  57823. * @returns the output or null if not found
  57824. */
  57825. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57826. /**
  57827. * Creates a new NodeMaterialBlock
  57828. * @param name defines the block name
  57829. * @param target defines the target of that block (Vertex by default)
  57830. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57831. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57832. */
  57833. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57834. /**
  57835. * Initialize the block and prepare the context for build
  57836. * @param state defines the state that will be used for the build
  57837. */
  57838. initialize(state: NodeMaterialBuildState): void;
  57839. /**
  57840. * Bind data to effect. Will only be called for blocks with isBindable === true
  57841. * @param effect defines the effect to bind data to
  57842. * @param nodeMaterial defines the hosting NodeMaterial
  57843. * @param mesh defines the mesh that will be rendered
  57844. */
  57845. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57846. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57847. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57848. protected _writeFloat(value: number): string;
  57849. /**
  57850. * Gets the current class name e.g. "NodeMaterialBlock"
  57851. * @returns the class name
  57852. */
  57853. getClassName(): string;
  57854. /**
  57855. * Register a new input. Must be called inside a block constructor
  57856. * @param name defines the connection point name
  57857. * @param type defines the connection point type
  57858. * @param isOptional defines a boolean indicating that this input can be omitted
  57859. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57860. * @returns the current block
  57861. */
  57862. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57863. /**
  57864. * Register a new output. Must be called inside a block constructor
  57865. * @param name defines the connection point name
  57866. * @param type defines the connection point type
  57867. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57868. * @returns the current block
  57869. */
  57870. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57871. /**
  57872. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57873. * @param forOutput defines an optional connection point to check compatibility with
  57874. * @returns the first available input or null
  57875. */
  57876. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57877. /**
  57878. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57879. * @param forBlock defines an optional block to check compatibility with
  57880. * @returns the first available input or null
  57881. */
  57882. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57883. /**
  57884. * Gets the sibling of the given output
  57885. * @param current defines the current output
  57886. * @returns the next output in the list or null
  57887. */
  57888. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57889. /**
  57890. * Connect current block with another block
  57891. * @param other defines the block to connect with
  57892. * @param options define the various options to help pick the right connections
  57893. * @returns the current block
  57894. */
  57895. connectTo(other: NodeMaterialBlock, options?: {
  57896. input?: string;
  57897. output?: string;
  57898. outputSwizzle?: string;
  57899. }): this | undefined;
  57900. protected _buildBlock(state: NodeMaterialBuildState): void;
  57901. /**
  57902. * Add uniforms, samplers and uniform buffers at compilation time
  57903. * @param state defines the state to update
  57904. * @param nodeMaterial defines the node material requesting the update
  57905. * @param defines defines the material defines to update
  57906. * @param uniformBuffers defines the list of uniform buffer names
  57907. */
  57908. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57909. /**
  57910. * Add potential fallbacks if shader compilation fails
  57911. * @param mesh defines the mesh to be rendered
  57912. * @param fallbacks defines the current prioritized list of fallbacks
  57913. */
  57914. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57915. /**
  57916. * Initialize defines for shader compilation
  57917. * @param mesh defines the mesh to be rendered
  57918. * @param nodeMaterial defines the node material requesting the update
  57919. * @param defines defines the material defines to update
  57920. * @param useInstances specifies that instances should be used
  57921. */
  57922. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57923. /**
  57924. * Update defines for shader compilation
  57925. * @param mesh defines the mesh to be rendered
  57926. * @param nodeMaterial defines the node material requesting the update
  57927. * @param defines defines the material defines to update
  57928. * @param useInstances specifies that instances should be used
  57929. */
  57930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57931. /**
  57932. * Lets the block try to connect some inputs automatically
  57933. * @param material defines the hosting NodeMaterial
  57934. */
  57935. autoConfigure(material: NodeMaterial): void;
  57936. /**
  57937. * Function called when a block is declared as repeatable content generator
  57938. * @param vertexShaderState defines the current compilation state for the vertex shader
  57939. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57940. * @param mesh defines the mesh to be rendered
  57941. * @param defines defines the material defines to update
  57942. */
  57943. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57944. /**
  57945. * Checks if the block is ready
  57946. * @param mesh defines the mesh to be rendered
  57947. * @param nodeMaterial defines the node material requesting the update
  57948. * @param defines defines the material defines to update
  57949. * @param useInstances specifies that instances should be used
  57950. * @returns true if the block is ready
  57951. */
  57952. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57953. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57954. private _processBuild;
  57955. /**
  57956. * Compile the current node and generate the shader code
  57957. * @param state defines the current compilation state (uniforms, samplers, current string)
  57958. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57959. * @returns true if already built
  57960. */
  57961. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57962. protected _inputRename(name: string): string;
  57963. protected _outputRename(name: string): string;
  57964. protected _dumpPropertiesCode(): string;
  57965. /** @hidden */
  57966. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57967. /** @hidden */
  57968. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57969. /**
  57970. * Clone the current block to a new identical block
  57971. * @param scene defines the hosting scene
  57972. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57973. * @returns a copy of the current block
  57974. */
  57975. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57976. /**
  57977. * Serializes this block in a JSON representation
  57978. * @returns the serialized block object
  57979. */
  57980. serialize(): any;
  57981. /** @hidden */
  57982. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57983. /**
  57984. * Release resources
  57985. */
  57986. dispose(): void;
  57987. }
  57988. }
  57989. declare module BABYLON {
  57990. /**
  57991. * Enum defining the type of animations supported by InputBlock
  57992. */
  57993. export enum AnimatedInputBlockTypes {
  57994. /** No animation */
  57995. None = 0,
  57996. /** Time based animation. Will only work for floats */
  57997. Time = 1
  57998. }
  57999. }
  58000. declare module BABYLON {
  58001. /**
  58002. * Block used to expose an input value
  58003. */
  58004. export class InputBlock extends NodeMaterialBlock {
  58005. private _mode;
  58006. private _associatedVariableName;
  58007. private _storedValue;
  58008. private _valueCallback;
  58009. private _type;
  58010. private _animationType;
  58011. /** Gets or set a value used to limit the range of float values */
  58012. min: number;
  58013. /** Gets or set a value used to limit the range of float values */
  58014. max: number;
  58015. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58016. isBoolean: boolean;
  58017. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58018. matrixMode: number;
  58019. /** @hidden */
  58020. _systemValue: Nullable<NodeMaterialSystemValues>;
  58021. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58022. visibleInInspector: boolean;
  58023. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58024. isConstant: boolean;
  58025. /** Gets or sets the group to use to display this block in the Inspector */
  58026. groupInInspector: string;
  58027. /**
  58028. * Gets or sets the connection point type (default is float)
  58029. */
  58030. get type(): NodeMaterialBlockConnectionPointTypes;
  58031. /**
  58032. * Creates a new InputBlock
  58033. * @param name defines the block name
  58034. * @param target defines the target of that block (Vertex by default)
  58035. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58036. */
  58037. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58038. /**
  58039. * Gets the output component
  58040. */
  58041. get output(): NodeMaterialConnectionPoint;
  58042. /**
  58043. * Set the source of this connection point to a vertex attribute
  58044. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58045. * @returns the current connection point
  58046. */
  58047. setAsAttribute(attributeName?: string): InputBlock;
  58048. /**
  58049. * Set the source of this connection point to a system value
  58050. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58051. * @returns the current connection point
  58052. */
  58053. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58054. /**
  58055. * Gets or sets the value of that point.
  58056. * Please note that this value will be ignored if valueCallback is defined
  58057. */
  58058. get value(): any;
  58059. set value(value: any);
  58060. /**
  58061. * Gets or sets a callback used to get the value of that point.
  58062. * Please note that setting this value will force the connection point to ignore the value property
  58063. */
  58064. get valueCallback(): () => any;
  58065. set valueCallback(value: () => any);
  58066. /**
  58067. * Gets or sets the associated variable name in the shader
  58068. */
  58069. get associatedVariableName(): string;
  58070. set associatedVariableName(value: string);
  58071. /** Gets or sets the type of animation applied to the input */
  58072. get animationType(): AnimatedInputBlockTypes;
  58073. set animationType(value: AnimatedInputBlockTypes);
  58074. /**
  58075. * Gets a boolean indicating that this connection point not defined yet
  58076. */
  58077. get isUndefined(): boolean;
  58078. /**
  58079. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58080. * In this case the connection point name must be the name of the uniform to use.
  58081. * Can only be set on inputs
  58082. */
  58083. get isUniform(): boolean;
  58084. set isUniform(value: boolean);
  58085. /**
  58086. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58087. * In this case the connection point name must be the name of the attribute to use
  58088. * Can only be set on inputs
  58089. */
  58090. get isAttribute(): boolean;
  58091. set isAttribute(value: boolean);
  58092. /**
  58093. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58094. * Can only be set on exit points
  58095. */
  58096. get isVarying(): boolean;
  58097. set isVarying(value: boolean);
  58098. /**
  58099. * Gets a boolean indicating that the current connection point is a system value
  58100. */
  58101. get isSystemValue(): boolean;
  58102. /**
  58103. * Gets or sets the current well known value or null if not defined as a system value
  58104. */
  58105. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58106. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58107. /**
  58108. * Gets the current class name
  58109. * @returns the class name
  58110. */
  58111. getClassName(): string;
  58112. /**
  58113. * Animate the input if animationType !== None
  58114. * @param scene defines the rendering scene
  58115. */
  58116. animate(scene: Scene): void;
  58117. private _emitDefine;
  58118. initialize(state: NodeMaterialBuildState): void;
  58119. /**
  58120. * Set the input block to its default value (based on its type)
  58121. */
  58122. setDefaultValue(): void;
  58123. private _emitConstant;
  58124. private _emit;
  58125. /** @hidden */
  58126. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58127. /** @hidden */
  58128. _transmit(effect: Effect, scene: Scene): void;
  58129. protected _buildBlock(state: NodeMaterialBuildState): void;
  58130. protected _dumpPropertiesCode(): string;
  58131. serialize(): any;
  58132. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58133. }
  58134. }
  58135. declare module BABYLON {
  58136. /**
  58137. * Enum used to define the compatibility state between two connection points
  58138. */
  58139. export enum NodeMaterialConnectionPointCompatibilityStates {
  58140. /** Points are compatibles */
  58141. Compatible = 0,
  58142. /** Points are incompatible because of their types */
  58143. TypeIncompatible = 1,
  58144. /** Points are incompatible because of their targets (vertex vs fragment) */
  58145. TargetIncompatible = 2
  58146. }
  58147. /**
  58148. * Defines the direction of a connection point
  58149. */
  58150. export enum NodeMaterialConnectionPointDirection {
  58151. /** Input */
  58152. Input = 0,
  58153. /** Output */
  58154. Output = 1
  58155. }
  58156. /**
  58157. * Defines a connection point for a block
  58158. */
  58159. export class NodeMaterialConnectionPoint {
  58160. /** @hidden */
  58161. _ownerBlock: NodeMaterialBlock;
  58162. /** @hidden */
  58163. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58164. private _endpoints;
  58165. private _associatedVariableName;
  58166. private _direction;
  58167. /** @hidden */
  58168. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58169. /** @hidden */
  58170. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58171. private _type;
  58172. /** @hidden */
  58173. _enforceAssociatedVariableName: boolean;
  58174. /** Gets the direction of the point */
  58175. get direction(): NodeMaterialConnectionPointDirection;
  58176. /**
  58177. * Gets or sets the additional types supported by this connection point
  58178. */
  58179. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58180. /**
  58181. * Gets or sets the additional types excluded by this connection point
  58182. */
  58183. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58184. /**
  58185. * Observable triggered when this point is connected
  58186. */
  58187. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58188. /**
  58189. * Gets or sets the associated variable name in the shader
  58190. */
  58191. get associatedVariableName(): string;
  58192. set associatedVariableName(value: string);
  58193. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  58194. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58195. /**
  58196. * Gets or sets the connection point type (default is float)
  58197. */
  58198. get type(): NodeMaterialBlockConnectionPointTypes;
  58199. set type(value: NodeMaterialBlockConnectionPointTypes);
  58200. /**
  58201. * Gets or sets the connection point name
  58202. */
  58203. name: string;
  58204. /**
  58205. * Gets or sets a boolean indicating that this connection point can be omitted
  58206. */
  58207. isOptional: boolean;
  58208. /**
  58209. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58210. */
  58211. define: string;
  58212. /** @hidden */
  58213. _prioritizeVertex: boolean;
  58214. private _target;
  58215. /** Gets or sets the target of that connection point */
  58216. get target(): NodeMaterialBlockTargets;
  58217. set target(value: NodeMaterialBlockTargets);
  58218. /**
  58219. * Gets a boolean indicating that the current point is connected
  58220. */
  58221. get isConnected(): boolean;
  58222. /**
  58223. * Gets a boolean indicating that the current point is connected to an input block
  58224. */
  58225. get isConnectedToInputBlock(): boolean;
  58226. /**
  58227. * Gets a the connected input block (if any)
  58228. */
  58229. get connectInputBlock(): Nullable<InputBlock>;
  58230. /** Get the other side of the connection (if any) */
  58231. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58232. /** Get the block that owns this connection point */
  58233. get ownerBlock(): NodeMaterialBlock;
  58234. /** Get the block connected on the other side of this connection (if any) */
  58235. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58236. /** Get the block connected on the endpoints of this connection (if any) */
  58237. get connectedBlocks(): Array<NodeMaterialBlock>;
  58238. /** Gets the list of connected endpoints */
  58239. get endpoints(): NodeMaterialConnectionPoint[];
  58240. /** Gets a boolean indicating if that output point is connected to at least one input */
  58241. get hasEndpoints(): boolean;
  58242. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58243. get isConnectedInVertexShader(): boolean;
  58244. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58245. get isConnectedInFragmentShader(): boolean;
  58246. /**
  58247. * Creates a new connection point
  58248. * @param name defines the connection point name
  58249. * @param ownerBlock defines the block hosting this connection point
  58250. * @param direction defines the direction of the connection point
  58251. */
  58252. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58253. /**
  58254. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58255. * @returns the class name
  58256. */
  58257. getClassName(): string;
  58258. /**
  58259. * Gets a boolean indicating if the current point can be connected to another point
  58260. * @param connectionPoint defines the other connection point
  58261. * @returns a boolean
  58262. */
  58263. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58264. /**
  58265. * Gets a number indicating if the current point can be connected to another point
  58266. * @param connectionPoint defines the other connection point
  58267. * @returns a number defining the compatibility state
  58268. */
  58269. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58270. /**
  58271. * Connect this point to another connection point
  58272. * @param connectionPoint defines the other connection point
  58273. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58274. * @returns the current connection point
  58275. */
  58276. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58277. /**
  58278. * Disconnect this point from one of his endpoint
  58279. * @param endpoint defines the other connection point
  58280. * @returns the current connection point
  58281. */
  58282. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58283. /**
  58284. * Serializes this point in a JSON representation
  58285. * @returns the serialized point object
  58286. */
  58287. serialize(): any;
  58288. /**
  58289. * Release resources
  58290. */
  58291. dispose(): void;
  58292. }
  58293. }
  58294. declare module BABYLON {
  58295. /**
  58296. * Block used to add support for vertex skinning (bones)
  58297. */
  58298. export class BonesBlock extends NodeMaterialBlock {
  58299. /**
  58300. * Creates a new BonesBlock
  58301. * @param name defines the block name
  58302. */
  58303. constructor(name: string);
  58304. /**
  58305. * Initialize the block and prepare the context for build
  58306. * @param state defines the state that will be used for the build
  58307. */
  58308. initialize(state: NodeMaterialBuildState): void;
  58309. /**
  58310. * Gets the current class name
  58311. * @returns the class name
  58312. */
  58313. getClassName(): string;
  58314. /**
  58315. * Gets the matrix indices input component
  58316. */
  58317. get matricesIndices(): NodeMaterialConnectionPoint;
  58318. /**
  58319. * Gets the matrix weights input component
  58320. */
  58321. get matricesWeights(): NodeMaterialConnectionPoint;
  58322. /**
  58323. * Gets the extra matrix indices input component
  58324. */
  58325. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58326. /**
  58327. * Gets the extra matrix weights input component
  58328. */
  58329. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58330. /**
  58331. * Gets the world input component
  58332. */
  58333. get world(): NodeMaterialConnectionPoint;
  58334. /**
  58335. * Gets the output component
  58336. */
  58337. get output(): NodeMaterialConnectionPoint;
  58338. autoConfigure(material: NodeMaterial): void;
  58339. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58340. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58342. protected _buildBlock(state: NodeMaterialBuildState): this;
  58343. }
  58344. }
  58345. declare module BABYLON {
  58346. /**
  58347. * Block used to add support for instances
  58348. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58349. */
  58350. export class InstancesBlock extends NodeMaterialBlock {
  58351. /**
  58352. * Creates a new InstancesBlock
  58353. * @param name defines the block name
  58354. */
  58355. constructor(name: string);
  58356. /**
  58357. * Gets the current class name
  58358. * @returns the class name
  58359. */
  58360. getClassName(): string;
  58361. /**
  58362. * Gets the first world row input component
  58363. */
  58364. get world0(): NodeMaterialConnectionPoint;
  58365. /**
  58366. * Gets the second world row input component
  58367. */
  58368. get world1(): NodeMaterialConnectionPoint;
  58369. /**
  58370. * Gets the third world row input component
  58371. */
  58372. get world2(): NodeMaterialConnectionPoint;
  58373. /**
  58374. * Gets the forth world row input component
  58375. */
  58376. get world3(): NodeMaterialConnectionPoint;
  58377. /**
  58378. * Gets the world input component
  58379. */
  58380. get world(): NodeMaterialConnectionPoint;
  58381. /**
  58382. * Gets the output component
  58383. */
  58384. get output(): NodeMaterialConnectionPoint;
  58385. /**
  58386. * Gets the isntanceID component
  58387. */
  58388. get instanceID(): NodeMaterialConnectionPoint;
  58389. autoConfigure(material: NodeMaterial): void;
  58390. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58391. protected _buildBlock(state: NodeMaterialBuildState): this;
  58392. }
  58393. }
  58394. declare module BABYLON {
  58395. /**
  58396. * Block used to add morph targets support to vertex shader
  58397. */
  58398. export class MorphTargetsBlock extends NodeMaterialBlock {
  58399. private _repeatableContentAnchor;
  58400. /**
  58401. * Create a new MorphTargetsBlock
  58402. * @param name defines the block name
  58403. */
  58404. constructor(name: string);
  58405. /**
  58406. * Gets the current class name
  58407. * @returns the class name
  58408. */
  58409. getClassName(): string;
  58410. /**
  58411. * Gets the position input component
  58412. */
  58413. get position(): NodeMaterialConnectionPoint;
  58414. /**
  58415. * Gets the normal input component
  58416. */
  58417. get normal(): NodeMaterialConnectionPoint;
  58418. /**
  58419. * Gets the tangent input component
  58420. */
  58421. get tangent(): NodeMaterialConnectionPoint;
  58422. /**
  58423. * Gets the tangent input component
  58424. */
  58425. get uv(): NodeMaterialConnectionPoint;
  58426. /**
  58427. * Gets the position output component
  58428. */
  58429. get positionOutput(): NodeMaterialConnectionPoint;
  58430. /**
  58431. * Gets the normal output component
  58432. */
  58433. get normalOutput(): NodeMaterialConnectionPoint;
  58434. /**
  58435. * Gets the tangent output component
  58436. */
  58437. get tangentOutput(): NodeMaterialConnectionPoint;
  58438. /**
  58439. * Gets the tangent output component
  58440. */
  58441. get uvOutput(): NodeMaterialConnectionPoint;
  58442. initialize(state: NodeMaterialBuildState): void;
  58443. autoConfigure(material: NodeMaterial): void;
  58444. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58445. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58446. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58447. protected _buildBlock(state: NodeMaterialBuildState): this;
  58448. }
  58449. }
  58450. declare module BABYLON {
  58451. /**
  58452. * Block used to get data information from a light
  58453. */
  58454. export class LightInformationBlock extends NodeMaterialBlock {
  58455. private _lightDataUniformName;
  58456. private _lightColorUniformName;
  58457. private _lightTypeDefineName;
  58458. /**
  58459. * Gets or sets the light associated with this block
  58460. */
  58461. light: Nullable<Light>;
  58462. /**
  58463. * Creates a new LightInformationBlock
  58464. * @param name defines the block name
  58465. */
  58466. constructor(name: string);
  58467. /**
  58468. * Gets the current class name
  58469. * @returns the class name
  58470. */
  58471. getClassName(): string;
  58472. /**
  58473. * Gets the world position input component
  58474. */
  58475. get worldPosition(): NodeMaterialConnectionPoint;
  58476. /**
  58477. * Gets the direction output component
  58478. */
  58479. get direction(): NodeMaterialConnectionPoint;
  58480. /**
  58481. * Gets the direction output component
  58482. */
  58483. get color(): NodeMaterialConnectionPoint;
  58484. /**
  58485. * Gets the direction output component
  58486. */
  58487. get intensity(): NodeMaterialConnectionPoint;
  58488. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58489. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58490. protected _buildBlock(state: NodeMaterialBuildState): this;
  58491. serialize(): any;
  58492. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58493. }
  58494. }
  58495. declare module BABYLON {
  58496. /**
  58497. * Block used to add image processing support to fragment shader
  58498. */
  58499. export class ImageProcessingBlock extends NodeMaterialBlock {
  58500. /**
  58501. * Create a new ImageProcessingBlock
  58502. * @param name defines the block name
  58503. */
  58504. constructor(name: string);
  58505. /**
  58506. * Gets the current class name
  58507. * @returns the class name
  58508. */
  58509. getClassName(): string;
  58510. /**
  58511. * Gets the color input component
  58512. */
  58513. get color(): NodeMaterialConnectionPoint;
  58514. /**
  58515. * Gets the output component
  58516. */
  58517. get output(): NodeMaterialConnectionPoint;
  58518. /**
  58519. * Initialize the block and prepare the context for build
  58520. * @param state defines the state that will be used for the build
  58521. */
  58522. initialize(state: NodeMaterialBuildState): void;
  58523. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58524. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58525. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58526. protected _buildBlock(state: NodeMaterialBuildState): this;
  58527. }
  58528. }
  58529. declare module BABYLON {
  58530. /**
  58531. * Block used to pertub normals based on a normal map
  58532. */
  58533. export class PerturbNormalBlock extends NodeMaterialBlock {
  58534. private _tangentSpaceParameterName;
  58535. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58536. invertX: boolean;
  58537. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58538. invertY: boolean;
  58539. /**
  58540. * Create a new PerturbNormalBlock
  58541. * @param name defines the block name
  58542. */
  58543. constructor(name: string);
  58544. /**
  58545. * Gets the current class name
  58546. * @returns the class name
  58547. */
  58548. getClassName(): string;
  58549. /**
  58550. * Gets the world position input component
  58551. */
  58552. get worldPosition(): NodeMaterialConnectionPoint;
  58553. /**
  58554. * Gets the world normal input component
  58555. */
  58556. get worldNormal(): NodeMaterialConnectionPoint;
  58557. /**
  58558. * Gets the uv input component
  58559. */
  58560. get uv(): NodeMaterialConnectionPoint;
  58561. /**
  58562. * Gets the normal map color input component
  58563. */
  58564. get normalMapColor(): NodeMaterialConnectionPoint;
  58565. /**
  58566. * Gets the strength input component
  58567. */
  58568. get strength(): NodeMaterialConnectionPoint;
  58569. /**
  58570. * Gets the output component
  58571. */
  58572. get output(): NodeMaterialConnectionPoint;
  58573. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58574. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58575. autoConfigure(material: NodeMaterial): void;
  58576. protected _buildBlock(state: NodeMaterialBuildState): this;
  58577. protected _dumpPropertiesCode(): string;
  58578. serialize(): any;
  58579. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58580. }
  58581. }
  58582. declare module BABYLON {
  58583. /**
  58584. * Block used to discard a pixel if a value is smaller than a cutoff
  58585. */
  58586. export class DiscardBlock extends NodeMaterialBlock {
  58587. /**
  58588. * Create a new DiscardBlock
  58589. * @param name defines the block name
  58590. */
  58591. constructor(name: string);
  58592. /**
  58593. * Gets the current class name
  58594. * @returns the class name
  58595. */
  58596. getClassName(): string;
  58597. /**
  58598. * Gets the color input component
  58599. */
  58600. get value(): NodeMaterialConnectionPoint;
  58601. /**
  58602. * Gets the cutoff input component
  58603. */
  58604. get cutoff(): NodeMaterialConnectionPoint;
  58605. protected _buildBlock(state: NodeMaterialBuildState): this;
  58606. }
  58607. }
  58608. declare module BABYLON {
  58609. /**
  58610. * Block used to test if the fragment shader is front facing
  58611. */
  58612. export class FrontFacingBlock extends NodeMaterialBlock {
  58613. /**
  58614. * Creates a new FrontFacingBlock
  58615. * @param name defines the block name
  58616. */
  58617. constructor(name: string);
  58618. /**
  58619. * Gets the current class name
  58620. * @returns the class name
  58621. */
  58622. getClassName(): string;
  58623. /**
  58624. * Gets the output component
  58625. */
  58626. get output(): NodeMaterialConnectionPoint;
  58627. protected _buildBlock(state: NodeMaterialBuildState): this;
  58628. }
  58629. }
  58630. declare module BABYLON {
  58631. /**
  58632. * Block used to get the derivative value on x and y of a given input
  58633. */
  58634. export class DerivativeBlock extends NodeMaterialBlock {
  58635. /**
  58636. * Create a new DerivativeBlock
  58637. * @param name defines the block name
  58638. */
  58639. constructor(name: string);
  58640. /**
  58641. * Gets the current class name
  58642. * @returns the class name
  58643. */
  58644. getClassName(): string;
  58645. /**
  58646. * Gets the input component
  58647. */
  58648. get input(): NodeMaterialConnectionPoint;
  58649. /**
  58650. * Gets the derivative output on x
  58651. */
  58652. get dx(): NodeMaterialConnectionPoint;
  58653. /**
  58654. * Gets the derivative output on y
  58655. */
  58656. get dy(): NodeMaterialConnectionPoint;
  58657. protected _buildBlock(state: NodeMaterialBuildState): this;
  58658. }
  58659. }
  58660. declare module BABYLON {
  58661. /**
  58662. * Block used to add support for scene fog
  58663. */
  58664. export class FogBlock extends NodeMaterialBlock {
  58665. private _fogDistanceName;
  58666. private _fogParameters;
  58667. /**
  58668. * Create a new FogBlock
  58669. * @param name defines the block name
  58670. */
  58671. constructor(name: string);
  58672. /**
  58673. * Gets the current class name
  58674. * @returns the class name
  58675. */
  58676. getClassName(): string;
  58677. /**
  58678. * Gets the world position input component
  58679. */
  58680. get worldPosition(): NodeMaterialConnectionPoint;
  58681. /**
  58682. * Gets the view input component
  58683. */
  58684. get view(): NodeMaterialConnectionPoint;
  58685. /**
  58686. * Gets the color input component
  58687. */
  58688. get input(): NodeMaterialConnectionPoint;
  58689. /**
  58690. * Gets the fog color input component
  58691. */
  58692. get fogColor(): NodeMaterialConnectionPoint;
  58693. /**
  58694. * Gets the output component
  58695. */
  58696. get output(): NodeMaterialConnectionPoint;
  58697. autoConfigure(material: NodeMaterial): void;
  58698. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58699. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58700. protected _buildBlock(state: NodeMaterialBuildState): this;
  58701. }
  58702. }
  58703. declare module BABYLON {
  58704. /**
  58705. * Block used to add light in the fragment shader
  58706. */
  58707. export class LightBlock extends NodeMaterialBlock {
  58708. private _lightId;
  58709. /**
  58710. * Gets or sets the light associated with this block
  58711. */
  58712. light: Nullable<Light>;
  58713. /**
  58714. * Create a new LightBlock
  58715. * @param name defines the block name
  58716. */
  58717. constructor(name: string);
  58718. /**
  58719. * Gets the current class name
  58720. * @returns the class name
  58721. */
  58722. getClassName(): string;
  58723. /**
  58724. * Gets the world position input component
  58725. */
  58726. get worldPosition(): NodeMaterialConnectionPoint;
  58727. /**
  58728. * Gets the world normal input component
  58729. */
  58730. get worldNormal(): NodeMaterialConnectionPoint;
  58731. /**
  58732. * Gets the camera (or eye) position component
  58733. */
  58734. get cameraPosition(): NodeMaterialConnectionPoint;
  58735. /**
  58736. * Gets the glossiness component
  58737. */
  58738. get glossiness(): NodeMaterialConnectionPoint;
  58739. /**
  58740. * Gets the glossinness power component
  58741. */
  58742. get glossPower(): NodeMaterialConnectionPoint;
  58743. /**
  58744. * Gets the diffuse color component
  58745. */
  58746. get diffuseColor(): NodeMaterialConnectionPoint;
  58747. /**
  58748. * Gets the specular color component
  58749. */
  58750. get specularColor(): NodeMaterialConnectionPoint;
  58751. /**
  58752. * Gets the diffuse output component
  58753. */
  58754. get diffuseOutput(): NodeMaterialConnectionPoint;
  58755. /**
  58756. * Gets the specular output component
  58757. */
  58758. get specularOutput(): NodeMaterialConnectionPoint;
  58759. /**
  58760. * Gets the shadow output component
  58761. */
  58762. get shadow(): NodeMaterialConnectionPoint;
  58763. autoConfigure(material: NodeMaterial): void;
  58764. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58765. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58766. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58767. private _injectVertexCode;
  58768. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58769. serialize(): any;
  58770. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58771. }
  58772. }
  58773. declare module BABYLON {
  58774. /**
  58775. * Block used to multiply 2 values
  58776. */
  58777. export class MultiplyBlock extends NodeMaterialBlock {
  58778. /**
  58779. * Creates a new MultiplyBlock
  58780. * @param name defines the block name
  58781. */
  58782. constructor(name: string);
  58783. /**
  58784. * Gets the current class name
  58785. * @returns the class name
  58786. */
  58787. getClassName(): string;
  58788. /**
  58789. * Gets the left operand input component
  58790. */
  58791. get left(): NodeMaterialConnectionPoint;
  58792. /**
  58793. * Gets the right operand input component
  58794. */
  58795. get right(): NodeMaterialConnectionPoint;
  58796. /**
  58797. * Gets the output component
  58798. */
  58799. get output(): NodeMaterialConnectionPoint;
  58800. protected _buildBlock(state: NodeMaterialBuildState): this;
  58801. }
  58802. }
  58803. declare module BABYLON {
  58804. /**
  58805. * Block used to add 2 vectors
  58806. */
  58807. export class AddBlock extends NodeMaterialBlock {
  58808. /**
  58809. * Creates a new AddBlock
  58810. * @param name defines the block name
  58811. */
  58812. constructor(name: string);
  58813. /**
  58814. * Gets the current class name
  58815. * @returns the class name
  58816. */
  58817. getClassName(): string;
  58818. /**
  58819. * Gets the left operand input component
  58820. */
  58821. get left(): NodeMaterialConnectionPoint;
  58822. /**
  58823. * Gets the right operand input component
  58824. */
  58825. get right(): NodeMaterialConnectionPoint;
  58826. /**
  58827. * Gets the output component
  58828. */
  58829. get output(): NodeMaterialConnectionPoint;
  58830. protected _buildBlock(state: NodeMaterialBuildState): this;
  58831. }
  58832. }
  58833. declare module BABYLON {
  58834. /**
  58835. * Block used to scale a vector by a float
  58836. */
  58837. export class ScaleBlock extends NodeMaterialBlock {
  58838. /**
  58839. * Creates a new ScaleBlock
  58840. * @param name defines the block name
  58841. */
  58842. constructor(name: string);
  58843. /**
  58844. * Gets the current class name
  58845. * @returns the class name
  58846. */
  58847. getClassName(): string;
  58848. /**
  58849. * Gets the input component
  58850. */
  58851. get input(): NodeMaterialConnectionPoint;
  58852. /**
  58853. * Gets the factor input component
  58854. */
  58855. get factor(): NodeMaterialConnectionPoint;
  58856. /**
  58857. * Gets the output component
  58858. */
  58859. get output(): NodeMaterialConnectionPoint;
  58860. protected _buildBlock(state: NodeMaterialBuildState): this;
  58861. }
  58862. }
  58863. declare module BABYLON {
  58864. /**
  58865. * Block used to clamp a float
  58866. */
  58867. export class ClampBlock extends NodeMaterialBlock {
  58868. /** Gets or sets the minimum range */
  58869. minimum: number;
  58870. /** Gets or sets the maximum range */
  58871. maximum: number;
  58872. /**
  58873. * Creates a new ClampBlock
  58874. * @param name defines the block name
  58875. */
  58876. constructor(name: string);
  58877. /**
  58878. * Gets the current class name
  58879. * @returns the class name
  58880. */
  58881. getClassName(): string;
  58882. /**
  58883. * Gets the value input component
  58884. */
  58885. get value(): NodeMaterialConnectionPoint;
  58886. /**
  58887. * Gets the output component
  58888. */
  58889. get output(): NodeMaterialConnectionPoint;
  58890. protected _buildBlock(state: NodeMaterialBuildState): this;
  58891. protected _dumpPropertiesCode(): string;
  58892. serialize(): any;
  58893. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58894. }
  58895. }
  58896. declare module BABYLON {
  58897. /**
  58898. * Block used to apply a cross product between 2 vectors
  58899. */
  58900. export class CrossBlock extends NodeMaterialBlock {
  58901. /**
  58902. * Creates a new CrossBlock
  58903. * @param name defines the block name
  58904. */
  58905. constructor(name: string);
  58906. /**
  58907. * Gets the current class name
  58908. * @returns the class name
  58909. */
  58910. getClassName(): string;
  58911. /**
  58912. * Gets the left operand input component
  58913. */
  58914. get left(): NodeMaterialConnectionPoint;
  58915. /**
  58916. * Gets the right operand input component
  58917. */
  58918. get right(): NodeMaterialConnectionPoint;
  58919. /**
  58920. * Gets the output component
  58921. */
  58922. get output(): NodeMaterialConnectionPoint;
  58923. protected _buildBlock(state: NodeMaterialBuildState): this;
  58924. }
  58925. }
  58926. declare module BABYLON {
  58927. /**
  58928. * Block used to apply a dot product between 2 vectors
  58929. */
  58930. export class DotBlock extends NodeMaterialBlock {
  58931. /**
  58932. * Creates a new DotBlock
  58933. * @param name defines the block name
  58934. */
  58935. constructor(name: string);
  58936. /**
  58937. * Gets the current class name
  58938. * @returns the class name
  58939. */
  58940. getClassName(): string;
  58941. /**
  58942. * Gets the left operand input component
  58943. */
  58944. get left(): NodeMaterialConnectionPoint;
  58945. /**
  58946. * Gets the right operand input component
  58947. */
  58948. get right(): NodeMaterialConnectionPoint;
  58949. /**
  58950. * Gets the output component
  58951. */
  58952. get output(): NodeMaterialConnectionPoint;
  58953. protected _buildBlock(state: NodeMaterialBuildState): this;
  58954. }
  58955. }
  58956. declare module BABYLON {
  58957. /**
  58958. * Block used to remap a float from a range to a new one
  58959. */
  58960. export class RemapBlock extends NodeMaterialBlock {
  58961. /**
  58962. * Gets or sets the source range
  58963. */
  58964. sourceRange: Vector2;
  58965. /**
  58966. * Gets or sets the target range
  58967. */
  58968. targetRange: Vector2;
  58969. /**
  58970. * Creates a new RemapBlock
  58971. * @param name defines the block name
  58972. */
  58973. constructor(name: string);
  58974. /**
  58975. * Gets the current class name
  58976. * @returns the class name
  58977. */
  58978. getClassName(): string;
  58979. /**
  58980. * Gets the input component
  58981. */
  58982. get input(): NodeMaterialConnectionPoint;
  58983. /**
  58984. * Gets the source min input component
  58985. */
  58986. get sourceMin(): NodeMaterialConnectionPoint;
  58987. /**
  58988. * Gets the source max input component
  58989. */
  58990. get sourceMax(): NodeMaterialConnectionPoint;
  58991. /**
  58992. * Gets the target min input component
  58993. */
  58994. get targetMin(): NodeMaterialConnectionPoint;
  58995. /**
  58996. * Gets the target max input component
  58997. */
  58998. get targetMax(): NodeMaterialConnectionPoint;
  58999. /**
  59000. * Gets the output component
  59001. */
  59002. get output(): NodeMaterialConnectionPoint;
  59003. protected _buildBlock(state: NodeMaterialBuildState): this;
  59004. protected _dumpPropertiesCode(): string;
  59005. serialize(): any;
  59006. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59007. }
  59008. }
  59009. declare module BABYLON {
  59010. /**
  59011. * Block used to normalize a vector
  59012. */
  59013. export class NormalizeBlock extends NodeMaterialBlock {
  59014. /**
  59015. * Creates a new NormalizeBlock
  59016. * @param name defines the block name
  59017. */
  59018. constructor(name: string);
  59019. /**
  59020. * Gets the current class name
  59021. * @returns the class name
  59022. */
  59023. getClassName(): string;
  59024. /**
  59025. * Gets the input component
  59026. */
  59027. get input(): NodeMaterialConnectionPoint;
  59028. /**
  59029. * Gets the output component
  59030. */
  59031. get output(): NodeMaterialConnectionPoint;
  59032. protected _buildBlock(state: NodeMaterialBuildState): this;
  59033. }
  59034. }
  59035. declare module BABYLON {
  59036. /**
  59037. * Operations supported by the Trigonometry block
  59038. */
  59039. export enum TrigonometryBlockOperations {
  59040. /** Cos */
  59041. Cos = 0,
  59042. /** Sin */
  59043. Sin = 1,
  59044. /** Abs */
  59045. Abs = 2,
  59046. /** Exp */
  59047. Exp = 3,
  59048. /** Exp2 */
  59049. Exp2 = 4,
  59050. /** Round */
  59051. Round = 5,
  59052. /** Floor */
  59053. Floor = 6,
  59054. /** Ceiling */
  59055. Ceiling = 7,
  59056. /** Square root */
  59057. Sqrt = 8,
  59058. /** Log */
  59059. Log = 9,
  59060. /** Tangent */
  59061. Tan = 10,
  59062. /** Arc tangent */
  59063. ArcTan = 11,
  59064. /** Arc cosinus */
  59065. ArcCos = 12,
  59066. /** Arc sinus */
  59067. ArcSin = 13,
  59068. /** Fraction */
  59069. Fract = 14,
  59070. /** Sign */
  59071. Sign = 15,
  59072. /** To radians (from degrees) */
  59073. Radians = 16,
  59074. /** To degrees (from radians) */
  59075. Degrees = 17
  59076. }
  59077. /**
  59078. * Block used to apply trigonometry operation to floats
  59079. */
  59080. export class TrigonometryBlock extends NodeMaterialBlock {
  59081. /**
  59082. * Gets or sets the operation applied by the block
  59083. */
  59084. operation: TrigonometryBlockOperations;
  59085. /**
  59086. * Creates a new TrigonometryBlock
  59087. * @param name defines the block name
  59088. */
  59089. constructor(name: string);
  59090. /**
  59091. * Gets the current class name
  59092. * @returns the class name
  59093. */
  59094. getClassName(): string;
  59095. /**
  59096. * Gets the input component
  59097. */
  59098. get input(): NodeMaterialConnectionPoint;
  59099. /**
  59100. * Gets the output component
  59101. */
  59102. get output(): NodeMaterialConnectionPoint;
  59103. protected _buildBlock(state: NodeMaterialBuildState): this;
  59104. serialize(): any;
  59105. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59106. protected _dumpPropertiesCode(): string;
  59107. }
  59108. }
  59109. declare module BABYLON {
  59110. /**
  59111. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59112. */
  59113. export class ColorMergerBlock extends NodeMaterialBlock {
  59114. /**
  59115. * Create a new ColorMergerBlock
  59116. * @param name defines the block name
  59117. */
  59118. constructor(name: string);
  59119. /**
  59120. * Gets the current class name
  59121. * @returns the class name
  59122. */
  59123. getClassName(): string;
  59124. /**
  59125. * Gets the rgb component (input)
  59126. */
  59127. get rgbIn(): NodeMaterialConnectionPoint;
  59128. /**
  59129. * Gets the r component (input)
  59130. */
  59131. get r(): NodeMaterialConnectionPoint;
  59132. /**
  59133. * Gets the g component (input)
  59134. */
  59135. get g(): NodeMaterialConnectionPoint;
  59136. /**
  59137. * Gets the b component (input)
  59138. */
  59139. get b(): NodeMaterialConnectionPoint;
  59140. /**
  59141. * Gets the a component (input)
  59142. */
  59143. get a(): NodeMaterialConnectionPoint;
  59144. /**
  59145. * Gets the rgba component (output)
  59146. */
  59147. get rgba(): NodeMaterialConnectionPoint;
  59148. /**
  59149. * Gets the rgb component (output)
  59150. */
  59151. get rgbOut(): NodeMaterialConnectionPoint;
  59152. /**
  59153. * Gets the rgb component (output)
  59154. * @deprecated Please use rgbOut instead.
  59155. */
  59156. get rgb(): NodeMaterialConnectionPoint;
  59157. protected _buildBlock(state: NodeMaterialBuildState): this;
  59158. }
  59159. }
  59160. declare module BABYLON {
  59161. /**
  59162. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59163. */
  59164. export class VectorMergerBlock extends NodeMaterialBlock {
  59165. /**
  59166. * Create a new VectorMergerBlock
  59167. * @param name defines the block name
  59168. */
  59169. constructor(name: string);
  59170. /**
  59171. * Gets the current class name
  59172. * @returns the class name
  59173. */
  59174. getClassName(): string;
  59175. /**
  59176. * Gets the xyz component (input)
  59177. */
  59178. get xyzIn(): NodeMaterialConnectionPoint;
  59179. /**
  59180. * Gets the xy component (input)
  59181. */
  59182. get xyIn(): NodeMaterialConnectionPoint;
  59183. /**
  59184. * Gets the x component (input)
  59185. */
  59186. get x(): NodeMaterialConnectionPoint;
  59187. /**
  59188. * Gets the y component (input)
  59189. */
  59190. get y(): NodeMaterialConnectionPoint;
  59191. /**
  59192. * Gets the z component (input)
  59193. */
  59194. get z(): NodeMaterialConnectionPoint;
  59195. /**
  59196. * Gets the w component (input)
  59197. */
  59198. get w(): NodeMaterialConnectionPoint;
  59199. /**
  59200. * Gets the xyzw component (output)
  59201. */
  59202. get xyzw(): NodeMaterialConnectionPoint;
  59203. /**
  59204. * Gets the xyz component (output)
  59205. */
  59206. get xyzOut(): NodeMaterialConnectionPoint;
  59207. /**
  59208. * Gets the xy component (output)
  59209. */
  59210. get xyOut(): NodeMaterialConnectionPoint;
  59211. /**
  59212. * Gets the xy component (output)
  59213. * @deprecated Please use xyOut instead.
  59214. */
  59215. get xy(): NodeMaterialConnectionPoint;
  59216. /**
  59217. * Gets the xyz component (output)
  59218. * @deprecated Please use xyzOut instead.
  59219. */
  59220. get xyz(): NodeMaterialConnectionPoint;
  59221. protected _buildBlock(state: NodeMaterialBuildState): this;
  59222. }
  59223. }
  59224. declare module BABYLON {
  59225. /**
  59226. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59227. */
  59228. export class ColorSplitterBlock extends NodeMaterialBlock {
  59229. /**
  59230. * Create a new ColorSplitterBlock
  59231. * @param name defines the block name
  59232. */
  59233. constructor(name: string);
  59234. /**
  59235. * Gets the current class name
  59236. * @returns the class name
  59237. */
  59238. getClassName(): string;
  59239. /**
  59240. * Gets the rgba component (input)
  59241. */
  59242. get rgba(): NodeMaterialConnectionPoint;
  59243. /**
  59244. * Gets the rgb component (input)
  59245. */
  59246. get rgbIn(): NodeMaterialConnectionPoint;
  59247. /**
  59248. * Gets the rgb component (output)
  59249. */
  59250. get rgbOut(): NodeMaterialConnectionPoint;
  59251. /**
  59252. * Gets the r component (output)
  59253. */
  59254. get r(): NodeMaterialConnectionPoint;
  59255. /**
  59256. * Gets the g component (output)
  59257. */
  59258. get g(): NodeMaterialConnectionPoint;
  59259. /**
  59260. * Gets the b component (output)
  59261. */
  59262. get b(): NodeMaterialConnectionPoint;
  59263. /**
  59264. * Gets the a component (output)
  59265. */
  59266. get a(): NodeMaterialConnectionPoint;
  59267. protected _inputRename(name: string): string;
  59268. protected _outputRename(name: string): string;
  59269. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59270. }
  59271. }
  59272. declare module BABYLON {
  59273. /**
  59274. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59275. */
  59276. export class VectorSplitterBlock extends NodeMaterialBlock {
  59277. /**
  59278. * Create a new VectorSplitterBlock
  59279. * @param name defines the block name
  59280. */
  59281. constructor(name: string);
  59282. /**
  59283. * Gets the current class name
  59284. * @returns the class name
  59285. */
  59286. getClassName(): string;
  59287. /**
  59288. * Gets the xyzw component (input)
  59289. */
  59290. get xyzw(): NodeMaterialConnectionPoint;
  59291. /**
  59292. * Gets the xyz component (input)
  59293. */
  59294. get xyzIn(): NodeMaterialConnectionPoint;
  59295. /**
  59296. * Gets the xy component (input)
  59297. */
  59298. get xyIn(): NodeMaterialConnectionPoint;
  59299. /**
  59300. * Gets the xyz component (output)
  59301. */
  59302. get xyzOut(): NodeMaterialConnectionPoint;
  59303. /**
  59304. * Gets the xy component (output)
  59305. */
  59306. get xyOut(): NodeMaterialConnectionPoint;
  59307. /**
  59308. * Gets the x component (output)
  59309. */
  59310. get x(): NodeMaterialConnectionPoint;
  59311. /**
  59312. * Gets the y component (output)
  59313. */
  59314. get y(): NodeMaterialConnectionPoint;
  59315. /**
  59316. * Gets the z component (output)
  59317. */
  59318. get z(): NodeMaterialConnectionPoint;
  59319. /**
  59320. * Gets the w component (output)
  59321. */
  59322. get w(): NodeMaterialConnectionPoint;
  59323. protected _inputRename(name: string): string;
  59324. protected _outputRename(name: string): string;
  59325. protected _buildBlock(state: NodeMaterialBuildState): this;
  59326. }
  59327. }
  59328. declare module BABYLON {
  59329. /**
  59330. * Block used to lerp between 2 values
  59331. */
  59332. export class LerpBlock extends NodeMaterialBlock {
  59333. /**
  59334. * Creates a new LerpBlock
  59335. * @param name defines the block name
  59336. */
  59337. constructor(name: string);
  59338. /**
  59339. * Gets the current class name
  59340. * @returns the class name
  59341. */
  59342. getClassName(): string;
  59343. /**
  59344. * Gets the left operand input component
  59345. */
  59346. get left(): NodeMaterialConnectionPoint;
  59347. /**
  59348. * Gets the right operand input component
  59349. */
  59350. get right(): NodeMaterialConnectionPoint;
  59351. /**
  59352. * Gets the gradient operand input component
  59353. */
  59354. get gradient(): NodeMaterialConnectionPoint;
  59355. /**
  59356. * Gets the output component
  59357. */
  59358. get output(): NodeMaterialConnectionPoint;
  59359. protected _buildBlock(state: NodeMaterialBuildState): this;
  59360. }
  59361. }
  59362. declare module BABYLON {
  59363. /**
  59364. * Block used to divide 2 vectors
  59365. */
  59366. export class DivideBlock extends NodeMaterialBlock {
  59367. /**
  59368. * Creates a new DivideBlock
  59369. * @param name defines the block name
  59370. */
  59371. constructor(name: string);
  59372. /**
  59373. * Gets the current class name
  59374. * @returns the class name
  59375. */
  59376. getClassName(): string;
  59377. /**
  59378. * Gets the left operand input component
  59379. */
  59380. get left(): NodeMaterialConnectionPoint;
  59381. /**
  59382. * Gets the right operand input component
  59383. */
  59384. get right(): NodeMaterialConnectionPoint;
  59385. /**
  59386. * Gets the output component
  59387. */
  59388. get output(): NodeMaterialConnectionPoint;
  59389. protected _buildBlock(state: NodeMaterialBuildState): this;
  59390. }
  59391. }
  59392. declare module BABYLON {
  59393. /**
  59394. * Block used to subtract 2 vectors
  59395. */
  59396. export class SubtractBlock extends NodeMaterialBlock {
  59397. /**
  59398. * Creates a new SubtractBlock
  59399. * @param name defines the block name
  59400. */
  59401. constructor(name: string);
  59402. /**
  59403. * Gets the current class name
  59404. * @returns the class name
  59405. */
  59406. getClassName(): string;
  59407. /**
  59408. * Gets the left operand input component
  59409. */
  59410. get left(): NodeMaterialConnectionPoint;
  59411. /**
  59412. * Gets the right operand input component
  59413. */
  59414. get right(): NodeMaterialConnectionPoint;
  59415. /**
  59416. * Gets the output component
  59417. */
  59418. get output(): NodeMaterialConnectionPoint;
  59419. protected _buildBlock(state: NodeMaterialBuildState): this;
  59420. }
  59421. }
  59422. declare module BABYLON {
  59423. /**
  59424. * Block used to step a value
  59425. */
  59426. export class StepBlock extends NodeMaterialBlock {
  59427. /**
  59428. * Creates a new StepBlock
  59429. * @param name defines the block name
  59430. */
  59431. constructor(name: string);
  59432. /**
  59433. * Gets the current class name
  59434. * @returns the class name
  59435. */
  59436. getClassName(): string;
  59437. /**
  59438. * Gets the value operand input component
  59439. */
  59440. get value(): NodeMaterialConnectionPoint;
  59441. /**
  59442. * Gets the edge operand input component
  59443. */
  59444. get edge(): NodeMaterialConnectionPoint;
  59445. /**
  59446. * Gets the output component
  59447. */
  59448. get output(): NodeMaterialConnectionPoint;
  59449. protected _buildBlock(state: NodeMaterialBuildState): this;
  59450. }
  59451. }
  59452. declare module BABYLON {
  59453. /**
  59454. * Block used to get the opposite (1 - x) of a value
  59455. */
  59456. export class OneMinusBlock extends NodeMaterialBlock {
  59457. /**
  59458. * Creates a new OneMinusBlock
  59459. * @param name defines the block name
  59460. */
  59461. constructor(name: string);
  59462. /**
  59463. * Gets the current class name
  59464. * @returns the class name
  59465. */
  59466. getClassName(): string;
  59467. /**
  59468. * Gets the input component
  59469. */
  59470. get input(): NodeMaterialConnectionPoint;
  59471. /**
  59472. * Gets the output component
  59473. */
  59474. get output(): NodeMaterialConnectionPoint;
  59475. protected _buildBlock(state: NodeMaterialBuildState): this;
  59476. }
  59477. }
  59478. declare module BABYLON {
  59479. /**
  59480. * Block used to get the view direction
  59481. */
  59482. export class ViewDirectionBlock extends NodeMaterialBlock {
  59483. /**
  59484. * Creates a new ViewDirectionBlock
  59485. * @param name defines the block name
  59486. */
  59487. constructor(name: string);
  59488. /**
  59489. * Gets the current class name
  59490. * @returns the class name
  59491. */
  59492. getClassName(): string;
  59493. /**
  59494. * Gets the world position component
  59495. */
  59496. get worldPosition(): NodeMaterialConnectionPoint;
  59497. /**
  59498. * Gets the camera position component
  59499. */
  59500. get cameraPosition(): NodeMaterialConnectionPoint;
  59501. /**
  59502. * Gets the output component
  59503. */
  59504. get output(): NodeMaterialConnectionPoint;
  59505. autoConfigure(material: NodeMaterial): void;
  59506. protected _buildBlock(state: NodeMaterialBuildState): this;
  59507. }
  59508. }
  59509. declare module BABYLON {
  59510. /**
  59511. * Block used to compute fresnel value
  59512. */
  59513. export class FresnelBlock extends NodeMaterialBlock {
  59514. /**
  59515. * Create a new FresnelBlock
  59516. * @param name defines the block name
  59517. */
  59518. constructor(name: string);
  59519. /**
  59520. * Gets the current class name
  59521. * @returns the class name
  59522. */
  59523. getClassName(): string;
  59524. /**
  59525. * Gets the world normal input component
  59526. */
  59527. get worldNormal(): NodeMaterialConnectionPoint;
  59528. /**
  59529. * Gets the view direction input component
  59530. */
  59531. get viewDirection(): NodeMaterialConnectionPoint;
  59532. /**
  59533. * Gets the bias input component
  59534. */
  59535. get bias(): NodeMaterialConnectionPoint;
  59536. /**
  59537. * Gets the camera (or eye) position component
  59538. */
  59539. get power(): NodeMaterialConnectionPoint;
  59540. /**
  59541. * Gets the fresnel output component
  59542. */
  59543. get fresnel(): NodeMaterialConnectionPoint;
  59544. autoConfigure(material: NodeMaterial): void;
  59545. protected _buildBlock(state: NodeMaterialBuildState): this;
  59546. }
  59547. }
  59548. declare module BABYLON {
  59549. /**
  59550. * Block used to get the max of 2 values
  59551. */
  59552. export class MaxBlock extends NodeMaterialBlock {
  59553. /**
  59554. * Creates a new MaxBlock
  59555. * @param name defines the block name
  59556. */
  59557. constructor(name: string);
  59558. /**
  59559. * Gets the current class name
  59560. * @returns the class name
  59561. */
  59562. getClassName(): string;
  59563. /**
  59564. * Gets the left operand input component
  59565. */
  59566. get left(): NodeMaterialConnectionPoint;
  59567. /**
  59568. * Gets the right operand input component
  59569. */
  59570. get right(): NodeMaterialConnectionPoint;
  59571. /**
  59572. * Gets the output component
  59573. */
  59574. get output(): NodeMaterialConnectionPoint;
  59575. protected _buildBlock(state: NodeMaterialBuildState): this;
  59576. }
  59577. }
  59578. declare module BABYLON {
  59579. /**
  59580. * Block used to get the min of 2 values
  59581. */
  59582. export class MinBlock extends NodeMaterialBlock {
  59583. /**
  59584. * Creates a new MinBlock
  59585. * @param name defines the block name
  59586. */
  59587. constructor(name: string);
  59588. /**
  59589. * Gets the current class name
  59590. * @returns the class name
  59591. */
  59592. getClassName(): string;
  59593. /**
  59594. * Gets the left operand input component
  59595. */
  59596. get left(): NodeMaterialConnectionPoint;
  59597. /**
  59598. * Gets the right operand input component
  59599. */
  59600. get right(): NodeMaterialConnectionPoint;
  59601. /**
  59602. * Gets the output component
  59603. */
  59604. get output(): NodeMaterialConnectionPoint;
  59605. protected _buildBlock(state: NodeMaterialBuildState): this;
  59606. }
  59607. }
  59608. declare module BABYLON {
  59609. /**
  59610. * Block used to get the distance between 2 values
  59611. */
  59612. export class DistanceBlock extends NodeMaterialBlock {
  59613. /**
  59614. * Creates a new DistanceBlock
  59615. * @param name defines the block name
  59616. */
  59617. constructor(name: string);
  59618. /**
  59619. * Gets the current class name
  59620. * @returns the class name
  59621. */
  59622. getClassName(): string;
  59623. /**
  59624. * Gets the left operand input component
  59625. */
  59626. get left(): NodeMaterialConnectionPoint;
  59627. /**
  59628. * Gets the right operand input component
  59629. */
  59630. get right(): NodeMaterialConnectionPoint;
  59631. /**
  59632. * Gets the output component
  59633. */
  59634. get output(): NodeMaterialConnectionPoint;
  59635. protected _buildBlock(state: NodeMaterialBuildState): this;
  59636. }
  59637. }
  59638. declare module BABYLON {
  59639. /**
  59640. * Block used to get the length of a vector
  59641. */
  59642. export class LengthBlock extends NodeMaterialBlock {
  59643. /**
  59644. * Creates a new LengthBlock
  59645. * @param name defines the block name
  59646. */
  59647. constructor(name: string);
  59648. /**
  59649. * Gets the current class name
  59650. * @returns the class name
  59651. */
  59652. getClassName(): string;
  59653. /**
  59654. * Gets the value input component
  59655. */
  59656. get value(): NodeMaterialConnectionPoint;
  59657. /**
  59658. * Gets the output component
  59659. */
  59660. get output(): NodeMaterialConnectionPoint;
  59661. protected _buildBlock(state: NodeMaterialBuildState): this;
  59662. }
  59663. }
  59664. declare module BABYLON {
  59665. /**
  59666. * Block used to get negative version of a value (i.e. x * -1)
  59667. */
  59668. export class NegateBlock extends NodeMaterialBlock {
  59669. /**
  59670. * Creates a new NegateBlock
  59671. * @param name defines the block name
  59672. */
  59673. constructor(name: string);
  59674. /**
  59675. * Gets the current class name
  59676. * @returns the class name
  59677. */
  59678. getClassName(): string;
  59679. /**
  59680. * Gets the value input component
  59681. */
  59682. get value(): NodeMaterialConnectionPoint;
  59683. /**
  59684. * Gets the output component
  59685. */
  59686. get output(): NodeMaterialConnectionPoint;
  59687. protected _buildBlock(state: NodeMaterialBuildState): this;
  59688. }
  59689. }
  59690. declare module BABYLON {
  59691. /**
  59692. * Block used to get the value of the first parameter raised to the power of the second
  59693. */
  59694. export class PowBlock extends NodeMaterialBlock {
  59695. /**
  59696. * Creates a new PowBlock
  59697. * @param name defines the block name
  59698. */
  59699. constructor(name: string);
  59700. /**
  59701. * Gets the current class name
  59702. * @returns the class name
  59703. */
  59704. getClassName(): string;
  59705. /**
  59706. * Gets the value operand input component
  59707. */
  59708. get value(): NodeMaterialConnectionPoint;
  59709. /**
  59710. * Gets the power operand input component
  59711. */
  59712. get power(): NodeMaterialConnectionPoint;
  59713. /**
  59714. * Gets the output component
  59715. */
  59716. get output(): NodeMaterialConnectionPoint;
  59717. protected _buildBlock(state: NodeMaterialBuildState): this;
  59718. }
  59719. }
  59720. declare module BABYLON {
  59721. /**
  59722. * Block used to get a random number
  59723. */
  59724. export class RandomNumberBlock extends NodeMaterialBlock {
  59725. /**
  59726. * Creates a new RandomNumberBlock
  59727. * @param name defines the block name
  59728. */
  59729. constructor(name: string);
  59730. /**
  59731. * Gets the current class name
  59732. * @returns the class name
  59733. */
  59734. getClassName(): string;
  59735. /**
  59736. * Gets the seed input component
  59737. */
  59738. get seed(): NodeMaterialConnectionPoint;
  59739. /**
  59740. * Gets the output component
  59741. */
  59742. get output(): NodeMaterialConnectionPoint;
  59743. protected _buildBlock(state: NodeMaterialBuildState): this;
  59744. }
  59745. }
  59746. declare module BABYLON {
  59747. /**
  59748. * Block used to compute arc tangent of 2 values
  59749. */
  59750. export class ArcTan2Block extends NodeMaterialBlock {
  59751. /**
  59752. * Creates a new ArcTan2Block
  59753. * @param name defines the block name
  59754. */
  59755. constructor(name: string);
  59756. /**
  59757. * Gets the current class name
  59758. * @returns the class name
  59759. */
  59760. getClassName(): string;
  59761. /**
  59762. * Gets the x operand input component
  59763. */
  59764. get x(): NodeMaterialConnectionPoint;
  59765. /**
  59766. * Gets the y operand input component
  59767. */
  59768. get y(): NodeMaterialConnectionPoint;
  59769. /**
  59770. * Gets the output component
  59771. */
  59772. get output(): NodeMaterialConnectionPoint;
  59773. protected _buildBlock(state: NodeMaterialBuildState): this;
  59774. }
  59775. }
  59776. declare module BABYLON {
  59777. /**
  59778. * Block used to smooth step a value
  59779. */
  59780. export class SmoothStepBlock extends NodeMaterialBlock {
  59781. /**
  59782. * Creates a new SmoothStepBlock
  59783. * @param name defines the block name
  59784. */
  59785. constructor(name: string);
  59786. /**
  59787. * Gets the current class name
  59788. * @returns the class name
  59789. */
  59790. getClassName(): string;
  59791. /**
  59792. * Gets the value operand input component
  59793. */
  59794. get value(): NodeMaterialConnectionPoint;
  59795. /**
  59796. * Gets the first edge operand input component
  59797. */
  59798. get edge0(): NodeMaterialConnectionPoint;
  59799. /**
  59800. * Gets the second edge operand input component
  59801. */
  59802. get edge1(): NodeMaterialConnectionPoint;
  59803. /**
  59804. * Gets the output component
  59805. */
  59806. get output(): NodeMaterialConnectionPoint;
  59807. protected _buildBlock(state: NodeMaterialBuildState): this;
  59808. }
  59809. }
  59810. declare module BABYLON {
  59811. /**
  59812. * Block used to get the reciprocal (1 / x) of a value
  59813. */
  59814. export class ReciprocalBlock extends NodeMaterialBlock {
  59815. /**
  59816. * Creates a new ReciprocalBlock
  59817. * @param name defines the block name
  59818. */
  59819. constructor(name: string);
  59820. /**
  59821. * Gets the current class name
  59822. * @returns the class name
  59823. */
  59824. getClassName(): string;
  59825. /**
  59826. * Gets the input component
  59827. */
  59828. get input(): NodeMaterialConnectionPoint;
  59829. /**
  59830. * Gets the output component
  59831. */
  59832. get output(): NodeMaterialConnectionPoint;
  59833. protected _buildBlock(state: NodeMaterialBuildState): this;
  59834. }
  59835. }
  59836. declare module BABYLON {
  59837. /**
  59838. * Block used to replace a color by another one
  59839. */
  59840. export class ReplaceColorBlock extends NodeMaterialBlock {
  59841. /**
  59842. * Creates a new ReplaceColorBlock
  59843. * @param name defines the block name
  59844. */
  59845. constructor(name: string);
  59846. /**
  59847. * Gets the current class name
  59848. * @returns the class name
  59849. */
  59850. getClassName(): string;
  59851. /**
  59852. * Gets the value input component
  59853. */
  59854. get value(): NodeMaterialConnectionPoint;
  59855. /**
  59856. * Gets the reference input component
  59857. */
  59858. get reference(): NodeMaterialConnectionPoint;
  59859. /**
  59860. * Gets the distance input component
  59861. */
  59862. get distance(): NodeMaterialConnectionPoint;
  59863. /**
  59864. * Gets the replacement input component
  59865. */
  59866. get replacement(): NodeMaterialConnectionPoint;
  59867. /**
  59868. * Gets the output component
  59869. */
  59870. get output(): NodeMaterialConnectionPoint;
  59871. protected _buildBlock(state: NodeMaterialBuildState): this;
  59872. }
  59873. }
  59874. declare module BABYLON {
  59875. /**
  59876. * Block used to posterize a value
  59877. * @see https://en.wikipedia.org/wiki/Posterization
  59878. */
  59879. export class PosterizeBlock extends NodeMaterialBlock {
  59880. /**
  59881. * Creates a new PosterizeBlock
  59882. * @param name defines the block name
  59883. */
  59884. constructor(name: string);
  59885. /**
  59886. * Gets the current class name
  59887. * @returns the class name
  59888. */
  59889. getClassName(): string;
  59890. /**
  59891. * Gets the value input component
  59892. */
  59893. get value(): NodeMaterialConnectionPoint;
  59894. /**
  59895. * Gets the steps input component
  59896. */
  59897. get steps(): NodeMaterialConnectionPoint;
  59898. /**
  59899. * Gets the output component
  59900. */
  59901. get output(): NodeMaterialConnectionPoint;
  59902. protected _buildBlock(state: NodeMaterialBuildState): this;
  59903. }
  59904. }
  59905. declare module BABYLON {
  59906. /**
  59907. * Operations supported by the Wave block
  59908. */
  59909. export enum WaveBlockKind {
  59910. /** SawTooth */
  59911. SawTooth = 0,
  59912. /** Square */
  59913. Square = 1,
  59914. /** Triangle */
  59915. Triangle = 2
  59916. }
  59917. /**
  59918. * Block used to apply wave operation to floats
  59919. */
  59920. export class WaveBlock extends NodeMaterialBlock {
  59921. /**
  59922. * Gets or sets the kibnd of wave to be applied by the block
  59923. */
  59924. kind: WaveBlockKind;
  59925. /**
  59926. * Creates a new WaveBlock
  59927. * @param name defines the block name
  59928. */
  59929. constructor(name: string);
  59930. /**
  59931. * Gets the current class name
  59932. * @returns the class name
  59933. */
  59934. getClassName(): string;
  59935. /**
  59936. * Gets the input component
  59937. */
  59938. get input(): NodeMaterialConnectionPoint;
  59939. /**
  59940. * Gets the output component
  59941. */
  59942. get output(): NodeMaterialConnectionPoint;
  59943. protected _buildBlock(state: NodeMaterialBuildState): this;
  59944. serialize(): any;
  59945. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59946. }
  59947. }
  59948. declare module BABYLON {
  59949. /**
  59950. * Class used to store a color step for the GradientBlock
  59951. */
  59952. export class GradientBlockColorStep {
  59953. /**
  59954. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59955. */
  59956. step: number;
  59957. /**
  59958. * Gets or sets the color associated with this step
  59959. */
  59960. color: Color3;
  59961. /**
  59962. * Creates a new GradientBlockColorStep
  59963. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59964. * @param color defines the color associated with this step
  59965. */
  59966. constructor(
  59967. /**
  59968. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59969. */
  59970. step: number,
  59971. /**
  59972. * Gets or sets the color associated with this step
  59973. */
  59974. color: Color3);
  59975. }
  59976. /**
  59977. * Block used to return a color from a gradient based on an input value between 0 and 1
  59978. */
  59979. export class GradientBlock extends NodeMaterialBlock {
  59980. /**
  59981. * Gets or sets the list of color steps
  59982. */
  59983. colorSteps: GradientBlockColorStep[];
  59984. /**
  59985. * Creates a new GradientBlock
  59986. * @param name defines the block name
  59987. */
  59988. constructor(name: string);
  59989. /**
  59990. * Gets the current class name
  59991. * @returns the class name
  59992. */
  59993. getClassName(): string;
  59994. /**
  59995. * Gets the gradient input component
  59996. */
  59997. get gradient(): NodeMaterialConnectionPoint;
  59998. /**
  59999. * Gets the output component
  60000. */
  60001. get output(): NodeMaterialConnectionPoint;
  60002. private _writeColorConstant;
  60003. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60004. serialize(): any;
  60005. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60006. protected _dumpPropertiesCode(): string;
  60007. }
  60008. }
  60009. declare module BABYLON {
  60010. /**
  60011. * Block used to normalize lerp between 2 values
  60012. */
  60013. export class NLerpBlock extends NodeMaterialBlock {
  60014. /**
  60015. * Creates a new NLerpBlock
  60016. * @param name defines the block name
  60017. */
  60018. constructor(name: string);
  60019. /**
  60020. * Gets the current class name
  60021. * @returns the class name
  60022. */
  60023. getClassName(): string;
  60024. /**
  60025. * Gets the left operand input component
  60026. */
  60027. get left(): NodeMaterialConnectionPoint;
  60028. /**
  60029. * Gets the right operand input component
  60030. */
  60031. get right(): NodeMaterialConnectionPoint;
  60032. /**
  60033. * Gets the gradient operand input component
  60034. */
  60035. get gradient(): NodeMaterialConnectionPoint;
  60036. /**
  60037. * Gets the output component
  60038. */
  60039. get output(): NodeMaterialConnectionPoint;
  60040. protected _buildBlock(state: NodeMaterialBuildState): this;
  60041. }
  60042. }
  60043. declare module BABYLON {
  60044. /**
  60045. * block used to Generate a Worley Noise 3D Noise Pattern
  60046. */
  60047. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60048. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60049. manhattanDistance: boolean;
  60050. /**
  60051. * Creates a new WorleyNoise3DBlock
  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 seed input component
  60062. */
  60063. get seed(): NodeMaterialConnectionPoint;
  60064. /**
  60065. * Gets the jitter input component
  60066. */
  60067. get jitter(): NodeMaterialConnectionPoint;
  60068. /**
  60069. * Gets the output component
  60070. */
  60071. get output(): NodeMaterialConnectionPoint;
  60072. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60073. /**
  60074. * Exposes the properties to the UI?
  60075. */
  60076. protected _dumpPropertiesCode(): string;
  60077. /**
  60078. * Exposes the properties to the Seralize?
  60079. */
  60080. serialize(): any;
  60081. /**
  60082. * Exposes the properties to the deseralize?
  60083. */
  60084. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60085. }
  60086. }
  60087. declare module BABYLON {
  60088. /**
  60089. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60090. */
  60091. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60092. /**
  60093. * Creates a new SimplexPerlin3DBlock
  60094. * @param name defines the block name
  60095. */
  60096. constructor(name: string);
  60097. /**
  60098. * Gets the current class name
  60099. * @returns the class name
  60100. */
  60101. getClassName(): string;
  60102. /**
  60103. * Gets the seed operand input component
  60104. */
  60105. get seed(): NodeMaterialConnectionPoint;
  60106. /**
  60107. * Gets the output component
  60108. */
  60109. get output(): NodeMaterialConnectionPoint;
  60110. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60111. }
  60112. }
  60113. declare module BABYLON {
  60114. /**
  60115. * Block used to blend normals
  60116. */
  60117. export class NormalBlendBlock extends NodeMaterialBlock {
  60118. /**
  60119. * Creates a new NormalBlendBlock
  60120. * @param name defines the block name
  60121. */
  60122. constructor(name: string);
  60123. /**
  60124. * Gets the current class name
  60125. * @returns the class name
  60126. */
  60127. getClassName(): string;
  60128. /**
  60129. * Gets the first input component
  60130. */
  60131. get normalMap0(): NodeMaterialConnectionPoint;
  60132. /**
  60133. * Gets the second input component
  60134. */
  60135. get normalMap1(): NodeMaterialConnectionPoint;
  60136. /**
  60137. * Gets the output component
  60138. */
  60139. get output(): NodeMaterialConnectionPoint;
  60140. protected _buildBlock(state: NodeMaterialBuildState): this;
  60141. }
  60142. }
  60143. declare module BABYLON {
  60144. /**
  60145. * Block used to rotate a 2d vector by a given angle
  60146. */
  60147. export class Rotate2dBlock extends NodeMaterialBlock {
  60148. /**
  60149. * Creates a new Rotate2dBlock
  60150. * @param name defines the block name
  60151. */
  60152. constructor(name: string);
  60153. /**
  60154. * Gets the current class name
  60155. * @returns the class name
  60156. */
  60157. getClassName(): string;
  60158. /**
  60159. * Gets the input vector
  60160. */
  60161. get input(): NodeMaterialConnectionPoint;
  60162. /**
  60163. * Gets the input angle
  60164. */
  60165. get angle(): NodeMaterialConnectionPoint;
  60166. /**
  60167. * Gets the output component
  60168. */
  60169. get output(): NodeMaterialConnectionPoint;
  60170. autoConfigure(material: NodeMaterial): void;
  60171. protected _buildBlock(state: NodeMaterialBuildState): this;
  60172. }
  60173. }
  60174. declare module BABYLON {
  60175. /**
  60176. * Block used to get the reflected vector from a direction and a normal
  60177. */
  60178. export class ReflectBlock extends NodeMaterialBlock {
  60179. /**
  60180. * Creates a new ReflectBlock
  60181. * @param name defines the block name
  60182. */
  60183. constructor(name: string);
  60184. /**
  60185. * Gets the current class name
  60186. * @returns the class name
  60187. */
  60188. getClassName(): string;
  60189. /**
  60190. * Gets the incident component
  60191. */
  60192. get incident(): NodeMaterialConnectionPoint;
  60193. /**
  60194. * Gets the normal component
  60195. */
  60196. get normal(): NodeMaterialConnectionPoint;
  60197. /**
  60198. * Gets the output component
  60199. */
  60200. get output(): NodeMaterialConnectionPoint;
  60201. protected _buildBlock(state: NodeMaterialBuildState): this;
  60202. }
  60203. }
  60204. declare module BABYLON {
  60205. /**
  60206. * Block used to get the refracted vector from a direction and a normal
  60207. */
  60208. export class RefractBlock extends NodeMaterialBlock {
  60209. /**
  60210. * Creates a new RefractBlock
  60211. * @param name defines the block name
  60212. */
  60213. constructor(name: string);
  60214. /**
  60215. * Gets the current class name
  60216. * @returns the class name
  60217. */
  60218. getClassName(): string;
  60219. /**
  60220. * Gets the incident component
  60221. */
  60222. get incident(): NodeMaterialConnectionPoint;
  60223. /**
  60224. * Gets the normal component
  60225. */
  60226. get normal(): NodeMaterialConnectionPoint;
  60227. /**
  60228. * Gets the index of refraction component
  60229. */
  60230. get ior(): NodeMaterialConnectionPoint;
  60231. /**
  60232. * Gets the output component
  60233. */
  60234. get output(): NodeMaterialConnectionPoint;
  60235. protected _buildBlock(state: NodeMaterialBuildState): this;
  60236. }
  60237. }
  60238. declare module BABYLON {
  60239. /**
  60240. * Block used to desaturate a color
  60241. */
  60242. export class DesaturateBlock extends NodeMaterialBlock {
  60243. /**
  60244. * Creates a new DesaturateBlock
  60245. * @param name defines the block name
  60246. */
  60247. constructor(name: string);
  60248. /**
  60249. * Gets the current class name
  60250. * @returns the class name
  60251. */
  60252. getClassName(): string;
  60253. /**
  60254. * Gets the color operand input component
  60255. */
  60256. get color(): NodeMaterialConnectionPoint;
  60257. /**
  60258. * Gets the level operand input component
  60259. */
  60260. get level(): NodeMaterialConnectionPoint;
  60261. /**
  60262. * Gets the output component
  60263. */
  60264. get output(): NodeMaterialConnectionPoint;
  60265. protected _buildBlock(state: NodeMaterialBuildState): this;
  60266. }
  60267. }
  60268. declare module BABYLON {
  60269. /**
  60270. * Effect Render Options
  60271. */
  60272. export interface IEffectRendererOptions {
  60273. /**
  60274. * Defines the vertices positions.
  60275. */
  60276. positions?: number[];
  60277. /**
  60278. * Defines the indices.
  60279. */
  60280. indices?: number[];
  60281. }
  60282. /**
  60283. * Helper class to render one or more effects
  60284. */
  60285. export class EffectRenderer {
  60286. private engine;
  60287. private static _DefaultOptions;
  60288. private _vertexBuffers;
  60289. private _indexBuffer;
  60290. private _ringBufferIndex;
  60291. private _ringScreenBuffer;
  60292. private _fullscreenViewport;
  60293. private _getNextFrameBuffer;
  60294. /**
  60295. * Creates an effect renderer
  60296. * @param engine the engine to use for rendering
  60297. * @param options defines the options of the effect renderer
  60298. */
  60299. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60300. /**
  60301. * Sets the current viewport in normalized coordinates 0-1
  60302. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60303. */
  60304. setViewport(viewport?: Viewport): void;
  60305. /**
  60306. * Binds the embedded attributes buffer to the effect.
  60307. * @param effect Defines the effect to bind the attributes for
  60308. */
  60309. bindBuffers(effect: Effect): void;
  60310. /**
  60311. * Sets the current effect wrapper to use during draw.
  60312. * The effect needs to be ready before calling this api.
  60313. * This also sets the default full screen position attribute.
  60314. * @param effectWrapper Defines the effect to draw with
  60315. */
  60316. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60317. /**
  60318. * Draws a full screen quad.
  60319. */
  60320. draw(): void;
  60321. /**
  60322. * renders one or more effects to a specified texture
  60323. * @param effectWrappers list of effects to renderer
  60324. * @param outputTexture texture to draw to, if null it will render to the screen
  60325. */
  60326. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60327. /**
  60328. * Disposes of the effect renderer
  60329. */
  60330. dispose(): void;
  60331. }
  60332. /**
  60333. * Options to create an EffectWrapper
  60334. */
  60335. interface EffectWrapperCreationOptions {
  60336. /**
  60337. * Engine to use to create the effect
  60338. */
  60339. engine: ThinEngine;
  60340. /**
  60341. * Fragment shader for the effect
  60342. */
  60343. fragmentShader: string;
  60344. /**
  60345. * Vertex shader for the effect
  60346. */
  60347. vertexShader?: string;
  60348. /**
  60349. * Attributes to use in the shader
  60350. */
  60351. attributeNames?: Array<string>;
  60352. /**
  60353. * Uniforms to use in the shader
  60354. */
  60355. uniformNames?: Array<string>;
  60356. /**
  60357. * Texture sampler names to use in the shader
  60358. */
  60359. samplerNames?: Array<string>;
  60360. /**
  60361. * The friendly name of the effect displayed in Spector.
  60362. */
  60363. name?: string;
  60364. }
  60365. /**
  60366. * Wraps an effect to be used for rendering
  60367. */
  60368. export class EffectWrapper {
  60369. /**
  60370. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60371. */
  60372. onApplyObservable: Observable<{}>;
  60373. /**
  60374. * The underlying effect
  60375. */
  60376. effect: Effect;
  60377. /**
  60378. * Creates an effect to be renderer
  60379. * @param creationOptions options to create the effect
  60380. */
  60381. constructor(creationOptions: EffectWrapperCreationOptions);
  60382. /**
  60383. * Disposes of the effect wrapper
  60384. */
  60385. dispose(): void;
  60386. }
  60387. }
  60388. declare module BABYLON {
  60389. /**
  60390. * Helper class to push actions to a pool of workers.
  60391. */
  60392. export class WorkerPool implements IDisposable {
  60393. private _workerInfos;
  60394. private _pendingActions;
  60395. /**
  60396. * Constructor
  60397. * @param workers Array of workers to use for actions
  60398. */
  60399. constructor(workers: Array<Worker>);
  60400. /**
  60401. * Terminates all workers and clears any pending actions.
  60402. */
  60403. dispose(): void;
  60404. /**
  60405. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60406. * pended until a worker has completed its action.
  60407. * @param action The action to perform. Call onComplete when the action is complete.
  60408. */
  60409. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60410. private _execute;
  60411. }
  60412. }
  60413. declare module BABYLON {
  60414. /**
  60415. * Configuration for Draco compression
  60416. */
  60417. export interface IDracoCompressionConfiguration {
  60418. /**
  60419. * Configuration for the decoder.
  60420. */
  60421. decoder: {
  60422. /**
  60423. * The url to the WebAssembly module.
  60424. */
  60425. wasmUrl?: string;
  60426. /**
  60427. * The url to the WebAssembly binary.
  60428. */
  60429. wasmBinaryUrl?: string;
  60430. /**
  60431. * The url to the fallback JavaScript module.
  60432. */
  60433. fallbackUrl?: string;
  60434. };
  60435. }
  60436. /**
  60437. * Draco compression (https://google.github.io/draco/)
  60438. *
  60439. * This class wraps the Draco module.
  60440. *
  60441. * **Encoder**
  60442. *
  60443. * The encoder is not currently implemented.
  60444. *
  60445. * **Decoder**
  60446. *
  60447. * 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.
  60448. *
  60449. * To update the configuration, use the following code:
  60450. * ```javascript
  60451. * DracoCompression.Configuration = {
  60452. * decoder: {
  60453. * wasmUrl: "<url to the WebAssembly library>",
  60454. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60455. * fallbackUrl: "<url to the fallback JavaScript library>",
  60456. * }
  60457. * };
  60458. * ```
  60459. *
  60460. * 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.
  60461. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60462. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60463. *
  60464. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60465. * ```javascript
  60466. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60467. * ```
  60468. *
  60469. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60470. */
  60471. export class DracoCompression implements IDisposable {
  60472. private _workerPoolPromise?;
  60473. private _decoderModulePromise?;
  60474. /**
  60475. * The configuration. Defaults to the following urls:
  60476. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60477. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60478. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60479. */
  60480. static Configuration: IDracoCompressionConfiguration;
  60481. /**
  60482. * Returns true if the decoder configuration is available.
  60483. */
  60484. static get DecoderAvailable(): boolean;
  60485. /**
  60486. * Default number of workers to create when creating the draco compression object.
  60487. */
  60488. static DefaultNumWorkers: number;
  60489. private static GetDefaultNumWorkers;
  60490. private static _Default;
  60491. /**
  60492. * Default instance for the draco compression object.
  60493. */
  60494. static get Default(): DracoCompression;
  60495. /**
  60496. * Constructor
  60497. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60498. */
  60499. constructor(numWorkers?: number);
  60500. /**
  60501. * Stop all async operations and release resources.
  60502. */
  60503. dispose(): void;
  60504. /**
  60505. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60506. * @returns a promise that resolves when ready
  60507. */
  60508. whenReadyAsync(): Promise<void>;
  60509. /**
  60510. * Decode Draco compressed mesh data to vertex data.
  60511. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60512. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60513. * @returns A promise that resolves with the decoded vertex data
  60514. */
  60515. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60516. [kind: string]: number;
  60517. }): Promise<VertexData>;
  60518. }
  60519. }
  60520. declare module BABYLON {
  60521. /**
  60522. * Class for building Constructive Solid Geometry
  60523. */
  60524. export class CSG {
  60525. private polygons;
  60526. /**
  60527. * The world matrix
  60528. */
  60529. matrix: Matrix;
  60530. /**
  60531. * Stores the position
  60532. */
  60533. position: Vector3;
  60534. /**
  60535. * Stores the rotation
  60536. */
  60537. rotation: Vector3;
  60538. /**
  60539. * Stores the rotation quaternion
  60540. */
  60541. rotationQuaternion: Nullable<Quaternion>;
  60542. /**
  60543. * Stores the scaling vector
  60544. */
  60545. scaling: Vector3;
  60546. /**
  60547. * Convert the Mesh to CSG
  60548. * @param mesh The Mesh to convert to CSG
  60549. * @returns A new CSG from the Mesh
  60550. */
  60551. static FromMesh(mesh: Mesh): CSG;
  60552. /**
  60553. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60554. * @param polygons Polygons used to construct a CSG solid
  60555. */
  60556. private static FromPolygons;
  60557. /**
  60558. * Clones, or makes a deep copy, of the CSG
  60559. * @returns A new CSG
  60560. */
  60561. clone(): CSG;
  60562. /**
  60563. * Unions this CSG with another CSG
  60564. * @param csg The CSG to union against this CSG
  60565. * @returns The unioned CSG
  60566. */
  60567. union(csg: CSG): CSG;
  60568. /**
  60569. * Unions this CSG with another CSG in place
  60570. * @param csg The CSG to union against this CSG
  60571. */
  60572. unionInPlace(csg: CSG): void;
  60573. /**
  60574. * Subtracts this CSG with another CSG
  60575. * @param csg The CSG to subtract against this CSG
  60576. * @returns A new CSG
  60577. */
  60578. subtract(csg: CSG): CSG;
  60579. /**
  60580. * Subtracts this CSG with another CSG in place
  60581. * @param csg The CSG to subtact against this CSG
  60582. */
  60583. subtractInPlace(csg: CSG): void;
  60584. /**
  60585. * Intersect this CSG with another CSG
  60586. * @param csg The CSG to intersect against this CSG
  60587. * @returns A new CSG
  60588. */
  60589. intersect(csg: CSG): CSG;
  60590. /**
  60591. * Intersects this CSG with another CSG in place
  60592. * @param csg The CSG to intersect against this CSG
  60593. */
  60594. intersectInPlace(csg: CSG): void;
  60595. /**
  60596. * Return a new CSG solid with solid and empty space switched. This solid is
  60597. * not modified.
  60598. * @returns A new CSG solid with solid and empty space switched
  60599. */
  60600. inverse(): CSG;
  60601. /**
  60602. * Inverses the CSG in place
  60603. */
  60604. inverseInPlace(): void;
  60605. /**
  60606. * This is used to keep meshes transformations so they can be restored
  60607. * when we build back a Babylon Mesh
  60608. * NB : All CSG operations are performed in world coordinates
  60609. * @param csg The CSG to copy the transform attributes from
  60610. * @returns This CSG
  60611. */
  60612. copyTransformAttributes(csg: CSG): CSG;
  60613. /**
  60614. * Build Raw mesh from CSG
  60615. * Coordinates here are in world space
  60616. * @param name The name of the mesh geometry
  60617. * @param scene The Scene
  60618. * @param keepSubMeshes Specifies if the submeshes should be kept
  60619. * @returns A new Mesh
  60620. */
  60621. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60622. /**
  60623. * Build Mesh from CSG taking material and transforms into account
  60624. * @param name The name of the Mesh
  60625. * @param material The material of the Mesh
  60626. * @param scene The Scene
  60627. * @param keepSubMeshes Specifies if submeshes should be kept
  60628. * @returns The new Mesh
  60629. */
  60630. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60631. }
  60632. }
  60633. declare module BABYLON {
  60634. /**
  60635. * Class used to create a trail following a mesh
  60636. */
  60637. export class TrailMesh extends Mesh {
  60638. private _generator;
  60639. private _autoStart;
  60640. private _running;
  60641. private _diameter;
  60642. private _length;
  60643. private _sectionPolygonPointsCount;
  60644. private _sectionVectors;
  60645. private _sectionNormalVectors;
  60646. private _beforeRenderObserver;
  60647. /**
  60648. * @constructor
  60649. * @param name The value used by scene.getMeshByName() to do a lookup.
  60650. * @param generator The mesh or transform node to generate a trail.
  60651. * @param scene The scene to add this mesh to.
  60652. * @param diameter Diameter of trailing mesh. Default is 1.
  60653. * @param length Length of trailing mesh. Default is 60.
  60654. * @param autoStart Automatically start trailing mesh. Default true.
  60655. */
  60656. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60657. /**
  60658. * "TrailMesh"
  60659. * @returns "TrailMesh"
  60660. */
  60661. getClassName(): string;
  60662. private _createMesh;
  60663. /**
  60664. * Start trailing mesh.
  60665. */
  60666. start(): void;
  60667. /**
  60668. * Stop trailing mesh.
  60669. */
  60670. stop(): void;
  60671. /**
  60672. * Update trailing mesh geometry.
  60673. */
  60674. update(): void;
  60675. /**
  60676. * Returns a new TrailMesh object.
  60677. * @param name is a string, the name given to the new mesh
  60678. * @param newGenerator use new generator object for cloned trail mesh
  60679. * @returns a new mesh
  60680. */
  60681. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60682. /**
  60683. * Serializes this trail mesh
  60684. * @param serializationObject object to write serialization to
  60685. */
  60686. serialize(serializationObject: any): void;
  60687. /**
  60688. * Parses a serialized trail mesh
  60689. * @param parsedMesh the serialized mesh
  60690. * @param scene the scene to create the trail mesh in
  60691. * @returns the created trail mesh
  60692. */
  60693. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60694. }
  60695. }
  60696. declare module BABYLON {
  60697. /**
  60698. * Class containing static functions to help procedurally build meshes
  60699. */
  60700. export class TiledBoxBuilder {
  60701. /**
  60702. * Creates a box mesh
  60703. * 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)
  60704. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60706. * * 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
  60707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60708. * @param name defines the name of the mesh
  60709. * @param options defines the options used to create the mesh
  60710. * @param scene defines the hosting scene
  60711. * @returns the box mesh
  60712. */
  60713. static CreateTiledBox(name: string, options: {
  60714. pattern?: number;
  60715. width?: number;
  60716. height?: number;
  60717. depth?: number;
  60718. tileSize?: number;
  60719. tileWidth?: number;
  60720. tileHeight?: number;
  60721. alignHorizontal?: number;
  60722. alignVertical?: number;
  60723. faceUV?: Vector4[];
  60724. faceColors?: Color4[];
  60725. sideOrientation?: number;
  60726. updatable?: boolean;
  60727. }, scene?: Nullable<Scene>): Mesh;
  60728. }
  60729. }
  60730. declare module BABYLON {
  60731. /**
  60732. * Class containing static functions to help procedurally build meshes
  60733. */
  60734. export class TorusKnotBuilder {
  60735. /**
  60736. * Creates a torus knot mesh
  60737. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60738. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60739. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60740. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60742. * * 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
  60743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60744. * @param name defines the name of the mesh
  60745. * @param options defines the options used to create the mesh
  60746. * @param scene defines the hosting scene
  60747. * @returns the torus knot mesh
  60748. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60749. */
  60750. static CreateTorusKnot(name: string, options: {
  60751. radius?: number;
  60752. tube?: number;
  60753. radialSegments?: number;
  60754. tubularSegments?: number;
  60755. p?: number;
  60756. q?: number;
  60757. updatable?: boolean;
  60758. sideOrientation?: number;
  60759. frontUVs?: Vector4;
  60760. backUVs?: Vector4;
  60761. }, scene: any): Mesh;
  60762. }
  60763. }
  60764. declare module BABYLON {
  60765. /**
  60766. * Polygon
  60767. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60768. */
  60769. export class Polygon {
  60770. /**
  60771. * Creates a rectangle
  60772. * @param xmin bottom X coord
  60773. * @param ymin bottom Y coord
  60774. * @param xmax top X coord
  60775. * @param ymax top Y coord
  60776. * @returns points that make the resulting rectation
  60777. */
  60778. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60779. /**
  60780. * Creates a circle
  60781. * @param radius radius of circle
  60782. * @param cx scale in x
  60783. * @param cy scale in y
  60784. * @param numberOfSides number of sides that make up the circle
  60785. * @returns points that make the resulting circle
  60786. */
  60787. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60788. /**
  60789. * Creates a polygon from input string
  60790. * @param input Input polygon data
  60791. * @returns the parsed points
  60792. */
  60793. static Parse(input: string): Vector2[];
  60794. /**
  60795. * Starts building a polygon from x and y coordinates
  60796. * @param x x coordinate
  60797. * @param y y coordinate
  60798. * @returns the started path2
  60799. */
  60800. static StartingAt(x: number, y: number): Path2;
  60801. }
  60802. /**
  60803. * Builds a polygon
  60804. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60805. */
  60806. export class PolygonMeshBuilder {
  60807. private _points;
  60808. private _outlinepoints;
  60809. private _holes;
  60810. private _name;
  60811. private _scene;
  60812. private _epoints;
  60813. private _eholes;
  60814. private _addToepoint;
  60815. /**
  60816. * Babylon reference to the earcut plugin.
  60817. */
  60818. bjsEarcut: any;
  60819. /**
  60820. * Creates a PolygonMeshBuilder
  60821. * @param name name of the builder
  60822. * @param contours Path of the polygon
  60823. * @param scene scene to add to when creating the mesh
  60824. * @param earcutInjection can be used to inject your own earcut reference
  60825. */
  60826. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60827. /**
  60828. * Adds a whole within the polygon
  60829. * @param hole Array of points defining the hole
  60830. * @returns this
  60831. */
  60832. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60833. /**
  60834. * Creates the polygon
  60835. * @param updatable If the mesh should be updatable
  60836. * @param depth The depth of the mesh created
  60837. * @returns the created mesh
  60838. */
  60839. build(updatable?: boolean, depth?: number): Mesh;
  60840. /**
  60841. * Creates the polygon
  60842. * @param depth The depth of the mesh created
  60843. * @returns the created VertexData
  60844. */
  60845. buildVertexData(depth?: number): VertexData;
  60846. /**
  60847. * Adds a side to the polygon
  60848. * @param positions points that make the polygon
  60849. * @param normals normals of the polygon
  60850. * @param uvs uvs of the polygon
  60851. * @param indices indices of the polygon
  60852. * @param bounds bounds of the polygon
  60853. * @param points points of the polygon
  60854. * @param depth depth of the polygon
  60855. * @param flip flip of the polygon
  60856. */
  60857. private addSide;
  60858. }
  60859. }
  60860. declare module BABYLON {
  60861. /**
  60862. * Class containing static functions to help procedurally build meshes
  60863. */
  60864. export class PolygonBuilder {
  60865. /**
  60866. * Creates a polygon mesh
  60867. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60868. * * 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
  60869. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60871. * * 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)
  60872. * * Remember you can only change the shape positions, not their number when updating a polygon
  60873. * @param name defines the name of the mesh
  60874. * @param options defines the options used to create the mesh
  60875. * @param scene defines the hosting scene
  60876. * @param earcutInjection can be used to inject your own earcut reference
  60877. * @returns the polygon mesh
  60878. */
  60879. static CreatePolygon(name: string, options: {
  60880. shape: Vector3[];
  60881. holes?: Vector3[][];
  60882. depth?: number;
  60883. faceUV?: Vector4[];
  60884. faceColors?: Color4[];
  60885. updatable?: boolean;
  60886. sideOrientation?: number;
  60887. frontUVs?: Vector4;
  60888. backUVs?: Vector4;
  60889. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60890. /**
  60891. * Creates an extruded polygon mesh, with depth in the Y direction.
  60892. * * 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)
  60893. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60894. * @param name defines the name of the mesh
  60895. * @param options defines the options used to create the mesh
  60896. * @param scene defines the hosting scene
  60897. * @param earcutInjection can be used to inject your own earcut reference
  60898. * @returns the polygon mesh
  60899. */
  60900. static ExtrudePolygon(name: string, options: {
  60901. shape: Vector3[];
  60902. holes?: Vector3[][];
  60903. depth?: number;
  60904. faceUV?: Vector4[];
  60905. faceColors?: Color4[];
  60906. updatable?: boolean;
  60907. sideOrientation?: number;
  60908. frontUVs?: Vector4;
  60909. backUVs?: Vector4;
  60910. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60911. }
  60912. }
  60913. declare module BABYLON {
  60914. /**
  60915. * Class containing static functions to help procedurally build meshes
  60916. */
  60917. export class LatheBuilder {
  60918. /**
  60919. * Creates lathe mesh.
  60920. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60921. * * 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
  60922. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60923. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60924. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60925. * * 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
  60926. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60927. * * 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
  60928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60929. * * 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
  60930. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60932. * @param name defines the name of the mesh
  60933. * @param options defines the options used to create the mesh
  60934. * @param scene defines the hosting scene
  60935. * @returns the lathe mesh
  60936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60937. */
  60938. static CreateLathe(name: string, options: {
  60939. shape: Vector3[];
  60940. radius?: number;
  60941. tessellation?: number;
  60942. clip?: number;
  60943. arc?: number;
  60944. closed?: boolean;
  60945. updatable?: boolean;
  60946. sideOrientation?: number;
  60947. frontUVs?: Vector4;
  60948. backUVs?: Vector4;
  60949. cap?: number;
  60950. invertUV?: boolean;
  60951. }, scene?: Nullable<Scene>): Mesh;
  60952. }
  60953. }
  60954. declare module BABYLON {
  60955. /**
  60956. * Class containing static functions to help procedurally build meshes
  60957. */
  60958. export class TiledPlaneBuilder {
  60959. /**
  60960. * Creates a tiled plane mesh
  60961. * * The parameter `pattern` will, depending on value, do nothing or
  60962. * * * flip (reflect about central vertical) alternate tiles across and up
  60963. * * * flip every tile on alternate rows
  60964. * * * rotate (180 degs) alternate tiles across and up
  60965. * * * rotate every tile on alternate rows
  60966. * * * flip and rotate alternate tiles across and up
  60967. * * * flip and rotate every tile on alternate rows
  60968. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60969. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60970. * * 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
  60971. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60972. * * 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)
  60973. * * 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)
  60974. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60975. * @param name defines the name of the mesh
  60976. * @param options defines the options used to create the mesh
  60977. * @param scene defines the hosting scene
  60978. * @returns the box mesh
  60979. */
  60980. static CreateTiledPlane(name: string, options: {
  60981. pattern?: number;
  60982. tileSize?: number;
  60983. tileWidth?: number;
  60984. tileHeight?: number;
  60985. size?: number;
  60986. width?: number;
  60987. height?: number;
  60988. alignHorizontal?: number;
  60989. alignVertical?: number;
  60990. sideOrientation?: number;
  60991. frontUVs?: Vector4;
  60992. backUVs?: Vector4;
  60993. updatable?: boolean;
  60994. }, scene?: Nullable<Scene>): Mesh;
  60995. }
  60996. }
  60997. declare module BABYLON {
  60998. /**
  60999. * Class containing static functions to help procedurally build meshes
  61000. */
  61001. export class TubeBuilder {
  61002. /**
  61003. * Creates a tube mesh.
  61004. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61005. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61006. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61007. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61008. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61009. * * 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)
  61010. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61011. * * 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
  61012. * * 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
  61013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61014. * * 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
  61015. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61017. * @param name defines the name of the mesh
  61018. * @param options defines the options used to create the mesh
  61019. * @param scene defines the hosting scene
  61020. * @returns the tube mesh
  61021. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61022. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61023. */
  61024. static CreateTube(name: string, options: {
  61025. path: Vector3[];
  61026. radius?: number;
  61027. tessellation?: number;
  61028. radiusFunction?: {
  61029. (i: number, distance: number): number;
  61030. };
  61031. cap?: number;
  61032. arc?: number;
  61033. updatable?: boolean;
  61034. sideOrientation?: number;
  61035. frontUVs?: Vector4;
  61036. backUVs?: Vector4;
  61037. instance?: Mesh;
  61038. invertUV?: boolean;
  61039. }, scene?: Nullable<Scene>): Mesh;
  61040. }
  61041. }
  61042. declare module BABYLON {
  61043. /**
  61044. * Class containing static functions to help procedurally build meshes
  61045. */
  61046. export class IcoSphereBuilder {
  61047. /**
  61048. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61049. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61050. * * 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`)
  61051. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61052. * * 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
  61053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61054. * * 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
  61055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61056. * @param name defines the name of the mesh
  61057. * @param options defines the options used to create the mesh
  61058. * @param scene defines the hosting scene
  61059. * @returns the icosahedron mesh
  61060. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61061. */
  61062. static CreateIcoSphere(name: string, options: {
  61063. radius?: number;
  61064. radiusX?: number;
  61065. radiusY?: number;
  61066. radiusZ?: number;
  61067. flat?: boolean;
  61068. subdivisions?: number;
  61069. sideOrientation?: number;
  61070. frontUVs?: Vector4;
  61071. backUVs?: Vector4;
  61072. updatable?: boolean;
  61073. }, scene?: Nullable<Scene>): Mesh;
  61074. }
  61075. }
  61076. declare module BABYLON {
  61077. /**
  61078. * Class containing static functions to help procedurally build meshes
  61079. */
  61080. export class DecalBuilder {
  61081. /**
  61082. * Creates a decal mesh.
  61083. * 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
  61084. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61085. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61086. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61087. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61088. * @param name defines the name of the mesh
  61089. * @param sourceMesh defines the mesh where the decal must be applied
  61090. * @param options defines the options used to create the mesh
  61091. * @param scene defines the hosting scene
  61092. * @returns the decal mesh
  61093. * @see https://doc.babylonjs.com/how_to/decals
  61094. */
  61095. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61096. position?: Vector3;
  61097. normal?: Vector3;
  61098. size?: Vector3;
  61099. angle?: number;
  61100. }): Mesh;
  61101. }
  61102. }
  61103. declare module BABYLON {
  61104. /**
  61105. * Class containing static functions to help procedurally build meshes
  61106. */
  61107. export class MeshBuilder {
  61108. /**
  61109. * Creates a box mesh
  61110. * * The parameter `size` sets the size (float) of each box side (default 1)
  61111. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61112. * * 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)
  61113. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61115. * * 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
  61116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61117. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61118. * @param name defines the name of the mesh
  61119. * @param options defines the options used to create the mesh
  61120. * @param scene defines the hosting scene
  61121. * @returns the box mesh
  61122. */
  61123. static CreateBox(name: string, options: {
  61124. size?: number;
  61125. width?: number;
  61126. height?: number;
  61127. depth?: number;
  61128. faceUV?: Vector4[];
  61129. faceColors?: Color4[];
  61130. sideOrientation?: number;
  61131. frontUVs?: Vector4;
  61132. backUVs?: Vector4;
  61133. updatable?: boolean;
  61134. }, scene?: Nullable<Scene>): Mesh;
  61135. /**
  61136. * Creates a tiled box mesh
  61137. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61139. * @param name defines the name of the mesh
  61140. * @param options defines the options used to create the mesh
  61141. * @param scene defines the hosting scene
  61142. * @returns the tiled box mesh
  61143. */
  61144. static CreateTiledBox(name: string, options: {
  61145. pattern?: number;
  61146. size?: number;
  61147. width?: number;
  61148. height?: number;
  61149. depth: number;
  61150. tileSize?: number;
  61151. tileWidth?: number;
  61152. tileHeight?: number;
  61153. faceUV?: Vector4[];
  61154. faceColors?: Color4[];
  61155. alignHorizontal?: number;
  61156. alignVertical?: number;
  61157. sideOrientation?: number;
  61158. updatable?: boolean;
  61159. }, scene?: Nullable<Scene>): Mesh;
  61160. /**
  61161. * Creates a sphere mesh
  61162. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61163. * * 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`)
  61164. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61165. * * 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
  61166. * * 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)
  61167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61168. * * 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
  61169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61170. * @param name defines the name of the mesh
  61171. * @param options defines the options used to create the mesh
  61172. * @param scene defines the hosting scene
  61173. * @returns the sphere mesh
  61174. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61175. */
  61176. static CreateSphere(name: string, options: {
  61177. segments?: number;
  61178. diameter?: number;
  61179. diameterX?: number;
  61180. diameterY?: number;
  61181. diameterZ?: number;
  61182. arc?: number;
  61183. slice?: number;
  61184. sideOrientation?: number;
  61185. frontUVs?: Vector4;
  61186. backUVs?: Vector4;
  61187. updatable?: boolean;
  61188. }, scene?: Nullable<Scene>): Mesh;
  61189. /**
  61190. * Creates a plane polygonal mesh. By default, this is a disc
  61191. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61192. * * 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
  61193. * * 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
  61194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61195. * * 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
  61196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61197. * @param name defines the name of the mesh
  61198. * @param options defines the options used to create the mesh
  61199. * @param scene defines the hosting scene
  61200. * @returns the plane polygonal mesh
  61201. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61202. */
  61203. static CreateDisc(name: string, options: {
  61204. radius?: number;
  61205. tessellation?: number;
  61206. arc?: number;
  61207. updatable?: boolean;
  61208. sideOrientation?: number;
  61209. frontUVs?: Vector4;
  61210. backUVs?: Vector4;
  61211. }, scene?: Nullable<Scene>): Mesh;
  61212. /**
  61213. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61214. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61215. * * 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`)
  61216. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61217. * * 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
  61218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61219. * * 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
  61220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61221. * @param name defines the name of the mesh
  61222. * @param options defines the options used to create the mesh
  61223. * @param scene defines the hosting scene
  61224. * @returns the icosahedron mesh
  61225. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61226. */
  61227. static CreateIcoSphere(name: string, options: {
  61228. radius?: number;
  61229. radiusX?: number;
  61230. radiusY?: number;
  61231. radiusZ?: number;
  61232. flat?: boolean;
  61233. subdivisions?: number;
  61234. sideOrientation?: number;
  61235. frontUVs?: Vector4;
  61236. backUVs?: Vector4;
  61237. updatable?: boolean;
  61238. }, scene?: Nullable<Scene>): Mesh;
  61239. /**
  61240. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61241. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61242. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61243. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61244. * * 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
  61245. * * 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
  61246. * * 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
  61247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61248. * * 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
  61249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61250. * * 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
  61251. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61252. * * 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
  61253. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61255. * @param name defines the name of the mesh
  61256. * @param options defines the options used to create the mesh
  61257. * @param scene defines the hosting scene
  61258. * @returns the ribbon mesh
  61259. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61260. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61261. */
  61262. static CreateRibbon(name: string, options: {
  61263. pathArray: Vector3[][];
  61264. closeArray?: boolean;
  61265. closePath?: boolean;
  61266. offset?: number;
  61267. updatable?: boolean;
  61268. sideOrientation?: number;
  61269. frontUVs?: Vector4;
  61270. backUVs?: Vector4;
  61271. instance?: Mesh;
  61272. invertUV?: boolean;
  61273. uvs?: Vector2[];
  61274. colors?: Color4[];
  61275. }, scene?: Nullable<Scene>): Mesh;
  61276. /**
  61277. * Creates a cylinder or a cone mesh
  61278. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61279. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61280. * * 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.
  61281. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61282. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61283. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61284. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61285. * * 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).
  61286. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61287. * * 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).
  61288. * * 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
  61289. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61290. * * 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
  61291. * * 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.
  61292. * * If `enclose` is false, a ring surface is one element.
  61293. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61294. * * 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
  61295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61296. * * 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
  61297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61298. * @param name defines the name of the mesh
  61299. * @param options defines the options used to create the mesh
  61300. * @param scene defines the hosting scene
  61301. * @returns the cylinder mesh
  61302. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61303. */
  61304. static CreateCylinder(name: string, options: {
  61305. height?: number;
  61306. diameterTop?: number;
  61307. diameterBottom?: number;
  61308. diameter?: number;
  61309. tessellation?: number;
  61310. subdivisions?: number;
  61311. arc?: number;
  61312. faceColors?: Color4[];
  61313. faceUV?: Vector4[];
  61314. updatable?: boolean;
  61315. hasRings?: boolean;
  61316. enclose?: boolean;
  61317. cap?: number;
  61318. sideOrientation?: number;
  61319. frontUVs?: Vector4;
  61320. backUVs?: Vector4;
  61321. }, scene?: Nullable<Scene>): Mesh;
  61322. /**
  61323. * Creates a torus mesh
  61324. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61325. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61326. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61328. * * 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
  61329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61330. * @param name defines the name of the mesh
  61331. * @param options defines the options used to create the mesh
  61332. * @param scene defines the hosting scene
  61333. * @returns the torus mesh
  61334. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61335. */
  61336. static CreateTorus(name: string, options: {
  61337. diameter?: number;
  61338. thickness?: number;
  61339. tessellation?: number;
  61340. updatable?: boolean;
  61341. sideOrientation?: number;
  61342. frontUVs?: Vector4;
  61343. backUVs?: Vector4;
  61344. }, scene?: Nullable<Scene>): Mesh;
  61345. /**
  61346. * Creates a torus knot mesh
  61347. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61348. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61349. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61350. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61352. * * 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
  61353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61354. * @param name defines the name of the mesh
  61355. * @param options defines the options used to create the mesh
  61356. * @param scene defines the hosting scene
  61357. * @returns the torus knot mesh
  61358. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61359. */
  61360. static CreateTorusKnot(name: string, options: {
  61361. radius?: number;
  61362. tube?: number;
  61363. radialSegments?: number;
  61364. tubularSegments?: number;
  61365. p?: number;
  61366. q?: number;
  61367. updatable?: boolean;
  61368. sideOrientation?: number;
  61369. frontUVs?: Vector4;
  61370. backUVs?: Vector4;
  61371. }, scene?: Nullable<Scene>): Mesh;
  61372. /**
  61373. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61374. * * 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
  61375. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61376. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61377. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61378. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61379. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61380. * * 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
  61381. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61384. * @param name defines the name of the new line system
  61385. * @param options defines the options used to create the line system
  61386. * @param scene defines the hosting scene
  61387. * @returns a new line system mesh
  61388. */
  61389. static CreateLineSystem(name: string, options: {
  61390. lines: Vector3[][];
  61391. updatable?: boolean;
  61392. instance?: Nullable<LinesMesh>;
  61393. colors?: Nullable<Color4[][]>;
  61394. useVertexAlpha?: boolean;
  61395. }, scene: Nullable<Scene>): LinesMesh;
  61396. /**
  61397. * Creates a line mesh
  61398. * 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
  61399. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61400. * * The parameter `points` is an array successive Vector3
  61401. * * 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
  61402. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61403. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61404. * * When updating an instance, remember that only point positions can change, not the number of points
  61405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61407. * @param name defines the name of the new line system
  61408. * @param options defines the options used to create the line system
  61409. * @param scene defines the hosting scene
  61410. * @returns a new line mesh
  61411. */
  61412. static CreateLines(name: string, options: {
  61413. points: Vector3[];
  61414. updatable?: boolean;
  61415. instance?: Nullable<LinesMesh>;
  61416. colors?: Color4[];
  61417. useVertexAlpha?: boolean;
  61418. }, scene?: Nullable<Scene>): LinesMesh;
  61419. /**
  61420. * Creates a dashed line mesh
  61421. * * 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
  61422. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61423. * * The parameter `points` is an array successive Vector3
  61424. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61425. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61426. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61427. * * 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
  61428. * * When updating an instance, remember that only point positions can change, not the number of points
  61429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61430. * @param name defines the name of the mesh
  61431. * @param options defines the options used to create the mesh
  61432. * @param scene defines the hosting scene
  61433. * @returns the dashed line mesh
  61434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61435. */
  61436. static CreateDashedLines(name: string, options: {
  61437. points: Vector3[];
  61438. dashSize?: number;
  61439. gapSize?: number;
  61440. dashNb?: number;
  61441. updatable?: boolean;
  61442. instance?: LinesMesh;
  61443. }, scene?: Nullable<Scene>): LinesMesh;
  61444. /**
  61445. * 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.
  61446. * * 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.
  61447. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61448. * * 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.
  61449. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61450. * * 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
  61451. * * 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
  61452. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61454. * * 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
  61455. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61457. * @param name defines the name of the mesh
  61458. * @param options defines the options used to create the mesh
  61459. * @param scene defines the hosting scene
  61460. * @returns the extruded shape mesh
  61461. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61463. */
  61464. static ExtrudeShape(name: string, options: {
  61465. shape: Vector3[];
  61466. path: Vector3[];
  61467. scale?: number;
  61468. rotation?: number;
  61469. cap?: number;
  61470. updatable?: boolean;
  61471. sideOrientation?: number;
  61472. frontUVs?: Vector4;
  61473. backUVs?: Vector4;
  61474. instance?: Mesh;
  61475. invertUV?: boolean;
  61476. }, scene?: Nullable<Scene>): Mesh;
  61477. /**
  61478. * Creates an custom extruded shape mesh.
  61479. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61480. * * 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.
  61481. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61482. * * 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
  61483. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61484. * * 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
  61485. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61486. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61487. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61488. * * 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
  61489. * * 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
  61490. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61492. * * 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
  61493. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61495. * @param name defines the name of the mesh
  61496. * @param options defines the options used to create the mesh
  61497. * @param scene defines the hosting scene
  61498. * @returns the custom extruded shape mesh
  61499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61500. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61501. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61502. */
  61503. static ExtrudeShapeCustom(name: string, options: {
  61504. shape: Vector3[];
  61505. path: Vector3[];
  61506. scaleFunction?: any;
  61507. rotationFunction?: any;
  61508. ribbonCloseArray?: boolean;
  61509. ribbonClosePath?: boolean;
  61510. cap?: number;
  61511. updatable?: boolean;
  61512. sideOrientation?: number;
  61513. frontUVs?: Vector4;
  61514. backUVs?: Vector4;
  61515. instance?: Mesh;
  61516. invertUV?: boolean;
  61517. }, scene?: Nullable<Scene>): Mesh;
  61518. /**
  61519. * Creates lathe mesh.
  61520. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61521. * * 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
  61522. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61523. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61524. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61525. * * 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
  61526. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61527. * * 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
  61528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61529. * * 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
  61530. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61532. * @param name defines the name of the mesh
  61533. * @param options defines the options used to create the mesh
  61534. * @param scene defines the hosting scene
  61535. * @returns the lathe mesh
  61536. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61537. */
  61538. static CreateLathe(name: string, options: {
  61539. shape: Vector3[];
  61540. radius?: number;
  61541. tessellation?: number;
  61542. clip?: number;
  61543. arc?: number;
  61544. closed?: boolean;
  61545. updatable?: boolean;
  61546. sideOrientation?: number;
  61547. frontUVs?: Vector4;
  61548. backUVs?: Vector4;
  61549. cap?: number;
  61550. invertUV?: boolean;
  61551. }, scene?: Nullable<Scene>): Mesh;
  61552. /**
  61553. * Creates a tiled plane mesh
  61554. * * You can set a limited pattern arrangement with the tiles
  61555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61556. * * 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
  61557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61558. * @param name defines the name of the mesh
  61559. * @param options defines the options used to create the mesh
  61560. * @param scene defines the hosting scene
  61561. * @returns the plane mesh
  61562. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61563. */
  61564. static CreateTiledPlane(name: string, options: {
  61565. pattern?: number;
  61566. tileSize?: number;
  61567. tileWidth?: number;
  61568. tileHeight?: number;
  61569. size?: number;
  61570. width?: number;
  61571. height?: number;
  61572. alignHorizontal?: number;
  61573. alignVertical?: number;
  61574. sideOrientation?: number;
  61575. frontUVs?: Vector4;
  61576. backUVs?: Vector4;
  61577. updatable?: boolean;
  61578. }, scene?: Nullable<Scene>): Mesh;
  61579. /**
  61580. * Creates a plane mesh
  61581. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61582. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61583. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61585. * * 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
  61586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61587. * @param name defines the name of the mesh
  61588. * @param options defines the options used to create the mesh
  61589. * @param scene defines the hosting scene
  61590. * @returns the plane mesh
  61591. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61592. */
  61593. static CreatePlane(name: string, options: {
  61594. size?: number;
  61595. width?: number;
  61596. height?: number;
  61597. sideOrientation?: number;
  61598. frontUVs?: Vector4;
  61599. backUVs?: Vector4;
  61600. updatable?: boolean;
  61601. sourcePlane?: Plane;
  61602. }, scene?: Nullable<Scene>): Mesh;
  61603. /**
  61604. * Creates a ground mesh
  61605. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61606. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61608. * @param name defines the name of the mesh
  61609. * @param options defines the options used to create the mesh
  61610. * @param scene defines the hosting scene
  61611. * @returns the ground mesh
  61612. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61613. */
  61614. static CreateGround(name: string, options: {
  61615. width?: number;
  61616. height?: number;
  61617. subdivisions?: number;
  61618. subdivisionsX?: number;
  61619. subdivisionsY?: number;
  61620. updatable?: boolean;
  61621. }, scene?: Nullable<Scene>): Mesh;
  61622. /**
  61623. * Creates a tiled ground mesh
  61624. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61625. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61626. * * 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
  61627. * * 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
  61628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61629. * @param name defines the name of the mesh
  61630. * @param options defines the options used to create the mesh
  61631. * @param scene defines the hosting scene
  61632. * @returns the tiled ground mesh
  61633. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61634. */
  61635. static CreateTiledGround(name: string, options: {
  61636. xmin: number;
  61637. zmin: number;
  61638. xmax: number;
  61639. zmax: number;
  61640. subdivisions?: {
  61641. w: number;
  61642. h: number;
  61643. };
  61644. precision?: {
  61645. w: number;
  61646. h: number;
  61647. };
  61648. updatable?: boolean;
  61649. }, scene?: Nullable<Scene>): Mesh;
  61650. /**
  61651. * Creates a ground mesh from a height map
  61652. * * The parameter `url` sets the URL of the height map image resource.
  61653. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61654. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61655. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61656. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61657. * * 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.
  61658. * * 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).
  61659. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61661. * @param name defines the name of the mesh
  61662. * @param url defines the url to the height map
  61663. * @param options defines the options used to create the mesh
  61664. * @param scene defines the hosting scene
  61665. * @returns the ground mesh
  61666. * @see https://doc.babylonjs.com/babylon101/height_map
  61667. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61668. */
  61669. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61670. width?: number;
  61671. height?: number;
  61672. subdivisions?: number;
  61673. minHeight?: number;
  61674. maxHeight?: number;
  61675. colorFilter?: Color3;
  61676. alphaFilter?: number;
  61677. updatable?: boolean;
  61678. onReady?: (mesh: GroundMesh) => void;
  61679. }, scene?: Nullable<Scene>): GroundMesh;
  61680. /**
  61681. * Creates a polygon mesh
  61682. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61683. * * 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
  61684. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61686. * * 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)
  61687. * * Remember you can only change the shape positions, not their number when updating a polygon
  61688. * @param name defines the name of the mesh
  61689. * @param options defines the options used to create the mesh
  61690. * @param scene defines the hosting scene
  61691. * @param earcutInjection can be used to inject your own earcut reference
  61692. * @returns the polygon mesh
  61693. */
  61694. static CreatePolygon(name: string, options: {
  61695. shape: Vector3[];
  61696. holes?: Vector3[][];
  61697. depth?: number;
  61698. faceUV?: Vector4[];
  61699. faceColors?: Color4[];
  61700. updatable?: boolean;
  61701. sideOrientation?: number;
  61702. frontUVs?: Vector4;
  61703. backUVs?: Vector4;
  61704. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61705. /**
  61706. * Creates an extruded polygon mesh, with depth in the Y direction.
  61707. * * 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)
  61708. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61709. * @param name defines the name of the mesh
  61710. * @param options defines the options used to create the mesh
  61711. * @param scene defines the hosting scene
  61712. * @param earcutInjection can be used to inject your own earcut reference
  61713. * @returns the polygon mesh
  61714. */
  61715. static ExtrudePolygon(name: string, options: {
  61716. shape: Vector3[];
  61717. holes?: Vector3[][];
  61718. depth?: number;
  61719. faceUV?: Vector4[];
  61720. faceColors?: Color4[];
  61721. updatable?: boolean;
  61722. sideOrientation?: number;
  61723. frontUVs?: Vector4;
  61724. backUVs?: Vector4;
  61725. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61726. /**
  61727. * Creates a tube mesh.
  61728. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61729. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61730. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61731. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61732. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61733. * * 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)
  61734. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61735. * * 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
  61736. * * 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
  61737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61738. * * 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
  61739. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61741. * @param name defines the name of the mesh
  61742. * @param options defines the options used to create the mesh
  61743. * @param scene defines the hosting scene
  61744. * @returns the tube mesh
  61745. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61746. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61747. */
  61748. static CreateTube(name: string, options: {
  61749. path: Vector3[];
  61750. radius?: number;
  61751. tessellation?: number;
  61752. radiusFunction?: {
  61753. (i: number, distance: number): number;
  61754. };
  61755. cap?: number;
  61756. arc?: number;
  61757. updatable?: boolean;
  61758. sideOrientation?: number;
  61759. frontUVs?: Vector4;
  61760. backUVs?: Vector4;
  61761. instance?: Mesh;
  61762. invertUV?: boolean;
  61763. }, scene?: Nullable<Scene>): Mesh;
  61764. /**
  61765. * Creates a polyhedron mesh
  61766. * * 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
  61767. * * The parameter `size` (positive float, default 1) sets the polygon size
  61768. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61769. * * 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`
  61770. * * 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
  61771. * * 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)`)
  61772. * * 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
  61773. * * 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
  61774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61775. * * 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
  61776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61777. * @param name defines the name of the mesh
  61778. * @param options defines the options used to create the mesh
  61779. * @param scene defines the hosting scene
  61780. * @returns the polyhedron mesh
  61781. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61782. */
  61783. static CreatePolyhedron(name: string, options: {
  61784. type?: number;
  61785. size?: number;
  61786. sizeX?: number;
  61787. sizeY?: number;
  61788. sizeZ?: number;
  61789. custom?: any;
  61790. faceUV?: Vector4[];
  61791. faceColors?: Color4[];
  61792. flat?: boolean;
  61793. updatable?: boolean;
  61794. sideOrientation?: number;
  61795. frontUVs?: Vector4;
  61796. backUVs?: Vector4;
  61797. }, scene?: Nullable<Scene>): Mesh;
  61798. /**
  61799. * Creates a decal mesh.
  61800. * 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
  61801. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61802. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61803. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61804. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61805. * @param name defines the name of the mesh
  61806. * @param sourceMesh defines the mesh where the decal must be applied
  61807. * @param options defines the options used to create the mesh
  61808. * @param scene defines the hosting scene
  61809. * @returns the decal mesh
  61810. * @see https://doc.babylonjs.com/how_to/decals
  61811. */
  61812. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61813. position?: Vector3;
  61814. normal?: Vector3;
  61815. size?: Vector3;
  61816. angle?: number;
  61817. }): Mesh;
  61818. }
  61819. }
  61820. declare module BABYLON {
  61821. /**
  61822. * A simplifier interface for future simplification implementations
  61823. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61824. */
  61825. export interface ISimplifier {
  61826. /**
  61827. * Simplification of a given mesh according to the given settings.
  61828. * Since this requires computation, it is assumed that the function runs async.
  61829. * @param settings The settings of the simplification, including quality and distance
  61830. * @param successCallback A callback that will be called after the mesh was simplified.
  61831. * @param errorCallback in case of an error, this callback will be called. optional.
  61832. */
  61833. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61834. }
  61835. /**
  61836. * Expected simplification settings.
  61837. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61838. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61839. */
  61840. export interface ISimplificationSettings {
  61841. /**
  61842. * Gets or sets the expected quality
  61843. */
  61844. quality: number;
  61845. /**
  61846. * Gets or sets the distance when this optimized version should be used
  61847. */
  61848. distance: number;
  61849. /**
  61850. * Gets an already optimized mesh
  61851. */
  61852. optimizeMesh?: boolean;
  61853. }
  61854. /**
  61855. * Class used to specify simplification options
  61856. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61857. */
  61858. export class SimplificationSettings implements ISimplificationSettings {
  61859. /** expected quality */
  61860. quality: number;
  61861. /** distance when this optimized version should be used */
  61862. distance: number;
  61863. /** already optimized mesh */
  61864. optimizeMesh?: boolean | undefined;
  61865. /**
  61866. * Creates a SimplificationSettings
  61867. * @param quality expected quality
  61868. * @param distance distance when this optimized version should be used
  61869. * @param optimizeMesh already optimized mesh
  61870. */
  61871. constructor(
  61872. /** expected quality */
  61873. quality: number,
  61874. /** distance when this optimized version should be used */
  61875. distance: number,
  61876. /** already optimized mesh */
  61877. optimizeMesh?: boolean | undefined);
  61878. }
  61879. /**
  61880. * Interface used to define a simplification task
  61881. */
  61882. export interface ISimplificationTask {
  61883. /**
  61884. * Array of settings
  61885. */
  61886. settings: Array<ISimplificationSettings>;
  61887. /**
  61888. * Simplification type
  61889. */
  61890. simplificationType: SimplificationType;
  61891. /**
  61892. * Mesh to simplify
  61893. */
  61894. mesh: Mesh;
  61895. /**
  61896. * Callback called on success
  61897. */
  61898. successCallback?: () => void;
  61899. /**
  61900. * Defines if parallel processing can be used
  61901. */
  61902. parallelProcessing: boolean;
  61903. }
  61904. /**
  61905. * Queue used to order the simplification tasks
  61906. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61907. */
  61908. export class SimplificationQueue {
  61909. private _simplificationArray;
  61910. /**
  61911. * Gets a boolean indicating that the process is still running
  61912. */
  61913. running: boolean;
  61914. /**
  61915. * Creates a new queue
  61916. */
  61917. constructor();
  61918. /**
  61919. * Adds a new simplification task
  61920. * @param task defines a task to add
  61921. */
  61922. addTask(task: ISimplificationTask): void;
  61923. /**
  61924. * Execute next task
  61925. */
  61926. executeNext(): void;
  61927. /**
  61928. * Execute a simplification task
  61929. * @param task defines the task to run
  61930. */
  61931. runSimplification(task: ISimplificationTask): void;
  61932. private getSimplifier;
  61933. }
  61934. /**
  61935. * The implemented types of simplification
  61936. * At the moment only Quadratic Error Decimation is implemented
  61937. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61938. */
  61939. export enum SimplificationType {
  61940. /** Quadratic error decimation */
  61941. QUADRATIC = 0
  61942. }
  61943. }
  61944. declare module BABYLON {
  61945. interface Scene {
  61946. /** @hidden (Backing field) */
  61947. _simplificationQueue: SimplificationQueue;
  61948. /**
  61949. * Gets or sets the simplification queue attached to the scene
  61950. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61951. */
  61952. simplificationQueue: SimplificationQueue;
  61953. }
  61954. interface Mesh {
  61955. /**
  61956. * Simplify the mesh according to the given array of settings.
  61957. * Function will return immediately and will simplify async
  61958. * @param settings a collection of simplification settings
  61959. * @param parallelProcessing should all levels calculate parallel or one after the other
  61960. * @param simplificationType the type of simplification to run
  61961. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61962. * @returns the current mesh
  61963. */
  61964. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61965. }
  61966. /**
  61967. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61968. * created in a scene
  61969. */
  61970. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61971. /**
  61972. * The component name helpfull to identify the component in the list of scene components.
  61973. */
  61974. readonly name: string;
  61975. /**
  61976. * The scene the component belongs to.
  61977. */
  61978. scene: Scene;
  61979. /**
  61980. * Creates a new instance of the component for the given scene
  61981. * @param scene Defines the scene to register the component in
  61982. */
  61983. constructor(scene: Scene);
  61984. /**
  61985. * Registers the component in a given scene
  61986. */
  61987. register(): void;
  61988. /**
  61989. * Rebuilds the elements related to this component in case of
  61990. * context lost for instance.
  61991. */
  61992. rebuild(): void;
  61993. /**
  61994. * Disposes the component and the associated ressources
  61995. */
  61996. dispose(): void;
  61997. private _beforeCameraUpdate;
  61998. }
  61999. }
  62000. declare module BABYLON {
  62001. /**
  62002. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62003. */
  62004. export interface INavigationEnginePlugin {
  62005. /**
  62006. * plugin name
  62007. */
  62008. name: string;
  62009. /**
  62010. * Creates a navigation mesh
  62011. * @param meshes array of all the geometry used to compute the navigatio mesh
  62012. * @param parameters bunch of parameters used to filter geometry
  62013. */
  62014. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62015. /**
  62016. * Create a navigation mesh debug mesh
  62017. * @param scene is where the mesh will be added
  62018. * @returns debug display mesh
  62019. */
  62020. createDebugNavMesh(scene: Scene): Mesh;
  62021. /**
  62022. * Get a navigation mesh constrained position, closest to the parameter position
  62023. * @param position world position
  62024. * @returns the closest point to position constrained by the navigation mesh
  62025. */
  62026. getClosestPoint(position: Vector3): Vector3;
  62027. /**
  62028. * Get a navigation mesh constrained position, within a particular radius
  62029. * @param position world position
  62030. * @param maxRadius the maximum distance to the constrained world position
  62031. * @returns the closest point to position constrained by the navigation mesh
  62032. */
  62033. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62034. /**
  62035. * Compute the final position from a segment made of destination-position
  62036. * @param position world position
  62037. * @param destination world position
  62038. * @returns the resulting point along the navmesh
  62039. */
  62040. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62041. /**
  62042. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62043. * @param start world position
  62044. * @param end world position
  62045. * @returns array containing world position composing the path
  62046. */
  62047. computePath(start: Vector3, end: Vector3): Vector3[];
  62048. /**
  62049. * If this plugin is supported
  62050. * @returns true if plugin is supported
  62051. */
  62052. isSupported(): boolean;
  62053. /**
  62054. * Create a new Crowd so you can add agents
  62055. * @param maxAgents the maximum agent count in the crowd
  62056. * @param maxAgentRadius the maximum radius an agent can have
  62057. * @param scene to attach the crowd to
  62058. * @returns the crowd you can add agents to
  62059. */
  62060. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62061. /**
  62062. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62063. * The queries will try to find a solution within those bounds
  62064. * default is (1,1,1)
  62065. * @param extent x,y,z value that define the extent around the queries point of reference
  62066. */
  62067. setDefaultQueryExtent(extent: Vector3): void;
  62068. /**
  62069. * Get the Bounding box extent specified by setDefaultQueryExtent
  62070. * @returns the box extent values
  62071. */
  62072. getDefaultQueryExtent(): Vector3;
  62073. /**
  62074. * Release all resources
  62075. */
  62076. dispose(): void;
  62077. }
  62078. /**
  62079. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62080. */
  62081. export interface ICrowd {
  62082. /**
  62083. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62084. * You can attach anything to that node. The node position is updated in the scene update tick.
  62085. * @param pos world position that will be constrained by the navigation mesh
  62086. * @param parameters agent parameters
  62087. * @param transform hooked to the agent that will be update by the scene
  62088. * @returns agent index
  62089. */
  62090. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62091. /**
  62092. * Returns the agent position in world space
  62093. * @param index agent index returned by addAgent
  62094. * @returns world space position
  62095. */
  62096. getAgentPosition(index: number): Vector3;
  62097. /**
  62098. * Gets the agent velocity in world space
  62099. * @param index agent index returned by addAgent
  62100. * @returns world space velocity
  62101. */
  62102. getAgentVelocity(index: number): Vector3;
  62103. /**
  62104. * remove a particular agent previously created
  62105. * @param index agent index returned by addAgent
  62106. */
  62107. removeAgent(index: number): void;
  62108. /**
  62109. * get the list of all agents attached to this crowd
  62110. * @returns list of agent indices
  62111. */
  62112. getAgents(): number[];
  62113. /**
  62114. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62115. * @param deltaTime in seconds
  62116. */
  62117. update(deltaTime: number): void;
  62118. /**
  62119. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62120. * @param index agent index returned by addAgent
  62121. * @param destination targeted world position
  62122. */
  62123. agentGoto(index: number, destination: Vector3): void;
  62124. /**
  62125. * Teleport the agent to a new position
  62126. * @param index agent index returned by addAgent
  62127. * @param destination targeted world position
  62128. */
  62129. agentTeleport(index: number, destination: Vector3): void;
  62130. /**
  62131. * Update agent parameters
  62132. * @param index agent index returned by addAgent
  62133. * @param parameters agent parameters
  62134. */
  62135. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62136. /**
  62137. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62138. * The queries will try to find a solution within those bounds
  62139. * default is (1,1,1)
  62140. * @param extent x,y,z value that define the extent around the queries point of reference
  62141. */
  62142. setDefaultQueryExtent(extent: Vector3): void;
  62143. /**
  62144. * Get the Bounding box extent specified by setDefaultQueryExtent
  62145. * @returns the box extent values
  62146. */
  62147. getDefaultQueryExtent(): Vector3;
  62148. /**
  62149. * Release all resources
  62150. */
  62151. dispose(): void;
  62152. }
  62153. /**
  62154. * Configures an agent
  62155. */
  62156. export interface IAgentParameters {
  62157. /**
  62158. * Agent radius. [Limit: >= 0]
  62159. */
  62160. radius: number;
  62161. /**
  62162. * Agent height. [Limit: > 0]
  62163. */
  62164. height: number;
  62165. /**
  62166. * Maximum allowed acceleration. [Limit: >= 0]
  62167. */
  62168. maxAcceleration: number;
  62169. /**
  62170. * Maximum allowed speed. [Limit: >= 0]
  62171. */
  62172. maxSpeed: number;
  62173. /**
  62174. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62175. */
  62176. collisionQueryRange: number;
  62177. /**
  62178. * The path visibility optimization range. [Limit: > 0]
  62179. */
  62180. pathOptimizationRange: number;
  62181. /**
  62182. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62183. */
  62184. separationWeight: number;
  62185. }
  62186. /**
  62187. * Configures the navigation mesh creation
  62188. */
  62189. export interface INavMeshParameters {
  62190. /**
  62191. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62192. */
  62193. cs: number;
  62194. /**
  62195. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62196. */
  62197. ch: number;
  62198. /**
  62199. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62200. */
  62201. walkableSlopeAngle: number;
  62202. /**
  62203. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62204. * be considered walkable. [Limit: >= 3] [Units: vx]
  62205. */
  62206. walkableHeight: number;
  62207. /**
  62208. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62209. */
  62210. walkableClimb: number;
  62211. /**
  62212. * The distance to erode/shrink the walkable area of the heightfield away from
  62213. * obstructions. [Limit: >=0] [Units: vx]
  62214. */
  62215. walkableRadius: number;
  62216. /**
  62217. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62218. */
  62219. maxEdgeLen: number;
  62220. /**
  62221. * The maximum distance a simplfied contour's border edges should deviate
  62222. * the original raw contour. [Limit: >=0] [Units: vx]
  62223. */
  62224. maxSimplificationError: number;
  62225. /**
  62226. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62227. */
  62228. minRegionArea: number;
  62229. /**
  62230. * Any regions with a span count smaller than this value will, if possible,
  62231. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62232. */
  62233. mergeRegionArea: number;
  62234. /**
  62235. * The maximum number of vertices allowed for polygons generated during the
  62236. * contour to polygon conversion process. [Limit: >= 3]
  62237. */
  62238. maxVertsPerPoly: number;
  62239. /**
  62240. * Sets the sampling distance to use when generating the detail mesh.
  62241. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62242. */
  62243. detailSampleDist: number;
  62244. /**
  62245. * The maximum distance the detail mesh surface should deviate from heightfield
  62246. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62247. */
  62248. detailSampleMaxError: number;
  62249. }
  62250. }
  62251. declare module BABYLON {
  62252. /**
  62253. * RecastJS navigation plugin
  62254. */
  62255. export class RecastJSPlugin implements INavigationEnginePlugin {
  62256. /**
  62257. * Reference to the Recast library
  62258. */
  62259. bjsRECAST: any;
  62260. /**
  62261. * plugin name
  62262. */
  62263. name: string;
  62264. /**
  62265. * the first navmesh created. We might extend this to support multiple navmeshes
  62266. */
  62267. navMesh: any;
  62268. /**
  62269. * Initializes the recastJS plugin
  62270. * @param recastInjection can be used to inject your own recast reference
  62271. */
  62272. constructor(recastInjection?: any);
  62273. /**
  62274. * Creates a navigation mesh
  62275. * @param meshes array of all the geometry used to compute the navigatio mesh
  62276. * @param parameters bunch of parameters used to filter geometry
  62277. */
  62278. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62279. /**
  62280. * Create a navigation mesh debug mesh
  62281. * @param scene is where the mesh will be added
  62282. * @returns debug display mesh
  62283. */
  62284. createDebugNavMesh(scene: Scene): Mesh;
  62285. /**
  62286. * Get a navigation mesh constrained position, closest to the parameter position
  62287. * @param position world position
  62288. * @returns the closest point to position constrained by the navigation mesh
  62289. */
  62290. getClosestPoint(position: Vector3): Vector3;
  62291. /**
  62292. * Get a navigation mesh constrained position, within a particular radius
  62293. * @param position world position
  62294. * @param maxRadius the maximum distance to the constrained world position
  62295. * @returns the closest point to position constrained by the navigation mesh
  62296. */
  62297. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62298. /**
  62299. * Compute the final position from a segment made of destination-position
  62300. * @param position world position
  62301. * @param destination world position
  62302. * @returns the resulting point along the navmesh
  62303. */
  62304. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62305. /**
  62306. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62307. * @param start world position
  62308. * @param end world position
  62309. * @returns array containing world position composing the path
  62310. */
  62311. computePath(start: Vector3, end: Vector3): Vector3[];
  62312. /**
  62313. * Create a new Crowd so you can add agents
  62314. * @param maxAgents the maximum agent count in the crowd
  62315. * @param maxAgentRadius the maximum radius an agent can have
  62316. * @param scene to attach the crowd to
  62317. * @returns the crowd you can add agents to
  62318. */
  62319. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62320. /**
  62321. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62322. * The queries will try to find a solution within those bounds
  62323. * default is (1,1,1)
  62324. * @param extent x,y,z value that define the extent around the queries point of reference
  62325. */
  62326. setDefaultQueryExtent(extent: Vector3): void;
  62327. /**
  62328. * Get the Bounding box extent specified by setDefaultQueryExtent
  62329. * @returns the box extent values
  62330. */
  62331. getDefaultQueryExtent(): Vector3;
  62332. /**
  62333. * Disposes
  62334. */
  62335. dispose(): void;
  62336. /**
  62337. * If this plugin is supported
  62338. * @returns true if plugin is supported
  62339. */
  62340. isSupported(): boolean;
  62341. }
  62342. /**
  62343. * Recast detour crowd implementation
  62344. */
  62345. export class RecastJSCrowd implements ICrowd {
  62346. /**
  62347. * Recast/detour plugin
  62348. */
  62349. bjsRECASTPlugin: RecastJSPlugin;
  62350. /**
  62351. * Link to the detour crowd
  62352. */
  62353. recastCrowd: any;
  62354. /**
  62355. * One transform per agent
  62356. */
  62357. transforms: TransformNode[];
  62358. /**
  62359. * All agents created
  62360. */
  62361. agents: number[];
  62362. /**
  62363. * Link to the scene is kept to unregister the crowd from the scene
  62364. */
  62365. private _scene;
  62366. /**
  62367. * Observer for crowd updates
  62368. */
  62369. private _onBeforeAnimationsObserver;
  62370. /**
  62371. * Constructor
  62372. * @param plugin recastJS plugin
  62373. * @param maxAgents the maximum agent count in the crowd
  62374. * @param maxAgentRadius the maximum radius an agent can have
  62375. * @param scene to attach the crowd to
  62376. * @returns the crowd you can add agents to
  62377. */
  62378. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62379. /**
  62380. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62381. * You can attach anything to that node. The node position is updated in the scene update tick.
  62382. * @param pos world position that will be constrained by the navigation mesh
  62383. * @param parameters agent parameters
  62384. * @param transform hooked to the agent that will be update by the scene
  62385. * @returns agent index
  62386. */
  62387. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62388. /**
  62389. * Returns the agent position in world space
  62390. * @param index agent index returned by addAgent
  62391. * @returns world space position
  62392. */
  62393. getAgentPosition(index: number): Vector3;
  62394. /**
  62395. * Returns the agent velocity in world space
  62396. * @param index agent index returned by addAgent
  62397. * @returns world space velocity
  62398. */
  62399. getAgentVelocity(index: number): Vector3;
  62400. /**
  62401. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62402. * @param index agent index returned by addAgent
  62403. * @param destination targeted world position
  62404. */
  62405. agentGoto(index: number, destination: Vector3): void;
  62406. /**
  62407. * Teleport the agent to a new position
  62408. * @param index agent index returned by addAgent
  62409. * @param destination targeted world position
  62410. */
  62411. agentTeleport(index: number, destination: Vector3): void;
  62412. /**
  62413. * Update agent parameters
  62414. * @param index agent index returned by addAgent
  62415. * @param parameters agent parameters
  62416. */
  62417. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62418. /**
  62419. * remove a particular agent previously created
  62420. * @param index agent index returned by addAgent
  62421. */
  62422. removeAgent(index: number): void;
  62423. /**
  62424. * get the list of all agents attached to this crowd
  62425. * @returns list of agent indices
  62426. */
  62427. getAgents(): number[];
  62428. /**
  62429. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62430. * @param deltaTime in seconds
  62431. */
  62432. update(deltaTime: number): void;
  62433. /**
  62434. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62435. * The queries will try to find a solution within those bounds
  62436. * default is (1,1,1)
  62437. * @param extent x,y,z value that define the extent around the queries point of reference
  62438. */
  62439. setDefaultQueryExtent(extent: Vector3): void;
  62440. /**
  62441. * Get the Bounding box extent specified by setDefaultQueryExtent
  62442. * @returns the box extent values
  62443. */
  62444. getDefaultQueryExtent(): Vector3;
  62445. /**
  62446. * Release all resources
  62447. */
  62448. dispose(): void;
  62449. }
  62450. }
  62451. declare module BABYLON {
  62452. /**
  62453. * Class used to enable access to IndexedDB
  62454. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62455. */
  62456. export class Database implements IOfflineProvider {
  62457. private _callbackManifestChecked;
  62458. private _currentSceneUrl;
  62459. private _db;
  62460. private _enableSceneOffline;
  62461. private _enableTexturesOffline;
  62462. private _manifestVersionFound;
  62463. private _mustUpdateRessources;
  62464. private _hasReachedQuota;
  62465. private _isSupported;
  62466. private _idbFactory;
  62467. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62468. private static IsUASupportingBlobStorage;
  62469. /**
  62470. * Gets a boolean indicating if Database storate is enabled (off by default)
  62471. */
  62472. static IDBStorageEnabled: boolean;
  62473. /**
  62474. * Gets a boolean indicating if scene must be saved in the database
  62475. */
  62476. get enableSceneOffline(): boolean;
  62477. /**
  62478. * Gets a boolean indicating if textures must be saved in the database
  62479. */
  62480. get enableTexturesOffline(): boolean;
  62481. /**
  62482. * Creates a new Database
  62483. * @param urlToScene defines the url to load the scene
  62484. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62485. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62486. */
  62487. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62488. private static _ParseURL;
  62489. private static _ReturnFullUrlLocation;
  62490. private _checkManifestFile;
  62491. /**
  62492. * Open the database and make it available
  62493. * @param successCallback defines the callback to call on success
  62494. * @param errorCallback defines the callback to call on error
  62495. */
  62496. open(successCallback: () => void, errorCallback: () => void): void;
  62497. /**
  62498. * Loads an image from the database
  62499. * @param url defines the url to load from
  62500. * @param image defines the target DOM image
  62501. */
  62502. loadImage(url: string, image: HTMLImageElement): void;
  62503. private _loadImageFromDBAsync;
  62504. private _saveImageIntoDBAsync;
  62505. private _checkVersionFromDB;
  62506. private _loadVersionFromDBAsync;
  62507. private _saveVersionIntoDBAsync;
  62508. /**
  62509. * Loads a file from database
  62510. * @param url defines the URL to load from
  62511. * @param sceneLoaded defines a callback to call on success
  62512. * @param progressCallBack defines a callback to call when progress changed
  62513. * @param errorCallback defines a callback to call on error
  62514. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62515. */
  62516. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62517. private _loadFileAsync;
  62518. private _saveFileAsync;
  62519. /**
  62520. * Validates if xhr data is correct
  62521. * @param xhr defines the request to validate
  62522. * @param dataType defines the expected data type
  62523. * @returns true if data is correct
  62524. */
  62525. private static _ValidateXHRData;
  62526. }
  62527. }
  62528. declare module BABYLON {
  62529. /** @hidden */
  62530. export var gpuUpdateParticlesPixelShader: {
  62531. name: string;
  62532. shader: string;
  62533. };
  62534. }
  62535. declare module BABYLON {
  62536. /** @hidden */
  62537. export var gpuUpdateParticlesVertexShader: {
  62538. name: string;
  62539. shader: string;
  62540. };
  62541. }
  62542. declare module BABYLON {
  62543. /** @hidden */
  62544. export var clipPlaneFragmentDeclaration2: {
  62545. name: string;
  62546. shader: string;
  62547. };
  62548. }
  62549. declare module BABYLON {
  62550. /** @hidden */
  62551. export var gpuRenderParticlesPixelShader: {
  62552. name: string;
  62553. shader: string;
  62554. };
  62555. }
  62556. declare module BABYLON {
  62557. /** @hidden */
  62558. export var clipPlaneVertexDeclaration2: {
  62559. name: string;
  62560. shader: string;
  62561. };
  62562. }
  62563. declare module BABYLON {
  62564. /** @hidden */
  62565. export var gpuRenderParticlesVertexShader: {
  62566. name: string;
  62567. shader: string;
  62568. };
  62569. }
  62570. declare module BABYLON {
  62571. /**
  62572. * This represents a GPU particle system in Babylon
  62573. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62574. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62575. */
  62576. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62577. /**
  62578. * The layer mask we are rendering the particles through.
  62579. */
  62580. layerMask: number;
  62581. private _capacity;
  62582. private _activeCount;
  62583. private _currentActiveCount;
  62584. private _accumulatedCount;
  62585. private _renderEffect;
  62586. private _updateEffect;
  62587. private _buffer0;
  62588. private _buffer1;
  62589. private _spriteBuffer;
  62590. private _updateVAO;
  62591. private _renderVAO;
  62592. private _targetIndex;
  62593. private _sourceBuffer;
  62594. private _targetBuffer;
  62595. private _engine;
  62596. private _currentRenderId;
  62597. private _started;
  62598. private _stopped;
  62599. private _timeDelta;
  62600. private _randomTexture;
  62601. private _randomTexture2;
  62602. private _attributesStrideSize;
  62603. private _updateEffectOptions;
  62604. private _randomTextureSize;
  62605. private _actualFrame;
  62606. private readonly _rawTextureWidth;
  62607. /**
  62608. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62609. */
  62610. static get IsSupported(): boolean;
  62611. /**
  62612. * An event triggered when the system is disposed.
  62613. */
  62614. onDisposeObservable: Observable<GPUParticleSystem>;
  62615. /**
  62616. * Gets the maximum number of particles active at the same time.
  62617. * @returns The max number of active particles.
  62618. */
  62619. getCapacity(): number;
  62620. /**
  62621. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62622. * to override the particles.
  62623. */
  62624. forceDepthWrite: boolean;
  62625. /**
  62626. * Gets or set the number of active particles
  62627. */
  62628. get activeParticleCount(): number;
  62629. set activeParticleCount(value: number);
  62630. private _preWarmDone;
  62631. /**
  62632. * Is this system ready to be used/rendered
  62633. * @return true if the system is ready
  62634. */
  62635. isReady(): boolean;
  62636. /**
  62637. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62638. * @returns True if it has been started, otherwise false.
  62639. */
  62640. isStarted(): boolean;
  62641. /**
  62642. * Starts the particle system and begins to emit
  62643. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62644. */
  62645. start(delay?: number): void;
  62646. /**
  62647. * Stops the particle system.
  62648. */
  62649. stop(): void;
  62650. /**
  62651. * Remove all active particles
  62652. */
  62653. reset(): void;
  62654. /**
  62655. * Returns the string "GPUParticleSystem"
  62656. * @returns a string containing the class name
  62657. */
  62658. getClassName(): string;
  62659. private _colorGradientsTexture;
  62660. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62661. /**
  62662. * Adds a new color gradient
  62663. * @param gradient defines the gradient to use (between 0 and 1)
  62664. * @param color1 defines the color to affect to the specified gradient
  62665. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62666. * @returns the current particle system
  62667. */
  62668. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62669. /**
  62670. * Remove a specific color gradient
  62671. * @param gradient defines the gradient to remove
  62672. * @returns the current particle system
  62673. */
  62674. removeColorGradient(gradient: number): GPUParticleSystem;
  62675. private _angularSpeedGradientsTexture;
  62676. private _sizeGradientsTexture;
  62677. private _velocityGradientsTexture;
  62678. private _limitVelocityGradientsTexture;
  62679. private _dragGradientsTexture;
  62680. private _addFactorGradient;
  62681. /**
  62682. * Adds a new size gradient
  62683. * @param gradient defines the gradient to use (between 0 and 1)
  62684. * @param factor defines the size factor to affect to the specified gradient
  62685. * @returns the current particle system
  62686. */
  62687. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62688. /**
  62689. * Remove a specific size gradient
  62690. * @param gradient defines the gradient to remove
  62691. * @returns the current particle system
  62692. */
  62693. removeSizeGradient(gradient: number): GPUParticleSystem;
  62694. /**
  62695. * Adds a new angular speed gradient
  62696. * @param gradient defines the gradient to use (between 0 and 1)
  62697. * @param factor defines the angular speed to affect to the specified gradient
  62698. * @returns the current particle system
  62699. */
  62700. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62701. /**
  62702. * Remove a specific angular speed gradient
  62703. * @param gradient defines the gradient to remove
  62704. * @returns the current particle system
  62705. */
  62706. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62707. /**
  62708. * Adds a new velocity gradient
  62709. * @param gradient defines the gradient to use (between 0 and 1)
  62710. * @param factor defines the velocity to affect to the specified gradient
  62711. * @returns the current particle system
  62712. */
  62713. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62714. /**
  62715. * Remove a specific velocity gradient
  62716. * @param gradient defines the gradient to remove
  62717. * @returns the current particle system
  62718. */
  62719. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62720. /**
  62721. * Adds a new limit velocity gradient
  62722. * @param gradient defines the gradient to use (between 0 and 1)
  62723. * @param factor defines the limit velocity value to affect to the specified gradient
  62724. * @returns the current particle system
  62725. */
  62726. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62727. /**
  62728. * Remove a specific limit velocity gradient
  62729. * @param gradient defines the gradient to remove
  62730. * @returns the current particle system
  62731. */
  62732. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62733. /**
  62734. * Adds a new drag gradient
  62735. * @param gradient defines the gradient to use (between 0 and 1)
  62736. * @param factor defines the drag value to affect to the specified gradient
  62737. * @returns the current particle system
  62738. */
  62739. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62740. /**
  62741. * Remove a specific drag gradient
  62742. * @param gradient defines the gradient to remove
  62743. * @returns the current particle system
  62744. */
  62745. removeDragGradient(gradient: number): GPUParticleSystem;
  62746. /**
  62747. * Not supported by GPUParticleSystem
  62748. * @param gradient defines the gradient to use (between 0 and 1)
  62749. * @param factor defines the emit rate value to affect to the specified gradient
  62750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62751. * @returns the current particle system
  62752. */
  62753. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62754. /**
  62755. * Not supported by GPUParticleSystem
  62756. * @param gradient defines the gradient to remove
  62757. * @returns the current particle system
  62758. */
  62759. removeEmitRateGradient(gradient: number): IParticleSystem;
  62760. /**
  62761. * Not supported by GPUParticleSystem
  62762. * @param gradient defines the gradient to use (between 0 and 1)
  62763. * @param factor defines the start size value to affect to the specified gradient
  62764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62765. * @returns the current particle system
  62766. */
  62767. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62768. /**
  62769. * Not supported by GPUParticleSystem
  62770. * @param gradient defines the gradient to remove
  62771. * @returns the current particle system
  62772. */
  62773. removeStartSizeGradient(gradient: number): IParticleSystem;
  62774. /**
  62775. * Not supported by GPUParticleSystem
  62776. * @param gradient defines the gradient to use (between 0 and 1)
  62777. * @param min defines the color remap minimal range
  62778. * @param max defines the color remap maximal range
  62779. * @returns the current particle system
  62780. */
  62781. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62782. /**
  62783. * Not supported by GPUParticleSystem
  62784. * @param gradient defines the gradient to remove
  62785. * @returns the current particle system
  62786. */
  62787. removeColorRemapGradient(): IParticleSystem;
  62788. /**
  62789. * Not supported by GPUParticleSystem
  62790. * @param gradient defines the gradient to use (between 0 and 1)
  62791. * @param min defines the alpha remap minimal range
  62792. * @param max defines the alpha remap maximal range
  62793. * @returns the current particle system
  62794. */
  62795. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62796. /**
  62797. * Not supported by GPUParticleSystem
  62798. * @param gradient defines the gradient to remove
  62799. * @returns the current particle system
  62800. */
  62801. removeAlphaRemapGradient(): IParticleSystem;
  62802. /**
  62803. * Not supported by GPUParticleSystem
  62804. * @param gradient defines the gradient to use (between 0 and 1)
  62805. * @param color defines the color to affect to the specified gradient
  62806. * @returns the current particle system
  62807. */
  62808. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62809. /**
  62810. * Not supported by GPUParticleSystem
  62811. * @param gradient defines the gradient to remove
  62812. * @returns the current particle system
  62813. */
  62814. removeRampGradient(): IParticleSystem;
  62815. /**
  62816. * Not supported by GPUParticleSystem
  62817. * @returns the list of ramp gradients
  62818. */
  62819. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62820. /**
  62821. * Not supported by GPUParticleSystem
  62822. * Gets or sets a boolean indicating that ramp gradients must be used
  62823. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62824. */
  62825. get useRampGradients(): boolean;
  62826. set useRampGradients(value: boolean);
  62827. /**
  62828. * Not supported by GPUParticleSystem
  62829. * @param gradient defines the gradient to use (between 0 and 1)
  62830. * @param factor defines the life time factor to affect to the specified gradient
  62831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62832. * @returns the current particle system
  62833. */
  62834. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62835. /**
  62836. * Not supported by GPUParticleSystem
  62837. * @param gradient defines the gradient to remove
  62838. * @returns the current particle system
  62839. */
  62840. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62841. /**
  62842. * Instantiates a GPU particle system.
  62843. * 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.
  62844. * @param name The name of the particle system
  62845. * @param options The options used to create the system
  62846. * @param scene The scene the particle system belongs to
  62847. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62848. */
  62849. constructor(name: string, options: Partial<{
  62850. capacity: number;
  62851. randomTextureSize: number;
  62852. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62853. protected _reset(): void;
  62854. private _createUpdateVAO;
  62855. private _createRenderVAO;
  62856. private _initialize;
  62857. /** @hidden */
  62858. _recreateUpdateEffect(): void;
  62859. /** @hidden */
  62860. _recreateRenderEffect(): void;
  62861. /**
  62862. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62863. * @param preWarm defines if we are in the pre-warmimg phase
  62864. */
  62865. animate(preWarm?: boolean): void;
  62866. private _createFactorGradientTexture;
  62867. private _createSizeGradientTexture;
  62868. private _createAngularSpeedGradientTexture;
  62869. private _createVelocityGradientTexture;
  62870. private _createLimitVelocityGradientTexture;
  62871. private _createDragGradientTexture;
  62872. private _createColorGradientTexture;
  62873. /**
  62874. * Renders the particle system in its current state
  62875. * @param preWarm defines if the system should only update the particles but not render them
  62876. * @returns the current number of particles
  62877. */
  62878. render(preWarm?: boolean): number;
  62879. /**
  62880. * Rebuilds the particle system
  62881. */
  62882. rebuild(): void;
  62883. private _releaseBuffers;
  62884. private _releaseVAOs;
  62885. /**
  62886. * Disposes the particle system and free the associated resources
  62887. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62888. */
  62889. dispose(disposeTexture?: boolean): void;
  62890. /**
  62891. * Clones the particle system.
  62892. * @param name The name of the cloned object
  62893. * @param newEmitter The new emitter to use
  62894. * @returns the cloned particle system
  62895. */
  62896. clone(name: string, newEmitter: any): GPUParticleSystem;
  62897. /**
  62898. * Serializes the particle system to a JSON object.
  62899. * @returns the JSON object
  62900. */
  62901. serialize(): any;
  62902. /**
  62903. * Parses a JSON object to create a GPU particle system.
  62904. * @param parsedParticleSystem The JSON object to parse
  62905. * @param scene The scene to create the particle system in
  62906. * @param rootUrl The root url to use to load external dependencies like texture
  62907. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62908. * @returns the parsed GPU particle system
  62909. */
  62910. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62911. }
  62912. }
  62913. declare module BABYLON {
  62914. /**
  62915. * Represents a set of particle systems working together to create a specific effect
  62916. */
  62917. export class ParticleSystemSet implements IDisposable {
  62918. /**
  62919. * Gets or sets base Assets URL
  62920. */
  62921. static BaseAssetsUrl: string;
  62922. private _emitterCreationOptions;
  62923. private _emitterNode;
  62924. /**
  62925. * Gets the particle system list
  62926. */
  62927. systems: IParticleSystem[];
  62928. /**
  62929. * Gets the emitter node used with this set
  62930. */
  62931. get emitterNode(): Nullable<TransformNode>;
  62932. /**
  62933. * Creates a new emitter mesh as a sphere
  62934. * @param options defines the options used to create the sphere
  62935. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62936. * @param scene defines the hosting scene
  62937. */
  62938. setEmitterAsSphere(options: {
  62939. diameter: number;
  62940. segments: number;
  62941. color: Color3;
  62942. }, renderingGroupId: number, scene: Scene): void;
  62943. /**
  62944. * Starts all particle systems of the set
  62945. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62946. */
  62947. start(emitter?: AbstractMesh): void;
  62948. /**
  62949. * Release all associated resources
  62950. */
  62951. dispose(): void;
  62952. /**
  62953. * Serialize the set into a JSON compatible object
  62954. * @returns a JSON compatible representation of the set
  62955. */
  62956. serialize(): any;
  62957. /**
  62958. * Parse a new ParticleSystemSet from a serialized source
  62959. * @param data defines a JSON compatible representation of the set
  62960. * @param scene defines the hosting scene
  62961. * @param gpu defines if we want GPU particles or CPU particles
  62962. * @returns a new ParticleSystemSet
  62963. */
  62964. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62965. }
  62966. }
  62967. declare module BABYLON {
  62968. /**
  62969. * This class is made for on one-liner static method to help creating particle system set.
  62970. */
  62971. export class ParticleHelper {
  62972. /**
  62973. * Gets or sets base Assets URL
  62974. */
  62975. static BaseAssetsUrl: string;
  62976. /**
  62977. * Create a default particle system that you can tweak
  62978. * @param emitter defines the emitter to use
  62979. * @param capacity defines the system capacity (default is 500 particles)
  62980. * @param scene defines the hosting scene
  62981. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62982. * @returns the new Particle system
  62983. */
  62984. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62985. /**
  62986. * This is the main static method (one-liner) of this helper to create different particle systems
  62987. * @param type This string represents the type to the particle system to create
  62988. * @param scene The scene where the particle system should live
  62989. * @param gpu If the system will use gpu
  62990. * @returns the ParticleSystemSet created
  62991. */
  62992. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62993. /**
  62994. * Static function used to export a particle system to a ParticleSystemSet variable.
  62995. * Please note that the emitter shape is not exported
  62996. * @param systems defines the particle systems to export
  62997. * @returns the created particle system set
  62998. */
  62999. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63000. }
  63001. }
  63002. declare module BABYLON {
  63003. interface Engine {
  63004. /**
  63005. * Create an effect to use with particle systems.
  63006. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63007. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63008. * @param uniformsNames defines a list of attribute names
  63009. * @param samplers defines an array of string used to represent textures
  63010. * @param defines defines the string containing the defines to use to compile the shaders
  63011. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63012. * @param onCompiled defines a function to call when the effect creation is successful
  63013. * @param onError defines a function to call when the effect creation has failed
  63014. * @returns the new Effect
  63015. */
  63016. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63017. }
  63018. interface Mesh {
  63019. /**
  63020. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63021. * @returns an array of IParticleSystem
  63022. */
  63023. getEmittedParticleSystems(): IParticleSystem[];
  63024. /**
  63025. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63026. * @returns an array of IParticleSystem
  63027. */
  63028. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63029. }
  63030. /**
  63031. * @hidden
  63032. */
  63033. export var _IDoNeedToBeInTheBuild: number;
  63034. }
  63035. declare module BABYLON {
  63036. /** Defines the 4 color options */
  63037. export enum PointColor {
  63038. /** color value */
  63039. Color = 2,
  63040. /** uv value */
  63041. UV = 1,
  63042. /** random value */
  63043. Random = 0,
  63044. /** stated value */
  63045. Stated = 3
  63046. }
  63047. /**
  63048. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63049. * 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.
  63050. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63051. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63052. *
  63053. * Full documentation here : TO BE ENTERED
  63054. */
  63055. export class PointsCloudSystem implements IDisposable {
  63056. /**
  63057. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63058. * Example : var p = SPS.particles[i];
  63059. */
  63060. particles: CloudPoint[];
  63061. /**
  63062. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63063. */
  63064. nbParticles: number;
  63065. /**
  63066. * This a counter for your own usage. It's not set by any SPS functions.
  63067. */
  63068. counter: number;
  63069. /**
  63070. * The PCS name. This name is also given to the underlying mesh.
  63071. */
  63072. name: string;
  63073. /**
  63074. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63075. */
  63076. mesh: Mesh;
  63077. /**
  63078. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63079. * Please read :
  63080. */
  63081. vars: any;
  63082. /**
  63083. * @hidden
  63084. */
  63085. _size: number;
  63086. private _scene;
  63087. private _promises;
  63088. private _positions;
  63089. private _indices;
  63090. private _normals;
  63091. private _colors;
  63092. private _uvs;
  63093. private _indices32;
  63094. private _positions32;
  63095. private _colors32;
  63096. private _uvs32;
  63097. private _updatable;
  63098. private _isVisibilityBoxLocked;
  63099. private _alwaysVisible;
  63100. private _groups;
  63101. private _groupCounter;
  63102. private _computeParticleColor;
  63103. private _computeParticleTexture;
  63104. private _computeParticleRotation;
  63105. private _computeBoundingBox;
  63106. private _isReady;
  63107. /**
  63108. * Creates a PCS (Points Cloud System) object
  63109. * @param name (String) is the PCS name, this will be the underlying mesh name
  63110. * @param pointSize (number) is the size for each point
  63111. * @param scene (Scene) is the scene in which the PCS is added
  63112. * @param options defines the options of the PCS e.g.
  63113. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63114. */
  63115. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63116. updatable?: boolean;
  63117. });
  63118. /**
  63119. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63120. * If no points were added to the PCS, the returned mesh is just a single point.
  63121. * @returns a promise for the created mesh
  63122. */
  63123. buildMeshAsync(): Promise<Mesh>;
  63124. /**
  63125. * @hidden
  63126. */
  63127. private _buildMesh;
  63128. private _addParticle;
  63129. private _randomUnitVector;
  63130. private _getColorIndicesForCoord;
  63131. private _setPointsColorOrUV;
  63132. private _colorFromTexture;
  63133. private _calculateDensity;
  63134. /**
  63135. * Adds points to the PCS in random positions within a unit sphere
  63136. * @param nb (positive integer) the number of particles to be created from this model
  63137. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63138. * @returns the number of groups in the system
  63139. */
  63140. addPoints(nb: number, pointFunction?: any): number;
  63141. /**
  63142. * Adds points to the PCS from the surface of the model shape
  63143. * @param mesh is any Mesh object that will be used as a surface model for the points
  63144. * @param nb (positive integer) the number of particles to be created from this model
  63145. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63146. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63147. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63148. * @returns the number of groups in the system
  63149. */
  63150. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63151. /**
  63152. * Adds points to the PCS inside the model shape
  63153. * @param mesh is any Mesh object that will be used as a surface model for the points
  63154. * @param nb (positive integer) the number of particles to be created from this model
  63155. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63156. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63157. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63158. * @returns the number of groups in the system
  63159. */
  63160. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63161. /**
  63162. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63163. * This method calls `updateParticle()` for each particle of the SPS.
  63164. * For an animated SPS, it is usually called within the render loop.
  63165. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63166. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63167. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63168. * @returns the PCS.
  63169. */
  63170. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63171. /**
  63172. * Disposes the PCS.
  63173. */
  63174. dispose(): void;
  63175. /**
  63176. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63177. * doc :
  63178. * @returns the PCS.
  63179. */
  63180. refreshVisibleSize(): PointsCloudSystem;
  63181. /**
  63182. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63183. * @param size the size (float) of the visibility box
  63184. * note : this doesn't lock the PCS mesh bounding box.
  63185. * doc :
  63186. */
  63187. setVisibilityBox(size: number): void;
  63188. /**
  63189. * Gets whether the PCS is always visible or not
  63190. * doc :
  63191. */
  63192. get isAlwaysVisible(): boolean;
  63193. /**
  63194. * Sets the PCS as always visible or not
  63195. * doc :
  63196. */
  63197. set isAlwaysVisible(val: boolean);
  63198. /**
  63199. * Tells to `setParticles()` to compute the particle rotations or not
  63200. * Default value : false. The PCS is faster when it's set to false
  63201. * Note : particle rotations are only applied to parent particles
  63202. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63203. */
  63204. set computeParticleRotation(val: boolean);
  63205. /**
  63206. * Tells to `setParticles()` to compute the particle colors or not.
  63207. * Default value : true. The PCS is faster when it's set to false.
  63208. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63209. */
  63210. set computeParticleColor(val: boolean);
  63211. set computeParticleTexture(val: boolean);
  63212. /**
  63213. * Gets if `setParticles()` computes the particle colors or not.
  63214. * Default value : false. The PCS is faster when it's set to false.
  63215. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63216. */
  63217. get computeParticleColor(): boolean;
  63218. /**
  63219. * Gets if `setParticles()` computes the particle textures or not.
  63220. * Default value : false. The PCS is faster when it's set to false.
  63221. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63222. */
  63223. get computeParticleTexture(): boolean;
  63224. /**
  63225. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63226. */
  63227. set computeBoundingBox(val: boolean);
  63228. /**
  63229. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63230. */
  63231. get computeBoundingBox(): boolean;
  63232. /**
  63233. * This function does nothing. It may be overwritten to set all the particle first values.
  63234. * The PCS doesn't call this function, you may have to call it by your own.
  63235. * doc :
  63236. */
  63237. initParticles(): void;
  63238. /**
  63239. * This function does nothing. It may be overwritten to recycle a particle
  63240. * The PCS doesn't call this function, you can to call it
  63241. * doc :
  63242. * @param particle The particle to recycle
  63243. * @returns the recycled particle
  63244. */
  63245. recycleParticle(particle: CloudPoint): CloudPoint;
  63246. /**
  63247. * Updates a particle : this function should be overwritten by the user.
  63248. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63249. * doc :
  63250. * @example : just set a particle position or velocity and recycle conditions
  63251. * @param particle The particle to update
  63252. * @returns the updated particle
  63253. */
  63254. updateParticle(particle: CloudPoint): CloudPoint;
  63255. /**
  63256. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63257. * This does nothing and may be overwritten by the user.
  63258. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63259. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63260. * @param update the boolean update value actually passed to setParticles()
  63261. */
  63262. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63263. /**
  63264. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63265. * This will be passed three parameters.
  63266. * This does nothing and may be overwritten by the user.
  63267. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63268. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63269. * @param update the boolean update value actually passed to setParticles()
  63270. */
  63271. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63272. }
  63273. }
  63274. declare module BABYLON {
  63275. /**
  63276. * Represents one particle of a points cloud system.
  63277. */
  63278. export class CloudPoint {
  63279. /**
  63280. * particle global index
  63281. */
  63282. idx: number;
  63283. /**
  63284. * The color of the particle
  63285. */
  63286. color: Nullable<Color4>;
  63287. /**
  63288. * The world space position of the particle.
  63289. */
  63290. position: Vector3;
  63291. /**
  63292. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63293. */
  63294. rotation: Vector3;
  63295. /**
  63296. * The world space rotation quaternion of the particle.
  63297. */
  63298. rotationQuaternion: Nullable<Quaternion>;
  63299. /**
  63300. * The uv of the particle.
  63301. */
  63302. uv: Nullable<Vector2>;
  63303. /**
  63304. * The current speed of the particle.
  63305. */
  63306. velocity: Vector3;
  63307. /**
  63308. * The pivot point in the particle local space.
  63309. */
  63310. pivot: Vector3;
  63311. /**
  63312. * Must the particle be translated from its pivot point in its local space ?
  63313. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63314. * Default : false
  63315. */
  63316. translateFromPivot: boolean;
  63317. /**
  63318. * Index of this particle in the global "positions" array (Internal use)
  63319. * @hidden
  63320. */
  63321. _pos: number;
  63322. /**
  63323. * @hidden Index of this particle in the global "indices" array (Internal use)
  63324. */
  63325. _ind: number;
  63326. /**
  63327. * Group this particle belongs to
  63328. */
  63329. _group: PointsGroup;
  63330. /**
  63331. * Group id of this particle
  63332. */
  63333. groupId: number;
  63334. /**
  63335. * Index of the particle in its group id (Internal use)
  63336. */
  63337. idxInGroup: number;
  63338. /**
  63339. * @hidden Particle BoundingInfo object (Internal use)
  63340. */
  63341. _boundingInfo: BoundingInfo;
  63342. /**
  63343. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63344. */
  63345. _pcs: PointsCloudSystem;
  63346. /**
  63347. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63348. */
  63349. _stillInvisible: boolean;
  63350. /**
  63351. * @hidden Last computed particle rotation matrix
  63352. */
  63353. _rotationMatrix: number[];
  63354. /**
  63355. * Parent particle Id, if any.
  63356. * Default null.
  63357. */
  63358. parentId: Nullable<number>;
  63359. /**
  63360. * @hidden Internal global position in the PCS.
  63361. */
  63362. _globalPosition: Vector3;
  63363. /**
  63364. * Creates a Point Cloud object.
  63365. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63366. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63367. * @param group (PointsGroup) is the group the particle belongs to
  63368. * @param groupId (integer) is the group identifier in the PCS.
  63369. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63370. * @param pcs defines the PCS it is associated to
  63371. */
  63372. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63373. /**
  63374. * get point size
  63375. */
  63376. get size(): Vector3;
  63377. /**
  63378. * Set point size
  63379. */
  63380. set size(scale: Vector3);
  63381. /**
  63382. * Legacy support, changed quaternion to rotationQuaternion
  63383. */
  63384. get quaternion(): Nullable<Quaternion>;
  63385. /**
  63386. * Legacy support, changed quaternion to rotationQuaternion
  63387. */
  63388. set quaternion(q: Nullable<Quaternion>);
  63389. /**
  63390. * Returns a boolean. True if the particle intersects a mesh, else false
  63391. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63392. * @param target is the object (point or mesh) what the intersection is computed against
  63393. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63394. * @returns true if it intersects
  63395. */
  63396. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63397. /**
  63398. * get the rotation matrix of the particle
  63399. * @hidden
  63400. */
  63401. getRotationMatrix(m: Matrix): void;
  63402. }
  63403. /**
  63404. * Represents a group of points in a points cloud system
  63405. * * PCS internal tool, don't use it manually.
  63406. */
  63407. export class PointsGroup {
  63408. /**
  63409. * The group id
  63410. * @hidden
  63411. */
  63412. groupID: number;
  63413. /**
  63414. * image data for group (internal use)
  63415. * @hidden
  63416. */
  63417. _groupImageData: Nullable<ArrayBufferView>;
  63418. /**
  63419. * Image Width (internal use)
  63420. * @hidden
  63421. */
  63422. _groupImgWidth: number;
  63423. /**
  63424. * Image Height (internal use)
  63425. * @hidden
  63426. */
  63427. _groupImgHeight: number;
  63428. /**
  63429. * Custom position function (internal use)
  63430. * @hidden
  63431. */
  63432. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63433. /**
  63434. * density per facet for surface points
  63435. * @hidden
  63436. */
  63437. _groupDensity: number[];
  63438. /**
  63439. * Only when points are colored by texture carries pointer to texture list array
  63440. * @hidden
  63441. */
  63442. _textureNb: number;
  63443. /**
  63444. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63445. * PCS internal tool, don't use it manually.
  63446. * @hidden
  63447. */
  63448. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63449. }
  63450. }
  63451. declare module BABYLON {
  63452. interface Scene {
  63453. /** @hidden (Backing field) */
  63454. _physicsEngine: Nullable<IPhysicsEngine>;
  63455. /** @hidden */
  63456. _physicsTimeAccumulator: number;
  63457. /**
  63458. * Gets the current physics engine
  63459. * @returns a IPhysicsEngine or null if none attached
  63460. */
  63461. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63462. /**
  63463. * Enables physics to the current scene
  63464. * @param gravity defines the scene's gravity for the physics engine
  63465. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63466. * @return a boolean indicating if the physics engine was initialized
  63467. */
  63468. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63469. /**
  63470. * Disables and disposes the physics engine associated with the scene
  63471. */
  63472. disablePhysicsEngine(): void;
  63473. /**
  63474. * Gets a boolean indicating if there is an active physics engine
  63475. * @returns a boolean indicating if there is an active physics engine
  63476. */
  63477. isPhysicsEnabled(): boolean;
  63478. /**
  63479. * Deletes a physics compound impostor
  63480. * @param compound defines the compound to delete
  63481. */
  63482. deleteCompoundImpostor(compound: any): void;
  63483. /**
  63484. * An event triggered when physic simulation is about to be run
  63485. */
  63486. onBeforePhysicsObservable: Observable<Scene>;
  63487. /**
  63488. * An event triggered when physic simulation has been done
  63489. */
  63490. onAfterPhysicsObservable: Observable<Scene>;
  63491. }
  63492. interface AbstractMesh {
  63493. /** @hidden */
  63494. _physicsImpostor: Nullable<PhysicsImpostor>;
  63495. /**
  63496. * Gets or sets impostor used for physic simulation
  63497. * @see http://doc.babylonjs.com/features/physics_engine
  63498. */
  63499. physicsImpostor: Nullable<PhysicsImpostor>;
  63500. /**
  63501. * Gets the current physics impostor
  63502. * @see http://doc.babylonjs.com/features/physics_engine
  63503. * @returns a physics impostor or null
  63504. */
  63505. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63506. /** Apply a physic impulse to the mesh
  63507. * @param force defines the force to apply
  63508. * @param contactPoint defines where to apply the force
  63509. * @returns the current mesh
  63510. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63511. */
  63512. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63513. /**
  63514. * Creates a physic joint between two meshes
  63515. * @param otherMesh defines the other mesh to use
  63516. * @param pivot1 defines the pivot to use on this mesh
  63517. * @param pivot2 defines the pivot to use on the other mesh
  63518. * @param options defines additional options (can be plugin dependent)
  63519. * @returns the current mesh
  63520. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63521. */
  63522. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63523. /** @hidden */
  63524. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63525. }
  63526. /**
  63527. * Defines the physics engine scene component responsible to manage a physics engine
  63528. */
  63529. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63530. /**
  63531. * The component name helpful to identify the component in the list of scene components.
  63532. */
  63533. readonly name: string;
  63534. /**
  63535. * The scene the component belongs to.
  63536. */
  63537. scene: Scene;
  63538. /**
  63539. * Creates a new instance of the component for the given scene
  63540. * @param scene Defines the scene to register the component in
  63541. */
  63542. constructor(scene: Scene);
  63543. /**
  63544. * Registers the component in a given scene
  63545. */
  63546. register(): void;
  63547. /**
  63548. * Rebuilds the elements related to this component in case of
  63549. * context lost for instance.
  63550. */
  63551. rebuild(): void;
  63552. /**
  63553. * Disposes the component and the associated ressources
  63554. */
  63555. dispose(): void;
  63556. }
  63557. }
  63558. declare module BABYLON {
  63559. /**
  63560. * A helper for physics simulations
  63561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63562. */
  63563. export class PhysicsHelper {
  63564. private _scene;
  63565. private _physicsEngine;
  63566. /**
  63567. * Initializes the Physics helper
  63568. * @param scene Babylon.js scene
  63569. */
  63570. constructor(scene: Scene);
  63571. /**
  63572. * Applies a radial explosion impulse
  63573. * @param origin the origin of the explosion
  63574. * @param radiusOrEventOptions the radius or the options of radial explosion
  63575. * @param strength the explosion strength
  63576. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63577. * @returns A physics radial explosion event, or null
  63578. */
  63579. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63580. /**
  63581. * Applies a radial explosion force
  63582. * @param origin the origin of the explosion
  63583. * @param radiusOrEventOptions the radius or the options of radial explosion
  63584. * @param strength the explosion strength
  63585. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63586. * @returns A physics radial explosion event, or null
  63587. */
  63588. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63589. /**
  63590. * Creates a gravitational field
  63591. * @param origin the origin of the explosion
  63592. * @param radiusOrEventOptions the radius or the options of radial explosion
  63593. * @param strength the explosion strength
  63594. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63595. * @returns A physics gravitational field event, or null
  63596. */
  63597. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63598. /**
  63599. * Creates a physics updraft event
  63600. * @param origin the origin of the updraft
  63601. * @param radiusOrEventOptions the radius or the options of the updraft
  63602. * @param strength the strength of the updraft
  63603. * @param height the height of the updraft
  63604. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63605. * @returns A physics updraft event, or null
  63606. */
  63607. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63608. /**
  63609. * Creates a physics vortex event
  63610. * @param origin the of the vortex
  63611. * @param radiusOrEventOptions the radius or the options of the vortex
  63612. * @param strength the strength of the vortex
  63613. * @param height the height of the vortex
  63614. * @returns a Physics vortex event, or null
  63615. * A physics vortex event or null
  63616. */
  63617. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63618. }
  63619. /**
  63620. * Represents a physics radial explosion event
  63621. */
  63622. class PhysicsRadialExplosionEvent {
  63623. private _scene;
  63624. private _options;
  63625. private _sphere;
  63626. private _dataFetched;
  63627. /**
  63628. * Initializes a radial explosioin event
  63629. * @param _scene BabylonJS scene
  63630. * @param _options The options for the vortex event
  63631. */
  63632. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63633. /**
  63634. * Returns the data related to the radial explosion event (sphere).
  63635. * @returns The radial explosion event data
  63636. */
  63637. getData(): PhysicsRadialExplosionEventData;
  63638. /**
  63639. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63640. * @param impostor A physics imposter
  63641. * @param origin the origin of the explosion
  63642. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63643. */
  63644. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63645. /**
  63646. * Triggers affecterd impostors callbacks
  63647. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63648. */
  63649. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63650. /**
  63651. * Disposes the sphere.
  63652. * @param force Specifies if the sphere should be disposed by force
  63653. */
  63654. dispose(force?: boolean): void;
  63655. /*** Helpers ***/
  63656. private _prepareSphere;
  63657. private _intersectsWithSphere;
  63658. }
  63659. /**
  63660. * Represents a gravitational field event
  63661. */
  63662. class PhysicsGravitationalFieldEvent {
  63663. private _physicsHelper;
  63664. private _scene;
  63665. private _origin;
  63666. private _options;
  63667. private _tickCallback;
  63668. private _sphere;
  63669. private _dataFetched;
  63670. /**
  63671. * Initializes the physics gravitational field event
  63672. * @param _physicsHelper A physics helper
  63673. * @param _scene BabylonJS scene
  63674. * @param _origin The origin position of the gravitational field event
  63675. * @param _options The options for the vortex event
  63676. */
  63677. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63678. /**
  63679. * Returns the data related to the gravitational field event (sphere).
  63680. * @returns A gravitational field event
  63681. */
  63682. getData(): PhysicsGravitationalFieldEventData;
  63683. /**
  63684. * Enables the gravitational field.
  63685. */
  63686. enable(): void;
  63687. /**
  63688. * Disables the gravitational field.
  63689. */
  63690. disable(): void;
  63691. /**
  63692. * Disposes the sphere.
  63693. * @param force The force to dispose from the gravitational field event
  63694. */
  63695. dispose(force?: boolean): void;
  63696. private _tick;
  63697. }
  63698. /**
  63699. * Represents a physics updraft event
  63700. */
  63701. class PhysicsUpdraftEvent {
  63702. private _scene;
  63703. private _origin;
  63704. private _options;
  63705. private _physicsEngine;
  63706. private _originTop;
  63707. private _originDirection;
  63708. private _tickCallback;
  63709. private _cylinder;
  63710. private _cylinderPosition;
  63711. private _dataFetched;
  63712. /**
  63713. * Initializes the physics updraft event
  63714. * @param _scene BabylonJS scene
  63715. * @param _origin The origin position of the updraft
  63716. * @param _options The options for the updraft event
  63717. */
  63718. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63719. /**
  63720. * Returns the data related to the updraft event (cylinder).
  63721. * @returns A physics updraft event
  63722. */
  63723. getData(): PhysicsUpdraftEventData;
  63724. /**
  63725. * Enables the updraft.
  63726. */
  63727. enable(): void;
  63728. /**
  63729. * Disables the updraft.
  63730. */
  63731. disable(): void;
  63732. /**
  63733. * Disposes the cylinder.
  63734. * @param force Specifies if the updraft should be disposed by force
  63735. */
  63736. dispose(force?: boolean): void;
  63737. private getImpostorHitData;
  63738. private _tick;
  63739. /*** Helpers ***/
  63740. private _prepareCylinder;
  63741. private _intersectsWithCylinder;
  63742. }
  63743. /**
  63744. * Represents a physics vortex event
  63745. */
  63746. class PhysicsVortexEvent {
  63747. private _scene;
  63748. private _origin;
  63749. private _options;
  63750. private _physicsEngine;
  63751. private _originTop;
  63752. private _tickCallback;
  63753. private _cylinder;
  63754. private _cylinderPosition;
  63755. private _dataFetched;
  63756. /**
  63757. * Initializes the physics vortex event
  63758. * @param _scene The BabylonJS scene
  63759. * @param _origin The origin position of the vortex
  63760. * @param _options The options for the vortex event
  63761. */
  63762. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63763. /**
  63764. * Returns the data related to the vortex event (cylinder).
  63765. * @returns The physics vortex event data
  63766. */
  63767. getData(): PhysicsVortexEventData;
  63768. /**
  63769. * Enables the vortex.
  63770. */
  63771. enable(): void;
  63772. /**
  63773. * Disables the cortex.
  63774. */
  63775. disable(): void;
  63776. /**
  63777. * Disposes the sphere.
  63778. * @param force
  63779. */
  63780. dispose(force?: boolean): void;
  63781. private getImpostorHitData;
  63782. private _tick;
  63783. /*** Helpers ***/
  63784. private _prepareCylinder;
  63785. private _intersectsWithCylinder;
  63786. }
  63787. /**
  63788. * Options fot the radial explosion event
  63789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63790. */
  63791. export class PhysicsRadialExplosionEventOptions {
  63792. /**
  63793. * The radius of the sphere for the radial explosion.
  63794. */
  63795. radius: number;
  63796. /**
  63797. * The strenth of the explosion.
  63798. */
  63799. strength: number;
  63800. /**
  63801. * The strenght of the force in correspondence to the distance of the affected object
  63802. */
  63803. falloff: PhysicsRadialImpulseFalloff;
  63804. /**
  63805. * Sphere options for the radial explosion.
  63806. */
  63807. sphere: {
  63808. segments: number;
  63809. diameter: number;
  63810. };
  63811. /**
  63812. * Sphere options for the radial explosion.
  63813. */
  63814. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63815. }
  63816. /**
  63817. * Options fot the updraft event
  63818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63819. */
  63820. export class PhysicsUpdraftEventOptions {
  63821. /**
  63822. * The radius of the cylinder for the vortex
  63823. */
  63824. radius: number;
  63825. /**
  63826. * The strenth of the updraft.
  63827. */
  63828. strength: number;
  63829. /**
  63830. * The height of the cylinder for the updraft.
  63831. */
  63832. height: number;
  63833. /**
  63834. * The mode for the the updraft.
  63835. */
  63836. updraftMode: PhysicsUpdraftMode;
  63837. }
  63838. /**
  63839. * Options fot the vortex event
  63840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63841. */
  63842. export class PhysicsVortexEventOptions {
  63843. /**
  63844. * The radius of the cylinder for the vortex
  63845. */
  63846. radius: number;
  63847. /**
  63848. * The strenth of the vortex.
  63849. */
  63850. strength: number;
  63851. /**
  63852. * The height of the cylinder for the vortex.
  63853. */
  63854. height: number;
  63855. /**
  63856. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63857. */
  63858. centripetalForceThreshold: number;
  63859. /**
  63860. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63861. */
  63862. centripetalForceMultiplier: number;
  63863. /**
  63864. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63865. */
  63866. centrifugalForceMultiplier: number;
  63867. /**
  63868. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63869. */
  63870. updraftForceMultiplier: number;
  63871. }
  63872. /**
  63873. * The strenght of the force in correspondence to the distance of the affected object
  63874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63875. */
  63876. export enum PhysicsRadialImpulseFalloff {
  63877. /** Defines that impulse is constant in strength across it's whole radius */
  63878. Constant = 0,
  63879. /** Defines that impulse gets weaker if it's further from the origin */
  63880. Linear = 1
  63881. }
  63882. /**
  63883. * The strength of the force in correspondence to the distance of the affected object
  63884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63885. */
  63886. export enum PhysicsUpdraftMode {
  63887. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63888. Center = 0,
  63889. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63890. Perpendicular = 1
  63891. }
  63892. /**
  63893. * Interface for a physics hit data
  63894. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63895. */
  63896. export interface PhysicsHitData {
  63897. /**
  63898. * The force applied at the contact point
  63899. */
  63900. force: Vector3;
  63901. /**
  63902. * The contact point
  63903. */
  63904. contactPoint: Vector3;
  63905. /**
  63906. * The distance from the origin to the contact point
  63907. */
  63908. distanceFromOrigin: number;
  63909. }
  63910. /**
  63911. * Interface for radial explosion event data
  63912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63913. */
  63914. export interface PhysicsRadialExplosionEventData {
  63915. /**
  63916. * A sphere used for the radial explosion event
  63917. */
  63918. sphere: Mesh;
  63919. }
  63920. /**
  63921. * Interface for gravitational field event data
  63922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63923. */
  63924. export interface PhysicsGravitationalFieldEventData {
  63925. /**
  63926. * A sphere mesh used for the gravitational field event
  63927. */
  63928. sphere: Mesh;
  63929. }
  63930. /**
  63931. * Interface for updraft event data
  63932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63933. */
  63934. export interface PhysicsUpdraftEventData {
  63935. /**
  63936. * A cylinder used for the updraft event
  63937. */
  63938. cylinder: Mesh;
  63939. }
  63940. /**
  63941. * Interface for vortex event data
  63942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63943. */
  63944. export interface PhysicsVortexEventData {
  63945. /**
  63946. * A cylinder used for the vortex event
  63947. */
  63948. cylinder: Mesh;
  63949. }
  63950. /**
  63951. * Interface for an affected physics impostor
  63952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63953. */
  63954. export interface PhysicsAffectedImpostorWithData {
  63955. /**
  63956. * The impostor affected by the effect
  63957. */
  63958. impostor: PhysicsImpostor;
  63959. /**
  63960. * The data about the hit/horce from the explosion
  63961. */
  63962. hitData: PhysicsHitData;
  63963. }
  63964. }
  63965. declare module BABYLON {
  63966. /** @hidden */
  63967. export var blackAndWhitePixelShader: {
  63968. name: string;
  63969. shader: string;
  63970. };
  63971. }
  63972. declare module BABYLON {
  63973. /**
  63974. * Post process used to render in black and white
  63975. */
  63976. export class BlackAndWhitePostProcess extends PostProcess {
  63977. /**
  63978. * Linear about to convert he result to black and white (default: 1)
  63979. */
  63980. degree: number;
  63981. /**
  63982. * Creates a black and white post process
  63983. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63984. * @param name The name of the effect.
  63985. * @param options The required width/height ratio to downsize to before computing the render pass.
  63986. * @param camera The camera to apply the render pass to.
  63987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63988. * @param engine The engine which the post process will be applied. (default: current engine)
  63989. * @param reusable If the post process can be reused on the same frame. (default: false)
  63990. */
  63991. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63992. }
  63993. }
  63994. declare module BABYLON {
  63995. /**
  63996. * This represents a set of one or more post processes in Babylon.
  63997. * A post process can be used to apply a shader to a texture after it is rendered.
  63998. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63999. */
  64000. export class PostProcessRenderEffect {
  64001. private _postProcesses;
  64002. private _getPostProcesses;
  64003. private _singleInstance;
  64004. private _cameras;
  64005. private _indicesForCamera;
  64006. /**
  64007. * Name of the effect
  64008. * @hidden
  64009. */
  64010. _name: string;
  64011. /**
  64012. * Instantiates a post process render effect.
  64013. * A post process can be used to apply a shader to a texture after it is rendered.
  64014. * @param engine The engine the effect is tied to
  64015. * @param name The name of the effect
  64016. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64017. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64018. */
  64019. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64020. /**
  64021. * Checks if all the post processes in the effect are supported.
  64022. */
  64023. get isSupported(): boolean;
  64024. /**
  64025. * Updates the current state of the effect
  64026. * @hidden
  64027. */
  64028. _update(): void;
  64029. /**
  64030. * Attaches the effect on cameras
  64031. * @param cameras The camera to attach to.
  64032. * @hidden
  64033. */
  64034. _attachCameras(cameras: Camera): void;
  64035. /**
  64036. * Attaches the effect on cameras
  64037. * @param cameras The camera to attach to.
  64038. * @hidden
  64039. */
  64040. _attachCameras(cameras: Camera[]): void;
  64041. /**
  64042. * Detaches the effect on cameras
  64043. * @param cameras The camera to detatch from.
  64044. * @hidden
  64045. */
  64046. _detachCameras(cameras: Camera): void;
  64047. /**
  64048. * Detatches the effect on cameras
  64049. * @param cameras The camera to detatch from.
  64050. * @hidden
  64051. */
  64052. _detachCameras(cameras: Camera[]): void;
  64053. /**
  64054. * Enables the effect on given cameras
  64055. * @param cameras The camera to enable.
  64056. * @hidden
  64057. */
  64058. _enable(cameras: Camera): void;
  64059. /**
  64060. * Enables the effect on given cameras
  64061. * @param cameras The camera to enable.
  64062. * @hidden
  64063. */
  64064. _enable(cameras: Nullable<Camera[]>): void;
  64065. /**
  64066. * Disables the effect on the given cameras
  64067. * @param cameras The camera to disable.
  64068. * @hidden
  64069. */
  64070. _disable(cameras: Camera): void;
  64071. /**
  64072. * Disables the effect on the given cameras
  64073. * @param cameras The camera to disable.
  64074. * @hidden
  64075. */
  64076. _disable(cameras: Nullable<Camera[]>): void;
  64077. /**
  64078. * Gets a list of the post processes contained in the effect.
  64079. * @param camera The camera to get the post processes on.
  64080. * @returns The list of the post processes in the effect.
  64081. */
  64082. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64083. }
  64084. }
  64085. declare module BABYLON {
  64086. /** @hidden */
  64087. export var extractHighlightsPixelShader: {
  64088. name: string;
  64089. shader: string;
  64090. };
  64091. }
  64092. declare module BABYLON {
  64093. /**
  64094. * 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.
  64095. */
  64096. export class ExtractHighlightsPostProcess extends PostProcess {
  64097. /**
  64098. * The luminance threshold, pixels below this value will be set to black.
  64099. */
  64100. threshold: number;
  64101. /** @hidden */
  64102. _exposure: number;
  64103. /**
  64104. * Post process which has the input texture to be used when performing highlight extraction
  64105. * @hidden
  64106. */
  64107. _inputPostProcess: Nullable<PostProcess>;
  64108. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64109. }
  64110. }
  64111. declare module BABYLON {
  64112. /** @hidden */
  64113. export var bloomMergePixelShader: {
  64114. name: string;
  64115. shader: string;
  64116. };
  64117. }
  64118. declare module BABYLON {
  64119. /**
  64120. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64121. */
  64122. export class BloomMergePostProcess extends PostProcess {
  64123. /** Weight of the bloom to be added to the original input. */
  64124. weight: number;
  64125. /**
  64126. * Creates a new instance of @see BloomMergePostProcess
  64127. * @param name The name of the effect.
  64128. * @param originalFromInput Post process which's input will be used for the merge.
  64129. * @param blurred Blurred highlights post process which's output will be used.
  64130. * @param weight Weight of the bloom to be added to the original input.
  64131. * @param options The required width/height ratio to downsize to before computing the render pass.
  64132. * @param camera The camera to apply the render pass to.
  64133. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64134. * @param engine The engine which the post process will be applied. (default: current engine)
  64135. * @param reusable If the post process can be reused on the same frame. (default: false)
  64136. * @param textureType Type of textures used when performing the post process. (default: 0)
  64137. * @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)
  64138. */
  64139. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64140. /** Weight of the bloom to be added to the original input. */
  64141. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64142. }
  64143. }
  64144. declare module BABYLON {
  64145. /**
  64146. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64147. */
  64148. export class BloomEffect extends PostProcessRenderEffect {
  64149. private bloomScale;
  64150. /**
  64151. * @hidden Internal
  64152. */
  64153. _effects: Array<PostProcess>;
  64154. /**
  64155. * @hidden Internal
  64156. */
  64157. _downscale: ExtractHighlightsPostProcess;
  64158. private _blurX;
  64159. private _blurY;
  64160. private _merge;
  64161. /**
  64162. * The luminance threshold to find bright areas of the image to bloom.
  64163. */
  64164. get threshold(): number;
  64165. set threshold(value: number);
  64166. /**
  64167. * The strength of the bloom.
  64168. */
  64169. get weight(): number;
  64170. set weight(value: number);
  64171. /**
  64172. * Specifies the size of the bloom blur kernel, relative to the final output size
  64173. */
  64174. get kernel(): number;
  64175. set kernel(value: number);
  64176. /**
  64177. * Creates a new instance of @see BloomEffect
  64178. * @param scene The scene the effect belongs to.
  64179. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64180. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64181. * @param bloomWeight The the strength of bloom.
  64182. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64183. * @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)
  64184. */
  64185. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64186. /**
  64187. * Disposes each of the internal effects for a given camera.
  64188. * @param camera The camera to dispose the effect on.
  64189. */
  64190. disposeEffects(camera: Camera): void;
  64191. /**
  64192. * @hidden Internal
  64193. */
  64194. _updateEffects(): void;
  64195. /**
  64196. * Internal
  64197. * @returns if all the contained post processes are ready.
  64198. * @hidden
  64199. */
  64200. _isReady(): boolean;
  64201. }
  64202. }
  64203. declare module BABYLON {
  64204. /** @hidden */
  64205. export var chromaticAberrationPixelShader: {
  64206. name: string;
  64207. shader: string;
  64208. };
  64209. }
  64210. declare module BABYLON {
  64211. /**
  64212. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64213. */
  64214. export class ChromaticAberrationPostProcess extends PostProcess {
  64215. /**
  64216. * The amount of seperation of rgb channels (default: 30)
  64217. */
  64218. aberrationAmount: number;
  64219. /**
  64220. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64221. */
  64222. radialIntensity: number;
  64223. /**
  64224. * 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))
  64225. */
  64226. direction: Vector2;
  64227. /**
  64228. * 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))
  64229. */
  64230. centerPosition: Vector2;
  64231. /**
  64232. * Creates a new instance ChromaticAberrationPostProcess
  64233. * @param name The name of the effect.
  64234. * @param screenWidth The width of the screen to apply the effect on.
  64235. * @param screenHeight The height of the screen to apply the effect on.
  64236. * @param options The required width/height ratio to downsize to before computing the render pass.
  64237. * @param camera The camera to apply the render pass to.
  64238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64239. * @param engine The engine which the post process will be applied. (default: current engine)
  64240. * @param reusable If the post process can be reused on the same frame. (default: false)
  64241. * @param textureType Type of textures used when performing the post process. (default: 0)
  64242. * @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)
  64243. */
  64244. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64245. }
  64246. }
  64247. declare module BABYLON {
  64248. /** @hidden */
  64249. export var circleOfConfusionPixelShader: {
  64250. name: string;
  64251. shader: string;
  64252. };
  64253. }
  64254. declare module BABYLON {
  64255. /**
  64256. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64257. */
  64258. export class CircleOfConfusionPostProcess extends PostProcess {
  64259. /**
  64260. * 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.
  64261. */
  64262. lensSize: number;
  64263. /**
  64264. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64265. */
  64266. fStop: number;
  64267. /**
  64268. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64269. */
  64270. focusDistance: number;
  64271. /**
  64272. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64273. */
  64274. focalLength: number;
  64275. private _depthTexture;
  64276. /**
  64277. * Creates a new instance CircleOfConfusionPostProcess
  64278. * @param name The name of the effect.
  64279. * @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.
  64280. * @param options The required width/height ratio to downsize to before computing the render pass.
  64281. * @param camera The camera to apply the render pass to.
  64282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64283. * @param engine The engine which the post process will be applied. (default: current engine)
  64284. * @param reusable If the post process can be reused on the same frame. (default: false)
  64285. * @param textureType Type of textures used when performing the post process. (default: 0)
  64286. * @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)
  64287. */
  64288. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64289. /**
  64290. * 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.
  64291. */
  64292. set depthTexture(value: RenderTargetTexture);
  64293. }
  64294. }
  64295. declare module BABYLON {
  64296. /** @hidden */
  64297. export var colorCorrectionPixelShader: {
  64298. name: string;
  64299. shader: string;
  64300. };
  64301. }
  64302. declare module BABYLON {
  64303. /**
  64304. *
  64305. * This post-process allows the modification of rendered colors by using
  64306. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64307. *
  64308. * The object needs to be provided an url to a texture containing the color
  64309. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64310. * Use an image editing software to tweak the LUT to match your needs.
  64311. *
  64312. * For an example of a color LUT, see here:
  64313. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64314. * For explanations on color grading, see here:
  64315. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64316. *
  64317. */
  64318. export class ColorCorrectionPostProcess extends PostProcess {
  64319. private _colorTableTexture;
  64320. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64321. }
  64322. }
  64323. declare module BABYLON {
  64324. /** @hidden */
  64325. export var convolutionPixelShader: {
  64326. name: string;
  64327. shader: string;
  64328. };
  64329. }
  64330. declare module BABYLON {
  64331. /**
  64332. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64333. * input texture to perform effects such as edge detection or sharpening
  64334. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64335. */
  64336. export class ConvolutionPostProcess extends PostProcess {
  64337. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64338. kernel: number[];
  64339. /**
  64340. * Creates a new instance ConvolutionPostProcess
  64341. * @param name The name of the effect.
  64342. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64343. * @param options The required width/height ratio to downsize to before computing the render pass.
  64344. * @param camera The camera to apply the render pass to.
  64345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64346. * @param engine The engine which the post process will be applied. (default: current engine)
  64347. * @param reusable If the post process can be reused on the same frame. (default: false)
  64348. * @param textureType Type of textures used when performing the post process. (default: 0)
  64349. */
  64350. constructor(name: string,
  64351. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64352. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64353. /**
  64354. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64355. */
  64356. static EdgeDetect0Kernel: number[];
  64357. /**
  64358. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64359. */
  64360. static EdgeDetect1Kernel: number[];
  64361. /**
  64362. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64363. */
  64364. static EdgeDetect2Kernel: number[];
  64365. /**
  64366. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64367. */
  64368. static SharpenKernel: number[];
  64369. /**
  64370. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64371. */
  64372. static EmbossKernel: number[];
  64373. /**
  64374. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64375. */
  64376. static GaussianKernel: number[];
  64377. }
  64378. }
  64379. declare module BABYLON {
  64380. /**
  64381. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64382. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64383. * based on samples that have a large difference in distance than the center pixel.
  64384. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64385. */
  64386. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64387. direction: Vector2;
  64388. /**
  64389. * Creates a new instance CircleOfConfusionPostProcess
  64390. * @param name The name of the effect.
  64391. * @param scene The scene the effect belongs to.
  64392. * @param direction The direction the blur should be applied.
  64393. * @param kernel The size of the kernel used to blur.
  64394. * @param options The required width/height ratio to downsize to before computing the render pass.
  64395. * @param camera The camera to apply the render pass to.
  64396. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64397. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64398. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64399. * @param engine The engine which the post process will be applied. (default: current engine)
  64400. * @param reusable If the post process can be reused on the same frame. (default: false)
  64401. * @param textureType Type of textures used when performing the post process. (default: 0)
  64402. * @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)
  64403. */
  64404. 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);
  64405. }
  64406. }
  64407. declare module BABYLON {
  64408. /** @hidden */
  64409. export var depthOfFieldMergePixelShader: {
  64410. name: string;
  64411. shader: string;
  64412. };
  64413. }
  64414. declare module BABYLON {
  64415. /**
  64416. * Options to be set when merging outputs from the default pipeline.
  64417. */
  64418. export class DepthOfFieldMergePostProcessOptions {
  64419. /**
  64420. * The original image to merge on top of
  64421. */
  64422. originalFromInput: PostProcess;
  64423. /**
  64424. * Parameters to perform the merge of the depth of field effect
  64425. */
  64426. depthOfField?: {
  64427. circleOfConfusion: PostProcess;
  64428. blurSteps: Array<PostProcess>;
  64429. };
  64430. /**
  64431. * Parameters to perform the merge of bloom effect
  64432. */
  64433. bloom?: {
  64434. blurred: PostProcess;
  64435. weight: number;
  64436. };
  64437. }
  64438. /**
  64439. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64440. */
  64441. export class DepthOfFieldMergePostProcess extends PostProcess {
  64442. private blurSteps;
  64443. /**
  64444. * Creates a new instance of DepthOfFieldMergePostProcess
  64445. * @param name The name of the effect.
  64446. * @param originalFromInput Post process which's input will be used for the merge.
  64447. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64448. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64449. * @param options The required width/height ratio to downsize to before computing the render pass.
  64450. * @param camera The camera to apply the render pass to.
  64451. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64452. * @param engine The engine which the post process will be applied. (default: current engine)
  64453. * @param reusable If the post process can be reused on the same frame. (default: false)
  64454. * @param textureType Type of textures used when performing the post process. (default: 0)
  64455. * @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)
  64456. */
  64457. 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);
  64458. /**
  64459. * Updates the effect with the current post process compile time values and recompiles the shader.
  64460. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64461. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64462. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64463. * @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
  64464. * @param onCompiled Called when the shader has been compiled.
  64465. * @param onError Called if there is an error when compiling a shader.
  64466. */
  64467. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64468. }
  64469. }
  64470. declare module BABYLON {
  64471. /**
  64472. * Specifies the level of max blur that should be applied when using the depth of field effect
  64473. */
  64474. export enum DepthOfFieldEffectBlurLevel {
  64475. /**
  64476. * Subtle blur
  64477. */
  64478. Low = 0,
  64479. /**
  64480. * Medium blur
  64481. */
  64482. Medium = 1,
  64483. /**
  64484. * Large blur
  64485. */
  64486. High = 2
  64487. }
  64488. /**
  64489. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64490. */
  64491. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64492. private _circleOfConfusion;
  64493. /**
  64494. * @hidden Internal, blurs from high to low
  64495. */
  64496. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64497. private _depthOfFieldBlurY;
  64498. private _dofMerge;
  64499. /**
  64500. * @hidden Internal post processes in depth of field effect
  64501. */
  64502. _effects: Array<PostProcess>;
  64503. /**
  64504. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64505. */
  64506. set focalLength(value: number);
  64507. get focalLength(): number;
  64508. /**
  64509. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64510. */
  64511. set fStop(value: number);
  64512. get fStop(): number;
  64513. /**
  64514. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64515. */
  64516. set focusDistance(value: number);
  64517. get focusDistance(): number;
  64518. /**
  64519. * 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.
  64520. */
  64521. set lensSize(value: number);
  64522. get lensSize(): number;
  64523. /**
  64524. * Creates a new instance DepthOfFieldEffect
  64525. * @param scene The scene the effect belongs to.
  64526. * @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.
  64527. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64528. * @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)
  64529. */
  64530. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64531. /**
  64532. * Get the current class name of the current effet
  64533. * @returns "DepthOfFieldEffect"
  64534. */
  64535. getClassName(): string;
  64536. /**
  64537. * 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.
  64538. */
  64539. set depthTexture(value: RenderTargetTexture);
  64540. /**
  64541. * Disposes each of the internal effects for a given camera.
  64542. * @param camera The camera to dispose the effect on.
  64543. */
  64544. disposeEffects(camera: Camera): void;
  64545. /**
  64546. * @hidden Internal
  64547. */
  64548. _updateEffects(): void;
  64549. /**
  64550. * Internal
  64551. * @returns if all the contained post processes are ready.
  64552. * @hidden
  64553. */
  64554. _isReady(): boolean;
  64555. }
  64556. }
  64557. declare module BABYLON {
  64558. /** @hidden */
  64559. export var displayPassPixelShader: {
  64560. name: string;
  64561. shader: string;
  64562. };
  64563. }
  64564. declare module BABYLON {
  64565. /**
  64566. * DisplayPassPostProcess which produces an output the same as it's input
  64567. */
  64568. export class DisplayPassPostProcess extends PostProcess {
  64569. /**
  64570. * Creates the DisplayPassPostProcess
  64571. * @param name The name of the effect.
  64572. * @param options The required width/height ratio to downsize to before computing the render pass.
  64573. * @param camera The camera to apply the render pass to.
  64574. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64575. * @param engine The engine which the post process will be applied. (default: current engine)
  64576. * @param reusable If the post process can be reused on the same frame. (default: false)
  64577. */
  64578. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64579. }
  64580. }
  64581. declare module BABYLON {
  64582. /** @hidden */
  64583. export var filterPixelShader: {
  64584. name: string;
  64585. shader: string;
  64586. };
  64587. }
  64588. declare module BABYLON {
  64589. /**
  64590. * Applies a kernel filter to the image
  64591. */
  64592. export class FilterPostProcess extends PostProcess {
  64593. /** The matrix to be applied to the image */
  64594. kernelMatrix: Matrix;
  64595. /**
  64596. *
  64597. * @param name The name of the effect.
  64598. * @param kernelMatrix The matrix to be applied to the image
  64599. * @param options The required width/height ratio to downsize to before computing the render pass.
  64600. * @param camera The camera to apply the render pass to.
  64601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64602. * @param engine The engine which the post process will be applied. (default: current engine)
  64603. * @param reusable If the post process can be reused on the same frame. (default: false)
  64604. */
  64605. constructor(name: string,
  64606. /** The matrix to be applied to the image */
  64607. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64608. }
  64609. }
  64610. declare module BABYLON {
  64611. /** @hidden */
  64612. export var fxaaPixelShader: {
  64613. name: string;
  64614. shader: string;
  64615. };
  64616. }
  64617. declare module BABYLON {
  64618. /** @hidden */
  64619. export var fxaaVertexShader: {
  64620. name: string;
  64621. shader: string;
  64622. };
  64623. }
  64624. declare module BABYLON {
  64625. /**
  64626. * Fxaa post process
  64627. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64628. */
  64629. export class FxaaPostProcess extends PostProcess {
  64630. /** @hidden */
  64631. texelWidth: number;
  64632. /** @hidden */
  64633. texelHeight: number;
  64634. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64635. private _getDefines;
  64636. }
  64637. }
  64638. declare module BABYLON {
  64639. /** @hidden */
  64640. export var grainPixelShader: {
  64641. name: string;
  64642. shader: string;
  64643. };
  64644. }
  64645. declare module BABYLON {
  64646. /**
  64647. * The GrainPostProcess adds noise to the image at mid luminance levels
  64648. */
  64649. export class GrainPostProcess extends PostProcess {
  64650. /**
  64651. * The intensity of the grain added (default: 30)
  64652. */
  64653. intensity: number;
  64654. /**
  64655. * If the grain should be randomized on every frame
  64656. */
  64657. animated: boolean;
  64658. /**
  64659. * Creates a new instance of @see GrainPostProcess
  64660. * @param name The name of the effect.
  64661. * @param options The required width/height ratio to downsize to before computing the render pass.
  64662. * @param camera The camera to apply the render pass to.
  64663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64664. * @param engine The engine which the post process will be applied. (default: current engine)
  64665. * @param reusable If the post process can be reused on the same frame. (default: false)
  64666. * @param textureType Type of textures used when performing the post process. (default: 0)
  64667. * @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)
  64668. */
  64669. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64670. }
  64671. }
  64672. declare module BABYLON {
  64673. /** @hidden */
  64674. export var highlightsPixelShader: {
  64675. name: string;
  64676. shader: string;
  64677. };
  64678. }
  64679. declare module BABYLON {
  64680. /**
  64681. * Extracts highlights from the image
  64682. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64683. */
  64684. export class HighlightsPostProcess extends PostProcess {
  64685. /**
  64686. * Extracts highlights from the image
  64687. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64688. * @param name The name of the effect.
  64689. * @param options The required width/height ratio to downsize to before computing the render pass.
  64690. * @param camera The camera to apply the render pass to.
  64691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64692. * @param engine The engine which the post process will be applied. (default: current engine)
  64693. * @param reusable If the post process can be reused on the same frame. (default: false)
  64694. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64695. */
  64696. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64697. }
  64698. }
  64699. declare module BABYLON {
  64700. /** @hidden */
  64701. export var mrtFragmentDeclaration: {
  64702. name: string;
  64703. shader: string;
  64704. };
  64705. }
  64706. declare module BABYLON {
  64707. /** @hidden */
  64708. export var geometryPixelShader: {
  64709. name: string;
  64710. shader: string;
  64711. };
  64712. }
  64713. declare module BABYLON {
  64714. /** @hidden */
  64715. export var geometryVertexShader: {
  64716. name: string;
  64717. shader: string;
  64718. };
  64719. }
  64720. declare module BABYLON {
  64721. /** @hidden */
  64722. interface ISavedTransformationMatrix {
  64723. world: Matrix;
  64724. viewProjection: Matrix;
  64725. }
  64726. /**
  64727. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64728. */
  64729. export class GeometryBufferRenderer {
  64730. /**
  64731. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64732. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64733. */
  64734. static readonly POSITION_TEXTURE_TYPE: number;
  64735. /**
  64736. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64737. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64738. */
  64739. static readonly VELOCITY_TEXTURE_TYPE: number;
  64740. /**
  64741. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64742. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64743. */
  64744. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64745. /**
  64746. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64747. * in order to compute objects velocities when enableVelocity is set to "true"
  64748. * @hidden
  64749. */
  64750. _previousTransformationMatrices: {
  64751. [index: number]: ISavedTransformationMatrix;
  64752. };
  64753. /**
  64754. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64755. * in order to compute objects velocities when enableVelocity is set to "true"
  64756. * @hidden
  64757. */
  64758. _previousBonesTransformationMatrices: {
  64759. [index: number]: Float32Array;
  64760. };
  64761. /**
  64762. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64763. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64764. */
  64765. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64766. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64767. renderTransparentMeshes: boolean;
  64768. private _scene;
  64769. private _multiRenderTarget;
  64770. private _ratio;
  64771. private _enablePosition;
  64772. private _enableVelocity;
  64773. private _enableReflectivity;
  64774. private _positionIndex;
  64775. private _velocityIndex;
  64776. private _reflectivityIndex;
  64777. protected _effect: Effect;
  64778. protected _cachedDefines: string;
  64779. /**
  64780. * Set the render list (meshes to be rendered) used in the G buffer.
  64781. */
  64782. set renderList(meshes: Mesh[]);
  64783. /**
  64784. * Gets wether or not G buffer are supported by the running hardware.
  64785. * This requires draw buffer supports
  64786. */
  64787. get isSupported(): boolean;
  64788. /**
  64789. * Returns the index of the given texture type in the G-Buffer textures array
  64790. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64791. * @returns the index of the given texture type in the G-Buffer textures array
  64792. */
  64793. getTextureIndex(textureType: number): number;
  64794. /**
  64795. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64796. */
  64797. get enablePosition(): boolean;
  64798. /**
  64799. * Sets whether or not objects positions are enabled for the G buffer.
  64800. */
  64801. set enablePosition(enable: boolean);
  64802. /**
  64803. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64804. */
  64805. get enableVelocity(): boolean;
  64806. /**
  64807. * Sets wether or not objects velocities are enabled for the G buffer.
  64808. */
  64809. set enableVelocity(enable: boolean);
  64810. /**
  64811. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64812. */
  64813. get enableReflectivity(): boolean;
  64814. /**
  64815. * Sets wether or not objects roughness are enabled for the G buffer.
  64816. */
  64817. set enableReflectivity(enable: boolean);
  64818. /**
  64819. * Gets the scene associated with the buffer.
  64820. */
  64821. get scene(): Scene;
  64822. /**
  64823. * Gets the ratio used by the buffer during its creation.
  64824. * How big is the buffer related to the main canvas.
  64825. */
  64826. get ratio(): number;
  64827. /** @hidden */
  64828. static _SceneComponentInitialization: (scene: Scene) => void;
  64829. /**
  64830. * Creates a new G Buffer for the scene
  64831. * @param scene The scene the buffer belongs to
  64832. * @param ratio How big is the buffer related to the main canvas.
  64833. */
  64834. constructor(scene: Scene, ratio?: number);
  64835. /**
  64836. * Checks wether everything is ready to render a submesh to the G buffer.
  64837. * @param subMesh the submesh to check readiness for
  64838. * @param useInstances is the mesh drawn using instance or not
  64839. * @returns true if ready otherwise false
  64840. */
  64841. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64842. /**
  64843. * Gets the current underlying G Buffer.
  64844. * @returns the buffer
  64845. */
  64846. getGBuffer(): MultiRenderTarget;
  64847. /**
  64848. * Gets the number of samples used to render the buffer (anti aliasing).
  64849. */
  64850. get samples(): number;
  64851. /**
  64852. * Sets the number of samples used to render the buffer (anti aliasing).
  64853. */
  64854. set samples(value: number);
  64855. /**
  64856. * Disposes the renderer and frees up associated resources.
  64857. */
  64858. dispose(): void;
  64859. protected _createRenderTargets(): void;
  64860. private _copyBonesTransformationMatrices;
  64861. }
  64862. }
  64863. declare module BABYLON {
  64864. interface Scene {
  64865. /** @hidden (Backing field) */
  64866. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64867. /**
  64868. * Gets or Sets the current geometry buffer associated to the scene.
  64869. */
  64870. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64871. /**
  64872. * Enables a GeometryBufferRender and associates it with the scene
  64873. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64874. * @returns the GeometryBufferRenderer
  64875. */
  64876. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64877. /**
  64878. * Disables the GeometryBufferRender associated with the scene
  64879. */
  64880. disableGeometryBufferRenderer(): void;
  64881. }
  64882. /**
  64883. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64884. * in several rendering techniques.
  64885. */
  64886. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64887. /**
  64888. * The component name helpful to identify the component in the list of scene components.
  64889. */
  64890. readonly name: string;
  64891. /**
  64892. * The scene the component belongs to.
  64893. */
  64894. scene: Scene;
  64895. /**
  64896. * Creates a new instance of the component for the given scene
  64897. * @param scene Defines the scene to register the component in
  64898. */
  64899. constructor(scene: Scene);
  64900. /**
  64901. * Registers the component in a given scene
  64902. */
  64903. register(): void;
  64904. /**
  64905. * Rebuilds the elements related to this component in case of
  64906. * context lost for instance.
  64907. */
  64908. rebuild(): void;
  64909. /**
  64910. * Disposes the component and the associated ressources
  64911. */
  64912. dispose(): void;
  64913. private _gatherRenderTargets;
  64914. }
  64915. }
  64916. declare module BABYLON {
  64917. /** @hidden */
  64918. export var motionBlurPixelShader: {
  64919. name: string;
  64920. shader: string;
  64921. };
  64922. }
  64923. declare module BABYLON {
  64924. /**
  64925. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64926. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64927. * As an example, all you have to do is to create the post-process:
  64928. * var mb = new BABYLON.MotionBlurPostProcess(
  64929. * 'mb', // The name of the effect.
  64930. * scene, // The scene containing the objects to blur according to their velocity.
  64931. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64932. * camera // The camera to apply the render pass to.
  64933. * );
  64934. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64935. */
  64936. export class MotionBlurPostProcess extends PostProcess {
  64937. /**
  64938. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64939. */
  64940. motionStrength: number;
  64941. /**
  64942. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64943. */
  64944. get motionBlurSamples(): number;
  64945. /**
  64946. * Sets the number of iterations to be used for motion blur quality
  64947. */
  64948. set motionBlurSamples(samples: number);
  64949. private _motionBlurSamples;
  64950. private _geometryBufferRenderer;
  64951. /**
  64952. * Creates a new instance MotionBlurPostProcess
  64953. * @param name The name of the effect.
  64954. * @param scene The scene containing the objects to blur according to their velocity.
  64955. * @param options The required width/height ratio to downsize to before computing the render pass.
  64956. * @param camera The camera to apply the render pass to.
  64957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64958. * @param engine The engine which the post process will be applied. (default: current engine)
  64959. * @param reusable If the post process can be reused on the same frame. (default: false)
  64960. * @param textureType Type of textures used when performing the post process. (default: 0)
  64961. * @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)
  64962. */
  64963. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64964. /**
  64965. * Excludes the given skinned mesh from computing bones velocities.
  64966. * 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.
  64967. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64968. */
  64969. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64970. /**
  64971. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64972. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64973. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64974. */
  64975. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64976. /**
  64977. * Disposes the post process.
  64978. * @param camera The camera to dispose the post process on.
  64979. */
  64980. dispose(camera?: Camera): void;
  64981. }
  64982. }
  64983. declare module BABYLON {
  64984. /** @hidden */
  64985. export var refractionPixelShader: {
  64986. name: string;
  64987. shader: string;
  64988. };
  64989. }
  64990. declare module BABYLON {
  64991. /**
  64992. * Post process which applies a refractin texture
  64993. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64994. */
  64995. export class RefractionPostProcess extends PostProcess {
  64996. /** the base color of the refraction (used to taint the rendering) */
  64997. color: Color3;
  64998. /** simulated refraction depth */
  64999. depth: number;
  65000. /** the coefficient of the base color (0 to remove base color tainting) */
  65001. colorLevel: number;
  65002. private _refTexture;
  65003. private _ownRefractionTexture;
  65004. /**
  65005. * Gets or sets the refraction texture
  65006. * Please note that you are responsible for disposing the texture if you set it manually
  65007. */
  65008. get refractionTexture(): Texture;
  65009. set refractionTexture(value: Texture);
  65010. /**
  65011. * Initializes the RefractionPostProcess
  65012. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65013. * @param name The name of the effect.
  65014. * @param refractionTextureUrl Url of the refraction texture to use
  65015. * @param color the base color of the refraction (used to taint the rendering)
  65016. * @param depth simulated refraction depth
  65017. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65018. * @param camera The camera to apply the render pass to.
  65019. * @param options The required width/height ratio to downsize to before computing the render pass.
  65020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65021. * @param engine The engine which the post process will be applied. (default: current engine)
  65022. * @param reusable If the post process can be reused on the same frame. (default: false)
  65023. */
  65024. constructor(name: string, refractionTextureUrl: string,
  65025. /** the base color of the refraction (used to taint the rendering) */
  65026. color: Color3,
  65027. /** simulated refraction depth */
  65028. depth: number,
  65029. /** the coefficient of the base color (0 to remove base color tainting) */
  65030. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65031. /**
  65032. * Disposes of the post process
  65033. * @param camera Camera to dispose post process on
  65034. */
  65035. dispose(camera: Camera): void;
  65036. }
  65037. }
  65038. declare module BABYLON {
  65039. /** @hidden */
  65040. export var sharpenPixelShader: {
  65041. name: string;
  65042. shader: string;
  65043. };
  65044. }
  65045. declare module BABYLON {
  65046. /**
  65047. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65048. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65049. */
  65050. export class SharpenPostProcess extends PostProcess {
  65051. /**
  65052. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65053. */
  65054. colorAmount: number;
  65055. /**
  65056. * How much sharpness should be applied (default: 0.3)
  65057. */
  65058. edgeAmount: number;
  65059. /**
  65060. * Creates a new instance ConvolutionPostProcess
  65061. * @param name The name of the effect.
  65062. * @param options The required width/height ratio to downsize to before computing the render pass.
  65063. * @param camera The camera to apply the render pass to.
  65064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65065. * @param engine The engine which the post process will be applied. (default: current engine)
  65066. * @param reusable If the post process can be reused on the same frame. (default: false)
  65067. * @param textureType Type of textures used when performing the post process. (default: 0)
  65068. * @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)
  65069. */
  65070. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65071. }
  65072. }
  65073. declare module BABYLON {
  65074. /**
  65075. * PostProcessRenderPipeline
  65076. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65077. */
  65078. export class PostProcessRenderPipeline {
  65079. private engine;
  65080. private _renderEffects;
  65081. private _renderEffectsForIsolatedPass;
  65082. /**
  65083. * List of inspectable custom properties (used by the Inspector)
  65084. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65085. */
  65086. inspectableCustomProperties: IInspectable[];
  65087. /**
  65088. * @hidden
  65089. */
  65090. protected _cameras: Camera[];
  65091. /** @hidden */
  65092. _name: string;
  65093. /**
  65094. * Gets pipeline name
  65095. */
  65096. get name(): string;
  65097. /** Gets the list of attached cameras */
  65098. get cameras(): Camera[];
  65099. /**
  65100. * Initializes a PostProcessRenderPipeline
  65101. * @param engine engine to add the pipeline to
  65102. * @param name name of the pipeline
  65103. */
  65104. constructor(engine: Engine, name: string);
  65105. /**
  65106. * Gets the class name
  65107. * @returns "PostProcessRenderPipeline"
  65108. */
  65109. getClassName(): string;
  65110. /**
  65111. * If all the render effects in the pipeline are supported
  65112. */
  65113. get isSupported(): boolean;
  65114. /**
  65115. * Adds an effect to the pipeline
  65116. * @param renderEffect the effect to add
  65117. */
  65118. addEffect(renderEffect: PostProcessRenderEffect): void;
  65119. /** @hidden */
  65120. _rebuild(): void;
  65121. /** @hidden */
  65122. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65123. /** @hidden */
  65124. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65125. /** @hidden */
  65126. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65127. /** @hidden */
  65128. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65129. /** @hidden */
  65130. _attachCameras(cameras: Camera, unique: boolean): void;
  65131. /** @hidden */
  65132. _attachCameras(cameras: Camera[], unique: boolean): void;
  65133. /** @hidden */
  65134. _detachCameras(cameras: Camera): void;
  65135. /** @hidden */
  65136. _detachCameras(cameras: Nullable<Camera[]>): void;
  65137. /** @hidden */
  65138. _update(): void;
  65139. /** @hidden */
  65140. _reset(): void;
  65141. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65142. /**
  65143. * Disposes of the pipeline
  65144. */
  65145. dispose(): void;
  65146. }
  65147. }
  65148. declare module BABYLON {
  65149. /**
  65150. * PostProcessRenderPipelineManager class
  65151. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65152. */
  65153. export class PostProcessRenderPipelineManager {
  65154. private _renderPipelines;
  65155. /**
  65156. * Initializes a PostProcessRenderPipelineManager
  65157. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65158. */
  65159. constructor();
  65160. /**
  65161. * Gets the list of supported render pipelines
  65162. */
  65163. get supportedPipelines(): PostProcessRenderPipeline[];
  65164. /**
  65165. * Adds a pipeline to the manager
  65166. * @param renderPipeline The pipeline to add
  65167. */
  65168. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65169. /**
  65170. * Attaches a camera to the pipeline
  65171. * @param renderPipelineName The name of the pipeline to attach to
  65172. * @param cameras the camera to attach
  65173. * @param unique if the camera can be attached multiple times to the pipeline
  65174. */
  65175. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65176. /**
  65177. * Detaches a camera from the pipeline
  65178. * @param renderPipelineName The name of the pipeline to detach from
  65179. * @param cameras the camera to detach
  65180. */
  65181. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65182. /**
  65183. * Enables an effect by name on a pipeline
  65184. * @param renderPipelineName the name of the pipeline to enable the effect in
  65185. * @param renderEffectName the name of the effect to enable
  65186. * @param cameras the cameras that the effect should be enabled on
  65187. */
  65188. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65189. /**
  65190. * Disables an effect by name on a pipeline
  65191. * @param renderPipelineName the name of the pipeline to disable the effect in
  65192. * @param renderEffectName the name of the effect to disable
  65193. * @param cameras the cameras that the effect should be disabled on
  65194. */
  65195. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65196. /**
  65197. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65198. */
  65199. update(): void;
  65200. /** @hidden */
  65201. _rebuild(): void;
  65202. /**
  65203. * Disposes of the manager and pipelines
  65204. */
  65205. dispose(): void;
  65206. }
  65207. }
  65208. declare module BABYLON {
  65209. interface Scene {
  65210. /** @hidden (Backing field) */
  65211. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65212. /**
  65213. * Gets the postprocess render pipeline manager
  65214. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65215. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65216. */
  65217. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65218. }
  65219. /**
  65220. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65221. */
  65222. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65223. /**
  65224. * The component name helpfull to identify the component in the list of scene components.
  65225. */
  65226. readonly name: string;
  65227. /**
  65228. * The scene the component belongs to.
  65229. */
  65230. scene: Scene;
  65231. /**
  65232. * Creates a new instance of the component for the given scene
  65233. * @param scene Defines the scene to register the component in
  65234. */
  65235. constructor(scene: Scene);
  65236. /**
  65237. * Registers the component in a given scene
  65238. */
  65239. register(): void;
  65240. /**
  65241. * Rebuilds the elements related to this component in case of
  65242. * context lost for instance.
  65243. */
  65244. rebuild(): void;
  65245. /**
  65246. * Disposes the component and the associated ressources
  65247. */
  65248. dispose(): void;
  65249. private _gatherRenderTargets;
  65250. }
  65251. }
  65252. declare module BABYLON {
  65253. /**
  65254. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65255. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65256. */
  65257. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65258. private _scene;
  65259. private _camerasToBeAttached;
  65260. /**
  65261. * ID of the sharpen post process,
  65262. */
  65263. private readonly SharpenPostProcessId;
  65264. /**
  65265. * @ignore
  65266. * ID of the image processing post process;
  65267. */
  65268. readonly ImageProcessingPostProcessId: string;
  65269. /**
  65270. * @ignore
  65271. * ID of the Fast Approximate Anti-Aliasing post process;
  65272. */
  65273. readonly FxaaPostProcessId: string;
  65274. /**
  65275. * ID of the chromatic aberration post process,
  65276. */
  65277. private readonly ChromaticAberrationPostProcessId;
  65278. /**
  65279. * ID of the grain post process
  65280. */
  65281. private readonly GrainPostProcessId;
  65282. /**
  65283. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65284. */
  65285. sharpen: SharpenPostProcess;
  65286. private _sharpenEffect;
  65287. private bloom;
  65288. /**
  65289. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65290. */
  65291. depthOfField: DepthOfFieldEffect;
  65292. /**
  65293. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65294. */
  65295. fxaa: FxaaPostProcess;
  65296. /**
  65297. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65298. */
  65299. imageProcessing: ImageProcessingPostProcess;
  65300. /**
  65301. * Chromatic aberration post process which will shift rgb colors in the image
  65302. */
  65303. chromaticAberration: ChromaticAberrationPostProcess;
  65304. private _chromaticAberrationEffect;
  65305. /**
  65306. * Grain post process which add noise to the image
  65307. */
  65308. grain: GrainPostProcess;
  65309. private _grainEffect;
  65310. /**
  65311. * Glow post process which adds a glow to emissive areas of the image
  65312. */
  65313. private _glowLayer;
  65314. /**
  65315. * Animations which can be used to tweak settings over a period of time
  65316. */
  65317. animations: Animation[];
  65318. private _imageProcessingConfigurationObserver;
  65319. private _sharpenEnabled;
  65320. private _bloomEnabled;
  65321. private _depthOfFieldEnabled;
  65322. private _depthOfFieldBlurLevel;
  65323. private _fxaaEnabled;
  65324. private _imageProcessingEnabled;
  65325. private _defaultPipelineTextureType;
  65326. private _bloomScale;
  65327. private _chromaticAberrationEnabled;
  65328. private _grainEnabled;
  65329. private _buildAllowed;
  65330. /**
  65331. * Gets active scene
  65332. */
  65333. get scene(): Scene;
  65334. /**
  65335. * Enable or disable the sharpen process from the pipeline
  65336. */
  65337. set sharpenEnabled(enabled: boolean);
  65338. get sharpenEnabled(): boolean;
  65339. private _resizeObserver;
  65340. private _hardwareScaleLevel;
  65341. private _bloomKernel;
  65342. /**
  65343. * Specifies the size of the bloom blur kernel, relative to the final output size
  65344. */
  65345. get bloomKernel(): number;
  65346. set bloomKernel(value: number);
  65347. /**
  65348. * Specifies the weight of the bloom in the final rendering
  65349. */
  65350. private _bloomWeight;
  65351. /**
  65352. * Specifies the luma threshold for the area that will be blurred by the bloom
  65353. */
  65354. private _bloomThreshold;
  65355. private _hdr;
  65356. /**
  65357. * The strength of the bloom.
  65358. */
  65359. set bloomWeight(value: number);
  65360. get bloomWeight(): number;
  65361. /**
  65362. * The strength of the bloom.
  65363. */
  65364. set bloomThreshold(value: number);
  65365. get bloomThreshold(): number;
  65366. /**
  65367. * The scale of the bloom, lower value will provide better performance.
  65368. */
  65369. set bloomScale(value: number);
  65370. get bloomScale(): number;
  65371. /**
  65372. * Enable or disable the bloom from the pipeline
  65373. */
  65374. set bloomEnabled(enabled: boolean);
  65375. get bloomEnabled(): boolean;
  65376. private _rebuildBloom;
  65377. /**
  65378. * If the depth of field is enabled.
  65379. */
  65380. get depthOfFieldEnabled(): boolean;
  65381. set depthOfFieldEnabled(enabled: boolean);
  65382. /**
  65383. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65384. */
  65385. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65386. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65387. /**
  65388. * If the anti aliasing is enabled.
  65389. */
  65390. set fxaaEnabled(enabled: boolean);
  65391. get fxaaEnabled(): boolean;
  65392. private _samples;
  65393. /**
  65394. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65395. */
  65396. set samples(sampleCount: number);
  65397. get samples(): number;
  65398. /**
  65399. * If image processing is enabled.
  65400. */
  65401. set imageProcessingEnabled(enabled: boolean);
  65402. get imageProcessingEnabled(): boolean;
  65403. /**
  65404. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65405. */
  65406. set glowLayerEnabled(enabled: boolean);
  65407. get glowLayerEnabled(): boolean;
  65408. /**
  65409. * Gets the glow layer (or null if not defined)
  65410. */
  65411. get glowLayer(): Nullable<GlowLayer>;
  65412. /**
  65413. * Enable or disable the chromaticAberration process from the pipeline
  65414. */
  65415. set chromaticAberrationEnabled(enabled: boolean);
  65416. get chromaticAberrationEnabled(): boolean;
  65417. /**
  65418. * Enable or disable the grain process from the pipeline
  65419. */
  65420. set grainEnabled(enabled: boolean);
  65421. get grainEnabled(): boolean;
  65422. /**
  65423. * @constructor
  65424. * @param name - The rendering pipeline name (default: "")
  65425. * @param hdr - If high dynamic range textures should be used (default: true)
  65426. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65427. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65428. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65429. */
  65430. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65431. /**
  65432. * Get the class name
  65433. * @returns "DefaultRenderingPipeline"
  65434. */
  65435. getClassName(): string;
  65436. /**
  65437. * Force the compilation of the entire pipeline.
  65438. */
  65439. prepare(): void;
  65440. private _hasCleared;
  65441. private _prevPostProcess;
  65442. private _prevPrevPostProcess;
  65443. private _setAutoClearAndTextureSharing;
  65444. private _depthOfFieldSceneObserver;
  65445. private _buildPipeline;
  65446. private _disposePostProcesses;
  65447. /**
  65448. * Adds a camera to the pipeline
  65449. * @param camera the camera to be added
  65450. */
  65451. addCamera(camera: Camera): void;
  65452. /**
  65453. * Removes a camera from the pipeline
  65454. * @param camera the camera to remove
  65455. */
  65456. removeCamera(camera: Camera): void;
  65457. /**
  65458. * Dispose of the pipeline and stop all post processes
  65459. */
  65460. dispose(): void;
  65461. /**
  65462. * Serialize the rendering pipeline (Used when exporting)
  65463. * @returns the serialized object
  65464. */
  65465. serialize(): any;
  65466. /**
  65467. * Parse the serialized pipeline
  65468. * @param source Source pipeline.
  65469. * @param scene The scene to load the pipeline to.
  65470. * @param rootUrl The URL of the serialized pipeline.
  65471. * @returns An instantiated pipeline from the serialized object.
  65472. */
  65473. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65474. }
  65475. }
  65476. declare module BABYLON {
  65477. /** @hidden */
  65478. export var lensHighlightsPixelShader: {
  65479. name: string;
  65480. shader: string;
  65481. };
  65482. }
  65483. declare module BABYLON {
  65484. /** @hidden */
  65485. export var depthOfFieldPixelShader: {
  65486. name: string;
  65487. shader: string;
  65488. };
  65489. }
  65490. declare module BABYLON {
  65491. /**
  65492. * BABYLON.JS Chromatic Aberration GLSL Shader
  65493. * Author: Olivier Guyot
  65494. * Separates very slightly R, G and B colors on the edges of the screen
  65495. * Inspired by Francois Tarlier & Martins Upitis
  65496. */
  65497. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65498. /**
  65499. * @ignore
  65500. * The chromatic aberration PostProcess id in the pipeline
  65501. */
  65502. LensChromaticAberrationEffect: string;
  65503. /**
  65504. * @ignore
  65505. * The highlights enhancing PostProcess id in the pipeline
  65506. */
  65507. HighlightsEnhancingEffect: string;
  65508. /**
  65509. * @ignore
  65510. * The depth-of-field PostProcess id in the pipeline
  65511. */
  65512. LensDepthOfFieldEffect: string;
  65513. private _scene;
  65514. private _depthTexture;
  65515. private _grainTexture;
  65516. private _chromaticAberrationPostProcess;
  65517. private _highlightsPostProcess;
  65518. private _depthOfFieldPostProcess;
  65519. private _edgeBlur;
  65520. private _grainAmount;
  65521. private _chromaticAberration;
  65522. private _distortion;
  65523. private _highlightsGain;
  65524. private _highlightsThreshold;
  65525. private _dofDistance;
  65526. private _dofAperture;
  65527. private _dofDarken;
  65528. private _dofPentagon;
  65529. private _blurNoise;
  65530. /**
  65531. * @constructor
  65532. *
  65533. * Effect parameters are as follow:
  65534. * {
  65535. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65536. * edge_blur: number; // from 0 to x (1 for realism)
  65537. * distortion: number; // from 0 to x (1 for realism)
  65538. * grain_amount: number; // from 0 to 1
  65539. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65540. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65541. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65542. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65543. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65544. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65545. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65546. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65547. * }
  65548. * Note: if an effect parameter is unset, effect is disabled
  65549. *
  65550. * @param name The rendering pipeline name
  65551. * @param parameters - An object containing all parameters (see above)
  65552. * @param scene The scene linked to this pipeline
  65553. * @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)
  65554. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65555. */
  65556. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65557. /**
  65558. * Get the class name
  65559. * @returns "LensRenderingPipeline"
  65560. */
  65561. getClassName(): string;
  65562. /**
  65563. * Gets associated scene
  65564. */
  65565. get scene(): Scene;
  65566. /**
  65567. * Gets or sets the edge blur
  65568. */
  65569. get edgeBlur(): number;
  65570. set edgeBlur(value: number);
  65571. /**
  65572. * Gets or sets the grain amount
  65573. */
  65574. get grainAmount(): number;
  65575. set grainAmount(value: number);
  65576. /**
  65577. * Gets or sets the chromatic aberration amount
  65578. */
  65579. get chromaticAberration(): number;
  65580. set chromaticAberration(value: number);
  65581. /**
  65582. * Gets or sets the depth of field aperture
  65583. */
  65584. get dofAperture(): number;
  65585. set dofAperture(value: number);
  65586. /**
  65587. * Gets or sets the edge distortion
  65588. */
  65589. get edgeDistortion(): number;
  65590. set edgeDistortion(value: number);
  65591. /**
  65592. * Gets or sets the depth of field distortion
  65593. */
  65594. get dofDistortion(): number;
  65595. set dofDistortion(value: number);
  65596. /**
  65597. * Gets or sets the darken out of focus amount
  65598. */
  65599. get darkenOutOfFocus(): number;
  65600. set darkenOutOfFocus(value: number);
  65601. /**
  65602. * Gets or sets a boolean indicating if blur noise is enabled
  65603. */
  65604. get blurNoise(): boolean;
  65605. set blurNoise(value: boolean);
  65606. /**
  65607. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65608. */
  65609. get pentagonBokeh(): boolean;
  65610. set pentagonBokeh(value: boolean);
  65611. /**
  65612. * Gets or sets the highlight grain amount
  65613. */
  65614. get highlightsGain(): number;
  65615. set highlightsGain(value: number);
  65616. /**
  65617. * Gets or sets the highlight threshold
  65618. */
  65619. get highlightsThreshold(): number;
  65620. set highlightsThreshold(value: number);
  65621. /**
  65622. * Sets the amount of blur at the edges
  65623. * @param amount blur amount
  65624. */
  65625. setEdgeBlur(amount: number): void;
  65626. /**
  65627. * Sets edge blur to 0
  65628. */
  65629. disableEdgeBlur(): void;
  65630. /**
  65631. * Sets the amout of grain
  65632. * @param amount Amount of grain
  65633. */
  65634. setGrainAmount(amount: number): void;
  65635. /**
  65636. * Set grain amount to 0
  65637. */
  65638. disableGrain(): void;
  65639. /**
  65640. * Sets the chromatic aberration amount
  65641. * @param amount amount of chromatic aberration
  65642. */
  65643. setChromaticAberration(amount: number): void;
  65644. /**
  65645. * Sets chromatic aberration amount to 0
  65646. */
  65647. disableChromaticAberration(): void;
  65648. /**
  65649. * Sets the EdgeDistortion amount
  65650. * @param amount amount of EdgeDistortion
  65651. */
  65652. setEdgeDistortion(amount: number): void;
  65653. /**
  65654. * Sets edge distortion to 0
  65655. */
  65656. disableEdgeDistortion(): void;
  65657. /**
  65658. * Sets the FocusDistance amount
  65659. * @param amount amount of FocusDistance
  65660. */
  65661. setFocusDistance(amount: number): void;
  65662. /**
  65663. * Disables depth of field
  65664. */
  65665. disableDepthOfField(): void;
  65666. /**
  65667. * Sets the Aperture amount
  65668. * @param amount amount of Aperture
  65669. */
  65670. setAperture(amount: number): void;
  65671. /**
  65672. * Sets the DarkenOutOfFocus amount
  65673. * @param amount amount of DarkenOutOfFocus
  65674. */
  65675. setDarkenOutOfFocus(amount: number): void;
  65676. private _pentagonBokehIsEnabled;
  65677. /**
  65678. * Creates a pentagon bokeh effect
  65679. */
  65680. enablePentagonBokeh(): void;
  65681. /**
  65682. * Disables the pentagon bokeh effect
  65683. */
  65684. disablePentagonBokeh(): void;
  65685. /**
  65686. * Enables noise blur
  65687. */
  65688. enableNoiseBlur(): void;
  65689. /**
  65690. * Disables noise blur
  65691. */
  65692. disableNoiseBlur(): void;
  65693. /**
  65694. * Sets the HighlightsGain amount
  65695. * @param amount amount of HighlightsGain
  65696. */
  65697. setHighlightsGain(amount: number): void;
  65698. /**
  65699. * Sets the HighlightsThreshold amount
  65700. * @param amount amount of HighlightsThreshold
  65701. */
  65702. setHighlightsThreshold(amount: number): void;
  65703. /**
  65704. * Disables highlights
  65705. */
  65706. disableHighlights(): void;
  65707. /**
  65708. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65709. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65710. */
  65711. dispose(disableDepthRender?: boolean): void;
  65712. private _createChromaticAberrationPostProcess;
  65713. private _createHighlightsPostProcess;
  65714. private _createDepthOfFieldPostProcess;
  65715. private _createGrainTexture;
  65716. }
  65717. }
  65718. declare module BABYLON {
  65719. /** @hidden */
  65720. export var ssao2PixelShader: {
  65721. name: string;
  65722. shader: string;
  65723. };
  65724. }
  65725. declare module BABYLON {
  65726. /** @hidden */
  65727. export var ssaoCombinePixelShader: {
  65728. name: string;
  65729. shader: string;
  65730. };
  65731. }
  65732. declare module BABYLON {
  65733. /**
  65734. * Render pipeline to produce ssao effect
  65735. */
  65736. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65737. /**
  65738. * @ignore
  65739. * The PassPostProcess id in the pipeline that contains the original scene color
  65740. */
  65741. SSAOOriginalSceneColorEffect: string;
  65742. /**
  65743. * @ignore
  65744. * The SSAO PostProcess id in the pipeline
  65745. */
  65746. SSAORenderEffect: string;
  65747. /**
  65748. * @ignore
  65749. * The horizontal blur PostProcess id in the pipeline
  65750. */
  65751. SSAOBlurHRenderEffect: string;
  65752. /**
  65753. * @ignore
  65754. * The vertical blur PostProcess id in the pipeline
  65755. */
  65756. SSAOBlurVRenderEffect: string;
  65757. /**
  65758. * @ignore
  65759. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65760. */
  65761. SSAOCombineRenderEffect: string;
  65762. /**
  65763. * The output strength of the SSAO post-process. Default value is 1.0.
  65764. */
  65765. totalStrength: number;
  65766. /**
  65767. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65768. */
  65769. maxZ: number;
  65770. /**
  65771. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65772. */
  65773. minZAspect: number;
  65774. private _samples;
  65775. /**
  65776. * Number of samples used for the SSAO calculations. Default value is 8
  65777. */
  65778. set samples(n: number);
  65779. get samples(): number;
  65780. private _textureSamples;
  65781. /**
  65782. * Number of samples to use for antialiasing
  65783. */
  65784. set textureSamples(n: number);
  65785. get textureSamples(): number;
  65786. /**
  65787. * Ratio object used for SSAO ratio and blur ratio
  65788. */
  65789. private _ratio;
  65790. /**
  65791. * Dynamically generated sphere sampler.
  65792. */
  65793. private _sampleSphere;
  65794. /**
  65795. * Blur filter offsets
  65796. */
  65797. private _samplerOffsets;
  65798. private _expensiveBlur;
  65799. /**
  65800. * If bilateral blur should be used
  65801. */
  65802. set expensiveBlur(b: boolean);
  65803. get expensiveBlur(): boolean;
  65804. /**
  65805. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65806. */
  65807. radius: number;
  65808. /**
  65809. * The base color of the SSAO post-process
  65810. * The final result is "base + ssao" between [0, 1]
  65811. */
  65812. base: number;
  65813. /**
  65814. * Support test.
  65815. */
  65816. static get IsSupported(): boolean;
  65817. private _scene;
  65818. private _depthTexture;
  65819. private _normalTexture;
  65820. private _randomTexture;
  65821. private _originalColorPostProcess;
  65822. private _ssaoPostProcess;
  65823. private _blurHPostProcess;
  65824. private _blurVPostProcess;
  65825. private _ssaoCombinePostProcess;
  65826. /**
  65827. * Gets active scene
  65828. */
  65829. get scene(): Scene;
  65830. /**
  65831. * @constructor
  65832. * @param name The rendering pipeline name
  65833. * @param scene The scene linked to this pipeline
  65834. * @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 }
  65835. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65836. */
  65837. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65838. /**
  65839. * Get the class name
  65840. * @returns "SSAO2RenderingPipeline"
  65841. */
  65842. getClassName(): string;
  65843. /**
  65844. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65845. */
  65846. dispose(disableGeometryBufferRenderer?: boolean): void;
  65847. private _createBlurPostProcess;
  65848. /** @hidden */
  65849. _rebuild(): void;
  65850. private _bits;
  65851. private _radicalInverse_VdC;
  65852. private _hammersley;
  65853. private _hemisphereSample_uniform;
  65854. private _generateHemisphere;
  65855. private _createSSAOPostProcess;
  65856. private _createSSAOCombinePostProcess;
  65857. private _createRandomTexture;
  65858. /**
  65859. * Serialize the rendering pipeline (Used when exporting)
  65860. * @returns the serialized object
  65861. */
  65862. serialize(): any;
  65863. /**
  65864. * Parse the serialized pipeline
  65865. * @param source Source pipeline.
  65866. * @param scene The scene to load the pipeline to.
  65867. * @param rootUrl The URL of the serialized pipeline.
  65868. * @returns An instantiated pipeline from the serialized object.
  65869. */
  65870. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65871. }
  65872. }
  65873. declare module BABYLON {
  65874. /** @hidden */
  65875. export var ssaoPixelShader: {
  65876. name: string;
  65877. shader: string;
  65878. };
  65879. }
  65880. declare module BABYLON {
  65881. /**
  65882. * Render pipeline to produce ssao effect
  65883. */
  65884. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65885. /**
  65886. * @ignore
  65887. * The PassPostProcess id in the pipeline that contains the original scene color
  65888. */
  65889. SSAOOriginalSceneColorEffect: string;
  65890. /**
  65891. * @ignore
  65892. * The SSAO PostProcess id in the pipeline
  65893. */
  65894. SSAORenderEffect: string;
  65895. /**
  65896. * @ignore
  65897. * The horizontal blur PostProcess id in the pipeline
  65898. */
  65899. SSAOBlurHRenderEffect: string;
  65900. /**
  65901. * @ignore
  65902. * The vertical blur PostProcess id in the pipeline
  65903. */
  65904. SSAOBlurVRenderEffect: string;
  65905. /**
  65906. * @ignore
  65907. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65908. */
  65909. SSAOCombineRenderEffect: string;
  65910. /**
  65911. * The output strength of the SSAO post-process. Default value is 1.0.
  65912. */
  65913. totalStrength: number;
  65914. /**
  65915. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65916. */
  65917. radius: number;
  65918. /**
  65919. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65920. * Must not be equal to fallOff and superior to fallOff.
  65921. * Default value is 0.0075
  65922. */
  65923. area: number;
  65924. /**
  65925. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65926. * Must not be equal to area and inferior to area.
  65927. * Default value is 0.000001
  65928. */
  65929. fallOff: number;
  65930. /**
  65931. * The base color of the SSAO post-process
  65932. * The final result is "base + ssao" between [0, 1]
  65933. */
  65934. base: number;
  65935. private _scene;
  65936. private _depthTexture;
  65937. private _randomTexture;
  65938. private _originalColorPostProcess;
  65939. private _ssaoPostProcess;
  65940. private _blurHPostProcess;
  65941. private _blurVPostProcess;
  65942. private _ssaoCombinePostProcess;
  65943. private _firstUpdate;
  65944. /**
  65945. * Gets active scene
  65946. */
  65947. get scene(): Scene;
  65948. /**
  65949. * @constructor
  65950. * @param name - The rendering pipeline name
  65951. * @param scene - The scene linked to this pipeline
  65952. * @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 }
  65953. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65954. */
  65955. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65956. /**
  65957. * Get the class name
  65958. * @returns "SSAORenderingPipeline"
  65959. */
  65960. getClassName(): string;
  65961. /**
  65962. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65963. */
  65964. dispose(disableDepthRender?: boolean): void;
  65965. private _createBlurPostProcess;
  65966. /** @hidden */
  65967. _rebuild(): void;
  65968. private _createSSAOPostProcess;
  65969. private _createSSAOCombinePostProcess;
  65970. private _createRandomTexture;
  65971. }
  65972. }
  65973. declare module BABYLON {
  65974. /** @hidden */
  65975. export var screenSpaceReflectionPixelShader: {
  65976. name: string;
  65977. shader: string;
  65978. };
  65979. }
  65980. declare module BABYLON {
  65981. /**
  65982. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65983. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65984. */
  65985. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65986. /**
  65987. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65988. */
  65989. threshold: number;
  65990. /**
  65991. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65992. */
  65993. strength: number;
  65994. /**
  65995. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65996. */
  65997. reflectionSpecularFalloffExponent: number;
  65998. /**
  65999. * 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]
  66000. */
  66001. step: number;
  66002. /**
  66003. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66004. */
  66005. roughnessFactor: number;
  66006. private _geometryBufferRenderer;
  66007. private _enableSmoothReflections;
  66008. private _reflectionSamples;
  66009. private _smoothSteps;
  66010. /**
  66011. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66012. * @param name The name of the effect.
  66013. * @param scene The scene containing the objects to calculate reflections.
  66014. * @param options The required width/height ratio to downsize to before computing the render pass.
  66015. * @param camera The camera to apply the render pass to.
  66016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66017. * @param engine The engine which the post process will be applied. (default: current engine)
  66018. * @param reusable If the post process can be reused on the same frame. (default: false)
  66019. * @param textureType Type of textures used when performing the post process. (default: 0)
  66020. * @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)
  66021. */
  66022. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66023. /**
  66024. * Gets wether or not smoothing reflections is enabled.
  66025. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66026. */
  66027. get enableSmoothReflections(): boolean;
  66028. /**
  66029. * Sets wether or not smoothing reflections is enabled.
  66030. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66031. */
  66032. set enableSmoothReflections(enabled: boolean);
  66033. /**
  66034. * Gets the number of samples taken while computing reflections. More samples count is high,
  66035. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66036. */
  66037. get reflectionSamples(): number;
  66038. /**
  66039. * Sets the number of samples taken while computing reflections. More samples count is high,
  66040. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66041. */
  66042. set reflectionSamples(samples: number);
  66043. /**
  66044. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66045. * more the post-process will require GPU power and can generate a drop in FPS.
  66046. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66047. */
  66048. get smoothSteps(): number;
  66049. set smoothSteps(steps: number);
  66050. private _updateEffectDefines;
  66051. }
  66052. }
  66053. declare module BABYLON {
  66054. /** @hidden */
  66055. export var standardPixelShader: {
  66056. name: string;
  66057. shader: string;
  66058. };
  66059. }
  66060. declare module BABYLON {
  66061. /**
  66062. * Standard rendering pipeline
  66063. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66064. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66065. */
  66066. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66067. /**
  66068. * Public members
  66069. */
  66070. /**
  66071. * Post-process which contains the original scene color before the pipeline applies all the effects
  66072. */
  66073. originalPostProcess: Nullable<PostProcess>;
  66074. /**
  66075. * Post-process used to down scale an image x4
  66076. */
  66077. downSampleX4PostProcess: Nullable<PostProcess>;
  66078. /**
  66079. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66080. */
  66081. brightPassPostProcess: Nullable<PostProcess>;
  66082. /**
  66083. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66084. */
  66085. blurHPostProcesses: PostProcess[];
  66086. /**
  66087. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66088. */
  66089. blurVPostProcesses: PostProcess[];
  66090. /**
  66091. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66092. */
  66093. textureAdderPostProcess: Nullable<PostProcess>;
  66094. /**
  66095. * Post-process used to create volumetric lighting effect
  66096. */
  66097. volumetricLightPostProcess: Nullable<PostProcess>;
  66098. /**
  66099. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66100. */
  66101. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66102. /**
  66103. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66104. */
  66105. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66106. /**
  66107. * Post-process used to merge the volumetric light effect and the real scene color
  66108. */
  66109. volumetricLightMergePostProces: Nullable<PostProcess>;
  66110. /**
  66111. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66112. */
  66113. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66114. /**
  66115. * Base post-process used to calculate the average luminance of the final image for HDR
  66116. */
  66117. luminancePostProcess: Nullable<PostProcess>;
  66118. /**
  66119. * Post-processes used to create down sample post-processes in order to get
  66120. * the average luminance of the final image for HDR
  66121. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66122. */
  66123. luminanceDownSamplePostProcesses: PostProcess[];
  66124. /**
  66125. * Post-process used to create a HDR effect (light adaptation)
  66126. */
  66127. hdrPostProcess: Nullable<PostProcess>;
  66128. /**
  66129. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66130. */
  66131. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66132. /**
  66133. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66134. */
  66135. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66136. /**
  66137. * Post-process used to merge the final HDR post-process and the real scene color
  66138. */
  66139. hdrFinalPostProcess: Nullable<PostProcess>;
  66140. /**
  66141. * Post-process used to create a lens flare effect
  66142. */
  66143. lensFlarePostProcess: Nullable<PostProcess>;
  66144. /**
  66145. * Post-process that merges the result of the lens flare post-process and the real scene color
  66146. */
  66147. lensFlareComposePostProcess: Nullable<PostProcess>;
  66148. /**
  66149. * Post-process used to create a motion blur effect
  66150. */
  66151. motionBlurPostProcess: Nullable<PostProcess>;
  66152. /**
  66153. * Post-process used to create a depth of field effect
  66154. */
  66155. depthOfFieldPostProcess: Nullable<PostProcess>;
  66156. /**
  66157. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66158. */
  66159. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66160. /**
  66161. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66162. */
  66163. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66164. /**
  66165. * Represents the brightness threshold in order to configure the illuminated surfaces
  66166. */
  66167. brightThreshold: number;
  66168. /**
  66169. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66170. */
  66171. blurWidth: number;
  66172. /**
  66173. * Sets if the blur for highlighted surfaces must be only horizontal
  66174. */
  66175. horizontalBlur: boolean;
  66176. /**
  66177. * Gets the overall exposure used by the pipeline
  66178. */
  66179. get exposure(): number;
  66180. /**
  66181. * Sets the overall exposure used by the pipeline
  66182. */
  66183. set exposure(value: number);
  66184. /**
  66185. * Texture used typically to simulate "dirty" on camera lens
  66186. */
  66187. lensTexture: Nullable<Texture>;
  66188. /**
  66189. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66190. */
  66191. volumetricLightCoefficient: number;
  66192. /**
  66193. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66194. */
  66195. volumetricLightPower: number;
  66196. /**
  66197. * Used the set the blur intensity to smooth the volumetric lights
  66198. */
  66199. volumetricLightBlurScale: number;
  66200. /**
  66201. * Light (spot or directional) used to generate the volumetric lights rays
  66202. * The source light must have a shadow generate so the pipeline can get its
  66203. * depth map
  66204. */
  66205. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66206. /**
  66207. * For eye adaptation, represents the minimum luminance the eye can see
  66208. */
  66209. hdrMinimumLuminance: number;
  66210. /**
  66211. * For eye adaptation, represents the decrease luminance speed
  66212. */
  66213. hdrDecreaseRate: number;
  66214. /**
  66215. * For eye adaptation, represents the increase luminance speed
  66216. */
  66217. hdrIncreaseRate: number;
  66218. /**
  66219. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66220. */
  66221. get hdrAutoExposure(): boolean;
  66222. /**
  66223. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66224. */
  66225. set hdrAutoExposure(value: boolean);
  66226. /**
  66227. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66228. */
  66229. lensColorTexture: Nullable<Texture>;
  66230. /**
  66231. * The overall strengh for the lens flare effect
  66232. */
  66233. lensFlareStrength: number;
  66234. /**
  66235. * Dispersion coefficient for lens flare ghosts
  66236. */
  66237. lensFlareGhostDispersal: number;
  66238. /**
  66239. * Main lens flare halo width
  66240. */
  66241. lensFlareHaloWidth: number;
  66242. /**
  66243. * Based on the lens distortion effect, defines how much the lens flare result
  66244. * is distorted
  66245. */
  66246. lensFlareDistortionStrength: number;
  66247. /**
  66248. * Configures the blur intensity used for for lens flare (halo)
  66249. */
  66250. lensFlareBlurWidth: number;
  66251. /**
  66252. * Lens star texture must be used to simulate rays on the flares and is available
  66253. * in the documentation
  66254. */
  66255. lensStarTexture: Nullable<Texture>;
  66256. /**
  66257. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66258. * flare effect by taking account of the dirt texture
  66259. */
  66260. lensFlareDirtTexture: Nullable<Texture>;
  66261. /**
  66262. * Represents the focal length for the depth of field effect
  66263. */
  66264. depthOfFieldDistance: number;
  66265. /**
  66266. * Represents the blur intensity for the blurred part of the depth of field effect
  66267. */
  66268. depthOfFieldBlurWidth: number;
  66269. /**
  66270. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66271. */
  66272. get motionStrength(): number;
  66273. /**
  66274. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66275. */
  66276. set motionStrength(strength: number);
  66277. /**
  66278. * Gets wether or not the motion blur post-process is object based or screen based.
  66279. */
  66280. get objectBasedMotionBlur(): boolean;
  66281. /**
  66282. * Sets wether or not the motion blur post-process should be object based or screen based
  66283. */
  66284. set objectBasedMotionBlur(value: boolean);
  66285. /**
  66286. * List of animations for the pipeline (IAnimatable implementation)
  66287. */
  66288. animations: Animation[];
  66289. /**
  66290. * Private members
  66291. */
  66292. private _scene;
  66293. private _currentDepthOfFieldSource;
  66294. private _basePostProcess;
  66295. private _fixedExposure;
  66296. private _currentExposure;
  66297. private _hdrAutoExposure;
  66298. private _hdrCurrentLuminance;
  66299. private _motionStrength;
  66300. private _isObjectBasedMotionBlur;
  66301. private _floatTextureType;
  66302. private _camerasToBeAttached;
  66303. private _ratio;
  66304. private _bloomEnabled;
  66305. private _depthOfFieldEnabled;
  66306. private _vlsEnabled;
  66307. private _lensFlareEnabled;
  66308. private _hdrEnabled;
  66309. private _motionBlurEnabled;
  66310. private _fxaaEnabled;
  66311. private _screenSpaceReflectionsEnabled;
  66312. private _motionBlurSamples;
  66313. private _volumetricLightStepsCount;
  66314. private _samples;
  66315. /**
  66316. * @ignore
  66317. * Specifies if the bloom pipeline is enabled
  66318. */
  66319. get BloomEnabled(): boolean;
  66320. set BloomEnabled(enabled: boolean);
  66321. /**
  66322. * @ignore
  66323. * Specifies if the depth of field pipeline is enabed
  66324. */
  66325. get DepthOfFieldEnabled(): boolean;
  66326. set DepthOfFieldEnabled(enabled: boolean);
  66327. /**
  66328. * @ignore
  66329. * Specifies if the lens flare pipeline is enabed
  66330. */
  66331. get LensFlareEnabled(): boolean;
  66332. set LensFlareEnabled(enabled: boolean);
  66333. /**
  66334. * @ignore
  66335. * Specifies if the HDR pipeline is enabled
  66336. */
  66337. get HDREnabled(): boolean;
  66338. set HDREnabled(enabled: boolean);
  66339. /**
  66340. * @ignore
  66341. * Specifies if the volumetric lights scattering effect is enabled
  66342. */
  66343. get VLSEnabled(): boolean;
  66344. set VLSEnabled(enabled: boolean);
  66345. /**
  66346. * @ignore
  66347. * Specifies if the motion blur effect is enabled
  66348. */
  66349. get MotionBlurEnabled(): boolean;
  66350. set MotionBlurEnabled(enabled: boolean);
  66351. /**
  66352. * Specifies if anti-aliasing is enabled
  66353. */
  66354. get fxaaEnabled(): boolean;
  66355. set fxaaEnabled(enabled: boolean);
  66356. /**
  66357. * Specifies if screen space reflections are enabled.
  66358. */
  66359. get screenSpaceReflectionsEnabled(): boolean;
  66360. set screenSpaceReflectionsEnabled(enabled: boolean);
  66361. /**
  66362. * Specifies the number of steps used to calculate the volumetric lights
  66363. * Typically in interval [50, 200]
  66364. */
  66365. get volumetricLightStepsCount(): number;
  66366. set volumetricLightStepsCount(count: number);
  66367. /**
  66368. * Specifies the number of samples used for the motion blur effect
  66369. * Typically in interval [16, 64]
  66370. */
  66371. get motionBlurSamples(): number;
  66372. set motionBlurSamples(samples: number);
  66373. /**
  66374. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66375. */
  66376. get samples(): number;
  66377. set samples(sampleCount: number);
  66378. /**
  66379. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66380. * @constructor
  66381. * @param name The rendering pipeline name
  66382. * @param scene The scene linked to this pipeline
  66383. * @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)
  66384. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66385. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66386. */
  66387. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66388. private _buildPipeline;
  66389. private _createDownSampleX4PostProcess;
  66390. private _createBrightPassPostProcess;
  66391. private _createBlurPostProcesses;
  66392. private _createTextureAdderPostProcess;
  66393. private _createVolumetricLightPostProcess;
  66394. private _createLuminancePostProcesses;
  66395. private _createHdrPostProcess;
  66396. private _createLensFlarePostProcess;
  66397. private _createDepthOfFieldPostProcess;
  66398. private _createMotionBlurPostProcess;
  66399. private _getDepthTexture;
  66400. private _disposePostProcesses;
  66401. /**
  66402. * Dispose of the pipeline and stop all post processes
  66403. */
  66404. dispose(): void;
  66405. /**
  66406. * Serialize the rendering pipeline (Used when exporting)
  66407. * @returns the serialized object
  66408. */
  66409. serialize(): any;
  66410. /**
  66411. * Parse the serialized pipeline
  66412. * @param source Source pipeline.
  66413. * @param scene The scene to load the pipeline to.
  66414. * @param rootUrl The URL of the serialized pipeline.
  66415. * @returns An instantiated pipeline from the serialized object.
  66416. */
  66417. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66418. /**
  66419. * Luminance steps
  66420. */
  66421. static LuminanceSteps: number;
  66422. }
  66423. }
  66424. declare module BABYLON {
  66425. /** @hidden */
  66426. export var tonemapPixelShader: {
  66427. name: string;
  66428. shader: string;
  66429. };
  66430. }
  66431. declare module BABYLON {
  66432. /** Defines operator used for tonemapping */
  66433. export enum TonemappingOperator {
  66434. /** Hable */
  66435. Hable = 0,
  66436. /** Reinhard */
  66437. Reinhard = 1,
  66438. /** HejiDawson */
  66439. HejiDawson = 2,
  66440. /** Photographic */
  66441. Photographic = 3
  66442. }
  66443. /**
  66444. * Defines a post process to apply tone mapping
  66445. */
  66446. export class TonemapPostProcess extends PostProcess {
  66447. private _operator;
  66448. /** Defines the required exposure adjustement */
  66449. exposureAdjustment: number;
  66450. /**
  66451. * Creates a new TonemapPostProcess
  66452. * @param name defines the name of the postprocess
  66453. * @param _operator defines the operator to use
  66454. * @param exposureAdjustment defines the required exposure adjustement
  66455. * @param camera defines the camera to use (can be null)
  66456. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66457. * @param engine defines the hosting engine (can be ignore if camera is set)
  66458. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66459. */
  66460. constructor(name: string, _operator: TonemappingOperator,
  66461. /** Defines the required exposure adjustement */
  66462. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66463. }
  66464. }
  66465. declare module BABYLON {
  66466. /** @hidden */
  66467. export var volumetricLightScatteringPixelShader: {
  66468. name: string;
  66469. shader: string;
  66470. };
  66471. }
  66472. declare module BABYLON {
  66473. /** @hidden */
  66474. export var volumetricLightScatteringPassVertexShader: {
  66475. name: string;
  66476. shader: string;
  66477. };
  66478. }
  66479. declare module BABYLON {
  66480. /** @hidden */
  66481. export var volumetricLightScatteringPassPixelShader: {
  66482. name: string;
  66483. shader: string;
  66484. };
  66485. }
  66486. declare module BABYLON {
  66487. /**
  66488. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66489. */
  66490. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66491. private _volumetricLightScatteringPass;
  66492. private _volumetricLightScatteringRTT;
  66493. private _viewPort;
  66494. private _screenCoordinates;
  66495. private _cachedDefines;
  66496. /**
  66497. * If not undefined, the mesh position is computed from the attached node position
  66498. */
  66499. attachedNode: {
  66500. position: Vector3;
  66501. };
  66502. /**
  66503. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66504. */
  66505. customMeshPosition: Vector3;
  66506. /**
  66507. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66508. */
  66509. useCustomMeshPosition: boolean;
  66510. /**
  66511. * If the post-process should inverse the light scattering direction
  66512. */
  66513. invert: boolean;
  66514. /**
  66515. * The internal mesh used by the post-process
  66516. */
  66517. mesh: Mesh;
  66518. /**
  66519. * @hidden
  66520. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66521. */
  66522. get useDiffuseColor(): boolean;
  66523. set useDiffuseColor(useDiffuseColor: boolean);
  66524. /**
  66525. * Array containing the excluded meshes not rendered in the internal pass
  66526. */
  66527. excludedMeshes: AbstractMesh[];
  66528. /**
  66529. * Controls the overall intensity of the post-process
  66530. */
  66531. exposure: number;
  66532. /**
  66533. * Dissipates each sample's contribution in range [0, 1]
  66534. */
  66535. decay: number;
  66536. /**
  66537. * Controls the overall intensity of each sample
  66538. */
  66539. weight: number;
  66540. /**
  66541. * Controls the density of each sample
  66542. */
  66543. density: number;
  66544. /**
  66545. * @constructor
  66546. * @param name The post-process name
  66547. * @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)
  66548. * @param camera The camera that the post-process will be attached to
  66549. * @param mesh The mesh used to create the light scattering
  66550. * @param samples The post-process quality, default 100
  66551. * @param samplingModeThe post-process filtering mode
  66552. * @param engine The babylon engine
  66553. * @param reusable If the post-process is reusable
  66554. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66555. */
  66556. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66557. /**
  66558. * Returns the string "VolumetricLightScatteringPostProcess"
  66559. * @returns "VolumetricLightScatteringPostProcess"
  66560. */
  66561. getClassName(): string;
  66562. private _isReady;
  66563. /**
  66564. * Sets the new light position for light scattering effect
  66565. * @param position The new custom light position
  66566. */
  66567. setCustomMeshPosition(position: Vector3): void;
  66568. /**
  66569. * Returns the light position for light scattering effect
  66570. * @return Vector3 The custom light position
  66571. */
  66572. getCustomMeshPosition(): Vector3;
  66573. /**
  66574. * Disposes the internal assets and detaches the post-process from the camera
  66575. */
  66576. dispose(camera: Camera): void;
  66577. /**
  66578. * Returns the render target texture used by the post-process
  66579. * @return the render target texture used by the post-process
  66580. */
  66581. getPass(): RenderTargetTexture;
  66582. private _meshExcluded;
  66583. private _createPass;
  66584. private _updateMeshScreenCoordinates;
  66585. /**
  66586. * Creates a default mesh for the Volumeric Light Scattering post-process
  66587. * @param name The mesh name
  66588. * @param scene The scene where to create the mesh
  66589. * @return the default mesh
  66590. */
  66591. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66592. }
  66593. }
  66594. declare module BABYLON {
  66595. interface Scene {
  66596. /** @hidden (Backing field) */
  66597. _boundingBoxRenderer: BoundingBoxRenderer;
  66598. /** @hidden (Backing field) */
  66599. _forceShowBoundingBoxes: boolean;
  66600. /**
  66601. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66602. */
  66603. forceShowBoundingBoxes: boolean;
  66604. /**
  66605. * Gets the bounding box renderer associated with the scene
  66606. * @returns a BoundingBoxRenderer
  66607. */
  66608. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66609. }
  66610. interface AbstractMesh {
  66611. /** @hidden (Backing field) */
  66612. _showBoundingBox: boolean;
  66613. /**
  66614. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66615. */
  66616. showBoundingBox: boolean;
  66617. }
  66618. /**
  66619. * Component responsible of rendering the bounding box of the meshes in a scene.
  66620. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66621. */
  66622. export class BoundingBoxRenderer implements ISceneComponent {
  66623. /**
  66624. * The component name helpfull to identify the component in the list of scene components.
  66625. */
  66626. readonly name: string;
  66627. /**
  66628. * The scene the component belongs to.
  66629. */
  66630. scene: Scene;
  66631. /**
  66632. * Color of the bounding box lines placed in front of an object
  66633. */
  66634. frontColor: Color3;
  66635. /**
  66636. * Color of the bounding box lines placed behind an object
  66637. */
  66638. backColor: Color3;
  66639. /**
  66640. * Defines if the renderer should show the back lines or not
  66641. */
  66642. showBackLines: boolean;
  66643. /**
  66644. * @hidden
  66645. */
  66646. renderList: SmartArray<BoundingBox>;
  66647. private _colorShader;
  66648. private _vertexBuffers;
  66649. private _indexBuffer;
  66650. private _fillIndexBuffer;
  66651. private _fillIndexData;
  66652. /**
  66653. * Instantiates a new bounding box renderer in a scene.
  66654. * @param scene the scene the renderer renders in
  66655. */
  66656. constructor(scene: Scene);
  66657. /**
  66658. * Registers the component in a given scene
  66659. */
  66660. register(): void;
  66661. private _evaluateSubMesh;
  66662. private _activeMesh;
  66663. private _prepareRessources;
  66664. private _createIndexBuffer;
  66665. /**
  66666. * Rebuilds the elements related to this component in case of
  66667. * context lost for instance.
  66668. */
  66669. rebuild(): void;
  66670. /**
  66671. * @hidden
  66672. */
  66673. reset(): void;
  66674. /**
  66675. * Render the bounding boxes of a specific rendering group
  66676. * @param renderingGroupId defines the rendering group to render
  66677. */
  66678. render(renderingGroupId: number): void;
  66679. /**
  66680. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66681. * @param mesh Define the mesh to render the occlusion bounding box for
  66682. */
  66683. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66684. /**
  66685. * Dispose and release the resources attached to this renderer.
  66686. */
  66687. dispose(): void;
  66688. }
  66689. }
  66690. declare module BABYLON {
  66691. interface Scene {
  66692. /** @hidden (Backing field) */
  66693. _depthRenderer: {
  66694. [id: string]: DepthRenderer;
  66695. };
  66696. /**
  66697. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66698. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66699. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66700. * @returns the created depth renderer
  66701. */
  66702. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66703. /**
  66704. * Disables a depth renderer for a given camera
  66705. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66706. */
  66707. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66708. }
  66709. /**
  66710. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66711. * in several rendering techniques.
  66712. */
  66713. export class DepthRendererSceneComponent implements ISceneComponent {
  66714. /**
  66715. * The component name helpfull to identify the component in the list of scene components.
  66716. */
  66717. readonly name: string;
  66718. /**
  66719. * The scene the component belongs to.
  66720. */
  66721. scene: Scene;
  66722. /**
  66723. * Creates a new instance of the component for the given scene
  66724. * @param scene Defines the scene to register the component in
  66725. */
  66726. constructor(scene: Scene);
  66727. /**
  66728. * Registers the component in a given scene
  66729. */
  66730. register(): void;
  66731. /**
  66732. * Rebuilds the elements related to this component in case of
  66733. * context lost for instance.
  66734. */
  66735. rebuild(): void;
  66736. /**
  66737. * Disposes the component and the associated ressources
  66738. */
  66739. dispose(): void;
  66740. private _gatherRenderTargets;
  66741. private _gatherActiveCameraRenderTargets;
  66742. }
  66743. }
  66744. declare module BABYLON {
  66745. /** @hidden */
  66746. export var outlinePixelShader: {
  66747. name: string;
  66748. shader: string;
  66749. };
  66750. }
  66751. declare module BABYLON {
  66752. /** @hidden */
  66753. export var outlineVertexShader: {
  66754. name: string;
  66755. shader: string;
  66756. };
  66757. }
  66758. declare module BABYLON {
  66759. interface Scene {
  66760. /** @hidden */
  66761. _outlineRenderer: OutlineRenderer;
  66762. /**
  66763. * Gets the outline renderer associated with the scene
  66764. * @returns a OutlineRenderer
  66765. */
  66766. getOutlineRenderer(): OutlineRenderer;
  66767. }
  66768. interface AbstractMesh {
  66769. /** @hidden (Backing field) */
  66770. _renderOutline: boolean;
  66771. /**
  66772. * Gets or sets a boolean indicating if the outline must be rendered as well
  66773. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66774. */
  66775. renderOutline: boolean;
  66776. /** @hidden (Backing field) */
  66777. _renderOverlay: boolean;
  66778. /**
  66779. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66780. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66781. */
  66782. renderOverlay: boolean;
  66783. }
  66784. /**
  66785. * This class is responsible to draw bothe outline/overlay of meshes.
  66786. * It should not be used directly but through the available method on mesh.
  66787. */
  66788. export class OutlineRenderer implements ISceneComponent {
  66789. /**
  66790. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66791. */
  66792. private static _StencilReference;
  66793. /**
  66794. * The name of the component. Each component must have a unique name.
  66795. */
  66796. name: string;
  66797. /**
  66798. * The scene the component belongs to.
  66799. */
  66800. scene: Scene;
  66801. /**
  66802. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66803. */
  66804. zOffset: number;
  66805. private _engine;
  66806. private _effect;
  66807. private _cachedDefines;
  66808. private _savedDepthWrite;
  66809. /**
  66810. * Instantiates a new outline renderer. (There could be only one per scene).
  66811. * @param scene Defines the scene it belongs to
  66812. */
  66813. constructor(scene: Scene);
  66814. /**
  66815. * Register the component to one instance of a scene.
  66816. */
  66817. register(): void;
  66818. /**
  66819. * Rebuilds the elements related to this component in case of
  66820. * context lost for instance.
  66821. */
  66822. rebuild(): void;
  66823. /**
  66824. * Disposes the component and the associated ressources.
  66825. */
  66826. dispose(): void;
  66827. /**
  66828. * Renders the outline in the canvas.
  66829. * @param subMesh Defines the sumesh to render
  66830. * @param batch Defines the batch of meshes in case of instances
  66831. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66832. */
  66833. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66834. /**
  66835. * Returns whether or not the outline renderer is ready for a given submesh.
  66836. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66837. * @param subMesh Defines the submesh to check readyness for
  66838. * @param useInstances Defines wheter wee are trying to render instances or not
  66839. * @returns true if ready otherwise false
  66840. */
  66841. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66842. private _beforeRenderingMesh;
  66843. private _afterRenderingMesh;
  66844. }
  66845. }
  66846. declare module BABYLON {
  66847. /**
  66848. * Defines the basic options interface of a Sprite Frame Source Size.
  66849. */
  66850. export interface ISpriteJSONSpriteSourceSize {
  66851. /**
  66852. * number of the original width of the Frame
  66853. */
  66854. w: number;
  66855. /**
  66856. * number of the original height of the Frame
  66857. */
  66858. h: number;
  66859. }
  66860. /**
  66861. * Defines the basic options interface of a Sprite Frame Data.
  66862. */
  66863. export interface ISpriteJSONSpriteFrameData {
  66864. /**
  66865. * number of the x offset of the Frame
  66866. */
  66867. x: number;
  66868. /**
  66869. * number of the y offset of the Frame
  66870. */
  66871. y: number;
  66872. /**
  66873. * number of the width of the Frame
  66874. */
  66875. w: number;
  66876. /**
  66877. * number of the height of the Frame
  66878. */
  66879. h: number;
  66880. }
  66881. /**
  66882. * Defines the basic options interface of a JSON Sprite.
  66883. */
  66884. export interface ISpriteJSONSprite {
  66885. /**
  66886. * string name of the Frame
  66887. */
  66888. filename: string;
  66889. /**
  66890. * ISpriteJSONSpriteFrame basic object of the frame data
  66891. */
  66892. frame: ISpriteJSONSpriteFrameData;
  66893. /**
  66894. * boolean to flag is the frame was rotated.
  66895. */
  66896. rotated: boolean;
  66897. /**
  66898. * boolean to flag is the frame was trimmed.
  66899. */
  66900. trimmed: boolean;
  66901. /**
  66902. * ISpriteJSONSpriteFrame basic object of the source data
  66903. */
  66904. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66905. /**
  66906. * ISpriteJSONSpriteFrame basic object of the source data
  66907. */
  66908. sourceSize: ISpriteJSONSpriteSourceSize;
  66909. }
  66910. /**
  66911. * Defines the basic options interface of a JSON atlas.
  66912. */
  66913. export interface ISpriteJSONAtlas {
  66914. /**
  66915. * Array of objects that contain the frame data.
  66916. */
  66917. frames: Array<ISpriteJSONSprite>;
  66918. /**
  66919. * object basic object containing the sprite meta data.
  66920. */
  66921. meta?: object;
  66922. }
  66923. }
  66924. declare module BABYLON {
  66925. /** @hidden */
  66926. export var spriteMapPixelShader: {
  66927. name: string;
  66928. shader: string;
  66929. };
  66930. }
  66931. declare module BABYLON {
  66932. /** @hidden */
  66933. export var spriteMapVertexShader: {
  66934. name: string;
  66935. shader: string;
  66936. };
  66937. }
  66938. declare module BABYLON {
  66939. /**
  66940. * Defines the basic options interface of a SpriteMap
  66941. */
  66942. export interface ISpriteMapOptions {
  66943. /**
  66944. * Vector2 of the number of cells in the grid.
  66945. */
  66946. stageSize?: Vector2;
  66947. /**
  66948. * Vector2 of the size of the output plane in World Units.
  66949. */
  66950. outputSize?: Vector2;
  66951. /**
  66952. * Vector3 of the position of the output plane in World Units.
  66953. */
  66954. outputPosition?: Vector3;
  66955. /**
  66956. * Vector3 of the rotation of the output plane.
  66957. */
  66958. outputRotation?: Vector3;
  66959. /**
  66960. * number of layers that the system will reserve in resources.
  66961. */
  66962. layerCount?: number;
  66963. /**
  66964. * number of max animation frames a single cell will reserve in resources.
  66965. */
  66966. maxAnimationFrames?: number;
  66967. /**
  66968. * number cell index of the base tile when the system compiles.
  66969. */
  66970. baseTile?: number;
  66971. /**
  66972. * boolean flip the sprite after its been repositioned by the framing data.
  66973. */
  66974. flipU?: boolean;
  66975. /**
  66976. * Vector3 scalar of the global RGB values of the SpriteMap.
  66977. */
  66978. colorMultiply?: Vector3;
  66979. }
  66980. /**
  66981. * Defines the IDisposable interface in order to be cleanable from resources.
  66982. */
  66983. export interface ISpriteMap extends IDisposable {
  66984. /**
  66985. * String name of the SpriteMap.
  66986. */
  66987. name: string;
  66988. /**
  66989. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66990. */
  66991. atlasJSON: ISpriteJSONAtlas;
  66992. /**
  66993. * Texture of the SpriteMap.
  66994. */
  66995. spriteSheet: Texture;
  66996. /**
  66997. * The parameters to initialize the SpriteMap with.
  66998. */
  66999. options: ISpriteMapOptions;
  67000. }
  67001. /**
  67002. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67003. */
  67004. export class SpriteMap implements ISpriteMap {
  67005. /** The Name of the spriteMap */
  67006. name: string;
  67007. /** The JSON file with the frame and meta data */
  67008. atlasJSON: ISpriteJSONAtlas;
  67009. /** The systems Sprite Sheet Texture */
  67010. spriteSheet: Texture;
  67011. /** Arguments passed with the Constructor */
  67012. options: ISpriteMapOptions;
  67013. /** Public Sprite Storage array, parsed from atlasJSON */
  67014. sprites: Array<ISpriteJSONSprite>;
  67015. /** Returns the Number of Sprites in the System */
  67016. get spriteCount(): number;
  67017. /** Returns the Position of Output Plane*/
  67018. get position(): Vector3;
  67019. /** Returns the Position of Output Plane*/
  67020. set position(v: Vector3);
  67021. /** Returns the Rotation of Output Plane*/
  67022. get rotation(): Vector3;
  67023. /** Returns the Rotation of Output Plane*/
  67024. set rotation(v: Vector3);
  67025. /** Sets the AnimationMap*/
  67026. get animationMap(): RawTexture;
  67027. /** Sets the AnimationMap*/
  67028. set animationMap(v: RawTexture);
  67029. /** Scene that the SpriteMap was created in */
  67030. private _scene;
  67031. /** Texture Buffer of Float32 that holds tile frame data*/
  67032. private _frameMap;
  67033. /** Texture Buffers of Float32 that holds tileMap data*/
  67034. private _tileMaps;
  67035. /** Texture Buffer of Float32 that holds Animation Data*/
  67036. private _animationMap;
  67037. /** Custom ShaderMaterial Central to the System*/
  67038. private _material;
  67039. /** Custom ShaderMaterial Central to the System*/
  67040. private _output;
  67041. /** Systems Time Ticker*/
  67042. private _time;
  67043. /**
  67044. * Creates a new SpriteMap
  67045. * @param name defines the SpriteMaps Name
  67046. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67047. * @param spriteSheet is the Texture that the Sprites are on.
  67048. * @param options a basic deployment configuration
  67049. * @param scene The Scene that the map is deployed on
  67050. */
  67051. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67052. /**
  67053. * Returns tileID location
  67054. * @returns Vector2 the cell position ID
  67055. */
  67056. getTileID(): Vector2;
  67057. /**
  67058. * Gets the UV location of the mouse over the SpriteMap.
  67059. * @returns Vector2 the UV position of the mouse interaction
  67060. */
  67061. getMousePosition(): Vector2;
  67062. /**
  67063. * Creates the "frame" texture Buffer
  67064. * -------------------------------------
  67065. * Structure of frames
  67066. * "filename": "Falling-Water-2.png",
  67067. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67068. * "rotated": true,
  67069. * "trimmed": true,
  67070. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67071. * "sourceSize": {"w":32,"h":32}
  67072. * @returns RawTexture of the frameMap
  67073. */
  67074. private _createFrameBuffer;
  67075. /**
  67076. * Creates the tileMap texture Buffer
  67077. * @param buffer normally and array of numbers, or a false to generate from scratch
  67078. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67079. * @returns RawTexture of the tileMap
  67080. */
  67081. private _createTileBuffer;
  67082. /**
  67083. * Modifies the data of the tileMaps
  67084. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67085. * @param pos is the iVector2 Coordinates of the Tile
  67086. * @param tile The SpriteIndex of the new Tile
  67087. */
  67088. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67089. /**
  67090. * Creates the animationMap texture Buffer
  67091. * @param buffer normally and array of numbers, or a false to generate from scratch
  67092. * @returns RawTexture of the animationMap
  67093. */
  67094. private _createTileAnimationBuffer;
  67095. /**
  67096. * Modifies the data of the animationMap
  67097. * @param cellID is the Index of the Sprite
  67098. * @param _frame is the target Animation frame
  67099. * @param toCell is the Target Index of the next frame of the animation
  67100. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67101. * @param speed is a global scalar of the time variable on the map.
  67102. */
  67103. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67104. /**
  67105. * Exports the .tilemaps file
  67106. */
  67107. saveTileMaps(): void;
  67108. /**
  67109. * Imports the .tilemaps file
  67110. * @param url of the .tilemaps file
  67111. */
  67112. loadTileMaps(url: string): void;
  67113. /**
  67114. * Release associated resources
  67115. */
  67116. dispose(): void;
  67117. }
  67118. }
  67119. declare module BABYLON {
  67120. /**
  67121. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67122. * @see http://doc.babylonjs.com/babylon101/sprites
  67123. */
  67124. export class SpritePackedManager extends SpriteManager {
  67125. /** defines the packed manager's name */
  67126. name: string;
  67127. /**
  67128. * Creates a new sprite manager from a packed sprite sheet
  67129. * @param name defines the manager's name
  67130. * @param imgUrl defines the sprite sheet url
  67131. * @param capacity defines the maximum allowed number of sprites
  67132. * @param scene defines the hosting scene
  67133. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67134. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67135. * @param samplingMode defines the smapling mode to use with spritesheet
  67136. * @param fromPacked set to true; do not alter
  67137. */
  67138. constructor(
  67139. /** defines the packed manager's name */
  67140. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67141. }
  67142. }
  67143. declare module BABYLON {
  67144. /**
  67145. * Defines the list of states available for a task inside a AssetsManager
  67146. */
  67147. export enum AssetTaskState {
  67148. /**
  67149. * Initialization
  67150. */
  67151. INIT = 0,
  67152. /**
  67153. * Running
  67154. */
  67155. RUNNING = 1,
  67156. /**
  67157. * Done
  67158. */
  67159. DONE = 2,
  67160. /**
  67161. * Error
  67162. */
  67163. ERROR = 3
  67164. }
  67165. /**
  67166. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67167. */
  67168. export abstract class AbstractAssetTask {
  67169. /**
  67170. * Task name
  67171. */ name: string;
  67172. /**
  67173. * Callback called when the task is successful
  67174. */
  67175. onSuccess: (task: any) => void;
  67176. /**
  67177. * Callback called when the task is not successful
  67178. */
  67179. onError: (task: any, message?: string, exception?: any) => void;
  67180. /**
  67181. * Creates a new AssetsManager
  67182. * @param name defines the name of the task
  67183. */
  67184. constructor(
  67185. /**
  67186. * Task name
  67187. */ name: string);
  67188. private _isCompleted;
  67189. private _taskState;
  67190. private _errorObject;
  67191. /**
  67192. * Get if the task is completed
  67193. */
  67194. get isCompleted(): boolean;
  67195. /**
  67196. * Gets the current state of the task
  67197. */
  67198. get taskState(): AssetTaskState;
  67199. /**
  67200. * Gets the current error object (if task is in error)
  67201. */
  67202. get errorObject(): {
  67203. message?: string;
  67204. exception?: any;
  67205. };
  67206. /**
  67207. * Internal only
  67208. * @hidden
  67209. */
  67210. _setErrorObject(message?: string, exception?: any): void;
  67211. /**
  67212. * Execute the current task
  67213. * @param scene defines the scene where you want your assets to be loaded
  67214. * @param onSuccess is a callback called when the task is successfully executed
  67215. * @param onError is a callback called if an error occurs
  67216. */
  67217. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67218. /**
  67219. * Execute the current task
  67220. * @param scene defines the scene where you want your assets to be loaded
  67221. * @param onSuccess is a callback called when the task is successfully executed
  67222. * @param onError is a callback called if an error occurs
  67223. */
  67224. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67225. /**
  67226. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67227. * This can be used with failed tasks that have the reason for failure fixed.
  67228. */
  67229. reset(): void;
  67230. private onErrorCallback;
  67231. private onDoneCallback;
  67232. }
  67233. /**
  67234. * Define the interface used by progress events raised during assets loading
  67235. */
  67236. export interface IAssetsProgressEvent {
  67237. /**
  67238. * Defines the number of remaining tasks to process
  67239. */
  67240. remainingCount: number;
  67241. /**
  67242. * Defines the total number of tasks
  67243. */
  67244. totalCount: number;
  67245. /**
  67246. * Defines the task that was just processed
  67247. */
  67248. task: AbstractAssetTask;
  67249. }
  67250. /**
  67251. * Class used to share progress information about assets loading
  67252. */
  67253. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67254. /**
  67255. * Defines the number of remaining tasks to process
  67256. */
  67257. remainingCount: number;
  67258. /**
  67259. * Defines the total number of tasks
  67260. */
  67261. totalCount: number;
  67262. /**
  67263. * Defines the task that was just processed
  67264. */
  67265. task: AbstractAssetTask;
  67266. /**
  67267. * Creates a AssetsProgressEvent
  67268. * @param remainingCount defines the number of remaining tasks to process
  67269. * @param totalCount defines the total number of tasks
  67270. * @param task defines the task that was just processed
  67271. */
  67272. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67273. }
  67274. /**
  67275. * Define a task used by AssetsManager to load meshes
  67276. */
  67277. export class MeshAssetTask extends AbstractAssetTask {
  67278. /**
  67279. * Defines the name of the task
  67280. */
  67281. name: string;
  67282. /**
  67283. * Defines the list of mesh's names you want to load
  67284. */
  67285. meshesNames: any;
  67286. /**
  67287. * Defines the root url to use as a base to load your meshes and associated resources
  67288. */
  67289. rootUrl: string;
  67290. /**
  67291. * Defines the filename of the scene to load from
  67292. */
  67293. sceneFilename: string;
  67294. /**
  67295. * Gets the list of loaded meshes
  67296. */
  67297. loadedMeshes: Array<AbstractMesh>;
  67298. /**
  67299. * Gets the list of loaded particle systems
  67300. */
  67301. loadedParticleSystems: Array<IParticleSystem>;
  67302. /**
  67303. * Gets the list of loaded skeletons
  67304. */
  67305. loadedSkeletons: Array<Skeleton>;
  67306. /**
  67307. * Gets the list of loaded animation groups
  67308. */
  67309. loadedAnimationGroups: Array<AnimationGroup>;
  67310. /**
  67311. * Callback called when the task is successful
  67312. */
  67313. onSuccess: (task: MeshAssetTask) => void;
  67314. /**
  67315. * Callback called when the task is successful
  67316. */
  67317. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67318. /**
  67319. * Creates a new MeshAssetTask
  67320. * @param name defines the name of the task
  67321. * @param meshesNames defines the list of mesh's names you want to load
  67322. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67323. * @param sceneFilename defines the filename of the scene to load from
  67324. */
  67325. constructor(
  67326. /**
  67327. * Defines the name of the task
  67328. */
  67329. name: string,
  67330. /**
  67331. * Defines the list of mesh's names you want to load
  67332. */
  67333. meshesNames: any,
  67334. /**
  67335. * Defines the root url to use as a base to load your meshes and associated resources
  67336. */
  67337. rootUrl: string,
  67338. /**
  67339. * Defines the filename of the scene to load from
  67340. */
  67341. sceneFilename: string);
  67342. /**
  67343. * Execute the current task
  67344. * @param scene defines the scene where you want your assets to be loaded
  67345. * @param onSuccess is a callback called when the task is successfully executed
  67346. * @param onError is a callback called if an error occurs
  67347. */
  67348. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67349. }
  67350. /**
  67351. * Define a task used by AssetsManager to load text content
  67352. */
  67353. export class TextFileAssetTask extends AbstractAssetTask {
  67354. /**
  67355. * Defines the name of the task
  67356. */
  67357. name: string;
  67358. /**
  67359. * Defines the location of the file to load
  67360. */
  67361. url: string;
  67362. /**
  67363. * Gets the loaded text string
  67364. */
  67365. text: string;
  67366. /**
  67367. * Callback called when the task is successful
  67368. */
  67369. onSuccess: (task: TextFileAssetTask) => void;
  67370. /**
  67371. * Callback called when the task is successful
  67372. */
  67373. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67374. /**
  67375. * Creates a new TextFileAssetTask object
  67376. * @param name defines the name of the task
  67377. * @param url defines the location of the file to load
  67378. */
  67379. constructor(
  67380. /**
  67381. * Defines the name of the task
  67382. */
  67383. name: string,
  67384. /**
  67385. * Defines the location of the file to load
  67386. */
  67387. url: string);
  67388. /**
  67389. * Execute the current task
  67390. * @param scene defines the scene where you want your assets to be loaded
  67391. * @param onSuccess is a callback called when the task is successfully executed
  67392. * @param onError is a callback called if an error occurs
  67393. */
  67394. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67395. }
  67396. /**
  67397. * Define a task used by AssetsManager to load binary data
  67398. */
  67399. export class BinaryFileAssetTask extends AbstractAssetTask {
  67400. /**
  67401. * Defines the name of the task
  67402. */
  67403. name: string;
  67404. /**
  67405. * Defines the location of the file to load
  67406. */
  67407. url: string;
  67408. /**
  67409. * Gets the lodaded data (as an array buffer)
  67410. */
  67411. data: ArrayBuffer;
  67412. /**
  67413. * Callback called when the task is successful
  67414. */
  67415. onSuccess: (task: BinaryFileAssetTask) => void;
  67416. /**
  67417. * Callback called when the task is successful
  67418. */
  67419. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67420. /**
  67421. * Creates a new BinaryFileAssetTask object
  67422. * @param name defines the name of the new task
  67423. * @param url defines the location of the file to load
  67424. */
  67425. constructor(
  67426. /**
  67427. * Defines the name of the task
  67428. */
  67429. name: string,
  67430. /**
  67431. * Defines the location of the file to load
  67432. */
  67433. url: string);
  67434. /**
  67435. * Execute the current task
  67436. * @param scene defines the scene where you want your assets to be loaded
  67437. * @param onSuccess is a callback called when the task is successfully executed
  67438. * @param onError is a callback called if an error occurs
  67439. */
  67440. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67441. }
  67442. /**
  67443. * Define a task used by AssetsManager to load images
  67444. */
  67445. export class ImageAssetTask extends AbstractAssetTask {
  67446. /**
  67447. * Defines the name of the task
  67448. */
  67449. name: string;
  67450. /**
  67451. * Defines the location of the image to load
  67452. */
  67453. url: string;
  67454. /**
  67455. * Gets the loaded images
  67456. */
  67457. image: HTMLImageElement;
  67458. /**
  67459. * Callback called when the task is successful
  67460. */
  67461. onSuccess: (task: ImageAssetTask) => void;
  67462. /**
  67463. * Callback called when the task is successful
  67464. */
  67465. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67466. /**
  67467. * Creates a new ImageAssetTask
  67468. * @param name defines the name of the task
  67469. * @param url defines the location of the image to load
  67470. */
  67471. constructor(
  67472. /**
  67473. * Defines the name of the task
  67474. */
  67475. name: string,
  67476. /**
  67477. * Defines the location of the image to load
  67478. */
  67479. url: string);
  67480. /**
  67481. * Execute the current task
  67482. * @param scene defines the scene where you want your assets to be loaded
  67483. * @param onSuccess is a callback called when the task is successfully executed
  67484. * @param onError is a callback called if an error occurs
  67485. */
  67486. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67487. }
  67488. /**
  67489. * Defines the interface used by texture loading tasks
  67490. */
  67491. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67492. /**
  67493. * Gets the loaded texture
  67494. */
  67495. texture: TEX;
  67496. }
  67497. /**
  67498. * Define a task used by AssetsManager to load 2D textures
  67499. */
  67500. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67501. /**
  67502. * Defines the name of the task
  67503. */
  67504. name: string;
  67505. /**
  67506. * Defines the location of the file to load
  67507. */
  67508. url: string;
  67509. /**
  67510. * Defines if mipmap should not be generated (default is false)
  67511. */
  67512. noMipmap?: boolean | undefined;
  67513. /**
  67514. * Defines if texture must be inverted on Y axis (default is false)
  67515. */
  67516. invertY?: boolean | undefined;
  67517. /**
  67518. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67519. */
  67520. samplingMode: number;
  67521. /**
  67522. * Gets the loaded texture
  67523. */
  67524. texture: Texture;
  67525. /**
  67526. * Callback called when the task is successful
  67527. */
  67528. onSuccess: (task: TextureAssetTask) => void;
  67529. /**
  67530. * Callback called when the task is successful
  67531. */
  67532. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67533. /**
  67534. * Creates a new TextureAssetTask object
  67535. * @param name defines the name of the task
  67536. * @param url defines the location of the file to load
  67537. * @param noMipmap defines if mipmap should not be generated (default is false)
  67538. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67539. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67540. */
  67541. constructor(
  67542. /**
  67543. * Defines the name of the task
  67544. */
  67545. name: string,
  67546. /**
  67547. * Defines the location of the file to load
  67548. */
  67549. url: string,
  67550. /**
  67551. * Defines if mipmap should not be generated (default is false)
  67552. */
  67553. noMipmap?: boolean | undefined,
  67554. /**
  67555. * Defines if texture must be inverted on Y axis (default is false)
  67556. */
  67557. invertY?: boolean | undefined,
  67558. /**
  67559. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67560. */
  67561. samplingMode?: number);
  67562. /**
  67563. * Execute the current task
  67564. * @param scene defines the scene where you want your assets to be loaded
  67565. * @param onSuccess is a callback called when the task is successfully executed
  67566. * @param onError is a callback called if an error occurs
  67567. */
  67568. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67569. }
  67570. /**
  67571. * Define a task used by AssetsManager to load cube textures
  67572. */
  67573. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67574. /**
  67575. * Defines the name of the task
  67576. */
  67577. name: string;
  67578. /**
  67579. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67580. */
  67581. url: string;
  67582. /**
  67583. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67584. */
  67585. extensions?: string[] | undefined;
  67586. /**
  67587. * Defines if mipmaps should not be generated (default is false)
  67588. */
  67589. noMipmap?: boolean | undefined;
  67590. /**
  67591. * Defines the explicit list of files (undefined by default)
  67592. */
  67593. files?: string[] | undefined;
  67594. /**
  67595. * Gets the loaded texture
  67596. */
  67597. texture: CubeTexture;
  67598. /**
  67599. * Callback called when the task is successful
  67600. */
  67601. onSuccess: (task: CubeTextureAssetTask) => void;
  67602. /**
  67603. * Callback called when the task is successful
  67604. */
  67605. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67606. /**
  67607. * Creates a new CubeTextureAssetTask
  67608. * @param name defines the name of the task
  67609. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67610. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67611. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67612. * @param files defines the explicit list of files (undefined by default)
  67613. */
  67614. constructor(
  67615. /**
  67616. * Defines the name of the task
  67617. */
  67618. name: string,
  67619. /**
  67620. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67621. */
  67622. url: string,
  67623. /**
  67624. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67625. */
  67626. extensions?: string[] | undefined,
  67627. /**
  67628. * Defines if mipmaps should not be generated (default is false)
  67629. */
  67630. noMipmap?: boolean | undefined,
  67631. /**
  67632. * Defines the explicit list of files (undefined by default)
  67633. */
  67634. files?: string[] | undefined);
  67635. /**
  67636. * Execute the current task
  67637. * @param scene defines the scene where you want your assets to be loaded
  67638. * @param onSuccess is a callback called when the task is successfully executed
  67639. * @param onError is a callback called if an error occurs
  67640. */
  67641. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67642. }
  67643. /**
  67644. * Define a task used by AssetsManager to load HDR cube textures
  67645. */
  67646. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67647. /**
  67648. * Defines the name of the task
  67649. */
  67650. name: string;
  67651. /**
  67652. * Defines the location of the file to load
  67653. */
  67654. url: string;
  67655. /**
  67656. * Defines the desired size (the more it increases the longer the generation will be)
  67657. */
  67658. size: number;
  67659. /**
  67660. * Defines if mipmaps should not be generated (default is false)
  67661. */
  67662. noMipmap: boolean;
  67663. /**
  67664. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67665. */
  67666. generateHarmonics: boolean;
  67667. /**
  67668. * 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)
  67669. */
  67670. gammaSpace: boolean;
  67671. /**
  67672. * Internal Use Only
  67673. */
  67674. reserved: boolean;
  67675. /**
  67676. * Gets the loaded texture
  67677. */
  67678. texture: HDRCubeTexture;
  67679. /**
  67680. * Callback called when the task is successful
  67681. */
  67682. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67683. /**
  67684. * Callback called when the task is successful
  67685. */
  67686. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67687. /**
  67688. * Creates a new HDRCubeTextureAssetTask object
  67689. * @param name defines the name of the task
  67690. * @param url defines the location of the file to load
  67691. * @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.
  67692. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67693. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67694. * @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)
  67695. * @param reserved Internal use only
  67696. */
  67697. constructor(
  67698. /**
  67699. * Defines the name of the task
  67700. */
  67701. name: string,
  67702. /**
  67703. * Defines the location of the file to load
  67704. */
  67705. url: string,
  67706. /**
  67707. * Defines the desired size (the more it increases the longer the generation will be)
  67708. */
  67709. size: number,
  67710. /**
  67711. * Defines if mipmaps should not be generated (default is false)
  67712. */
  67713. noMipmap?: boolean,
  67714. /**
  67715. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67716. */
  67717. generateHarmonics?: boolean,
  67718. /**
  67719. * 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)
  67720. */
  67721. gammaSpace?: boolean,
  67722. /**
  67723. * Internal Use Only
  67724. */
  67725. reserved?: boolean);
  67726. /**
  67727. * Execute the current task
  67728. * @param scene defines the scene where you want your assets to be loaded
  67729. * @param onSuccess is a callback called when the task is successfully executed
  67730. * @param onError is a callback called if an error occurs
  67731. */
  67732. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67733. }
  67734. /**
  67735. * Define a task used by AssetsManager to load Equirectangular cube textures
  67736. */
  67737. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67738. /**
  67739. * Defines the name of the task
  67740. */
  67741. name: string;
  67742. /**
  67743. * Defines the location of the file to load
  67744. */
  67745. url: string;
  67746. /**
  67747. * Defines the desired size (the more it increases the longer the generation will be)
  67748. */
  67749. size: number;
  67750. /**
  67751. * Defines if mipmaps should not be generated (default is false)
  67752. */
  67753. noMipmap: boolean;
  67754. /**
  67755. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67756. * but the standard material would require them in Gamma space) (default is true)
  67757. */
  67758. gammaSpace: boolean;
  67759. /**
  67760. * Gets the loaded texture
  67761. */
  67762. texture: EquiRectangularCubeTexture;
  67763. /**
  67764. * Callback called when the task is successful
  67765. */
  67766. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67767. /**
  67768. * Callback called when the task is successful
  67769. */
  67770. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67771. /**
  67772. * Creates a new EquiRectangularCubeTextureAssetTask object
  67773. * @param name defines the name of the task
  67774. * @param url defines the location of the file to load
  67775. * @param size defines the desired size (the more it increases the longer the generation will be)
  67776. * If the size is omitted this implies you are using a preprocessed cubemap.
  67777. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67778. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67779. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67780. * (default is true)
  67781. */
  67782. constructor(
  67783. /**
  67784. * Defines the name of the task
  67785. */
  67786. name: string,
  67787. /**
  67788. * Defines the location of the file to load
  67789. */
  67790. url: string,
  67791. /**
  67792. * Defines the desired size (the more it increases the longer the generation will be)
  67793. */
  67794. size: number,
  67795. /**
  67796. * Defines if mipmaps should not be generated (default is false)
  67797. */
  67798. noMipmap?: boolean,
  67799. /**
  67800. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67801. * but the standard material would require them in Gamma space) (default is true)
  67802. */
  67803. gammaSpace?: boolean);
  67804. /**
  67805. * Execute the current task
  67806. * @param scene defines the scene where you want your assets to be loaded
  67807. * @param onSuccess is a callback called when the task is successfully executed
  67808. * @param onError is a callback called if an error occurs
  67809. */
  67810. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67811. }
  67812. /**
  67813. * This class can be used to easily import assets into a scene
  67814. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67815. */
  67816. export class AssetsManager {
  67817. private _scene;
  67818. private _isLoading;
  67819. protected _tasks: AbstractAssetTask[];
  67820. protected _waitingTasksCount: number;
  67821. protected _totalTasksCount: number;
  67822. /**
  67823. * Callback called when all tasks are processed
  67824. */
  67825. onFinish: (tasks: AbstractAssetTask[]) => void;
  67826. /**
  67827. * Callback called when a task is successful
  67828. */
  67829. onTaskSuccess: (task: AbstractAssetTask) => void;
  67830. /**
  67831. * Callback called when a task had an error
  67832. */
  67833. onTaskError: (task: AbstractAssetTask) => void;
  67834. /**
  67835. * Callback called when a task is done (whatever the result is)
  67836. */
  67837. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67838. /**
  67839. * Observable called when all tasks are processed
  67840. */
  67841. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67842. /**
  67843. * Observable called when a task had an error
  67844. */
  67845. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67846. /**
  67847. * Observable called when all tasks were executed
  67848. */
  67849. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67850. /**
  67851. * Observable called when a task is done (whatever the result is)
  67852. */
  67853. onProgressObservable: Observable<IAssetsProgressEvent>;
  67854. /**
  67855. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67856. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67857. */
  67858. useDefaultLoadingScreen: boolean;
  67859. /**
  67860. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67861. * when all assets have been downloaded.
  67862. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67863. */
  67864. autoHideLoadingUI: boolean;
  67865. /**
  67866. * Creates a new AssetsManager
  67867. * @param scene defines the scene to work on
  67868. */
  67869. constructor(scene: Scene);
  67870. /**
  67871. * Add a MeshAssetTask to the list of active tasks
  67872. * @param taskName defines the name of the new task
  67873. * @param meshesNames defines the name of meshes to load
  67874. * @param rootUrl defines the root url to use to locate files
  67875. * @param sceneFilename defines the filename of the scene file
  67876. * @returns a new MeshAssetTask object
  67877. */
  67878. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67879. /**
  67880. * Add a TextFileAssetTask to the list of active tasks
  67881. * @param taskName defines the name of the new task
  67882. * @param url defines the url of the file to load
  67883. * @returns a new TextFileAssetTask object
  67884. */
  67885. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67886. /**
  67887. * Add a BinaryFileAssetTask to the list of active tasks
  67888. * @param taskName defines the name of the new task
  67889. * @param url defines the url of the file to load
  67890. * @returns a new BinaryFileAssetTask object
  67891. */
  67892. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67893. /**
  67894. * Add a ImageAssetTask to the list of active tasks
  67895. * @param taskName defines the name of the new task
  67896. * @param url defines the url of the file to load
  67897. * @returns a new ImageAssetTask object
  67898. */
  67899. addImageTask(taskName: string, url: string): ImageAssetTask;
  67900. /**
  67901. * Add a TextureAssetTask to the list of active tasks
  67902. * @param taskName defines the name of the new task
  67903. * @param url defines the url of the file to load
  67904. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67905. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67906. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67907. * @returns a new TextureAssetTask object
  67908. */
  67909. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67910. /**
  67911. * Add a CubeTextureAssetTask to the list of active tasks
  67912. * @param taskName defines the name of the new task
  67913. * @param url defines the url of the file to load
  67914. * @param extensions defines the extension to use to load the cube map (can be null)
  67915. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67916. * @param files defines the list of files to load (can be null)
  67917. * @returns a new CubeTextureAssetTask object
  67918. */
  67919. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67920. /**
  67921. *
  67922. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67923. * @param taskName defines the name of the new task
  67924. * @param url defines the url of the file to load
  67925. * @param size defines the size you want for the cubemap (can be null)
  67926. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67927. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67928. * @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)
  67929. * @param reserved Internal use only
  67930. * @returns a new HDRCubeTextureAssetTask object
  67931. */
  67932. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67933. /**
  67934. *
  67935. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67936. * @param taskName defines the name of the new task
  67937. * @param url defines the url of the file to load
  67938. * @param size defines the size you want for the cubemap (can be null)
  67939. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67940. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67941. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67942. * @returns a new EquiRectangularCubeTextureAssetTask object
  67943. */
  67944. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67945. /**
  67946. * Remove a task from the assets manager.
  67947. * @param task the task to remove
  67948. */
  67949. removeTask(task: AbstractAssetTask): void;
  67950. private _decreaseWaitingTasksCount;
  67951. private _runTask;
  67952. /**
  67953. * Reset the AssetsManager and remove all tasks
  67954. * @return the current instance of the AssetsManager
  67955. */
  67956. reset(): AssetsManager;
  67957. /**
  67958. * Start the loading process
  67959. * @return the current instance of the AssetsManager
  67960. */
  67961. load(): AssetsManager;
  67962. /**
  67963. * Start the loading process as an async operation
  67964. * @return a promise returning the list of failed tasks
  67965. */
  67966. loadAsync(): Promise<void>;
  67967. }
  67968. }
  67969. declare module BABYLON {
  67970. /**
  67971. * Wrapper class for promise with external resolve and reject.
  67972. */
  67973. export class Deferred<T> {
  67974. /**
  67975. * The promise associated with this deferred object.
  67976. */
  67977. readonly promise: Promise<T>;
  67978. private _resolve;
  67979. private _reject;
  67980. /**
  67981. * The resolve method of the promise associated with this deferred object.
  67982. */
  67983. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67984. /**
  67985. * The reject method of the promise associated with this deferred object.
  67986. */
  67987. get reject(): (reason?: any) => void;
  67988. /**
  67989. * Constructor for this deferred object.
  67990. */
  67991. constructor();
  67992. }
  67993. }
  67994. declare module BABYLON {
  67995. /**
  67996. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67997. */
  67998. export class MeshExploder {
  67999. private _centerMesh;
  68000. private _meshes;
  68001. private _meshesOrigins;
  68002. private _toCenterVectors;
  68003. private _scaledDirection;
  68004. private _newPosition;
  68005. private _centerPosition;
  68006. /**
  68007. * Explodes meshes from a center mesh.
  68008. * @param meshes The meshes to explode.
  68009. * @param centerMesh The mesh to be center of explosion.
  68010. */
  68011. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68012. private _setCenterMesh;
  68013. /**
  68014. * Get class name
  68015. * @returns "MeshExploder"
  68016. */
  68017. getClassName(): string;
  68018. /**
  68019. * "Exploded meshes"
  68020. * @returns Array of meshes with the centerMesh at index 0.
  68021. */
  68022. getMeshes(): Array<Mesh>;
  68023. /**
  68024. * Explodes meshes giving a specific direction
  68025. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68026. */
  68027. explode(direction?: number): void;
  68028. }
  68029. }
  68030. declare module BABYLON {
  68031. /**
  68032. * Class used to help managing file picking and drag'n'drop
  68033. */
  68034. export class FilesInput {
  68035. /**
  68036. * List of files ready to be loaded
  68037. */
  68038. static get FilesToLoad(): {
  68039. [key: string]: File;
  68040. };
  68041. /**
  68042. * Callback called when a file is processed
  68043. */
  68044. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68045. private _engine;
  68046. private _currentScene;
  68047. private _sceneLoadedCallback;
  68048. private _progressCallback;
  68049. private _additionalRenderLoopLogicCallback;
  68050. private _textureLoadingCallback;
  68051. private _startingProcessingFilesCallback;
  68052. private _onReloadCallback;
  68053. private _errorCallback;
  68054. private _elementToMonitor;
  68055. private _sceneFileToLoad;
  68056. private _filesToLoad;
  68057. /**
  68058. * Creates a new FilesInput
  68059. * @param engine defines the rendering engine
  68060. * @param scene defines the hosting scene
  68061. * @param sceneLoadedCallback callback called when scene is loaded
  68062. * @param progressCallback callback called to track progress
  68063. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68064. * @param textureLoadingCallback callback called when a texture is loading
  68065. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68066. * @param onReloadCallback callback called when a reload is requested
  68067. * @param errorCallback callback call if an error occurs
  68068. */
  68069. 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);
  68070. private _dragEnterHandler;
  68071. private _dragOverHandler;
  68072. private _dropHandler;
  68073. /**
  68074. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68075. * @param elementToMonitor defines the DOM element to track
  68076. */
  68077. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68078. /**
  68079. * Release all associated resources
  68080. */
  68081. dispose(): void;
  68082. private renderFunction;
  68083. private drag;
  68084. private drop;
  68085. private _traverseFolder;
  68086. private _processFiles;
  68087. /**
  68088. * Load files from a drop event
  68089. * @param event defines the drop event to use as source
  68090. */
  68091. loadFiles(event: any): void;
  68092. private _processReload;
  68093. /**
  68094. * Reload the current scene from the loaded files
  68095. */
  68096. reload(): void;
  68097. }
  68098. }
  68099. declare module BABYLON {
  68100. /**
  68101. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68102. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68103. */
  68104. export class SceneOptimization {
  68105. /**
  68106. * Defines the priority of this optimization (0 by default which means first in the list)
  68107. */
  68108. priority: number;
  68109. /**
  68110. * Gets a string describing the action executed by the current optimization
  68111. * @returns description string
  68112. */
  68113. getDescription(): string;
  68114. /**
  68115. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68116. * @param scene defines the current scene where to apply this optimization
  68117. * @param optimizer defines the current optimizer
  68118. * @returns true if everything that can be done was applied
  68119. */
  68120. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68121. /**
  68122. * Creates the SceneOptimization object
  68123. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68124. * @param desc defines the description associated with the optimization
  68125. */
  68126. constructor(
  68127. /**
  68128. * Defines the priority of this optimization (0 by default which means first in the list)
  68129. */
  68130. priority?: number);
  68131. }
  68132. /**
  68133. * Defines an optimization used to reduce the size of render target textures
  68134. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68135. */
  68136. export class TextureOptimization extends SceneOptimization {
  68137. /**
  68138. * Defines the priority of this optimization (0 by default which means first in the list)
  68139. */
  68140. priority: number;
  68141. /**
  68142. * 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
  68143. */
  68144. maximumSize: number;
  68145. /**
  68146. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68147. */
  68148. step: number;
  68149. /**
  68150. * Gets a string describing the action executed by the current optimization
  68151. * @returns description string
  68152. */
  68153. getDescription(): string;
  68154. /**
  68155. * Creates the TextureOptimization object
  68156. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68157. * @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
  68158. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68159. */
  68160. constructor(
  68161. /**
  68162. * Defines the priority of this optimization (0 by default which means first in the list)
  68163. */
  68164. priority?: number,
  68165. /**
  68166. * 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
  68167. */
  68168. maximumSize?: number,
  68169. /**
  68170. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68171. */
  68172. step?: number);
  68173. /**
  68174. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68175. * @param scene defines the current scene where to apply this optimization
  68176. * @param optimizer defines the current optimizer
  68177. * @returns true if everything that can be done was applied
  68178. */
  68179. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68180. }
  68181. /**
  68182. * Defines an optimization used to increase or decrease the rendering resolution
  68183. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68184. */
  68185. export class HardwareScalingOptimization extends SceneOptimization {
  68186. /**
  68187. * Defines the priority of this optimization (0 by default which means first in the list)
  68188. */
  68189. priority: number;
  68190. /**
  68191. * Defines the maximum scale to use (2 by default)
  68192. */
  68193. maximumScale: number;
  68194. /**
  68195. * Defines the step to use between two passes (0.5 by default)
  68196. */
  68197. step: number;
  68198. private _currentScale;
  68199. private _directionOffset;
  68200. /**
  68201. * Gets a string describing the action executed by the current optimization
  68202. * @return description string
  68203. */
  68204. getDescription(): string;
  68205. /**
  68206. * Creates the HardwareScalingOptimization object
  68207. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68208. * @param maximumScale defines the maximum scale to use (2 by default)
  68209. * @param step defines the step to use between two passes (0.5 by default)
  68210. */
  68211. constructor(
  68212. /**
  68213. * Defines the priority of this optimization (0 by default which means first in the list)
  68214. */
  68215. priority?: number,
  68216. /**
  68217. * Defines the maximum scale to use (2 by default)
  68218. */
  68219. maximumScale?: number,
  68220. /**
  68221. * Defines the step to use between two passes (0.5 by default)
  68222. */
  68223. step?: number);
  68224. /**
  68225. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68226. * @param scene defines the current scene where to apply this optimization
  68227. * @param optimizer defines the current optimizer
  68228. * @returns true if everything that can be done was applied
  68229. */
  68230. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68231. }
  68232. /**
  68233. * Defines an optimization used to remove shadows
  68234. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68235. */
  68236. export class ShadowsOptimization extends SceneOptimization {
  68237. /**
  68238. * Gets a string describing the action executed by the current optimization
  68239. * @return description string
  68240. */
  68241. getDescription(): string;
  68242. /**
  68243. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68244. * @param scene defines the current scene where to apply this optimization
  68245. * @param optimizer defines the current optimizer
  68246. * @returns true if everything that can be done was applied
  68247. */
  68248. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68249. }
  68250. /**
  68251. * Defines an optimization used to turn post-processes off
  68252. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68253. */
  68254. export class PostProcessesOptimization extends SceneOptimization {
  68255. /**
  68256. * Gets a string describing the action executed by the current optimization
  68257. * @return description string
  68258. */
  68259. getDescription(): string;
  68260. /**
  68261. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68262. * @param scene defines the current scene where to apply this optimization
  68263. * @param optimizer defines the current optimizer
  68264. * @returns true if everything that can be done was applied
  68265. */
  68266. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68267. }
  68268. /**
  68269. * Defines an optimization used to turn lens flares off
  68270. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68271. */
  68272. export class LensFlaresOptimization extends SceneOptimization {
  68273. /**
  68274. * Gets a string describing the action executed by the current optimization
  68275. * @return description string
  68276. */
  68277. getDescription(): string;
  68278. /**
  68279. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68280. * @param scene defines the current scene where to apply this optimization
  68281. * @param optimizer defines the current optimizer
  68282. * @returns true if everything that can be done was applied
  68283. */
  68284. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68285. }
  68286. /**
  68287. * Defines an optimization based on user defined callback.
  68288. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68289. */
  68290. export class CustomOptimization extends SceneOptimization {
  68291. /**
  68292. * Callback called to apply the custom optimization.
  68293. */
  68294. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68295. /**
  68296. * Callback called to get custom description
  68297. */
  68298. onGetDescription: () => string;
  68299. /**
  68300. * Gets a string describing the action executed by the current optimization
  68301. * @returns description string
  68302. */
  68303. getDescription(): string;
  68304. /**
  68305. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68306. * @param scene defines the current scene where to apply this optimization
  68307. * @param optimizer defines the current optimizer
  68308. * @returns true if everything that can be done was applied
  68309. */
  68310. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68311. }
  68312. /**
  68313. * Defines an optimization used to turn particles off
  68314. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68315. */
  68316. export class ParticlesOptimization extends SceneOptimization {
  68317. /**
  68318. * Gets a string describing the action executed by the current optimization
  68319. * @return description string
  68320. */
  68321. getDescription(): string;
  68322. /**
  68323. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68324. * @param scene defines the current scene where to apply this optimization
  68325. * @param optimizer defines the current optimizer
  68326. * @returns true if everything that can be done was applied
  68327. */
  68328. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68329. }
  68330. /**
  68331. * Defines an optimization used to turn render targets off
  68332. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68333. */
  68334. export class RenderTargetsOptimization extends SceneOptimization {
  68335. /**
  68336. * Gets a string describing the action executed by the current optimization
  68337. * @return description string
  68338. */
  68339. getDescription(): string;
  68340. /**
  68341. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68342. * @param scene defines the current scene where to apply this optimization
  68343. * @param optimizer defines the current optimizer
  68344. * @returns true if everything that can be done was applied
  68345. */
  68346. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68347. }
  68348. /**
  68349. * Defines an optimization used to merge meshes with compatible materials
  68350. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68351. */
  68352. export class MergeMeshesOptimization extends SceneOptimization {
  68353. private static _UpdateSelectionTree;
  68354. /**
  68355. * Gets or sets a boolean which defines if optimization octree has to be updated
  68356. */
  68357. static get UpdateSelectionTree(): boolean;
  68358. /**
  68359. * Gets or sets a boolean which defines if optimization octree has to be updated
  68360. */
  68361. static set UpdateSelectionTree(value: boolean);
  68362. /**
  68363. * Gets a string describing the action executed by the current optimization
  68364. * @return description string
  68365. */
  68366. getDescription(): string;
  68367. private _canBeMerged;
  68368. /**
  68369. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68370. * @param scene defines the current scene where to apply this optimization
  68371. * @param optimizer defines the current optimizer
  68372. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68373. * @returns true if everything that can be done was applied
  68374. */
  68375. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68376. }
  68377. /**
  68378. * Defines a list of options used by SceneOptimizer
  68379. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68380. */
  68381. export class SceneOptimizerOptions {
  68382. /**
  68383. * Defines the target frame rate to reach (60 by default)
  68384. */
  68385. targetFrameRate: number;
  68386. /**
  68387. * Defines the interval between two checkes (2000ms by default)
  68388. */
  68389. trackerDuration: number;
  68390. /**
  68391. * Gets the list of optimizations to apply
  68392. */
  68393. optimizations: SceneOptimization[];
  68394. /**
  68395. * Creates a new list of options used by SceneOptimizer
  68396. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68397. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68398. */
  68399. constructor(
  68400. /**
  68401. * Defines the target frame rate to reach (60 by default)
  68402. */
  68403. targetFrameRate?: number,
  68404. /**
  68405. * Defines the interval between two checkes (2000ms by default)
  68406. */
  68407. trackerDuration?: number);
  68408. /**
  68409. * Add a new optimization
  68410. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68411. * @returns the current SceneOptimizerOptions
  68412. */
  68413. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68414. /**
  68415. * Add a new custom optimization
  68416. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68417. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68418. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68419. * @returns the current SceneOptimizerOptions
  68420. */
  68421. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68422. /**
  68423. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68424. * @param targetFrameRate defines the target frame rate (60 by default)
  68425. * @returns a SceneOptimizerOptions object
  68426. */
  68427. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68428. /**
  68429. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68430. * @param targetFrameRate defines the target frame rate (60 by default)
  68431. * @returns a SceneOptimizerOptions object
  68432. */
  68433. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68434. /**
  68435. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68436. * @param targetFrameRate defines the target frame rate (60 by default)
  68437. * @returns a SceneOptimizerOptions object
  68438. */
  68439. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68440. }
  68441. /**
  68442. * Class used to run optimizations in order to reach a target frame rate
  68443. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68444. */
  68445. export class SceneOptimizer implements IDisposable {
  68446. private _isRunning;
  68447. private _options;
  68448. private _scene;
  68449. private _currentPriorityLevel;
  68450. private _targetFrameRate;
  68451. private _trackerDuration;
  68452. private _currentFrameRate;
  68453. private _sceneDisposeObserver;
  68454. private _improvementMode;
  68455. /**
  68456. * Defines an observable called when the optimizer reaches the target frame rate
  68457. */
  68458. onSuccessObservable: Observable<SceneOptimizer>;
  68459. /**
  68460. * Defines an observable called when the optimizer enables an optimization
  68461. */
  68462. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68463. /**
  68464. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68465. */
  68466. onFailureObservable: Observable<SceneOptimizer>;
  68467. /**
  68468. * Gets a boolean indicating if the optimizer is in improvement mode
  68469. */
  68470. get isInImprovementMode(): boolean;
  68471. /**
  68472. * Gets the current priority level (0 at start)
  68473. */
  68474. get currentPriorityLevel(): number;
  68475. /**
  68476. * Gets the current frame rate checked by the SceneOptimizer
  68477. */
  68478. get currentFrameRate(): number;
  68479. /**
  68480. * Gets or sets the current target frame rate (60 by default)
  68481. */
  68482. get targetFrameRate(): number;
  68483. /**
  68484. * Gets or sets the current target frame rate (60 by default)
  68485. */
  68486. set targetFrameRate(value: number);
  68487. /**
  68488. * Gets or sets the current interval between two checks (every 2000ms by default)
  68489. */
  68490. get trackerDuration(): number;
  68491. /**
  68492. * Gets or sets the current interval between two checks (every 2000ms by default)
  68493. */
  68494. set trackerDuration(value: number);
  68495. /**
  68496. * Gets the list of active optimizations
  68497. */
  68498. get optimizations(): SceneOptimization[];
  68499. /**
  68500. * Creates a new SceneOptimizer
  68501. * @param scene defines the scene to work on
  68502. * @param options defines the options to use with the SceneOptimizer
  68503. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68504. * @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)
  68505. */
  68506. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68507. /**
  68508. * Stops the current optimizer
  68509. */
  68510. stop(): void;
  68511. /**
  68512. * Reset the optimizer to initial step (current priority level = 0)
  68513. */
  68514. reset(): void;
  68515. /**
  68516. * Start the optimizer. By default it will try to reach a specific framerate
  68517. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68518. */
  68519. start(): void;
  68520. private _checkCurrentState;
  68521. /**
  68522. * Release all resources
  68523. */
  68524. dispose(): void;
  68525. /**
  68526. * Helper function to create a SceneOptimizer with one single line of code
  68527. * @param scene defines the scene to work on
  68528. * @param options defines the options to use with the SceneOptimizer
  68529. * @param onSuccess defines a callback to call on success
  68530. * @param onFailure defines a callback to call on failure
  68531. * @returns the new SceneOptimizer object
  68532. */
  68533. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68534. }
  68535. }
  68536. declare module BABYLON {
  68537. /**
  68538. * Class used to serialize a scene into a string
  68539. */
  68540. export class SceneSerializer {
  68541. /**
  68542. * Clear cache used by a previous serialization
  68543. */
  68544. static ClearCache(): void;
  68545. /**
  68546. * Serialize a scene into a JSON compatible object
  68547. * @param scene defines the scene to serialize
  68548. * @returns a JSON compatible object
  68549. */
  68550. static Serialize(scene: Scene): any;
  68551. /**
  68552. * Serialize a mesh into a JSON compatible object
  68553. * @param toSerialize defines the mesh to serialize
  68554. * @param withParents defines if parents must be serialized as well
  68555. * @param withChildren defines if children must be serialized as well
  68556. * @returns a JSON compatible object
  68557. */
  68558. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68559. }
  68560. }
  68561. declare module BABYLON {
  68562. /**
  68563. * Class used to host texture specific utilities
  68564. */
  68565. export class TextureTools {
  68566. /**
  68567. * Uses the GPU to create a copy texture rescaled at a given size
  68568. * @param texture Texture to copy from
  68569. * @param width defines the desired width
  68570. * @param height defines the desired height
  68571. * @param useBilinearMode defines if bilinear mode has to be used
  68572. * @return the generated texture
  68573. */
  68574. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68575. }
  68576. }
  68577. declare module BABYLON {
  68578. /**
  68579. * This represents the different options available for the video capture.
  68580. */
  68581. export interface VideoRecorderOptions {
  68582. /** Defines the mime type of the video. */
  68583. mimeType: string;
  68584. /** Defines the FPS the video should be recorded at. */
  68585. fps: number;
  68586. /** Defines the chunk size for the recording data. */
  68587. recordChunckSize: number;
  68588. /** The audio tracks to attach to the recording. */
  68589. audioTracks?: MediaStreamTrack[];
  68590. }
  68591. /**
  68592. * This can help with recording videos from BabylonJS.
  68593. * This is based on the available WebRTC functionalities of the browser.
  68594. *
  68595. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68596. */
  68597. export class VideoRecorder {
  68598. private static readonly _defaultOptions;
  68599. /**
  68600. * Returns whether or not the VideoRecorder is available in your browser.
  68601. * @param engine Defines the Babylon Engine.
  68602. * @returns true if supported otherwise false.
  68603. */
  68604. static IsSupported(engine: Engine): boolean;
  68605. private readonly _options;
  68606. private _canvas;
  68607. private _mediaRecorder;
  68608. private _recordedChunks;
  68609. private _fileName;
  68610. private _resolve;
  68611. private _reject;
  68612. /**
  68613. * True when a recording is already in progress.
  68614. */
  68615. get isRecording(): boolean;
  68616. /**
  68617. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68618. * @param engine Defines the BabylonJS Engine you wish to record.
  68619. * @param options Defines options that can be used to customize the capture.
  68620. */
  68621. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68622. /**
  68623. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68624. */
  68625. stopRecording(): void;
  68626. /**
  68627. * Starts recording the canvas for a max duration specified in parameters.
  68628. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68629. * If null no automatic download will start and you can rely on the promise to get the data back.
  68630. * @param maxDuration Defines the maximum recording time in seconds.
  68631. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68632. * @return A promise callback at the end of the recording with the video data in Blob.
  68633. */
  68634. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68635. /**
  68636. * Releases internal resources used during the recording.
  68637. */
  68638. dispose(): void;
  68639. private _handleDataAvailable;
  68640. private _handleError;
  68641. private _handleStop;
  68642. }
  68643. }
  68644. declare module BABYLON {
  68645. /**
  68646. * Class containing a set of static utilities functions for screenshots
  68647. */
  68648. export class ScreenshotTools {
  68649. /**
  68650. * Captures a screenshot of the current rendering
  68651. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68652. * @param engine defines the rendering engine
  68653. * @param camera defines the source camera
  68654. * @param size This parameter can be set to a single number or to an object with the
  68655. * following (optional) properties: precision, width, height. If a single number is passed,
  68656. * it will be used for both width and height. If an object is passed, the screenshot size
  68657. * will be derived from the parameters. The precision property is a multiplier allowing
  68658. * rendering at a higher or lower resolution
  68659. * @param successCallback defines the callback receives a single parameter which contains the
  68660. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68661. * src parameter of an <img> to display it
  68662. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68663. * Check your browser for supported MIME types
  68664. */
  68665. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68666. /**
  68667. * Captures a screenshot of the current rendering
  68668. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68669. * @param engine defines the rendering engine
  68670. * @param camera defines the source camera
  68671. * @param size This parameter can be set to a single number or to an object with the
  68672. * following (optional) properties: precision, width, height. If a single number is passed,
  68673. * it will be used for both width and height. If an object is passed, the screenshot size
  68674. * will be derived from the parameters. The precision property is a multiplier allowing
  68675. * rendering at a higher or lower resolution
  68676. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68677. * Check your browser for supported MIME types
  68678. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68679. * to the src parameter of an <img> to display it
  68680. */
  68681. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68682. /**
  68683. * Generates an image screenshot from the specified camera.
  68684. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68685. * @param engine The engine to use for rendering
  68686. * @param camera The camera to use for rendering
  68687. * @param size This parameter can be set to a single number or to an object with the
  68688. * following (optional) properties: precision, width, height. If a single number is passed,
  68689. * it will be used for both width and height. If an object is passed, the screenshot size
  68690. * will be derived from the parameters. The precision property is a multiplier allowing
  68691. * rendering at a higher or lower resolution
  68692. * @param successCallback The callback receives a single parameter which contains the
  68693. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68694. * src parameter of an <img> to display it
  68695. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68696. * Check your browser for supported MIME types
  68697. * @param samples Texture samples (default: 1)
  68698. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68699. * @param fileName A name for for the downloaded file.
  68700. */
  68701. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68702. /**
  68703. * Generates an image screenshot from the specified camera.
  68704. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68705. * @param engine The engine to use for rendering
  68706. * @param camera The camera to use for rendering
  68707. * @param size This parameter can be set to a single number or to an object with the
  68708. * following (optional) properties: precision, width, height. If a single number is passed,
  68709. * it will be used for both width and height. If an object is passed, the screenshot size
  68710. * will be derived from the parameters. The precision property is a multiplier allowing
  68711. * rendering at a higher or lower resolution
  68712. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68713. * Check your browser for supported MIME types
  68714. * @param samples Texture samples (default: 1)
  68715. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68716. * @param fileName A name for for the downloaded file.
  68717. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68718. * to the src parameter of an <img> to display it
  68719. */
  68720. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68721. /**
  68722. * Gets height and width for screenshot size
  68723. * @private
  68724. */
  68725. private static _getScreenshotSize;
  68726. }
  68727. }
  68728. declare module BABYLON {
  68729. /**
  68730. * Interface for a data buffer
  68731. */
  68732. export interface IDataBuffer {
  68733. /**
  68734. * Reads bytes from the data buffer.
  68735. * @param byteOffset The byte offset to read
  68736. * @param byteLength The byte length to read
  68737. * @returns A promise that resolves when the bytes are read
  68738. */
  68739. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68740. /**
  68741. * The byte length of the buffer.
  68742. */
  68743. readonly byteLength: number;
  68744. }
  68745. /**
  68746. * Utility class for reading from a data buffer
  68747. */
  68748. export class DataReader {
  68749. /**
  68750. * The data buffer associated with this data reader.
  68751. */
  68752. readonly buffer: IDataBuffer;
  68753. /**
  68754. * The current byte offset from the beginning of the data buffer.
  68755. */
  68756. byteOffset: number;
  68757. private _dataView;
  68758. private _dataByteOffset;
  68759. /**
  68760. * Constructor
  68761. * @param buffer The buffer to read
  68762. */
  68763. constructor(buffer: IDataBuffer);
  68764. /**
  68765. * Loads the given byte length.
  68766. * @param byteLength The byte length to load
  68767. * @returns A promise that resolves when the load is complete
  68768. */
  68769. loadAsync(byteLength: number): Promise<void>;
  68770. /**
  68771. * Read a unsigned 32-bit integer from the currently loaded data range.
  68772. * @returns The 32-bit integer read
  68773. */
  68774. readUint32(): number;
  68775. /**
  68776. * Read a byte array from the currently loaded data range.
  68777. * @param byteLength The byte length to read
  68778. * @returns The byte array read
  68779. */
  68780. readUint8Array(byteLength: number): Uint8Array;
  68781. /**
  68782. * Read a string from the currently loaded data range.
  68783. * @param byteLength The byte length to read
  68784. * @returns The string read
  68785. */
  68786. readString(byteLength: number): string;
  68787. /**
  68788. * Skips the given byte length the currently loaded data range.
  68789. * @param byteLength The byte length to skip
  68790. */
  68791. skipBytes(byteLength: number): void;
  68792. }
  68793. }
  68794. declare module BABYLON {
  68795. /**
  68796. * A cursor which tracks a point on a path
  68797. */
  68798. export class PathCursor {
  68799. private path;
  68800. /**
  68801. * Stores path cursor callbacks for when an onchange event is triggered
  68802. */
  68803. private _onchange;
  68804. /**
  68805. * The value of the path cursor
  68806. */
  68807. value: number;
  68808. /**
  68809. * The animation array of the path cursor
  68810. */
  68811. animations: Animation[];
  68812. /**
  68813. * Initializes the path cursor
  68814. * @param path The path to track
  68815. */
  68816. constructor(path: Path2);
  68817. /**
  68818. * Gets the cursor point on the path
  68819. * @returns A point on the path cursor at the cursor location
  68820. */
  68821. getPoint(): Vector3;
  68822. /**
  68823. * Moves the cursor ahead by the step amount
  68824. * @param step The amount to move the cursor forward
  68825. * @returns This path cursor
  68826. */
  68827. moveAhead(step?: number): PathCursor;
  68828. /**
  68829. * Moves the cursor behind by the step amount
  68830. * @param step The amount to move the cursor back
  68831. * @returns This path cursor
  68832. */
  68833. moveBack(step?: number): PathCursor;
  68834. /**
  68835. * Moves the cursor by the step amount
  68836. * If the step amount is greater than one, an exception is thrown
  68837. * @param step The amount to move the cursor
  68838. * @returns This path cursor
  68839. */
  68840. move(step: number): PathCursor;
  68841. /**
  68842. * Ensures that the value is limited between zero and one
  68843. * @returns This path cursor
  68844. */
  68845. private ensureLimits;
  68846. /**
  68847. * Runs onchange callbacks on change (used by the animation engine)
  68848. * @returns This path cursor
  68849. */
  68850. private raiseOnChange;
  68851. /**
  68852. * Executes a function on change
  68853. * @param f A path cursor onchange callback
  68854. * @returns This path cursor
  68855. */
  68856. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68857. }
  68858. }
  68859. declare module BABYLON {
  68860. /** @hidden */
  68861. export var blurPixelShader: {
  68862. name: string;
  68863. shader: string;
  68864. };
  68865. }
  68866. declare module BABYLON {
  68867. /** @hidden */
  68868. export var pointCloudVertexDeclaration: {
  68869. name: string;
  68870. shader: string;
  68871. };
  68872. }
  68873. // Mixins
  68874. interface Window {
  68875. mozIndexedDB: IDBFactory;
  68876. webkitIndexedDB: IDBFactory;
  68877. msIndexedDB: IDBFactory;
  68878. webkitURL: typeof URL;
  68879. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  68880. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  68881. WebGLRenderingContext: WebGLRenderingContext;
  68882. MSGesture: MSGesture;
  68883. CANNON: any;
  68884. AudioContext: AudioContext;
  68885. webkitAudioContext: AudioContext;
  68886. PointerEvent: any;
  68887. Math: Math;
  68888. Uint8Array: Uint8ArrayConstructor;
  68889. Float32Array: Float32ArrayConstructor;
  68890. mozURL: typeof URL;
  68891. msURL: typeof URL;
  68892. VRFrameData: any; // WebVR, from specs 1.1
  68893. DracoDecoderModule: any;
  68894. setImmediate(handler: (...args: any[]) => void): number;
  68895. }
  68896. interface HTMLCanvasElement {
  68897. requestPointerLock(): void;
  68898. msRequestPointerLock?(): void;
  68899. mozRequestPointerLock?(): void;
  68900. webkitRequestPointerLock?(): void;
  68901. /** Track wether a record is in progress */
  68902. isRecording: boolean;
  68903. /** Capture Stream method defined by some browsers */
  68904. captureStream(fps?: number): MediaStream;
  68905. }
  68906. interface CanvasRenderingContext2D {
  68907. msImageSmoothingEnabled: boolean;
  68908. }
  68909. interface MouseEvent {
  68910. mozMovementX: number;
  68911. mozMovementY: number;
  68912. webkitMovementX: number;
  68913. webkitMovementY: number;
  68914. msMovementX: number;
  68915. msMovementY: number;
  68916. }
  68917. interface Navigator {
  68918. mozGetVRDevices: (any: any) => any;
  68919. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68920. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68921. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68922. webkitGetGamepads(): Gamepad[];
  68923. msGetGamepads(): Gamepad[];
  68924. webkitGamepads(): Gamepad[];
  68925. }
  68926. interface HTMLVideoElement {
  68927. mozSrcObject: any;
  68928. }
  68929. interface Math {
  68930. fround(x: number): number;
  68931. imul(a: number, b: number): number;
  68932. }
  68933. interface WebGLRenderingContext {
  68934. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  68935. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  68936. vertexAttribDivisor(index: number, divisor: number): void;
  68937. createVertexArray(): any;
  68938. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  68939. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  68940. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  68941. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  68942. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  68943. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  68944. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  68945. // Queries
  68946. createQuery(): WebGLQuery;
  68947. deleteQuery(query: WebGLQuery): void;
  68948. beginQuery(target: number, query: WebGLQuery): void;
  68949. endQuery(target: number): void;
  68950. getQueryParameter(query: WebGLQuery, pname: number): any;
  68951. getQuery(target: number, pname: number): any;
  68952. MAX_SAMPLES: number;
  68953. RGBA8: number;
  68954. READ_FRAMEBUFFER: number;
  68955. DRAW_FRAMEBUFFER: number;
  68956. UNIFORM_BUFFER: number;
  68957. HALF_FLOAT_OES: number;
  68958. RGBA16F: number;
  68959. RGBA32F: number;
  68960. R32F: number;
  68961. RG32F: number;
  68962. RGB32F: number;
  68963. R16F: number;
  68964. RG16F: number;
  68965. RGB16F: number;
  68966. RED: number;
  68967. RG: number;
  68968. R8: number;
  68969. RG8: number;
  68970. UNSIGNED_INT_24_8: number;
  68971. DEPTH24_STENCIL8: number;
  68972. MIN: number;
  68973. MAX: number;
  68974. /* Multiple Render Targets */
  68975. drawBuffers(buffers: number[]): void;
  68976. readBuffer(src: number): void;
  68977. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  68978. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  68979. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  68980. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  68981. // Occlusion Query
  68982. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  68983. ANY_SAMPLES_PASSED: number;
  68984. QUERY_RESULT_AVAILABLE: number;
  68985. QUERY_RESULT: number;
  68986. }
  68987. interface WebGLProgram {
  68988. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  68989. }
  68990. interface EXT_disjoint_timer_query {
  68991. QUERY_COUNTER_BITS_EXT: number;
  68992. TIME_ELAPSED_EXT: number;
  68993. TIMESTAMP_EXT: number;
  68994. GPU_DISJOINT_EXT: number;
  68995. QUERY_RESULT_EXT: number;
  68996. QUERY_RESULT_AVAILABLE_EXT: number;
  68997. queryCounterEXT(query: WebGLQuery, target: number): void;
  68998. createQueryEXT(): WebGLQuery;
  68999. beginQueryEXT(target: number, query: WebGLQuery): void;
  69000. endQueryEXT(target: number): void;
  69001. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69002. deleteQueryEXT(query: WebGLQuery): void;
  69003. }
  69004. interface WebGLUniformLocation {
  69005. _currentState: any;
  69006. }
  69007. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69008. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69009. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69010. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69011. interface WebGLRenderingContext {
  69012. readonly RASTERIZER_DISCARD: number;
  69013. readonly DEPTH_COMPONENT24: number;
  69014. readonly TEXTURE_3D: number;
  69015. readonly TEXTURE_2D_ARRAY: number;
  69016. readonly TEXTURE_COMPARE_FUNC: number;
  69017. readonly TEXTURE_COMPARE_MODE: number;
  69018. readonly COMPARE_REF_TO_TEXTURE: number;
  69019. readonly TEXTURE_WRAP_R: number;
  69020. readonly HALF_FLOAT: number;
  69021. readonly RGB8: number;
  69022. readonly RED_INTEGER: number;
  69023. readonly RG_INTEGER: number;
  69024. readonly RGB_INTEGER: number;
  69025. readonly RGBA_INTEGER: number;
  69026. readonly R8_SNORM: number;
  69027. readonly RG8_SNORM: number;
  69028. readonly RGB8_SNORM: number;
  69029. readonly RGBA8_SNORM: number;
  69030. readonly R8I: number;
  69031. readonly RG8I: number;
  69032. readonly RGB8I: number;
  69033. readonly RGBA8I: number;
  69034. readonly R8UI: number;
  69035. readonly RG8UI: number;
  69036. readonly RGB8UI: number;
  69037. readonly RGBA8UI: number;
  69038. readonly R16I: number;
  69039. readonly RG16I: number;
  69040. readonly RGB16I: number;
  69041. readonly RGBA16I: number;
  69042. readonly R16UI: number;
  69043. readonly RG16UI: number;
  69044. readonly RGB16UI: number;
  69045. readonly RGBA16UI: number;
  69046. readonly R32I: number;
  69047. readonly RG32I: number;
  69048. readonly RGB32I: number;
  69049. readonly RGBA32I: number;
  69050. readonly R32UI: number;
  69051. readonly RG32UI: number;
  69052. readonly RGB32UI: number;
  69053. readonly RGBA32UI: number;
  69054. readonly RGB10_A2UI: number;
  69055. readonly R11F_G11F_B10F: number;
  69056. readonly RGB9_E5: number;
  69057. readonly RGB10_A2: number;
  69058. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69059. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69060. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69061. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69062. readonly DEPTH_COMPONENT32F: number;
  69063. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69064. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69065. 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;
  69066. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69067. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69068. readonly TRANSFORM_FEEDBACK: number;
  69069. readonly INTERLEAVED_ATTRIBS: number;
  69070. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69071. createTransformFeedback(): WebGLTransformFeedback;
  69072. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69073. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69074. beginTransformFeedback(primitiveMode: number): void;
  69075. endTransformFeedback(): void;
  69076. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69077. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69078. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69079. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69080. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69081. }
  69082. interface ImageBitmap {
  69083. readonly width: number;
  69084. readonly height: number;
  69085. close(): void;
  69086. }
  69087. interface WebGLQuery extends WebGLObject {
  69088. }
  69089. declare var WebGLQuery: {
  69090. prototype: WebGLQuery;
  69091. new(): WebGLQuery;
  69092. };
  69093. interface WebGLSampler extends WebGLObject {
  69094. }
  69095. declare var WebGLSampler: {
  69096. prototype: WebGLSampler;
  69097. new(): WebGLSampler;
  69098. };
  69099. interface WebGLSync extends WebGLObject {
  69100. }
  69101. declare var WebGLSync: {
  69102. prototype: WebGLSync;
  69103. new(): WebGLSync;
  69104. };
  69105. interface WebGLTransformFeedback extends WebGLObject {
  69106. }
  69107. declare var WebGLTransformFeedback: {
  69108. prototype: WebGLTransformFeedback;
  69109. new(): WebGLTransformFeedback;
  69110. };
  69111. interface WebGLVertexArrayObject extends WebGLObject {
  69112. }
  69113. declare var WebGLVertexArrayObject: {
  69114. prototype: WebGLVertexArrayObject;
  69115. new(): WebGLVertexArrayObject;
  69116. };
  69117. // Type definitions for WebVR API
  69118. // Project: https://w3c.github.io/webvr/
  69119. // Definitions by: six a <https://github.com/lostfictions>
  69120. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69121. interface VRDisplay extends EventTarget {
  69122. /**
  69123. * Dictionary of capabilities describing the VRDisplay.
  69124. */
  69125. readonly capabilities: VRDisplayCapabilities;
  69126. /**
  69127. * z-depth defining the far plane of the eye view frustum
  69128. * enables mapping of values in the render target depth
  69129. * attachment to scene coordinates. Initially set to 10000.0.
  69130. */
  69131. depthFar: number;
  69132. /**
  69133. * z-depth defining the near plane of the eye view frustum
  69134. * enables mapping of values in the render target depth
  69135. * attachment to scene coordinates. Initially set to 0.01.
  69136. */
  69137. depthNear: number;
  69138. /**
  69139. * An identifier for this distinct VRDisplay. Used as an
  69140. * association point in the Gamepad API.
  69141. */
  69142. readonly displayId: number;
  69143. /**
  69144. * A display name, a user-readable name identifying it.
  69145. */
  69146. readonly displayName: string;
  69147. readonly isConnected: boolean;
  69148. readonly isPresenting: boolean;
  69149. /**
  69150. * If this VRDisplay supports room-scale experiences, the optional
  69151. * stage attribute contains details on the room-scale parameters.
  69152. */
  69153. readonly stageParameters: VRStageParameters | null;
  69154. /**
  69155. * Passing the value returned by `requestAnimationFrame` to
  69156. * `cancelAnimationFrame` will unregister the callback.
  69157. * @param handle Define the hanle of the request to cancel
  69158. */
  69159. cancelAnimationFrame(handle: number): void;
  69160. /**
  69161. * Stops presenting to the VRDisplay.
  69162. * @returns a promise to know when it stopped
  69163. */
  69164. exitPresent(): Promise<void>;
  69165. /**
  69166. * Return the current VREyeParameters for the given eye.
  69167. * @param whichEye Define the eye we want the parameter for
  69168. * @returns the eye parameters
  69169. */
  69170. getEyeParameters(whichEye: string): VREyeParameters;
  69171. /**
  69172. * Populates the passed VRFrameData with the information required to render
  69173. * the current frame.
  69174. * @param frameData Define the data structure to populate
  69175. * @returns true if ok otherwise false
  69176. */
  69177. getFrameData(frameData: VRFrameData): boolean;
  69178. /**
  69179. * Get the layers currently being presented.
  69180. * @returns the list of VR layers
  69181. */
  69182. getLayers(): VRLayer[];
  69183. /**
  69184. * Return a VRPose containing the future predicted pose of the VRDisplay
  69185. * when the current frame will be presented. The value returned will not
  69186. * change until JavaScript has returned control to the browser.
  69187. *
  69188. * The VRPose will contain the position, orientation, velocity,
  69189. * and acceleration of each of these properties.
  69190. * @returns the pose object
  69191. */
  69192. getPose(): VRPose;
  69193. /**
  69194. * Return the current instantaneous pose of the VRDisplay, with no
  69195. * prediction applied.
  69196. * @returns the current instantaneous pose
  69197. */
  69198. getImmediatePose(): VRPose;
  69199. /**
  69200. * The callback passed to `requestAnimationFrame` will be called
  69201. * any time a new frame should be rendered. When the VRDisplay is
  69202. * presenting the callback will be called at the native refresh
  69203. * rate of the HMD. When not presenting this function acts
  69204. * identically to how window.requestAnimationFrame acts. Content should
  69205. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69206. * asynchronously from other displays and at differing refresh rates.
  69207. * @param callback Define the eaction to run next frame
  69208. * @returns the request handle it
  69209. */
  69210. requestAnimationFrame(callback: FrameRequestCallback): number;
  69211. /**
  69212. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69213. * Repeat calls while already presenting will update the VRLayers being displayed.
  69214. * @param layers Define the list of layer to present
  69215. * @returns a promise to know when the request has been fulfilled
  69216. */
  69217. requestPresent(layers: VRLayer[]): Promise<void>;
  69218. /**
  69219. * Reset the pose for this display, treating its current position and
  69220. * orientation as the "origin/zero" values. VRPose.position,
  69221. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69222. * updated when calling resetPose(). This should be called in only
  69223. * sitting-space experiences.
  69224. */
  69225. resetPose(): void;
  69226. /**
  69227. * The VRLayer provided to the VRDisplay will be captured and presented
  69228. * in the HMD. Calling this function has the same effect on the source
  69229. * canvas as any other operation that uses its source image, and canvases
  69230. * created without preserveDrawingBuffer set to true will be cleared.
  69231. * @param pose Define the pose to submit
  69232. */
  69233. submitFrame(pose?: VRPose): void;
  69234. }
  69235. declare var VRDisplay: {
  69236. prototype: VRDisplay;
  69237. new(): VRDisplay;
  69238. };
  69239. interface VRLayer {
  69240. leftBounds?: number[] | Float32Array | null;
  69241. rightBounds?: number[] | Float32Array | null;
  69242. source?: HTMLCanvasElement | null;
  69243. }
  69244. interface VRDisplayCapabilities {
  69245. readonly canPresent: boolean;
  69246. readonly hasExternalDisplay: boolean;
  69247. readonly hasOrientation: boolean;
  69248. readonly hasPosition: boolean;
  69249. readonly maxLayers: number;
  69250. }
  69251. interface VREyeParameters {
  69252. /** @deprecated */
  69253. readonly fieldOfView: VRFieldOfView;
  69254. readonly offset: Float32Array;
  69255. readonly renderHeight: number;
  69256. readonly renderWidth: number;
  69257. }
  69258. interface VRFieldOfView {
  69259. readonly downDegrees: number;
  69260. readonly leftDegrees: number;
  69261. readonly rightDegrees: number;
  69262. readonly upDegrees: number;
  69263. }
  69264. interface VRFrameData {
  69265. readonly leftProjectionMatrix: Float32Array;
  69266. readonly leftViewMatrix: Float32Array;
  69267. readonly pose: VRPose;
  69268. readonly rightProjectionMatrix: Float32Array;
  69269. readonly rightViewMatrix: Float32Array;
  69270. readonly timestamp: number;
  69271. }
  69272. interface VRPose {
  69273. readonly angularAcceleration: Float32Array | null;
  69274. readonly angularVelocity: Float32Array | null;
  69275. readonly linearAcceleration: Float32Array | null;
  69276. readonly linearVelocity: Float32Array | null;
  69277. readonly orientation: Float32Array | null;
  69278. readonly position: Float32Array | null;
  69279. readonly timestamp: number;
  69280. }
  69281. interface VRStageParameters {
  69282. sittingToStandingTransform?: Float32Array;
  69283. sizeX?: number;
  69284. sizeY?: number;
  69285. }
  69286. interface Navigator {
  69287. getVRDisplays(): Promise<VRDisplay[]>;
  69288. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69289. }
  69290. interface Window {
  69291. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69292. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69293. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69294. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69295. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69296. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69297. }
  69298. interface Gamepad {
  69299. readonly displayId: number;
  69300. }
  69301. type XRSessionMode =
  69302. | "inline"
  69303. | "immersive-vr"
  69304. | "immersive-ar";
  69305. type XRReferenceSpaceType =
  69306. | "viewer"
  69307. | "local"
  69308. | "local-floor"
  69309. | "bounded-floor"
  69310. | "unbounded";
  69311. type XREnvironmentBlendMode =
  69312. | "opaque"
  69313. | "additive"
  69314. | "alpha-blend";
  69315. type XRVisibilityState =
  69316. | "visible"
  69317. | "visible-blurred"
  69318. | "hidden";
  69319. type XRHandedness =
  69320. | "none"
  69321. | "left"
  69322. | "right";
  69323. type XRTargetRayMode =
  69324. | "gaze"
  69325. | "tracked-pointer"
  69326. | "screen";
  69327. type XREye =
  69328. | "none"
  69329. | "left"
  69330. | "right";
  69331. interface XRSpace extends EventTarget {
  69332. }
  69333. interface XRRenderState {
  69334. depthNear?: number;
  69335. depthFar?: number;
  69336. inlineVerticalFieldOfView?: number;
  69337. baseLayer?: XRWebGLLayer;
  69338. }
  69339. interface XRInputSource {
  69340. handedness: XRHandedness;
  69341. targetRayMode: XRTargetRayMode;
  69342. targetRaySpace: XRSpace;
  69343. gripSpace: XRSpace | undefined;
  69344. gamepad: Gamepad | undefined;
  69345. profiles: Array<string>;
  69346. }
  69347. interface XRSessionInit {
  69348. optionalFeatures?: XRReferenceSpaceType[];
  69349. requiredFeatures?: XRReferenceSpaceType[];
  69350. }
  69351. interface XRSession extends XRAnchorCreator {
  69352. addEventListener: Function;
  69353. removeEventListener: Function;
  69354. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  69355. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  69356. requestAnimationFrame: Function;
  69357. end(): Promise<void>;
  69358. renderState: XRRenderState;
  69359. inputSources: Array<XRInputSource>;
  69360. // AR hit test
  69361. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69362. updateWorldTrackingState(options: {
  69363. planeDetectionState?: { enabled: boolean; }
  69364. }): void;
  69365. }
  69366. interface XRReferenceSpace extends XRSpace {
  69367. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  69368. onreset: any;
  69369. }
  69370. type XRPlaneSet = Set<XRPlane>;
  69371. type XRAnchorSet = Set<XRAnchor>;
  69372. interface XRFrame {
  69373. session: XRSession;
  69374. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  69375. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  69376. // Anchors
  69377. trackedAnchors?: XRAnchorSet;
  69378. // Planes
  69379. worldInformation: {
  69380. detectedPlanes?: XRPlaneSet;
  69381. };
  69382. }
  69383. interface XRViewerPose extends XRPose {
  69384. views: Array<XRView>;
  69385. }
  69386. interface XRPose {
  69387. transform: XRRigidTransform;
  69388. emulatedPosition: boolean;
  69389. }
  69390. interface XRWebGLLayerOptions {
  69391. antialias?: boolean;
  69392. depth?: boolean;
  69393. stencil?: boolean;
  69394. alpha?: boolean;
  69395. multiview?: boolean;
  69396. framebufferScaleFactor?: number;
  69397. }
  69398. declare var XRWebGLLayer: {
  69399. prototype: XRWebGLLayer;
  69400. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  69401. };
  69402. interface XRWebGLLayer {
  69403. framebuffer: WebGLFramebuffer;
  69404. framebufferWidth: number;
  69405. framebufferHeight: number;
  69406. getViewport: Function;
  69407. }
  69408. declare class XRRigidTransform {
  69409. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  69410. position: DOMPointReadOnly;
  69411. orientation: DOMPointReadOnly;
  69412. matrix: Float32Array;
  69413. inverse: XRRigidTransform;
  69414. }
  69415. interface XRView {
  69416. eye: XREye;
  69417. projectionMatrix: Float32Array;
  69418. transform: XRRigidTransform;
  69419. }
  69420. interface XRInputSourceChangeEvent {
  69421. session: XRSession;
  69422. removed: Array<XRInputSource>;
  69423. added: Array<XRInputSource>;
  69424. }
  69425. interface XRInputSourceEvent extends Event {
  69426. readonly frame: XRFrame;
  69427. readonly inputSource: XRInputSource;
  69428. }
  69429. // Experimental(er) features
  69430. declare class XRRay {
  69431. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  69432. origin: DOMPointReadOnly;
  69433. direction: DOMPointReadOnly;
  69434. matrix: Float32Array;
  69435. }
  69436. interface XRHitResult {
  69437. hitMatrix: Float32Array;
  69438. }
  69439. interface XRAnchor {
  69440. // remove?
  69441. id?: string;
  69442. anchorSpace: XRSpace;
  69443. lastChangedTime: number;
  69444. detach(): void;
  69445. }
  69446. interface XRPlane extends XRAnchorCreator {
  69447. orientation: "Horizontal" | "Vertical";
  69448. planeSpace: XRSpace;
  69449. polygon: Array<DOMPointReadOnly>;
  69450. lastChangedTime: number;
  69451. }
  69452. interface XRAnchorCreator {
  69453. // AR Anchors
  69454. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  69455. }
  69456. /**
  69457. * @ignore
  69458. */
  69459. declare module BABYLON.GLTF2.Exporter {
  69460. }
  69461. /**
  69462. * @ignore
  69463. */
  69464. declare module BABYLON.GLTF1 {
  69465. }
  69466. declare module BABYLON.GUI {
  69467. /**
  69468. * Class used to specific a value and its associated unit
  69469. */
  69470. export class ValueAndUnit {
  69471. /** defines the unit to store */
  69472. unit: number;
  69473. /** defines a boolean indicating if the value can be negative */
  69474. negativeValueAllowed: boolean;
  69475. private _value;
  69476. private _originalUnit;
  69477. /**
  69478. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  69479. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69480. */
  69481. ignoreAdaptiveScaling: boolean;
  69482. /**
  69483. * Creates a new ValueAndUnit
  69484. * @param value defines the value to store
  69485. * @param unit defines the unit to store
  69486. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  69487. */
  69488. constructor(value: number,
  69489. /** defines the unit to store */
  69490. unit?: number,
  69491. /** defines a boolean indicating if the value can be negative */
  69492. negativeValueAllowed?: boolean);
  69493. /** Gets a boolean indicating if the value is a percentage */
  69494. get isPercentage(): boolean;
  69495. /** Gets a boolean indicating if the value is store as pixel */
  69496. get isPixel(): boolean;
  69497. /** Gets direct internal value */
  69498. get internalValue(): number;
  69499. /**
  69500. * Gets value as pixel
  69501. * @param host defines the root host
  69502. * @param refValue defines the reference value for percentages
  69503. * @returns the value as pixel
  69504. */
  69505. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  69506. /**
  69507. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  69508. * @param value defines the value to store
  69509. * @param unit defines the unit to store
  69510. * @returns the current ValueAndUnit
  69511. */
  69512. updateInPlace(value: number, unit?: number): ValueAndUnit;
  69513. /**
  69514. * Gets the value accordingly to its unit
  69515. * @param host defines the root host
  69516. * @returns the value
  69517. */
  69518. getValue(host: AdvancedDynamicTexture): number;
  69519. /**
  69520. * Gets a string representation of the value
  69521. * @param host defines the root host
  69522. * @param decimals defines an optional number of decimals to display
  69523. * @returns a string
  69524. */
  69525. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  69526. /**
  69527. * Store a value parsed from a string
  69528. * @param source defines the source string
  69529. * @returns true if the value was successfully parsed
  69530. */
  69531. fromString(source: string | number): boolean;
  69532. private static _Regex;
  69533. private static _UNITMODE_PERCENTAGE;
  69534. private static _UNITMODE_PIXEL;
  69535. /** UNITMODE_PERCENTAGE */
  69536. static get UNITMODE_PERCENTAGE(): number;
  69537. /** UNITMODE_PIXEL */
  69538. static get UNITMODE_PIXEL(): number;
  69539. }
  69540. }
  69541. declare module BABYLON.GUI {
  69542. /**
  69543. * Define a style used by control to automatically setup properties based on a template.
  69544. * Only support font related properties so far
  69545. */
  69546. export class Style implements BABYLON.IDisposable {
  69547. private _fontFamily;
  69548. private _fontStyle;
  69549. private _fontWeight;
  69550. /** @hidden */
  69551. _host: AdvancedDynamicTexture;
  69552. /** @hidden */
  69553. _fontSize: ValueAndUnit;
  69554. /**
  69555. * BABYLON.Observable raised when the style values are changed
  69556. */
  69557. onChangedObservable: BABYLON.Observable<Style>;
  69558. /**
  69559. * Creates a new style object
  69560. * @param host defines the AdvancedDynamicTexture which hosts this style
  69561. */
  69562. constructor(host: AdvancedDynamicTexture);
  69563. /**
  69564. * Gets or sets the font size
  69565. */
  69566. get fontSize(): string | number;
  69567. set fontSize(value: string | number);
  69568. /**
  69569. * Gets or sets the font family
  69570. */
  69571. get fontFamily(): string;
  69572. set fontFamily(value: string);
  69573. /**
  69574. * Gets or sets the font style
  69575. */
  69576. get fontStyle(): string;
  69577. set fontStyle(value: string);
  69578. /** Gets or sets font weight */
  69579. get fontWeight(): string;
  69580. set fontWeight(value: string);
  69581. /** Dispose all associated resources */
  69582. dispose(): void;
  69583. }
  69584. }
  69585. declare module BABYLON.GUI {
  69586. /**
  69587. * Class used to transport BABYLON.Vector2 information for pointer events
  69588. */
  69589. export class Vector2WithInfo extends BABYLON.Vector2 {
  69590. /** defines the current mouse button index */
  69591. buttonIndex: number;
  69592. /**
  69593. * Creates a new Vector2WithInfo
  69594. * @param source defines the vector2 data to transport
  69595. * @param buttonIndex defines the current mouse button index
  69596. */
  69597. constructor(source: BABYLON.Vector2,
  69598. /** defines the current mouse button index */
  69599. buttonIndex?: number);
  69600. }
  69601. /** Class used to provide 2D matrix features */
  69602. export class Matrix2D {
  69603. /** Gets the internal array of 6 floats used to store matrix data */
  69604. m: Float32Array;
  69605. /**
  69606. * Creates a new matrix
  69607. * @param m00 defines value for (0, 0)
  69608. * @param m01 defines value for (0, 1)
  69609. * @param m10 defines value for (1, 0)
  69610. * @param m11 defines value for (1, 1)
  69611. * @param m20 defines value for (2, 0)
  69612. * @param m21 defines value for (2, 1)
  69613. */
  69614. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  69615. /**
  69616. * Fills the matrix from direct values
  69617. * @param m00 defines value for (0, 0)
  69618. * @param m01 defines value for (0, 1)
  69619. * @param m10 defines value for (1, 0)
  69620. * @param m11 defines value for (1, 1)
  69621. * @param m20 defines value for (2, 0)
  69622. * @param m21 defines value for (2, 1)
  69623. * @returns the current modified matrix
  69624. */
  69625. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  69626. /**
  69627. * Gets matrix determinant
  69628. * @returns the determinant
  69629. */
  69630. determinant(): number;
  69631. /**
  69632. * Inverses the matrix and stores it in a target matrix
  69633. * @param result defines the target matrix
  69634. * @returns the current matrix
  69635. */
  69636. invertToRef(result: Matrix2D): Matrix2D;
  69637. /**
  69638. * Multiplies the current matrix with another one
  69639. * @param other defines the second operand
  69640. * @param result defines the target matrix
  69641. * @returns the current matrix
  69642. */
  69643. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  69644. /**
  69645. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  69646. * @param x defines the x coordinate to transform
  69647. * @param y defines the x coordinate to transform
  69648. * @param result defines the target vector2
  69649. * @returns the current matrix
  69650. */
  69651. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  69652. /**
  69653. * Creates an identity matrix
  69654. * @returns a new matrix
  69655. */
  69656. static Identity(): Matrix2D;
  69657. /**
  69658. * Creates a translation matrix and stores it in a target matrix
  69659. * @param x defines the x coordinate of the translation
  69660. * @param y defines the y coordinate of the translation
  69661. * @param result defines the target matrix
  69662. */
  69663. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  69664. /**
  69665. * Creates a scaling matrix and stores it in a target matrix
  69666. * @param x defines the x coordinate of the scaling
  69667. * @param y defines the y coordinate of the scaling
  69668. * @param result defines the target matrix
  69669. */
  69670. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  69671. /**
  69672. * Creates a rotation matrix and stores it in a target matrix
  69673. * @param angle defines the rotation angle
  69674. * @param result defines the target matrix
  69675. */
  69676. static RotationToRef(angle: number, result: Matrix2D): void;
  69677. private static _TempPreTranslationMatrix;
  69678. private static _TempPostTranslationMatrix;
  69679. private static _TempRotationMatrix;
  69680. private static _TempScalingMatrix;
  69681. private static _TempCompose0;
  69682. private static _TempCompose1;
  69683. private static _TempCompose2;
  69684. /**
  69685. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  69686. * @param tx defines the x coordinate of the translation
  69687. * @param ty defines the y coordinate of the translation
  69688. * @param angle defines the rotation angle
  69689. * @param scaleX defines the x coordinate of the scaling
  69690. * @param scaleY defines the y coordinate of the scaling
  69691. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  69692. * @param result defines the target matrix
  69693. */
  69694. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  69695. }
  69696. }
  69697. declare module BABYLON.GUI {
  69698. /**
  69699. * Class used to store 2D control sizes
  69700. */
  69701. export class Measure {
  69702. /** defines left coordinate */
  69703. left: number;
  69704. /** defines top coordinate */
  69705. top: number;
  69706. /** defines width dimension */
  69707. width: number;
  69708. /** defines height dimension */
  69709. height: number;
  69710. /**
  69711. * Creates a new measure
  69712. * @param left defines left coordinate
  69713. * @param top defines top coordinate
  69714. * @param width defines width dimension
  69715. * @param height defines height dimension
  69716. */
  69717. constructor(
  69718. /** defines left coordinate */
  69719. left: number,
  69720. /** defines top coordinate */
  69721. top: number,
  69722. /** defines width dimension */
  69723. width: number,
  69724. /** defines height dimension */
  69725. height: number);
  69726. /**
  69727. * Copy from another measure
  69728. * @param other defines the other measure to copy from
  69729. */
  69730. copyFrom(other: Measure): void;
  69731. /**
  69732. * Copy from a group of 4 floats
  69733. * @param left defines left coordinate
  69734. * @param top defines top coordinate
  69735. * @param width defines width dimension
  69736. * @param height defines height dimension
  69737. */
  69738. copyFromFloats(left: number, top: number, width: number, height: number): void;
  69739. /**
  69740. * Computes the axis aligned bounding box measure for two given measures
  69741. * @param a Input measure
  69742. * @param b Input measure
  69743. * @param result the resulting bounding measure
  69744. */
  69745. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  69746. /**
  69747. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  69748. * @param transform the matrix to transform the measure before computing the AABB
  69749. * @param result the resulting AABB
  69750. */
  69751. transformToRef(transform: Matrix2D, result: Measure): void;
  69752. /**
  69753. * Check equality between this measure and another one
  69754. * @param other defines the other measures
  69755. * @returns true if both measures are equals
  69756. */
  69757. isEqualsTo(other: Measure): boolean;
  69758. /**
  69759. * Creates an empty measure
  69760. * @returns a new measure
  69761. */
  69762. static Empty(): Measure;
  69763. }
  69764. }
  69765. declare module BABYLON.GUI {
  69766. /**
  69767. * Interface used to define a control that can receive focus
  69768. */
  69769. export interface IFocusableControl {
  69770. /**
  69771. * Function called when the control receives the focus
  69772. */
  69773. onFocus(): void;
  69774. /**
  69775. * Function called when the control loses the focus
  69776. */
  69777. onBlur(): void;
  69778. /**
  69779. * Function called to let the control handle keyboard events
  69780. * @param evt defines the current keyboard event
  69781. */
  69782. processKeyboard(evt: KeyboardEvent): void;
  69783. /**
  69784. * Function called to get the list of controls that should not steal the focus from this control
  69785. * @returns an array of controls
  69786. */
  69787. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  69788. }
  69789. /**
  69790. * Class used to create texture to support 2D GUI elements
  69791. * @see http://doc.babylonjs.com/how_to/gui
  69792. */
  69793. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  69794. private _isDirty;
  69795. private _renderObserver;
  69796. private _resizeObserver;
  69797. private _preKeyboardObserver;
  69798. private _pointerMoveObserver;
  69799. private _pointerObserver;
  69800. private _canvasPointerOutObserver;
  69801. private _background;
  69802. /** @hidden */
  69803. _rootContainer: Container;
  69804. /** @hidden */
  69805. _lastPickedControl: Control;
  69806. /** @hidden */
  69807. _lastControlOver: {
  69808. [pointerId: number]: Control;
  69809. };
  69810. /** @hidden */
  69811. _lastControlDown: {
  69812. [pointerId: number]: Control;
  69813. };
  69814. /** @hidden */
  69815. _capturingControl: {
  69816. [pointerId: number]: Control;
  69817. };
  69818. /** @hidden */
  69819. _shouldBlockPointer: boolean;
  69820. /** @hidden */
  69821. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  69822. /** @hidden */
  69823. _linkedControls: Control[];
  69824. private _isFullscreen;
  69825. private _fullscreenViewport;
  69826. private _idealWidth;
  69827. private _idealHeight;
  69828. private _useSmallestIdeal;
  69829. private _renderAtIdealSize;
  69830. private _focusedControl;
  69831. private _blockNextFocusCheck;
  69832. private _renderScale;
  69833. private _rootElement;
  69834. private _cursorChanged;
  69835. /**
  69836. * Define type to string to ensure compatibility across browsers
  69837. * Safari doesn't support DataTransfer constructor
  69838. */
  69839. private _clipboardData;
  69840. /**
  69841. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  69842. */
  69843. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  69844. /**
  69845. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  69846. */
  69847. onControlPickedObservable: BABYLON.Observable<Control>;
  69848. /**
  69849. * BABYLON.Observable event triggered before layout is evaluated
  69850. */
  69851. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69852. /**
  69853. * BABYLON.Observable event triggered after the layout was evaluated
  69854. */
  69855. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69856. /**
  69857. * BABYLON.Observable event triggered before the texture is rendered
  69858. */
  69859. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69860. /**
  69861. * BABYLON.Observable event triggered after the texture was rendered
  69862. */
  69863. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69864. /**
  69865. * Gets or sets a boolean defining if alpha is stored as premultiplied
  69866. */
  69867. premulAlpha: boolean;
  69868. /**
  69869. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  69870. * Useful when you want more antialiasing
  69871. */
  69872. get renderScale(): number;
  69873. set renderScale(value: number);
  69874. /** Gets or sets the background color */
  69875. get background(): string;
  69876. set background(value: string);
  69877. /**
  69878. * Gets or sets the ideal width used to design controls.
  69879. * The GUI will then rescale everything accordingly
  69880. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69881. */
  69882. get idealWidth(): number;
  69883. set idealWidth(value: number);
  69884. /**
  69885. * Gets or sets the ideal height used to design controls.
  69886. * The GUI will then rescale everything accordingly
  69887. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69888. */
  69889. get idealHeight(): number;
  69890. set idealHeight(value: number);
  69891. /**
  69892. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  69893. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69894. */
  69895. get useSmallestIdeal(): boolean;
  69896. set useSmallestIdeal(value: boolean);
  69897. /**
  69898. * Gets or sets a boolean indicating if adaptive scaling must be used
  69899. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69900. */
  69901. get renderAtIdealSize(): boolean;
  69902. set renderAtIdealSize(value: boolean);
  69903. /**
  69904. * Gets the underlying layer used to render the texture when in fullscreen mode
  69905. */
  69906. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  69907. /**
  69908. * Gets the root container control
  69909. */
  69910. get rootContainer(): Container;
  69911. /**
  69912. * Returns an array containing the root container.
  69913. * This is mostly used to let the Inspector introspects the ADT
  69914. * @returns an array containing the rootContainer
  69915. */
  69916. getChildren(): Array<Container>;
  69917. /**
  69918. * Will return all controls that are inside this texture
  69919. * @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
  69920. * @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
  69921. * @return all child controls
  69922. */
  69923. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  69924. /**
  69925. * Gets or sets the current focused control
  69926. */
  69927. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  69928. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  69929. /**
  69930. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  69931. */
  69932. get isForeground(): boolean;
  69933. set isForeground(value: boolean);
  69934. /**
  69935. * Gets or set information about clipboardData
  69936. */
  69937. get clipboardData(): string;
  69938. set clipboardData(value: string);
  69939. /**
  69940. * Creates a new AdvancedDynamicTexture
  69941. * @param name defines the name of the texture
  69942. * @param width defines the width of the texture
  69943. * @param height defines the height of the texture
  69944. * @param scene defines the hosting scene
  69945. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  69946. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  69947. */
  69948. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  69949. /**
  69950. * Get the current class name of the texture useful for serialization or dynamic coding.
  69951. * @returns "AdvancedDynamicTexture"
  69952. */
  69953. getClassName(): string;
  69954. /**
  69955. * Function used to execute a function on all controls
  69956. * @param func defines the function to execute
  69957. * @param container defines the container where controls belong. If null the root container will be used
  69958. */
  69959. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  69960. private _useInvalidateRectOptimization;
  69961. /**
  69962. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  69963. */
  69964. get useInvalidateRectOptimization(): boolean;
  69965. set useInvalidateRectOptimization(value: boolean);
  69966. private _invalidatedRectangle;
  69967. /**
  69968. * Invalidates a rectangle area on the gui texture
  69969. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  69970. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  69971. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  69972. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  69973. */
  69974. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  69975. /**
  69976. * Marks the texture as dirty forcing a complete update
  69977. */
  69978. markAsDirty(): void;
  69979. /**
  69980. * Helper function used to create a new style
  69981. * @returns a new style
  69982. * @see http://doc.babylonjs.com/how_to/gui#styles
  69983. */
  69984. createStyle(): Style;
  69985. /**
  69986. * Adds a new control to the root container
  69987. * @param control defines the control to add
  69988. * @returns the current texture
  69989. */
  69990. addControl(control: Control): AdvancedDynamicTexture;
  69991. /**
  69992. * Removes a control from the root container
  69993. * @param control defines the control to remove
  69994. * @returns the current texture
  69995. */
  69996. removeControl(control: Control): AdvancedDynamicTexture;
  69997. /**
  69998. * Release all resources
  69999. */
  70000. dispose(): void;
  70001. private _onResize;
  70002. /** @hidden */
  70003. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  70004. /**
  70005. * Get screen coordinates for a vector3
  70006. * @param position defines the position to project
  70007. * @param worldMatrix defines the world matrix to use
  70008. * @returns the projected position
  70009. */
  70010. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  70011. private _checkUpdate;
  70012. private _clearMeasure;
  70013. private _render;
  70014. /** @hidden */
  70015. _changeCursor(cursor: string): void;
  70016. /** @hidden */
  70017. _registerLastControlDown(control: Control, pointerId: number): void;
  70018. private _doPicking;
  70019. /** @hidden */
  70020. _cleanControlAfterRemovalFromList(list: {
  70021. [pointerId: number]: Control;
  70022. }, control: Control): void;
  70023. /** @hidden */
  70024. _cleanControlAfterRemoval(control: Control): void;
  70025. /** Attach to all scene events required to support pointer events */
  70026. attach(): void;
  70027. /** @hidden */
  70028. private onClipboardCopy;
  70029. /** @hidden */
  70030. private onClipboardCut;
  70031. /** @hidden */
  70032. private onClipboardPaste;
  70033. /**
  70034. * Register the clipboard Events onto the canvas
  70035. */
  70036. registerClipboardEvents(): void;
  70037. /**
  70038. * Unregister the clipboard Events from the canvas
  70039. */
  70040. unRegisterClipboardEvents(): void;
  70041. /**
  70042. * Connect the texture to a hosting mesh to enable interactions
  70043. * @param mesh defines the mesh to attach to
  70044. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  70045. */
  70046. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  70047. /**
  70048. * Move the focus to a specific control
  70049. * @param control defines the control which will receive the focus
  70050. */
  70051. moveFocusToControl(control: IFocusableControl): void;
  70052. private _manageFocus;
  70053. private _attachToOnPointerOut;
  70054. /**
  70055. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  70056. * @param mesh defines the mesh which will receive the texture
  70057. * @param width defines the texture width (1024 by default)
  70058. * @param height defines the texture height (1024 by default)
  70059. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  70060. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  70061. * @returns a new AdvancedDynamicTexture
  70062. */
  70063. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  70064. /**
  70065. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  70066. * In this mode the texture will rely on a layer for its rendering.
  70067. * This allows it to be treated like any other layer.
  70068. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  70069. * LayerMask is set through advancedTexture.layer.layerMask
  70070. * @param name defines name for the texture
  70071. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  70072. * @param scene defines the hsoting scene
  70073. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  70074. * @returns a new AdvancedDynamicTexture
  70075. */
  70076. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  70077. }
  70078. }
  70079. declare module BABYLON.GUI {
  70080. /**
  70081. * Root class used for all 2D controls
  70082. * @see http://doc.babylonjs.com/how_to/gui#controls
  70083. */
  70084. export class Control {
  70085. /** defines the name of the control */
  70086. name?: string | undefined;
  70087. /**
  70088. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  70089. */
  70090. static AllowAlphaInheritance: boolean;
  70091. private _alpha;
  70092. private _alphaSet;
  70093. private _zIndex;
  70094. /** @hidden */
  70095. _host: AdvancedDynamicTexture;
  70096. /** Gets or sets the control parent */
  70097. parent: BABYLON.Nullable<Container>;
  70098. /** @hidden */
  70099. _currentMeasure: Measure;
  70100. private _fontFamily;
  70101. private _fontStyle;
  70102. private _fontWeight;
  70103. private _fontSize;
  70104. private _font;
  70105. /** @hidden */
  70106. _width: ValueAndUnit;
  70107. /** @hidden */
  70108. _height: ValueAndUnit;
  70109. /** @hidden */
  70110. protected _fontOffset: {
  70111. ascent: number;
  70112. height: number;
  70113. descent: number;
  70114. };
  70115. private _color;
  70116. private _style;
  70117. private _styleObserver;
  70118. /** @hidden */
  70119. protected _horizontalAlignment: number;
  70120. /** @hidden */
  70121. protected _verticalAlignment: number;
  70122. /** @hidden */
  70123. protected _isDirty: boolean;
  70124. /** @hidden */
  70125. protected _wasDirty: boolean;
  70126. /** @hidden */
  70127. _tempParentMeasure: Measure;
  70128. /** @hidden */
  70129. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  70130. /** @hidden */
  70131. protected _cachedParentMeasure: Measure;
  70132. private _paddingLeft;
  70133. private _paddingRight;
  70134. private _paddingTop;
  70135. private _paddingBottom;
  70136. /** @hidden */
  70137. _left: ValueAndUnit;
  70138. /** @hidden */
  70139. _top: ValueAndUnit;
  70140. private _scaleX;
  70141. private _scaleY;
  70142. private _rotation;
  70143. private _transformCenterX;
  70144. private _transformCenterY;
  70145. /** @hidden */
  70146. _transformMatrix: Matrix2D;
  70147. /** @hidden */
  70148. protected _invertTransformMatrix: Matrix2D;
  70149. /** @hidden */
  70150. protected _transformedPosition: BABYLON.Vector2;
  70151. private _isMatrixDirty;
  70152. private _cachedOffsetX;
  70153. private _cachedOffsetY;
  70154. private _isVisible;
  70155. private _isHighlighted;
  70156. /** @hidden */
  70157. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70158. private _fontSet;
  70159. private _dummyVector2;
  70160. private _downCount;
  70161. private _enterCount;
  70162. private _doNotRender;
  70163. private _downPointerIds;
  70164. protected _isEnabled: boolean;
  70165. protected _disabledColor: string;
  70166. /** @hidden */
  70167. protected _rebuildLayout: boolean;
  70168. /** @hidden */
  70169. _isClipped: boolean;
  70170. /** @hidden */
  70171. _automaticSize: boolean;
  70172. /** @hidden */
  70173. _tag: any;
  70174. /**
  70175. * 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
  70176. */
  70177. uniqueId: number;
  70178. /**
  70179. * Gets or sets an object used to store user defined information for the node
  70180. */
  70181. metadata: any;
  70182. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70183. isHitTestVisible: boolean;
  70184. /** Gets or sets a boolean indicating if the control can block pointer events */
  70185. isPointerBlocker: boolean;
  70186. /** Gets or sets a boolean indicating if the control can be focusable */
  70187. isFocusInvisible: boolean;
  70188. /**
  70189. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70190. * 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
  70191. */
  70192. clipChildren: boolean;
  70193. /**
  70194. * Gets or sets a boolean indicating that control content must be clipped
  70195. * 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
  70196. */
  70197. clipContent: boolean;
  70198. /**
  70199. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70200. */
  70201. useBitmapCache: boolean;
  70202. private _cacheData;
  70203. private _shadowOffsetX;
  70204. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70205. get shadowOffsetX(): number;
  70206. set shadowOffsetX(value: number);
  70207. private _shadowOffsetY;
  70208. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70209. get shadowOffsetY(): number;
  70210. set shadowOffsetY(value: number);
  70211. private _shadowBlur;
  70212. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70213. get shadowBlur(): number;
  70214. set shadowBlur(value: number);
  70215. private _shadowColor;
  70216. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70217. get shadowColor(): string;
  70218. set shadowColor(value: string);
  70219. /** Gets or sets the cursor to use when the control is hovered */
  70220. hoverCursor: string;
  70221. /** @hidden */
  70222. protected _linkOffsetX: ValueAndUnit;
  70223. /** @hidden */
  70224. protected _linkOffsetY: ValueAndUnit;
  70225. /** Gets the control type name */
  70226. get typeName(): string;
  70227. /**
  70228. * Get the current class name of the control.
  70229. * @returns current class name
  70230. */
  70231. getClassName(): string;
  70232. /**
  70233. * An event triggered when the pointer move over the control.
  70234. */
  70235. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70236. /**
  70237. * An event triggered when the pointer move out of the control.
  70238. */
  70239. onPointerOutObservable: BABYLON.Observable<Control>;
  70240. /**
  70241. * An event triggered when the pointer taps the control
  70242. */
  70243. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70244. /**
  70245. * An event triggered when pointer up
  70246. */
  70247. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70248. /**
  70249. * An event triggered when a control is clicked on
  70250. */
  70251. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70252. /**
  70253. * An event triggered when pointer enters the control
  70254. */
  70255. onPointerEnterObservable: BABYLON.Observable<Control>;
  70256. /**
  70257. * An event triggered when the control is marked as dirty
  70258. */
  70259. onDirtyObservable: BABYLON.Observable<Control>;
  70260. /**
  70261. * An event triggered before drawing the control
  70262. */
  70263. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70264. /**
  70265. * An event triggered after the control was drawn
  70266. */
  70267. onAfterDrawObservable: BABYLON.Observable<Control>;
  70268. /**
  70269. * Get the hosting AdvancedDynamicTexture
  70270. */
  70271. get host(): AdvancedDynamicTexture;
  70272. /** Gets or set information about font offsets (used to render and align text) */
  70273. get fontOffset(): {
  70274. ascent: number;
  70275. height: number;
  70276. descent: number;
  70277. };
  70278. set fontOffset(offset: {
  70279. ascent: number;
  70280. height: number;
  70281. descent: number;
  70282. });
  70283. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70284. get alpha(): number;
  70285. set alpha(value: number);
  70286. /**
  70287. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70288. */
  70289. get isHighlighted(): boolean;
  70290. set isHighlighted(value: boolean);
  70291. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70292. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70293. */
  70294. get scaleX(): number;
  70295. set scaleX(value: number);
  70296. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70297. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70298. */
  70299. get scaleY(): number;
  70300. set scaleY(value: number);
  70301. /** Gets or sets the rotation angle (0 by default)
  70302. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70303. */
  70304. get rotation(): number;
  70305. set rotation(value: number);
  70306. /** Gets or sets the transformation center on Y axis (0 by default)
  70307. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70308. */
  70309. get transformCenterY(): number;
  70310. set transformCenterY(value: number);
  70311. /** Gets or sets the transformation center on X axis (0 by default)
  70312. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70313. */
  70314. get transformCenterX(): number;
  70315. set transformCenterX(value: number);
  70316. /**
  70317. * Gets or sets the horizontal alignment
  70318. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70319. */
  70320. get horizontalAlignment(): number;
  70321. set horizontalAlignment(value: number);
  70322. /**
  70323. * Gets or sets the vertical alignment
  70324. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70325. */
  70326. get verticalAlignment(): number;
  70327. set verticalAlignment(value: number);
  70328. /**
  70329. * Gets or sets control width
  70330. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70331. */
  70332. get width(): string | number;
  70333. set width(value: string | number);
  70334. /**
  70335. * Gets or sets the control width in pixel
  70336. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70337. */
  70338. get widthInPixels(): number;
  70339. set widthInPixels(value: number);
  70340. /**
  70341. * Gets or sets control height
  70342. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70343. */
  70344. get height(): string | number;
  70345. set height(value: string | number);
  70346. /**
  70347. * Gets or sets control height in pixel
  70348. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70349. */
  70350. get heightInPixels(): number;
  70351. set heightInPixels(value: number);
  70352. /** Gets or set font family */
  70353. get fontFamily(): string;
  70354. set fontFamily(value: string);
  70355. /** Gets or sets font style */
  70356. get fontStyle(): string;
  70357. set fontStyle(value: string);
  70358. /** Gets or sets font weight */
  70359. get fontWeight(): string;
  70360. set fontWeight(value: string);
  70361. /**
  70362. * Gets or sets style
  70363. * @see http://doc.babylonjs.com/how_to/gui#styles
  70364. */
  70365. get style(): BABYLON.Nullable<Style>;
  70366. set style(value: BABYLON.Nullable<Style>);
  70367. /** @hidden */
  70368. get _isFontSizeInPercentage(): boolean;
  70369. /** Gets or sets font size in pixels */
  70370. get fontSizeInPixels(): number;
  70371. set fontSizeInPixels(value: number);
  70372. /** Gets or sets font size */
  70373. get fontSize(): string | number;
  70374. set fontSize(value: string | number);
  70375. /** Gets or sets foreground color */
  70376. get color(): string;
  70377. set color(value: string);
  70378. /** Gets or sets z index which is used to reorder controls on the z axis */
  70379. get zIndex(): number;
  70380. set zIndex(value: number);
  70381. /** Gets or sets a boolean indicating if the control can be rendered */
  70382. get notRenderable(): boolean;
  70383. set notRenderable(value: boolean);
  70384. /** Gets or sets a boolean indicating if the control is visible */
  70385. get isVisible(): boolean;
  70386. set isVisible(value: boolean);
  70387. /** Gets a boolean indicating that the control needs to update its rendering */
  70388. get isDirty(): boolean;
  70389. /**
  70390. * Gets the current linked mesh (or null if none)
  70391. */
  70392. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  70393. /**
  70394. * Gets or sets a value indicating the padding to use on the left of the control
  70395. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70396. */
  70397. get paddingLeft(): string | number;
  70398. set paddingLeft(value: string | number);
  70399. /**
  70400. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  70401. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70402. */
  70403. get paddingLeftInPixels(): number;
  70404. set paddingLeftInPixels(value: number);
  70405. /**
  70406. * Gets or sets a value indicating the padding to use on the right of the control
  70407. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70408. */
  70409. get paddingRight(): string | number;
  70410. set paddingRight(value: string | number);
  70411. /**
  70412. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  70413. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70414. */
  70415. get paddingRightInPixels(): number;
  70416. set paddingRightInPixels(value: number);
  70417. /**
  70418. * Gets or sets a value indicating the padding to use on the top of the control
  70419. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70420. */
  70421. get paddingTop(): string | number;
  70422. set paddingTop(value: string | number);
  70423. /**
  70424. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  70425. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70426. */
  70427. get paddingTopInPixels(): number;
  70428. set paddingTopInPixels(value: number);
  70429. /**
  70430. * Gets or sets a value indicating the padding to use on the bottom of the control
  70431. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70432. */
  70433. get paddingBottom(): string | number;
  70434. set paddingBottom(value: string | number);
  70435. /**
  70436. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  70437. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70438. */
  70439. get paddingBottomInPixels(): number;
  70440. set paddingBottomInPixels(value: number);
  70441. /**
  70442. * Gets or sets a value indicating the left coordinate of the control
  70443. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70444. */
  70445. get left(): string | number;
  70446. set left(value: string | number);
  70447. /**
  70448. * Gets or sets a value indicating the left coordinate in pixels of the control
  70449. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70450. */
  70451. get leftInPixels(): number;
  70452. set leftInPixels(value: number);
  70453. /**
  70454. * Gets or sets a value indicating the top coordinate of the control
  70455. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70456. */
  70457. get top(): string | number;
  70458. set top(value: string | number);
  70459. /**
  70460. * Gets or sets a value indicating the top coordinate in pixels of the control
  70461. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70462. */
  70463. get topInPixels(): number;
  70464. set topInPixels(value: number);
  70465. /**
  70466. * Gets or sets a value indicating the offset on X axis to the linked mesh
  70467. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70468. */
  70469. get linkOffsetX(): string | number;
  70470. set linkOffsetX(value: string | number);
  70471. /**
  70472. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  70473. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70474. */
  70475. get linkOffsetXInPixels(): number;
  70476. set linkOffsetXInPixels(value: number);
  70477. /**
  70478. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  70479. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70480. */
  70481. get linkOffsetY(): string | number;
  70482. set linkOffsetY(value: string | number);
  70483. /**
  70484. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  70485. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70486. */
  70487. get linkOffsetYInPixels(): number;
  70488. set linkOffsetYInPixels(value: number);
  70489. /** Gets the center coordinate on X axis */
  70490. get centerX(): number;
  70491. /** Gets the center coordinate on Y axis */
  70492. get centerY(): number;
  70493. /** Gets or sets if control is Enabled*/
  70494. get isEnabled(): boolean;
  70495. set isEnabled(value: boolean);
  70496. /** Gets or sets background color of control if it's disabled*/
  70497. get disabledColor(): string;
  70498. set disabledColor(value: string);
  70499. /**
  70500. * Creates a new control
  70501. * @param name defines the name of the control
  70502. */
  70503. constructor(
  70504. /** defines the name of the control */
  70505. name?: string | undefined);
  70506. /** @hidden */
  70507. protected _getTypeName(): string;
  70508. /**
  70509. * Gets the first ascendant in the hierarchy of the given type
  70510. * @param className defines the required type
  70511. * @returns the ascendant or null if not found
  70512. */
  70513. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  70514. /** @hidden */
  70515. _resetFontCache(): void;
  70516. /**
  70517. * Determines if a container is an ascendant of the current control
  70518. * @param container defines the container to look for
  70519. * @returns true if the container is one of the ascendant of the control
  70520. */
  70521. isAscendant(container: Control): boolean;
  70522. /**
  70523. * Gets coordinates in local control space
  70524. * @param globalCoordinates defines the coordinates to transform
  70525. * @returns the new coordinates in local space
  70526. */
  70527. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  70528. /**
  70529. * Gets coordinates in local control space
  70530. * @param globalCoordinates defines the coordinates to transform
  70531. * @param result defines the target vector2 where to store the result
  70532. * @returns the current control
  70533. */
  70534. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  70535. /**
  70536. * Gets coordinates in parent local control space
  70537. * @param globalCoordinates defines the coordinates to transform
  70538. * @returns the new coordinates in parent local space
  70539. */
  70540. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  70541. /**
  70542. * Move the current control to a vector3 position projected onto the screen.
  70543. * @param position defines the target position
  70544. * @param scene defines the hosting scene
  70545. */
  70546. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  70547. /**
  70548. * Will store all controls that have this control as ascendant in a given array
  70549. * @param results defines the array where to store the descendants
  70550. * @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
  70551. * @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
  70552. */
  70553. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  70554. /**
  70555. * Will return all controls that have this control as ascendant
  70556. * @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
  70557. * @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
  70558. * @return all child controls
  70559. */
  70560. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70561. /**
  70562. * Link current control with a target mesh
  70563. * @param mesh defines the mesh to link with
  70564. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70565. */
  70566. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  70567. /** @hidden */
  70568. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  70569. /** @hidden */
  70570. _offsetLeft(offset: number): void;
  70571. /** @hidden */
  70572. _offsetTop(offset: number): void;
  70573. /** @hidden */
  70574. _markMatrixAsDirty(): void;
  70575. /** @hidden */
  70576. _flagDescendantsAsMatrixDirty(): void;
  70577. /** @hidden */
  70578. _intersectsRect(rect: Measure): boolean;
  70579. /** @hidden */
  70580. protected invalidateRect(): void;
  70581. /** @hidden */
  70582. _markAsDirty(force?: boolean): void;
  70583. /** @hidden */
  70584. _markAllAsDirty(): void;
  70585. /** @hidden */
  70586. _link(host: AdvancedDynamicTexture): void;
  70587. /** @hidden */
  70588. protected _transform(context?: CanvasRenderingContext2D): void;
  70589. /** @hidden */
  70590. _renderHighlight(context: CanvasRenderingContext2D): void;
  70591. /** @hidden */
  70592. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  70593. /** @hidden */
  70594. protected _applyStates(context: CanvasRenderingContext2D): void;
  70595. /** @hidden */
  70596. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  70597. /** @hidden */
  70598. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70599. protected _evaluateClippingState(parentMeasure: Measure): void;
  70600. /** @hidden */
  70601. _measure(): void;
  70602. /** @hidden */
  70603. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70604. /** @hidden */
  70605. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70606. /** @hidden */
  70607. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70608. /** @hidden */
  70609. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  70610. private static _ClipMeasure;
  70611. private _tmpMeasureA;
  70612. private _clip;
  70613. /** @hidden */
  70614. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  70615. /** @hidden */
  70616. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70617. /**
  70618. * Tests if a given coordinates belong to the current control
  70619. * @param x defines x coordinate to test
  70620. * @param y defines y coordinate to test
  70621. * @returns true if the coordinates are inside the control
  70622. */
  70623. contains(x: number, y: number): boolean;
  70624. /** @hidden */
  70625. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  70626. /** @hidden */
  70627. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  70628. /** @hidden */
  70629. _onPointerEnter(target: Control): boolean;
  70630. /** @hidden */
  70631. _onPointerOut(target: Control, force?: boolean): void;
  70632. /** @hidden */
  70633. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70634. /** @hidden */
  70635. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70636. /** @hidden */
  70637. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  70638. /** @hidden */
  70639. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  70640. private _prepareFont;
  70641. /** Releases associated resources */
  70642. dispose(): void;
  70643. private static _HORIZONTAL_ALIGNMENT_LEFT;
  70644. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  70645. private static _HORIZONTAL_ALIGNMENT_CENTER;
  70646. private static _VERTICAL_ALIGNMENT_TOP;
  70647. private static _VERTICAL_ALIGNMENT_BOTTOM;
  70648. private static _VERTICAL_ALIGNMENT_CENTER;
  70649. /** HORIZONTAL_ALIGNMENT_LEFT */
  70650. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  70651. /** HORIZONTAL_ALIGNMENT_RIGHT */
  70652. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  70653. /** HORIZONTAL_ALIGNMENT_CENTER */
  70654. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  70655. /** VERTICAL_ALIGNMENT_TOP */
  70656. static get VERTICAL_ALIGNMENT_TOP(): number;
  70657. /** VERTICAL_ALIGNMENT_BOTTOM */
  70658. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  70659. /** VERTICAL_ALIGNMENT_CENTER */
  70660. static get VERTICAL_ALIGNMENT_CENTER(): number;
  70661. private static _FontHeightSizes;
  70662. /** @hidden */
  70663. static _GetFontOffset(font: string): {
  70664. ascent: number;
  70665. height: number;
  70666. descent: number;
  70667. };
  70668. /**
  70669. * Creates a stack panel that can be used to render headers
  70670. * @param control defines the control to associate with the header
  70671. * @param text defines the text of the header
  70672. * @param size defines the size of the header
  70673. * @param options defines options used to configure the header
  70674. * @returns a new StackPanel
  70675. * @ignore
  70676. * @hidden
  70677. */
  70678. static AddHeader: (control: Control, text: string, size: string | number, options: {
  70679. isHorizontal: boolean;
  70680. controlFirst: boolean;
  70681. }) => any;
  70682. /** @hidden */
  70683. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  70684. }
  70685. }
  70686. declare module BABYLON.GUI {
  70687. /**
  70688. * Root class for 2D containers
  70689. * @see http://doc.babylonjs.com/how_to/gui#containers
  70690. */
  70691. export class Container extends Control {
  70692. name?: string | undefined;
  70693. /** @hidden */
  70694. protected _children: Control[];
  70695. /** @hidden */
  70696. protected _measureForChildren: Measure;
  70697. /** @hidden */
  70698. protected _background: string;
  70699. /** @hidden */
  70700. protected _adaptWidthToChildren: boolean;
  70701. /** @hidden */
  70702. protected _adaptHeightToChildren: boolean;
  70703. /**
  70704. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  70705. */
  70706. logLayoutCycleErrors: boolean;
  70707. /**
  70708. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  70709. */
  70710. maxLayoutCycle: number;
  70711. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  70712. get adaptHeightToChildren(): boolean;
  70713. set adaptHeightToChildren(value: boolean);
  70714. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  70715. get adaptWidthToChildren(): boolean;
  70716. set adaptWidthToChildren(value: boolean);
  70717. /** Gets or sets background color */
  70718. get background(): string;
  70719. set background(value: string);
  70720. /** Gets the list of children */
  70721. get children(): Control[];
  70722. /**
  70723. * Creates a new Container
  70724. * @param name defines the name of the container
  70725. */
  70726. constructor(name?: string | undefined);
  70727. protected _getTypeName(): string;
  70728. _flagDescendantsAsMatrixDirty(): void;
  70729. /**
  70730. * Gets a child using its name
  70731. * @param name defines the child name to look for
  70732. * @returns the child control if found
  70733. */
  70734. getChildByName(name: string): BABYLON.Nullable<Control>;
  70735. /**
  70736. * Gets a child using its type and its name
  70737. * @param name defines the child name to look for
  70738. * @param type defines the child type to look for
  70739. * @returns the child control if found
  70740. */
  70741. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  70742. /**
  70743. * Search for a specific control in children
  70744. * @param control defines the control to look for
  70745. * @returns true if the control is in child list
  70746. */
  70747. containsControl(control: Control): boolean;
  70748. /**
  70749. * Adds a new control to the current container
  70750. * @param control defines the control to add
  70751. * @returns the current container
  70752. */
  70753. addControl(control: BABYLON.Nullable<Control>): Container;
  70754. /**
  70755. * Removes all controls from the current container
  70756. * @returns the current container
  70757. */
  70758. clearControls(): Container;
  70759. /**
  70760. * Removes a control from the current container
  70761. * @param control defines the control to remove
  70762. * @returns the current container
  70763. */
  70764. removeControl(control: Control): Container;
  70765. /** @hidden */
  70766. _reOrderControl(control: Control): void;
  70767. /** @hidden */
  70768. _offsetLeft(offset: number): void;
  70769. /** @hidden */
  70770. _offsetTop(offset: number): void;
  70771. /** @hidden */
  70772. _markAllAsDirty(): void;
  70773. /** @hidden */
  70774. protected _localDraw(context: CanvasRenderingContext2D): void;
  70775. /** @hidden */
  70776. _link(host: AdvancedDynamicTexture): void;
  70777. /** @hidden */
  70778. protected _beforeLayout(): void;
  70779. /** @hidden */
  70780. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70781. /** @hidden */
  70782. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  70783. protected _postMeasure(): void;
  70784. /** @hidden */
  70785. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  70786. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  70787. /** @hidden */
  70788. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  70789. /** @hidden */
  70790. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70791. /** Releases associated resources */
  70792. dispose(): void;
  70793. }
  70794. }
  70795. declare module BABYLON.GUI {
  70796. /** Class used to create rectangle container */
  70797. export class Rectangle extends Container {
  70798. name?: string | undefined;
  70799. private _thickness;
  70800. private _cornerRadius;
  70801. /** Gets or sets border thickness */
  70802. get thickness(): number;
  70803. set thickness(value: number);
  70804. /** Gets or sets the corner radius angle */
  70805. get cornerRadius(): number;
  70806. set cornerRadius(value: number);
  70807. /**
  70808. * Creates a new Rectangle
  70809. * @param name defines the control name
  70810. */
  70811. constructor(name?: string | undefined);
  70812. protected _getTypeName(): string;
  70813. protected _localDraw(context: CanvasRenderingContext2D): void;
  70814. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70815. private _drawRoundedRect;
  70816. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  70817. }
  70818. }
  70819. declare module BABYLON.GUI {
  70820. /**
  70821. * Enum that determines the text-wrapping mode to use.
  70822. */
  70823. export enum TextWrapping {
  70824. /**
  70825. * Clip the text when it's larger than Control.width; this is the default mode.
  70826. */
  70827. Clip = 0,
  70828. /**
  70829. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  70830. */
  70831. WordWrap = 1,
  70832. /**
  70833. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  70834. */
  70835. Ellipsis = 2
  70836. }
  70837. /**
  70838. * Class used to create text block control
  70839. */
  70840. export class TextBlock extends Control {
  70841. /**
  70842. * Defines the name of the control
  70843. */
  70844. name?: string | undefined;
  70845. private _text;
  70846. private _textWrapping;
  70847. private _textHorizontalAlignment;
  70848. private _textVerticalAlignment;
  70849. private _lines;
  70850. private _resizeToFit;
  70851. private _lineSpacing;
  70852. private _outlineWidth;
  70853. private _outlineColor;
  70854. /**
  70855. * An event triggered after the text is changed
  70856. */
  70857. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  70858. /**
  70859. * An event triggered after the text was broken up into lines
  70860. */
  70861. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  70862. /**
  70863. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  70864. */
  70865. get lines(): any[];
  70866. /**
  70867. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  70868. */
  70869. get resizeToFit(): boolean;
  70870. /**
  70871. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  70872. */
  70873. set resizeToFit(value: boolean);
  70874. /**
  70875. * Gets or sets a boolean indicating if text must be wrapped
  70876. */
  70877. get textWrapping(): TextWrapping | boolean;
  70878. /**
  70879. * Gets or sets a boolean indicating if text must be wrapped
  70880. */
  70881. set textWrapping(value: TextWrapping | boolean);
  70882. /**
  70883. * Gets or sets text to display
  70884. */
  70885. get text(): string;
  70886. /**
  70887. * Gets or sets text to display
  70888. */
  70889. set text(value: string);
  70890. /**
  70891. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  70892. */
  70893. get textHorizontalAlignment(): number;
  70894. /**
  70895. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  70896. */
  70897. set textHorizontalAlignment(value: number);
  70898. /**
  70899. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  70900. */
  70901. get textVerticalAlignment(): number;
  70902. /**
  70903. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  70904. */
  70905. set textVerticalAlignment(value: number);
  70906. /**
  70907. * Gets or sets line spacing value
  70908. */
  70909. set lineSpacing(value: string | number);
  70910. /**
  70911. * Gets or sets line spacing value
  70912. */
  70913. get lineSpacing(): string | number;
  70914. /**
  70915. * Gets or sets outlineWidth of the text to display
  70916. */
  70917. get outlineWidth(): number;
  70918. /**
  70919. * Gets or sets outlineWidth of the text to display
  70920. */
  70921. set outlineWidth(value: number);
  70922. /**
  70923. * Gets or sets outlineColor of the text to display
  70924. */
  70925. get outlineColor(): string;
  70926. /**
  70927. * Gets or sets outlineColor of the text to display
  70928. */
  70929. set outlineColor(value: string);
  70930. /**
  70931. * Creates a new TextBlock object
  70932. * @param name defines the name of the control
  70933. * @param text defines the text to display (emptry string by default)
  70934. */
  70935. constructor(
  70936. /**
  70937. * Defines the name of the control
  70938. */
  70939. name?: string | undefined, text?: string);
  70940. protected _getTypeName(): string;
  70941. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70942. private _drawText;
  70943. /** @hidden */
  70944. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70945. protected _applyStates(context: CanvasRenderingContext2D): void;
  70946. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  70947. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  70948. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  70949. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  70950. protected _renderLines(context: CanvasRenderingContext2D): void;
  70951. /**
  70952. * Given a width constraint applied on the text block, find the expected height
  70953. * @returns expected height
  70954. */
  70955. computeExpectedHeight(): number;
  70956. dispose(): void;
  70957. }
  70958. }
  70959. declare module BABYLON.GUI {
  70960. /**
  70961. * Class used to create 2D images
  70962. */
  70963. export class Image extends Control {
  70964. name?: string | undefined;
  70965. private _workingCanvas;
  70966. private _domImage;
  70967. private _imageWidth;
  70968. private _imageHeight;
  70969. private _loaded;
  70970. private _stretch;
  70971. private _source;
  70972. private _autoScale;
  70973. private _sourceLeft;
  70974. private _sourceTop;
  70975. private _sourceWidth;
  70976. private _sourceHeight;
  70977. private _cellWidth;
  70978. private _cellHeight;
  70979. private _cellId;
  70980. private _populateNinePatchSlicesFromImage;
  70981. private _sliceLeft;
  70982. private _sliceRight;
  70983. private _sliceTop;
  70984. private _sliceBottom;
  70985. private _detectPointerOnOpaqueOnly;
  70986. /**
  70987. * BABYLON.Observable notified when the content is loaded
  70988. */
  70989. onImageLoadedObservable: BABYLON.Observable<Image>;
  70990. /**
  70991. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  70992. */
  70993. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  70994. /**
  70995. * Gets a boolean indicating that the content is loaded
  70996. */
  70997. get isLoaded(): boolean;
  70998. /**
  70999. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  71000. */
  71001. get populateNinePatchSlicesFromImage(): boolean;
  71002. set populateNinePatchSlicesFromImage(value: boolean);
  71003. /**
  71004. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  71005. * Beware using this as this will comsume more memory as the image has to be stored twice
  71006. */
  71007. get detectPointerOnOpaqueOnly(): boolean;
  71008. set detectPointerOnOpaqueOnly(value: boolean);
  71009. /**
  71010. * Gets or sets the left value for slicing (9-patch)
  71011. */
  71012. get sliceLeft(): number;
  71013. set sliceLeft(value: number);
  71014. /**
  71015. * Gets or sets the right value for slicing (9-patch)
  71016. */
  71017. get sliceRight(): number;
  71018. set sliceRight(value: number);
  71019. /**
  71020. * Gets or sets the top value for slicing (9-patch)
  71021. */
  71022. get sliceTop(): number;
  71023. set sliceTop(value: number);
  71024. /**
  71025. * Gets or sets the bottom value for slicing (9-patch)
  71026. */
  71027. get sliceBottom(): number;
  71028. set sliceBottom(value: number);
  71029. /**
  71030. * Gets or sets the left coordinate in the source image
  71031. */
  71032. get sourceLeft(): number;
  71033. set sourceLeft(value: number);
  71034. /**
  71035. * Gets or sets the top coordinate in the source image
  71036. */
  71037. get sourceTop(): number;
  71038. set sourceTop(value: number);
  71039. /**
  71040. * Gets or sets the width to capture in the source image
  71041. */
  71042. get sourceWidth(): number;
  71043. set sourceWidth(value: number);
  71044. /**
  71045. * Gets or sets the height to capture in the source image
  71046. */
  71047. get sourceHeight(): number;
  71048. set sourceHeight(value: number);
  71049. /**
  71050. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  71051. * @see http://doc.babylonjs.com/how_to/gui#image
  71052. */
  71053. get autoScale(): boolean;
  71054. set autoScale(value: boolean);
  71055. /** Gets or sets the streching mode used by the image */
  71056. get stretch(): number;
  71057. set stretch(value: number);
  71058. /** @hidden */
  71059. _rotate90(n: number): Image;
  71060. /**
  71061. * Gets or sets the internal DOM image used to render the control
  71062. */
  71063. set domImage(value: HTMLImageElement);
  71064. get domImage(): HTMLImageElement;
  71065. private _onImageLoaded;
  71066. private _extractNinePatchSliceDataFromImage;
  71067. /**
  71068. * Gets or sets image source url
  71069. */
  71070. set source(value: BABYLON.Nullable<string>);
  71071. /**
  71072. * Checks for svg document with icon id present
  71073. */
  71074. private _svgCheck;
  71075. /**
  71076. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  71077. * given external svg file and icon id
  71078. */
  71079. private _getSVGAttribs;
  71080. /**
  71081. * Gets or sets the cell width to use when animation sheet is enabled
  71082. * @see http://doc.babylonjs.com/how_to/gui#image
  71083. */
  71084. get cellWidth(): number;
  71085. set cellWidth(value: number);
  71086. /**
  71087. * Gets or sets the cell height to use when animation sheet is enabled
  71088. * @see http://doc.babylonjs.com/how_to/gui#image
  71089. */
  71090. get cellHeight(): number;
  71091. set cellHeight(value: number);
  71092. /**
  71093. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  71094. * @see http://doc.babylonjs.com/how_to/gui#image
  71095. */
  71096. get cellId(): number;
  71097. set cellId(value: number);
  71098. /**
  71099. * Creates a new Image
  71100. * @param name defines the control name
  71101. * @param url defines the image url
  71102. */
  71103. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  71104. /**
  71105. * Tests if a given coordinates belong to the current control
  71106. * @param x defines x coordinate to test
  71107. * @param y defines y coordinate to test
  71108. * @returns true if the coordinates are inside the control
  71109. */
  71110. contains(x: number, y: number): boolean;
  71111. protected _getTypeName(): string;
  71112. /** Force the control to synchronize with its content */
  71113. synchronizeSizeWithContent(): void;
  71114. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71115. private _prepareWorkingCanvasForOpaqueDetection;
  71116. private _drawImage;
  71117. _draw(context: CanvasRenderingContext2D): void;
  71118. private _renderCornerPatch;
  71119. private _renderNinePatch;
  71120. dispose(): void;
  71121. /** STRETCH_NONE */
  71122. static readonly STRETCH_NONE: number;
  71123. /** STRETCH_FILL */
  71124. static readonly STRETCH_FILL: number;
  71125. /** STRETCH_UNIFORM */
  71126. static readonly STRETCH_UNIFORM: number;
  71127. /** STRETCH_EXTEND */
  71128. static readonly STRETCH_EXTEND: number;
  71129. /** NINE_PATCH */
  71130. static readonly STRETCH_NINE_PATCH: number;
  71131. }
  71132. }
  71133. declare module BABYLON.GUI {
  71134. /**
  71135. * Class used to create 2D buttons
  71136. */
  71137. export class Button extends Rectangle {
  71138. name?: string | undefined;
  71139. /**
  71140. * Function called to generate a pointer enter animation
  71141. */
  71142. pointerEnterAnimation: () => void;
  71143. /**
  71144. * Function called to generate a pointer out animation
  71145. */
  71146. pointerOutAnimation: () => void;
  71147. /**
  71148. * Function called to generate a pointer down animation
  71149. */
  71150. pointerDownAnimation: () => void;
  71151. /**
  71152. * Function called to generate a pointer up animation
  71153. */
  71154. pointerUpAnimation: () => void;
  71155. /**
  71156. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  71157. */
  71158. delegatePickingToChildren: boolean;
  71159. private _image;
  71160. /**
  71161. * Returns the image part of the button (if any)
  71162. */
  71163. get image(): BABYLON.Nullable<Image>;
  71164. private _textBlock;
  71165. /**
  71166. * Returns the image part of the button (if any)
  71167. */
  71168. get textBlock(): BABYLON.Nullable<TextBlock>;
  71169. /**
  71170. * Creates a new Button
  71171. * @param name defines the name of the button
  71172. */
  71173. constructor(name?: string | undefined);
  71174. protected _getTypeName(): string;
  71175. /** @hidden */
  71176. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71177. /** @hidden */
  71178. _onPointerEnter(target: Control): boolean;
  71179. /** @hidden */
  71180. _onPointerOut(target: Control, force?: boolean): void;
  71181. /** @hidden */
  71182. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71183. /** @hidden */
  71184. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71185. /**
  71186. * Creates a new button made with an image and a text
  71187. * @param name defines the name of the button
  71188. * @param text defines the text of the button
  71189. * @param imageUrl defines the url of the image
  71190. * @returns a new Button
  71191. */
  71192. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71193. /**
  71194. * Creates a new button made with an image
  71195. * @param name defines the name of the button
  71196. * @param imageUrl defines the url of the image
  71197. * @returns a new Button
  71198. */
  71199. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71200. /**
  71201. * Creates a new button made with a text
  71202. * @param name defines the name of the button
  71203. * @param text defines the text of the button
  71204. * @returns a new Button
  71205. */
  71206. static CreateSimpleButton(name: string, text: string): Button;
  71207. /**
  71208. * Creates a new button made with an image and a centered text
  71209. * @param name defines the name of the button
  71210. * @param text defines the text of the button
  71211. * @param imageUrl defines the url of the image
  71212. * @returns a new Button
  71213. */
  71214. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71215. }
  71216. }
  71217. declare module BABYLON.GUI {
  71218. /**
  71219. * Class used to create a 2D stack panel container
  71220. */
  71221. export class StackPanel extends Container {
  71222. name?: string | undefined;
  71223. private _isVertical;
  71224. private _manualWidth;
  71225. private _manualHeight;
  71226. private _doNotTrackManualChanges;
  71227. /**
  71228. * Gets or sets a boolean indicating that layou warnings should be ignored
  71229. */
  71230. ignoreLayoutWarnings: boolean;
  71231. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71232. get isVertical(): boolean;
  71233. set isVertical(value: boolean);
  71234. /**
  71235. * Gets or sets panel width.
  71236. * This value should not be set when in horizontal mode as it will be computed automatically
  71237. */
  71238. set width(value: string | number);
  71239. get width(): string | number;
  71240. /**
  71241. * Gets or sets panel height.
  71242. * This value should not be set when in vertical mode as it will be computed automatically
  71243. */
  71244. set height(value: string | number);
  71245. get height(): string | number;
  71246. /**
  71247. * Creates a new StackPanel
  71248. * @param name defines control name
  71249. */
  71250. constructor(name?: string | undefined);
  71251. protected _getTypeName(): string;
  71252. /** @hidden */
  71253. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71254. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71255. protected _postMeasure(): void;
  71256. }
  71257. }
  71258. declare module BABYLON.GUI {
  71259. /**
  71260. * Class used to represent a 2D checkbox
  71261. */
  71262. export class Checkbox extends Control {
  71263. name?: string | undefined;
  71264. private _isChecked;
  71265. private _background;
  71266. private _checkSizeRatio;
  71267. private _thickness;
  71268. /** Gets or sets border thickness */
  71269. get thickness(): number;
  71270. set thickness(value: number);
  71271. /**
  71272. * BABYLON.Observable raised when isChecked property changes
  71273. */
  71274. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71275. /** Gets or sets a value indicating the ratio between overall size and check size */
  71276. get checkSizeRatio(): number;
  71277. set checkSizeRatio(value: number);
  71278. /** Gets or sets background color */
  71279. get background(): string;
  71280. set background(value: string);
  71281. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71282. get isChecked(): boolean;
  71283. set isChecked(value: boolean);
  71284. /**
  71285. * Creates a new CheckBox
  71286. * @param name defines the control name
  71287. */
  71288. constructor(name?: string | undefined);
  71289. protected _getTypeName(): string;
  71290. /** @hidden */
  71291. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71292. /** @hidden */
  71293. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71294. /**
  71295. * Utility function to easily create a checkbox with a header
  71296. * @param title defines the label to use for the header
  71297. * @param onValueChanged defines the callback to call when value changes
  71298. * @returns a StackPanel containing the checkbox and a textBlock
  71299. */
  71300. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  71301. }
  71302. }
  71303. declare module BABYLON.GUI {
  71304. /**
  71305. * Class used to store key control properties
  71306. */
  71307. export class KeyPropertySet {
  71308. /** Width */
  71309. width?: string;
  71310. /** Height */
  71311. height?: string;
  71312. /** Left padding */
  71313. paddingLeft?: string;
  71314. /** Right padding */
  71315. paddingRight?: string;
  71316. /** Top padding */
  71317. paddingTop?: string;
  71318. /** Bottom padding */
  71319. paddingBottom?: string;
  71320. /** Foreground color */
  71321. color?: string;
  71322. /** Background color */
  71323. background?: string;
  71324. }
  71325. /**
  71326. * Class used to create virtual keyboard
  71327. */
  71328. export class VirtualKeyboard extends StackPanel {
  71329. /** BABYLON.Observable raised when a key is pressed */
  71330. onKeyPressObservable: BABYLON.Observable<string>;
  71331. /** Gets or sets default key button width */
  71332. defaultButtonWidth: string;
  71333. /** Gets or sets default key button height */
  71334. defaultButtonHeight: string;
  71335. /** Gets or sets default key button left padding */
  71336. defaultButtonPaddingLeft: string;
  71337. /** Gets or sets default key button right padding */
  71338. defaultButtonPaddingRight: string;
  71339. /** Gets or sets default key button top padding */
  71340. defaultButtonPaddingTop: string;
  71341. /** Gets or sets default key button bottom padding */
  71342. defaultButtonPaddingBottom: string;
  71343. /** Gets or sets default key button foreground color */
  71344. defaultButtonColor: string;
  71345. /** Gets or sets default key button background color */
  71346. defaultButtonBackground: string;
  71347. /** Gets or sets shift button foreground color */
  71348. shiftButtonColor: string;
  71349. /** Gets or sets shift button thickness*/
  71350. selectedShiftThickness: number;
  71351. /** Gets shift key state */
  71352. shiftState: number;
  71353. protected _getTypeName(): string;
  71354. private _createKey;
  71355. /**
  71356. * Adds a new row of keys
  71357. * @param keys defines the list of keys to add
  71358. * @param propertySets defines the associated property sets
  71359. */
  71360. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  71361. /**
  71362. * Set the shift key to a specific state
  71363. * @param shiftState defines the new shift state
  71364. */
  71365. applyShiftState(shiftState: number): void;
  71366. private _currentlyConnectedInputText;
  71367. private _connectedInputTexts;
  71368. private _onKeyPressObserver;
  71369. /** Gets the input text control currently attached to the keyboard */
  71370. get connectedInputText(): BABYLON.Nullable<InputText>;
  71371. /**
  71372. * Connects the keyboard with an input text control
  71373. *
  71374. * @param input defines the target control
  71375. */
  71376. connect(input: InputText): void;
  71377. /**
  71378. * Disconnects the keyboard from connected InputText controls
  71379. *
  71380. * @param input optionally defines a target control, otherwise all are disconnected
  71381. */
  71382. disconnect(input?: InputText): void;
  71383. private _removeConnectedInputObservables;
  71384. /**
  71385. * Release all resources
  71386. */
  71387. dispose(): void;
  71388. /**
  71389. * Creates a new keyboard using a default layout
  71390. *
  71391. * @param name defines control name
  71392. * @returns a new VirtualKeyboard
  71393. */
  71394. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  71395. }
  71396. }
  71397. declare module BABYLON.GUI {
  71398. /**
  71399. * Class used to create input text control
  71400. */
  71401. export class InputText extends Control implements IFocusableControl {
  71402. name?: string | undefined;
  71403. private _text;
  71404. private _placeholderText;
  71405. private _background;
  71406. private _focusedBackground;
  71407. private _focusedColor;
  71408. private _placeholderColor;
  71409. private _thickness;
  71410. private _margin;
  71411. private _autoStretchWidth;
  71412. private _maxWidth;
  71413. private _isFocused;
  71414. private _blinkTimeout;
  71415. private _blinkIsEven;
  71416. private _cursorOffset;
  71417. private _scrollLeft;
  71418. private _textWidth;
  71419. private _clickedCoordinate;
  71420. private _deadKey;
  71421. private _addKey;
  71422. private _currentKey;
  71423. private _isTextHighlightOn;
  71424. private _textHighlightColor;
  71425. private _highligherOpacity;
  71426. private _highlightedText;
  71427. private _startHighlightIndex;
  71428. private _endHighlightIndex;
  71429. private _cursorIndex;
  71430. private _onFocusSelectAll;
  71431. private _isPointerDown;
  71432. private _onClipboardObserver;
  71433. private _onPointerDblTapObserver;
  71434. /** @hidden */
  71435. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  71436. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  71437. promptMessage: string;
  71438. /** Force disable prompt on mobile device */
  71439. disableMobilePrompt: boolean;
  71440. /** BABYLON.Observable raised when the text changes */
  71441. onTextChangedObservable: BABYLON.Observable<InputText>;
  71442. /** BABYLON.Observable raised just before an entered character is to be added */
  71443. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  71444. /** BABYLON.Observable raised when the control gets the focus */
  71445. onFocusObservable: BABYLON.Observable<InputText>;
  71446. /** BABYLON.Observable raised when the control loses the focus */
  71447. onBlurObservable: BABYLON.Observable<InputText>;
  71448. /**Observable raised when the text is highlighted */
  71449. onTextHighlightObservable: BABYLON.Observable<InputText>;
  71450. /**Observable raised when copy event is triggered */
  71451. onTextCopyObservable: BABYLON.Observable<InputText>;
  71452. /** BABYLON.Observable raised when cut event is triggered */
  71453. onTextCutObservable: BABYLON.Observable<InputText>;
  71454. /** BABYLON.Observable raised when paste event is triggered */
  71455. onTextPasteObservable: BABYLON.Observable<InputText>;
  71456. /** BABYLON.Observable raised when a key event was processed */
  71457. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  71458. /** Gets or sets the maximum width allowed by the control */
  71459. get maxWidth(): string | number;
  71460. /** Gets the maximum width allowed by the control in pixels */
  71461. get maxWidthInPixels(): number;
  71462. set maxWidth(value: string | number);
  71463. /** Gets or sets the text highlighter transparency; default: 0.4 */
  71464. get highligherOpacity(): number;
  71465. set highligherOpacity(value: number);
  71466. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  71467. get onFocusSelectAll(): boolean;
  71468. set onFocusSelectAll(value: boolean);
  71469. /** Gets or sets the text hightlight color */
  71470. get textHighlightColor(): string;
  71471. set textHighlightColor(value: string);
  71472. /** Gets or sets control margin */
  71473. get margin(): string;
  71474. /** Gets control margin in pixels */
  71475. get marginInPixels(): number;
  71476. set margin(value: string);
  71477. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  71478. get autoStretchWidth(): boolean;
  71479. set autoStretchWidth(value: boolean);
  71480. /** Gets or sets border thickness */
  71481. get thickness(): number;
  71482. set thickness(value: number);
  71483. /** Gets or sets the background color when focused */
  71484. get focusedBackground(): string;
  71485. set focusedBackground(value: string);
  71486. /** Gets or sets the background color when focused */
  71487. get focusedColor(): string;
  71488. set focusedColor(value: string);
  71489. /** Gets or sets the background color */
  71490. get background(): string;
  71491. set background(value: string);
  71492. /** Gets or sets the placeholder color */
  71493. get placeholderColor(): string;
  71494. set placeholderColor(value: string);
  71495. /** Gets or sets the text displayed when the control is empty */
  71496. get placeholderText(): string;
  71497. set placeholderText(value: string);
  71498. /** Gets or sets the dead key flag */
  71499. get deadKey(): boolean;
  71500. set deadKey(flag: boolean);
  71501. /** Gets or sets the highlight text */
  71502. get highlightedText(): string;
  71503. set highlightedText(text: string);
  71504. /** Gets or sets if the current key should be added */
  71505. get addKey(): boolean;
  71506. set addKey(flag: boolean);
  71507. /** Gets or sets the value of the current key being entered */
  71508. get currentKey(): string;
  71509. set currentKey(key: string);
  71510. /** Gets or sets the text displayed in the control */
  71511. get text(): string;
  71512. set text(value: string);
  71513. /** Gets or sets control width */
  71514. get width(): string | number;
  71515. set width(value: string | number);
  71516. /**
  71517. * Creates a new InputText
  71518. * @param name defines the control name
  71519. * @param text defines the text of the control
  71520. */
  71521. constructor(name?: string | undefined, text?: string);
  71522. /** @hidden */
  71523. onBlur(): void;
  71524. /** @hidden */
  71525. onFocus(): void;
  71526. protected _getTypeName(): string;
  71527. /**
  71528. * Function called to get the list of controls that should not steal the focus from this control
  71529. * @returns an array of controls
  71530. */
  71531. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71532. /** @hidden */
  71533. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  71534. /** @hidden */
  71535. private _updateValueFromCursorIndex;
  71536. /** @hidden */
  71537. private _processDblClick;
  71538. /** @hidden */
  71539. private _selectAllText;
  71540. /**
  71541. * Handles the keyboard event
  71542. * @param evt Defines the KeyboardEvent
  71543. */
  71544. processKeyboard(evt: KeyboardEvent): void;
  71545. /** @hidden */
  71546. private _onCopyText;
  71547. /** @hidden */
  71548. private _onCutText;
  71549. /** @hidden */
  71550. private _onPasteText;
  71551. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71552. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71553. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71554. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71555. protected _beforeRenderText(text: string): string;
  71556. dispose(): void;
  71557. }
  71558. }
  71559. declare module BABYLON.GUI {
  71560. /**
  71561. * Class used to create a 2D grid container
  71562. */
  71563. export class Grid extends Container {
  71564. name?: string | undefined;
  71565. private _rowDefinitions;
  71566. private _columnDefinitions;
  71567. private _cells;
  71568. private _childControls;
  71569. /**
  71570. * Gets the number of columns
  71571. */
  71572. get columnCount(): number;
  71573. /**
  71574. * Gets the number of rows
  71575. */
  71576. get rowCount(): number;
  71577. /** Gets the list of children */
  71578. get children(): Control[];
  71579. /** Gets the list of cells (e.g. the containers) */
  71580. get cells(): {
  71581. [key: string]: Container;
  71582. };
  71583. /**
  71584. * Gets the definition of a specific row
  71585. * @param index defines the index of the row
  71586. * @returns the row definition
  71587. */
  71588. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  71589. /**
  71590. * Gets the definition of a specific column
  71591. * @param index defines the index of the column
  71592. * @returns the column definition
  71593. */
  71594. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  71595. /**
  71596. * Adds a new row to the grid
  71597. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  71598. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  71599. * @returns the current grid
  71600. */
  71601. addRowDefinition(height: number, isPixel?: boolean): Grid;
  71602. /**
  71603. * Adds a new column to the grid
  71604. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  71605. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  71606. * @returns the current grid
  71607. */
  71608. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  71609. /**
  71610. * Update a row definition
  71611. * @param index defines the index of the row to update
  71612. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  71613. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  71614. * @returns the current grid
  71615. */
  71616. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  71617. /**
  71618. * Update a column definition
  71619. * @param index defines the index of the column to update
  71620. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  71621. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  71622. * @returns the current grid
  71623. */
  71624. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  71625. /**
  71626. * Gets the list of children stored in a specific cell
  71627. * @param row defines the row to check
  71628. * @param column defines the column to check
  71629. * @returns the list of controls
  71630. */
  71631. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  71632. /**
  71633. * Gets a string representing the child cell info (row x column)
  71634. * @param child defines the control to get info from
  71635. * @returns a string containing the child cell info (row x column)
  71636. */
  71637. getChildCellInfo(child: Control): string;
  71638. private _removeCell;
  71639. private _offsetCell;
  71640. /**
  71641. * Remove a column definition at specified index
  71642. * @param index defines the index of the column to remove
  71643. * @returns the current grid
  71644. */
  71645. removeColumnDefinition(index: number): Grid;
  71646. /**
  71647. * Remove a row definition at specified index
  71648. * @param index defines the index of the row to remove
  71649. * @returns the current grid
  71650. */
  71651. removeRowDefinition(index: number): Grid;
  71652. /**
  71653. * Adds a new control to the current grid
  71654. * @param control defines the control to add
  71655. * @param row defines the row where to add the control (0 by default)
  71656. * @param column defines the column where to add the control (0 by default)
  71657. * @returns the current grid
  71658. */
  71659. addControl(control: Control, row?: number, column?: number): Grid;
  71660. /**
  71661. * Removes a control from the current container
  71662. * @param control defines the control to remove
  71663. * @returns the current container
  71664. */
  71665. removeControl(control: Control): Container;
  71666. /**
  71667. * Creates a new Grid
  71668. * @param name defines control name
  71669. */
  71670. constructor(name?: string | undefined);
  71671. protected _getTypeName(): string;
  71672. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  71673. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71674. _flagDescendantsAsMatrixDirty(): void;
  71675. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71676. /** Releases associated resources */
  71677. dispose(): void;
  71678. }
  71679. }
  71680. declare module BABYLON.GUI {
  71681. /** Class used to create color pickers */
  71682. export class ColorPicker extends Control {
  71683. name?: string | undefined;
  71684. private static _Epsilon;
  71685. private _colorWheelCanvas;
  71686. private _value;
  71687. private _tmpColor;
  71688. private _pointerStartedOnSquare;
  71689. private _pointerStartedOnWheel;
  71690. private _squareLeft;
  71691. private _squareTop;
  71692. private _squareSize;
  71693. private _h;
  71694. private _s;
  71695. private _v;
  71696. private _lastPointerDownID;
  71697. /**
  71698. * BABYLON.Observable raised when the value changes
  71699. */
  71700. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  71701. /** Gets or sets the color of the color picker */
  71702. get value(): BABYLON.Color3;
  71703. set value(value: BABYLON.Color3);
  71704. /**
  71705. * Gets or sets control width
  71706. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71707. */
  71708. get width(): string | number;
  71709. set width(value: string | number);
  71710. /**
  71711. * Gets or sets control height
  71712. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71713. */
  71714. get height(): string | number;
  71715. /** Gets or sets control height */
  71716. set height(value: string | number);
  71717. /** Gets or sets control size */
  71718. get size(): string | number;
  71719. set size(value: string | number);
  71720. /**
  71721. * Creates a new ColorPicker
  71722. * @param name defines the control name
  71723. */
  71724. constructor(name?: string | undefined);
  71725. protected _getTypeName(): string;
  71726. /** @hidden */
  71727. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71728. private _updateSquareProps;
  71729. private _drawGradientSquare;
  71730. private _drawCircle;
  71731. private _createColorWheelCanvas;
  71732. /** @hidden */
  71733. _draw(context: CanvasRenderingContext2D): void;
  71734. private _pointerIsDown;
  71735. private _updateValueFromPointer;
  71736. private _isPointOnSquare;
  71737. private _isPointOnWheel;
  71738. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71739. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71740. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71741. /**
  71742. * This function expands the color picker by creating a color picker dialog with manual
  71743. * color value input and the ability to save colors into an array to be used later in
  71744. * subsequent launches of the dialogue.
  71745. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  71746. * @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.
  71747. * @returns picked color as a hex string and the saved colors array as hex strings.
  71748. */
  71749. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  71750. pickerWidth?: string;
  71751. pickerHeight?: string;
  71752. headerHeight?: string;
  71753. lastColor?: string;
  71754. swatchLimit?: number;
  71755. numSwatchesPerLine?: number;
  71756. savedColors?: Array<string>;
  71757. }): Promise<{
  71758. savedColors?: string[];
  71759. pickedColor: string;
  71760. }>;
  71761. }
  71762. }
  71763. declare module BABYLON.GUI {
  71764. /** Class used to create 2D ellipse containers */
  71765. export class Ellipse extends Container {
  71766. name?: string | undefined;
  71767. private _thickness;
  71768. /** Gets or sets border thickness */
  71769. get thickness(): number;
  71770. set thickness(value: number);
  71771. /**
  71772. * Creates a new Ellipse
  71773. * @param name defines the control name
  71774. */
  71775. constructor(name?: string | undefined);
  71776. protected _getTypeName(): string;
  71777. protected _localDraw(context: CanvasRenderingContext2D): void;
  71778. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71779. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71780. }
  71781. }
  71782. declare module BABYLON.GUI {
  71783. /**
  71784. * Class used to create a password control
  71785. */
  71786. export class InputPassword extends InputText {
  71787. protected _beforeRenderText(text: string): string;
  71788. }
  71789. }
  71790. declare module BABYLON.GUI {
  71791. /** Class used to render 2D lines */
  71792. export class Line extends Control {
  71793. name?: string | undefined;
  71794. private _lineWidth;
  71795. private _x1;
  71796. private _y1;
  71797. private _x2;
  71798. private _y2;
  71799. private _dash;
  71800. private _connectedControl;
  71801. private _connectedControlDirtyObserver;
  71802. /** Gets or sets the dash pattern */
  71803. get dash(): Array<number>;
  71804. set dash(value: Array<number>);
  71805. /** Gets or sets the control connected with the line end */
  71806. get connectedControl(): Control;
  71807. set connectedControl(value: Control);
  71808. /** Gets or sets start coordinates on X axis */
  71809. get x1(): string | number;
  71810. set x1(value: string | number);
  71811. /** Gets or sets start coordinates on Y axis */
  71812. get y1(): string | number;
  71813. set y1(value: string | number);
  71814. /** Gets or sets end coordinates on X axis */
  71815. get x2(): string | number;
  71816. set x2(value: string | number);
  71817. /** Gets or sets end coordinates on Y axis */
  71818. get y2(): string | number;
  71819. set y2(value: string | number);
  71820. /** Gets or sets line width */
  71821. get lineWidth(): number;
  71822. set lineWidth(value: number);
  71823. /** Gets or sets horizontal alignment */
  71824. set horizontalAlignment(value: number);
  71825. /** Gets or sets vertical alignment */
  71826. set verticalAlignment(value: number);
  71827. private get _effectiveX2();
  71828. private get _effectiveY2();
  71829. /**
  71830. * Creates a new Line
  71831. * @param name defines the control name
  71832. */
  71833. constructor(name?: string | undefined);
  71834. protected _getTypeName(): string;
  71835. _draw(context: CanvasRenderingContext2D): void;
  71836. _measure(): void;
  71837. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71838. /**
  71839. * Move one end of the line given 3D cartesian coordinates.
  71840. * @param position Targeted world position
  71841. * @param scene BABYLON.Scene
  71842. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  71843. */
  71844. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  71845. /**
  71846. * Move one end of the line to a position in screen absolute space.
  71847. * @param projectedPosition Position in screen absolute space (X, Y)
  71848. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  71849. */
  71850. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  71851. }
  71852. }
  71853. declare module BABYLON.GUI {
  71854. /**
  71855. * Class used to store a point for a MultiLine object.
  71856. * The point can be pure 2D coordinates, a mesh or a control
  71857. */
  71858. export class MultiLinePoint {
  71859. private _multiLine;
  71860. private _x;
  71861. private _y;
  71862. private _control;
  71863. private _mesh;
  71864. private _controlObserver;
  71865. private _meshObserver;
  71866. /** @hidden */
  71867. _point: BABYLON.Vector2;
  71868. /**
  71869. * Creates a new MultiLinePoint
  71870. * @param multiLine defines the source MultiLine object
  71871. */
  71872. constructor(multiLine: MultiLine);
  71873. /** Gets or sets x coordinate */
  71874. get x(): string | number;
  71875. set x(value: string | number);
  71876. /** Gets or sets y coordinate */
  71877. get y(): string | number;
  71878. set y(value: string | number);
  71879. /** Gets or sets the control associated with this point */
  71880. get control(): BABYLON.Nullable<Control>;
  71881. set control(value: BABYLON.Nullable<Control>);
  71882. /** Gets or sets the mesh associated with this point */
  71883. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71884. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  71885. /** Resets links */
  71886. resetLinks(): void;
  71887. /**
  71888. * Gets a translation vector
  71889. * @returns the translation vector
  71890. */
  71891. translate(): BABYLON.Vector2;
  71892. private _translatePoint;
  71893. /** Release associated resources */
  71894. dispose(): void;
  71895. }
  71896. }
  71897. declare module BABYLON.GUI {
  71898. /**
  71899. * Class used to create multi line control
  71900. */
  71901. export class MultiLine extends Control {
  71902. name?: string | undefined;
  71903. private _lineWidth;
  71904. private _dash;
  71905. private _points;
  71906. private _minX;
  71907. private _minY;
  71908. private _maxX;
  71909. private _maxY;
  71910. /**
  71911. * Creates a new MultiLine
  71912. * @param name defines the control name
  71913. */
  71914. constructor(name?: string | undefined);
  71915. /** Gets or sets dash pattern */
  71916. get dash(): Array<number>;
  71917. set dash(value: Array<number>);
  71918. /**
  71919. * Gets point stored at specified index
  71920. * @param index defines the index to look for
  71921. * @returns the requested point if found
  71922. */
  71923. getAt(index: number): MultiLinePoint;
  71924. /** Function called when a point is updated */
  71925. onPointUpdate: () => void;
  71926. /**
  71927. * Adds new points to the point collection
  71928. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  71929. * @returns the list of created MultiLinePoint
  71930. */
  71931. add(...items: (AbstractMesh | Control | {
  71932. x: string | number;
  71933. y: string | number;
  71934. })[]): MultiLinePoint[];
  71935. /**
  71936. * Adds a new point to the point collection
  71937. * @param item defines the item (mesh, control or 2d coordiantes) to add
  71938. * @returns the created MultiLinePoint
  71939. */
  71940. push(item?: (AbstractMesh | Control | {
  71941. x: string | number;
  71942. y: string | number;
  71943. })): MultiLinePoint;
  71944. /**
  71945. * Remove a specific value or point from the active point collection
  71946. * @param value defines the value or point to remove
  71947. */
  71948. remove(value: number | MultiLinePoint): void;
  71949. /**
  71950. * Resets this object to initial state (no point)
  71951. */
  71952. reset(): void;
  71953. /**
  71954. * Resets all links
  71955. */
  71956. resetLinks(): void;
  71957. /** Gets or sets line width */
  71958. get lineWidth(): number;
  71959. set lineWidth(value: number);
  71960. set horizontalAlignment(value: number);
  71961. set verticalAlignment(value: number);
  71962. protected _getTypeName(): string;
  71963. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71964. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71965. _measure(): void;
  71966. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71967. dispose(): void;
  71968. }
  71969. }
  71970. declare module BABYLON.GUI {
  71971. /**
  71972. * Class used to create radio button controls
  71973. */
  71974. export class RadioButton extends Control {
  71975. name?: string | undefined;
  71976. private _isChecked;
  71977. private _background;
  71978. private _checkSizeRatio;
  71979. private _thickness;
  71980. /** Gets or sets border thickness */
  71981. get thickness(): number;
  71982. set thickness(value: number);
  71983. /** Gets or sets group name */
  71984. group: string;
  71985. /** BABYLON.Observable raised when isChecked is changed */
  71986. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71987. /** Gets or sets a value indicating the ratio between overall size and check size */
  71988. get checkSizeRatio(): number;
  71989. set checkSizeRatio(value: number);
  71990. /** Gets or sets background color */
  71991. get background(): string;
  71992. set background(value: string);
  71993. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71994. get isChecked(): boolean;
  71995. set isChecked(value: boolean);
  71996. /**
  71997. * Creates a new RadioButton
  71998. * @param name defines the control name
  71999. */
  72000. constructor(name?: string | undefined);
  72001. protected _getTypeName(): string;
  72002. _draw(context: CanvasRenderingContext2D): void;
  72003. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72004. /**
  72005. * Utility function to easily create a radio button with a header
  72006. * @param title defines the label to use for the header
  72007. * @param group defines the group to use for the radio button
  72008. * @param isChecked defines the initial state of the radio button
  72009. * @param onValueChanged defines the callback to call when value changes
  72010. * @returns a StackPanel containing the radio button and a textBlock
  72011. */
  72012. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  72013. }
  72014. }
  72015. declare module BABYLON.GUI {
  72016. /**
  72017. * Class used to create slider controls
  72018. */
  72019. export class BaseSlider extends Control {
  72020. name?: string | undefined;
  72021. protected _thumbWidth: ValueAndUnit;
  72022. private _minimum;
  72023. private _maximum;
  72024. private _value;
  72025. private _isVertical;
  72026. protected _barOffset: ValueAndUnit;
  72027. private _isThumbClamped;
  72028. protected _displayThumb: boolean;
  72029. private _step;
  72030. private _lastPointerDownID;
  72031. protected _effectiveBarOffset: number;
  72032. protected _renderLeft: number;
  72033. protected _renderTop: number;
  72034. protected _renderWidth: number;
  72035. protected _renderHeight: number;
  72036. protected _backgroundBoxLength: number;
  72037. protected _backgroundBoxThickness: number;
  72038. protected _effectiveThumbThickness: number;
  72039. /** BABYLON.Observable raised when the sldier value changes */
  72040. onValueChangedObservable: BABYLON.Observable<number>;
  72041. /** Gets or sets a boolean indicating if the thumb must be rendered */
  72042. get displayThumb(): boolean;
  72043. set displayThumb(value: boolean);
  72044. /** Gets or sets a step to apply to values (0 by default) */
  72045. get step(): number;
  72046. set step(value: number);
  72047. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  72048. get barOffset(): string | number;
  72049. /** Gets main bar offset in pixels*/
  72050. get barOffsetInPixels(): number;
  72051. set barOffset(value: string | number);
  72052. /** Gets or sets thumb width */
  72053. get thumbWidth(): string | number;
  72054. /** Gets thumb width in pixels */
  72055. get thumbWidthInPixels(): number;
  72056. set thumbWidth(value: string | number);
  72057. /** Gets or sets minimum value */
  72058. get minimum(): number;
  72059. set minimum(value: number);
  72060. /** Gets or sets maximum value */
  72061. get maximum(): number;
  72062. set maximum(value: number);
  72063. /** Gets or sets current value */
  72064. get value(): number;
  72065. set value(value: number);
  72066. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  72067. get isVertical(): boolean;
  72068. set isVertical(value: boolean);
  72069. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  72070. get isThumbClamped(): boolean;
  72071. set isThumbClamped(value: boolean);
  72072. /**
  72073. * Creates a new BaseSlider
  72074. * @param name defines the control name
  72075. */
  72076. constructor(name?: string | undefined);
  72077. protected _getTypeName(): string;
  72078. protected _getThumbPosition(): number;
  72079. protected _getThumbThickness(type: string): number;
  72080. protected _prepareRenderingData(type: string): void;
  72081. private _pointerIsDown;
  72082. /** @hidden */
  72083. protected _updateValueFromPointer(x: number, y: number): void;
  72084. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72085. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72086. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72087. }
  72088. }
  72089. declare module BABYLON.GUI {
  72090. /**
  72091. * Class used to create slider controls
  72092. */
  72093. export class Slider extends BaseSlider {
  72094. name?: string | undefined;
  72095. private _background;
  72096. private _borderColor;
  72097. private _isThumbCircle;
  72098. protected _displayValueBar: boolean;
  72099. /** Gets or sets a boolean indicating if the value bar must be rendered */
  72100. get displayValueBar(): boolean;
  72101. set displayValueBar(value: boolean);
  72102. /** Gets or sets border color */
  72103. get borderColor(): string;
  72104. set borderColor(value: string);
  72105. /** Gets or sets background color */
  72106. get background(): string;
  72107. set background(value: string);
  72108. /** Gets or sets a boolean indicating if the thumb should be round or square */
  72109. get isThumbCircle(): boolean;
  72110. set isThumbCircle(value: boolean);
  72111. /**
  72112. * Creates a new Slider
  72113. * @param name defines the control name
  72114. */
  72115. constructor(name?: string | undefined);
  72116. protected _getTypeName(): string;
  72117. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72118. }
  72119. }
  72120. declare module BABYLON.GUI {
  72121. /** Class used to create a RadioGroup
  72122. * which contains groups of radio buttons
  72123. */
  72124. export class SelectorGroup {
  72125. /** name of SelectorGroup */
  72126. name: string;
  72127. private _groupPanel;
  72128. private _selectors;
  72129. private _groupHeader;
  72130. /**
  72131. * Creates a new SelectorGroup
  72132. * @param name of group, used as a group heading
  72133. */
  72134. constructor(
  72135. /** name of SelectorGroup */
  72136. name: string);
  72137. /** Gets the groupPanel of the SelectorGroup */
  72138. get groupPanel(): StackPanel;
  72139. /** Gets the selectors array */
  72140. get selectors(): StackPanel[];
  72141. /** Gets and sets the group header */
  72142. get header(): string;
  72143. set header(label: string);
  72144. /** @hidden */
  72145. private _addGroupHeader;
  72146. /** @hidden*/
  72147. _getSelector(selectorNb: number): StackPanel | undefined;
  72148. /** Removes the selector at the given position
  72149. * @param selectorNb the position of the selector within the group
  72150. */
  72151. removeSelector(selectorNb: number): void;
  72152. }
  72153. /** Class used to create a CheckboxGroup
  72154. * which contains groups of checkbox buttons
  72155. */
  72156. export class CheckboxGroup extends SelectorGroup {
  72157. /** Adds a checkbox as a control
  72158. * @param text is the label for the selector
  72159. * @param func is the function called when the Selector is checked
  72160. * @param checked is true when Selector is checked
  72161. */
  72162. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  72163. /** @hidden */
  72164. _setSelectorLabel(selectorNb: number, label: string): void;
  72165. /** @hidden */
  72166. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72167. /** @hidden */
  72168. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72169. /** @hidden */
  72170. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72171. }
  72172. /** Class used to create a RadioGroup
  72173. * which contains groups of radio buttons
  72174. */
  72175. export class RadioGroup extends SelectorGroup {
  72176. private _selectNb;
  72177. /** Adds a radio button as a control
  72178. * @param label is the label for the selector
  72179. * @param func is the function called when the Selector is checked
  72180. * @param checked is true when Selector is checked
  72181. */
  72182. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72183. /** @hidden */
  72184. _setSelectorLabel(selectorNb: number, label: string): void;
  72185. /** @hidden */
  72186. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72187. /** @hidden */
  72188. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72189. /** @hidden */
  72190. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72191. }
  72192. /** Class used to create a SliderGroup
  72193. * which contains groups of slider buttons
  72194. */
  72195. export class SliderGroup extends SelectorGroup {
  72196. /**
  72197. * Adds a slider to the SelectorGroup
  72198. * @param label is the label for the SliderBar
  72199. * @param func is the function called when the Slider moves
  72200. * @param unit is a string describing the units used, eg degrees or metres
  72201. * @param min is the minimum value for the Slider
  72202. * @param max is the maximum value for the Slider
  72203. * @param value is the start value for the Slider between min and max
  72204. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72205. */
  72206. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72207. /** @hidden */
  72208. _setSelectorLabel(selectorNb: number, label: string): void;
  72209. /** @hidden */
  72210. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72211. /** @hidden */
  72212. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72213. /** @hidden */
  72214. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72215. }
  72216. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72217. * @see http://doc.babylonjs.com/how_to/selector
  72218. */
  72219. export class SelectionPanel extends Rectangle {
  72220. /** name of SelectionPanel */
  72221. name: string;
  72222. /** an array of SelectionGroups */
  72223. groups: SelectorGroup[];
  72224. private _panel;
  72225. private _buttonColor;
  72226. private _buttonBackground;
  72227. private _headerColor;
  72228. private _barColor;
  72229. private _barHeight;
  72230. private _spacerHeight;
  72231. private _labelColor;
  72232. private _groups;
  72233. private _bars;
  72234. /**
  72235. * Creates a new SelectionPanel
  72236. * @param name of SelectionPanel
  72237. * @param groups is an array of SelectionGroups
  72238. */
  72239. constructor(
  72240. /** name of SelectionPanel */
  72241. name: string,
  72242. /** an array of SelectionGroups */
  72243. groups?: SelectorGroup[]);
  72244. protected _getTypeName(): string;
  72245. /** Gets or sets the headerColor */
  72246. get headerColor(): string;
  72247. set headerColor(color: string);
  72248. private _setHeaderColor;
  72249. /** Gets or sets the button color */
  72250. get buttonColor(): string;
  72251. set buttonColor(color: string);
  72252. private _setbuttonColor;
  72253. /** Gets or sets the label color */
  72254. get labelColor(): string;
  72255. set labelColor(color: string);
  72256. private _setLabelColor;
  72257. /** Gets or sets the button background */
  72258. get buttonBackground(): string;
  72259. set buttonBackground(color: string);
  72260. private _setButtonBackground;
  72261. /** Gets or sets the color of separator bar */
  72262. get barColor(): string;
  72263. set barColor(color: string);
  72264. private _setBarColor;
  72265. /** Gets or sets the height of separator bar */
  72266. get barHeight(): string;
  72267. set barHeight(value: string);
  72268. private _setBarHeight;
  72269. /** Gets or sets the height of spacers*/
  72270. get spacerHeight(): string;
  72271. set spacerHeight(value: string);
  72272. private _setSpacerHeight;
  72273. /** Adds a bar between groups */
  72274. private _addSpacer;
  72275. /** Add a group to the selection panel
  72276. * @param group is the selector group to add
  72277. */
  72278. addGroup(group: SelectorGroup): void;
  72279. /** Remove the group from the given position
  72280. * @param groupNb is the position of the group in the list
  72281. */
  72282. removeGroup(groupNb: number): void;
  72283. /** Change a group header label
  72284. * @param label is the new group header label
  72285. * @param groupNb is the number of the group to relabel
  72286. * */
  72287. setHeaderName(label: string, groupNb: number): void;
  72288. /** Change selector label to the one given
  72289. * @param label is the new selector label
  72290. * @param groupNb is the number of the groupcontaining the selector
  72291. * @param selectorNb is the number of the selector within a group to relabel
  72292. * */
  72293. relabel(label: string, groupNb: number, selectorNb: number): void;
  72294. /** For a given group position remove the selector at the given position
  72295. * @param groupNb is the number of the group to remove the selector from
  72296. * @param selectorNb is the number of the selector within the group
  72297. */
  72298. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  72299. /** For a given group position of correct type add a checkbox button
  72300. * @param groupNb is the number of the group to remove the selector from
  72301. * @param label is the label for the selector
  72302. * @param func is the function called when the Selector is checked
  72303. * @param checked is true when Selector is checked
  72304. */
  72305. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72306. /** For a given group position of correct type add a radio button
  72307. * @param groupNb is the number of the group to remove the selector from
  72308. * @param label is the label for the selector
  72309. * @param func is the function called when the Selector is checked
  72310. * @param checked is true when Selector is checked
  72311. */
  72312. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72313. /**
  72314. * For a given slider group add a slider
  72315. * @param groupNb is the number of the group to add the slider to
  72316. * @param label is the label for the Slider
  72317. * @param func is the function called when the Slider moves
  72318. * @param unit is a string describing the units used, eg degrees or metres
  72319. * @param min is the minimum value for the Slider
  72320. * @param max is the maximum value for the Slider
  72321. * @param value is the start value for the Slider between min and max
  72322. * @param onVal is the function used to format the value displayed, eg radians to degrees
  72323. */
  72324. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  72325. }
  72326. }
  72327. declare module BABYLON.GUI {
  72328. /**
  72329. * Class used to hold a the container for ScrollViewer
  72330. * @hidden
  72331. */
  72332. export class _ScrollViewerWindow extends Container {
  72333. parentClientWidth: number;
  72334. parentClientHeight: number;
  72335. /**
  72336. * Creates a new ScrollViewerWindow
  72337. * @param name of ScrollViewerWindow
  72338. */
  72339. constructor(name?: string);
  72340. protected _getTypeName(): string;
  72341. /** @hidden */
  72342. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72343. protected _postMeasure(): void;
  72344. }
  72345. }
  72346. declare module BABYLON.GUI {
  72347. /**
  72348. * Class used to create slider controls
  72349. */
  72350. export class ScrollBar extends BaseSlider {
  72351. name?: string | undefined;
  72352. private _background;
  72353. private _borderColor;
  72354. private _tempMeasure;
  72355. /** Gets or sets border color */
  72356. get borderColor(): string;
  72357. set borderColor(value: string);
  72358. /** Gets or sets background color */
  72359. get background(): string;
  72360. set background(value: string);
  72361. /**
  72362. * Creates a new Slider
  72363. * @param name defines the control name
  72364. */
  72365. constructor(name?: string | undefined);
  72366. protected _getTypeName(): string;
  72367. protected _getThumbThickness(): number;
  72368. _draw(context: CanvasRenderingContext2D): void;
  72369. private _first;
  72370. private _originX;
  72371. private _originY;
  72372. /** @hidden */
  72373. protected _updateValueFromPointer(x: number, y: number): void;
  72374. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72375. }
  72376. }
  72377. declare module BABYLON.GUI {
  72378. /**
  72379. * Class used to create slider controls
  72380. */
  72381. export class ImageScrollBar extends BaseSlider {
  72382. name?: string | undefined;
  72383. private _backgroundBaseImage;
  72384. private _backgroundImage;
  72385. private _thumbImage;
  72386. private _thumbBaseImage;
  72387. private _thumbLength;
  72388. private _thumbHeight;
  72389. private _barImageHeight;
  72390. private _tempMeasure;
  72391. /**
  72392. * Gets or sets the image used to render the background for horizontal bar
  72393. */
  72394. get backgroundImage(): Image;
  72395. set backgroundImage(value: Image);
  72396. /**
  72397. * Gets or sets the image used to render the thumb
  72398. */
  72399. get thumbImage(): Image;
  72400. set thumbImage(value: Image);
  72401. /**
  72402. * Gets or sets the length of the thumb
  72403. */
  72404. get thumbLength(): number;
  72405. set thumbLength(value: number);
  72406. /**
  72407. * Gets or sets the height of the thumb
  72408. */
  72409. get thumbHeight(): number;
  72410. set thumbHeight(value: number);
  72411. /**
  72412. * Gets or sets the height of the bar image
  72413. */
  72414. get barImageHeight(): number;
  72415. set barImageHeight(value: number);
  72416. /**
  72417. * Creates a new ImageScrollBar
  72418. * @param name defines the control name
  72419. */
  72420. constructor(name?: string | undefined);
  72421. protected _getTypeName(): string;
  72422. protected _getThumbThickness(): number;
  72423. _draw(context: CanvasRenderingContext2D): void;
  72424. private _first;
  72425. private _originX;
  72426. private _originY;
  72427. /** @hidden */
  72428. protected _updateValueFromPointer(x: number, y: number): void;
  72429. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72430. }
  72431. }
  72432. declare module BABYLON.GUI {
  72433. /**
  72434. * Class used to hold a viewer window and sliders in a grid
  72435. */
  72436. export class ScrollViewer extends Rectangle {
  72437. private _grid;
  72438. private _horizontalBarSpace;
  72439. private _verticalBarSpace;
  72440. private _dragSpace;
  72441. private _horizontalBar;
  72442. private _verticalBar;
  72443. private _barColor;
  72444. private _barBackground;
  72445. private _barImage;
  72446. private _barBackgroundImage;
  72447. private _barSize;
  72448. private _endLeft;
  72449. private _endTop;
  72450. private _window;
  72451. private _pointerIsOver;
  72452. private _wheelPrecision;
  72453. private _onPointerObserver;
  72454. private _clientWidth;
  72455. private _clientHeight;
  72456. private _useImageBar;
  72457. private _thumbLength;
  72458. private _thumbHeight;
  72459. private _barImageHeight;
  72460. /**
  72461. * Gets the horizontal scrollbar
  72462. */
  72463. get horizontalBar(): ScrollBar | ImageScrollBar;
  72464. /**
  72465. * Gets the vertical scrollbar
  72466. */
  72467. get verticalBar(): ScrollBar | ImageScrollBar;
  72468. /**
  72469. * Adds a new control to the current container
  72470. * @param control defines the control to add
  72471. * @returns the current container
  72472. */
  72473. addControl(control: BABYLON.Nullable<Control>): Container;
  72474. /**
  72475. * Removes a control from the current container
  72476. * @param control defines the control to remove
  72477. * @returns the current container
  72478. */
  72479. removeControl(control: Control): Container;
  72480. /** Gets the list of children */
  72481. get children(): Control[];
  72482. _flagDescendantsAsMatrixDirty(): void;
  72483. /**
  72484. * Creates a new ScrollViewer
  72485. * @param name of ScrollViewer
  72486. */
  72487. constructor(name?: string, isImageBased?: boolean);
  72488. /** Reset the scroll viewer window to initial size */
  72489. resetWindow(): void;
  72490. protected _getTypeName(): string;
  72491. private _buildClientSizes;
  72492. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72493. protected _postMeasure(): void;
  72494. /**
  72495. * Gets or sets the mouse wheel precision
  72496. * from 0 to 1 with a default value of 0.05
  72497. * */
  72498. get wheelPrecision(): number;
  72499. set wheelPrecision(value: number);
  72500. /** Gets or sets the scroll bar container background color */
  72501. get scrollBackground(): string;
  72502. set scrollBackground(color: string);
  72503. /** Gets or sets the bar color */
  72504. get barColor(): string;
  72505. set barColor(color: string);
  72506. /** Gets or sets the bar image */
  72507. get thumbImage(): Image;
  72508. set thumbImage(value: Image);
  72509. /** Gets or sets the size of the bar */
  72510. get barSize(): number;
  72511. set barSize(value: number);
  72512. /** Gets or sets the length of the thumb */
  72513. get thumbLength(): number;
  72514. set thumbLength(value: number);
  72515. /** Gets or sets the height of the thumb */
  72516. get thumbHeight(): number;
  72517. set thumbHeight(value: number);
  72518. /** Gets or sets the height of the bar image */
  72519. get barImageHeight(): number;
  72520. set barImageHeight(value: number);
  72521. /** Gets or sets the bar background */
  72522. get barBackground(): string;
  72523. set barBackground(color: string);
  72524. /** Gets or sets the bar background image */
  72525. get barImage(): Image;
  72526. set barImage(value: Image);
  72527. /** @hidden */
  72528. private _updateScroller;
  72529. _link(host: AdvancedDynamicTexture): void;
  72530. /** @hidden */
  72531. private _addBar;
  72532. /** @hidden */
  72533. private _attachWheel;
  72534. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72535. /** Releases associated resources */
  72536. dispose(): void;
  72537. }
  72538. }
  72539. declare module BABYLON.GUI {
  72540. /** Class used to render a grid */
  72541. export class DisplayGrid extends Control {
  72542. name?: string | undefined;
  72543. private _cellWidth;
  72544. private _cellHeight;
  72545. private _minorLineTickness;
  72546. private _minorLineColor;
  72547. private _majorLineTickness;
  72548. private _majorLineColor;
  72549. private _majorLineFrequency;
  72550. private _background;
  72551. private _displayMajorLines;
  72552. private _displayMinorLines;
  72553. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  72554. get displayMinorLines(): boolean;
  72555. set displayMinorLines(value: boolean);
  72556. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  72557. get displayMajorLines(): boolean;
  72558. set displayMajorLines(value: boolean);
  72559. /** Gets or sets background color (Black by default) */
  72560. get background(): string;
  72561. set background(value: string);
  72562. /** Gets or sets the width of each cell (20 by default) */
  72563. get cellWidth(): number;
  72564. set cellWidth(value: number);
  72565. /** Gets or sets the height of each cell (20 by default) */
  72566. get cellHeight(): number;
  72567. set cellHeight(value: number);
  72568. /** Gets or sets the tickness of minor lines (1 by default) */
  72569. get minorLineTickness(): number;
  72570. set minorLineTickness(value: number);
  72571. /** Gets or sets the color of minor lines (DarkGray by default) */
  72572. get minorLineColor(): string;
  72573. set minorLineColor(value: string);
  72574. /** Gets or sets the tickness of major lines (2 by default) */
  72575. get majorLineTickness(): number;
  72576. set majorLineTickness(value: number);
  72577. /** Gets or sets the color of major lines (White by default) */
  72578. get majorLineColor(): string;
  72579. set majorLineColor(value: string);
  72580. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  72581. get majorLineFrequency(): number;
  72582. set majorLineFrequency(value: number);
  72583. /**
  72584. * Creates a new GridDisplayRectangle
  72585. * @param name defines the control name
  72586. */
  72587. constructor(name?: string | undefined);
  72588. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72589. protected _getTypeName(): string;
  72590. }
  72591. }
  72592. declare module BABYLON.GUI {
  72593. /**
  72594. * Class used to create slider controls based on images
  72595. */
  72596. export class ImageBasedSlider extends BaseSlider {
  72597. name?: string | undefined;
  72598. private _backgroundImage;
  72599. private _thumbImage;
  72600. private _valueBarImage;
  72601. private _tempMeasure;
  72602. get displayThumb(): boolean;
  72603. set displayThumb(value: boolean);
  72604. /**
  72605. * Gets or sets the image used to render the background
  72606. */
  72607. get backgroundImage(): Image;
  72608. set backgroundImage(value: Image);
  72609. /**
  72610. * Gets or sets the image used to render the value bar
  72611. */
  72612. get valueBarImage(): Image;
  72613. set valueBarImage(value: Image);
  72614. /**
  72615. * Gets or sets the image used to render the thumb
  72616. */
  72617. get thumbImage(): Image;
  72618. set thumbImage(value: Image);
  72619. /**
  72620. * Creates a new ImageBasedSlider
  72621. * @param name defines the control name
  72622. */
  72623. constructor(name?: string | undefined);
  72624. protected _getTypeName(): string;
  72625. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72626. }
  72627. }
  72628. declare module BABYLON.GUI {
  72629. /**
  72630. * Forcing an export so that this code will execute
  72631. * @hidden
  72632. */
  72633. const name = "Statics";
  72634. }
  72635. declare module BABYLON.GUI {
  72636. /**
  72637. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  72638. */
  72639. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  72640. /**
  72641. * Define the instrumented AdvancedDynamicTexture.
  72642. */
  72643. texture: AdvancedDynamicTexture;
  72644. private _captureRenderTime;
  72645. private _renderTime;
  72646. private _captureLayoutTime;
  72647. private _layoutTime;
  72648. private _onBeginRenderObserver;
  72649. private _onEndRenderObserver;
  72650. private _onBeginLayoutObserver;
  72651. private _onEndLayoutObserver;
  72652. /**
  72653. * Gets the perf counter used to capture render time
  72654. */
  72655. get renderTimeCounter(): BABYLON.PerfCounter;
  72656. /**
  72657. * Gets the perf counter used to capture layout time
  72658. */
  72659. get layoutTimeCounter(): BABYLON.PerfCounter;
  72660. /**
  72661. * Enable or disable the render time capture
  72662. */
  72663. get captureRenderTime(): boolean;
  72664. set captureRenderTime(value: boolean);
  72665. /**
  72666. * Enable or disable the layout time capture
  72667. */
  72668. get captureLayoutTime(): boolean;
  72669. set captureLayoutTime(value: boolean);
  72670. /**
  72671. * Instantiates a new advanced dynamic texture instrumentation.
  72672. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  72673. * @param texture Defines the AdvancedDynamicTexture to instrument
  72674. */
  72675. constructor(
  72676. /**
  72677. * Define the instrumented AdvancedDynamicTexture.
  72678. */
  72679. texture: AdvancedDynamicTexture);
  72680. /**
  72681. * Dispose and release associated resources.
  72682. */
  72683. dispose(): void;
  72684. }
  72685. }
  72686. declare module BABYLON.GUI {
  72687. /**
  72688. * Class used to load GUI via XML.
  72689. */
  72690. export class XmlLoader {
  72691. private _nodes;
  72692. private _nodeTypes;
  72693. private _isLoaded;
  72694. private _objectAttributes;
  72695. private _parentClass;
  72696. /**
  72697. * Create a new xml loader
  72698. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  72699. */
  72700. constructor(parentClass?: null);
  72701. private _getChainElement;
  72702. private _getClassAttribute;
  72703. private _createGuiElement;
  72704. private _parseGrid;
  72705. private _parseElement;
  72706. private _prepareSourceElement;
  72707. private _parseElementsFromSource;
  72708. private _parseXml;
  72709. /**
  72710. * Gets if the loading has finished.
  72711. * @returns whether the loading has finished or not
  72712. */
  72713. isLoaded(): boolean;
  72714. /**
  72715. * Gets a loaded node / control by id.
  72716. * @param id the Controls id set in the xml
  72717. * @returns element of type Control
  72718. */
  72719. getNodeById(id: string): any;
  72720. /**
  72721. * Gets all loaded nodes / controls
  72722. * @returns Array of controls
  72723. */
  72724. getNodes(): any;
  72725. /**
  72726. * Initiates the xml layout loading
  72727. * @param xmlFile defines the xml layout to load
  72728. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  72729. * @param callback defines the callback called on layout load.
  72730. */
  72731. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  72732. }
  72733. }
  72734. declare module BABYLON.GUI {
  72735. /**
  72736. * Class used to create containers for controls
  72737. */
  72738. export class Container3D extends Control3D {
  72739. private _blockLayout;
  72740. /**
  72741. * Gets the list of child controls
  72742. */
  72743. protected _children: Control3D[];
  72744. /**
  72745. * Gets the list of child controls
  72746. */
  72747. get children(): Array<Control3D>;
  72748. /**
  72749. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  72750. * This is helpful to optimize layout operation when adding multiple children in a row
  72751. */
  72752. get blockLayout(): boolean;
  72753. set blockLayout(value: boolean);
  72754. /**
  72755. * Creates a new container
  72756. * @param name defines the container name
  72757. */
  72758. constructor(name?: string);
  72759. /**
  72760. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  72761. * @returns the current container
  72762. */
  72763. updateLayout(): Container3D;
  72764. /**
  72765. * Gets a boolean indicating if the given control is in the children of this control
  72766. * @param control defines the control to check
  72767. * @returns true if the control is in the child list
  72768. */
  72769. containsControl(control: Control3D): boolean;
  72770. /**
  72771. * Adds a control to the children of this control
  72772. * @param control defines the control to add
  72773. * @returns the current container
  72774. */
  72775. addControl(control: Control3D): Container3D;
  72776. /**
  72777. * This function will be called everytime a new control is added
  72778. */
  72779. protected _arrangeChildren(): void;
  72780. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  72781. /**
  72782. * Removes a control from the children of this control
  72783. * @param control defines the control to remove
  72784. * @returns the current container
  72785. */
  72786. removeControl(control: Control3D): Container3D;
  72787. protected _getTypeName(): string;
  72788. /**
  72789. * Releases all associated resources
  72790. */
  72791. dispose(): void;
  72792. /** Control rotation will remain unchanged */
  72793. static readonly UNSET_ORIENTATION: number;
  72794. /** Control will rotate to make it look at sphere central axis */
  72795. static readonly FACEORIGIN_ORIENTATION: number;
  72796. /** Control will rotate to make it look back at sphere central axis */
  72797. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  72798. /** Control will rotate to look at z axis (0, 0, 1) */
  72799. static readonly FACEFORWARD_ORIENTATION: number;
  72800. /** Control will rotate to look at negative z axis (0, 0, -1) */
  72801. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  72802. }
  72803. }
  72804. declare module BABYLON.GUI {
  72805. /**
  72806. * Class used to manage 3D user interface
  72807. * @see http://doc.babylonjs.com/how_to/gui3d
  72808. */
  72809. export class GUI3DManager implements BABYLON.IDisposable {
  72810. private _scene;
  72811. private _sceneDisposeObserver;
  72812. private _utilityLayer;
  72813. private _rootContainer;
  72814. private _pointerObserver;
  72815. private _pointerOutObserver;
  72816. /** @hidden */
  72817. _lastPickedControl: Control3D;
  72818. /** @hidden */
  72819. _lastControlOver: {
  72820. [pointerId: number]: Control3D;
  72821. };
  72822. /** @hidden */
  72823. _lastControlDown: {
  72824. [pointerId: number]: Control3D;
  72825. };
  72826. /**
  72827. * BABYLON.Observable raised when the point picked by the pointer events changed
  72828. */
  72829. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  72830. /** @hidden */
  72831. _sharedMaterials: {
  72832. [key: string]: BABYLON.Material;
  72833. };
  72834. /** Gets the hosting scene */
  72835. get scene(): BABYLON.Scene;
  72836. /** Gets associated utility layer */
  72837. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  72838. /**
  72839. * Creates a new GUI3DManager
  72840. * @param scene
  72841. */
  72842. constructor(scene?: BABYLON.Scene);
  72843. private _handlePointerOut;
  72844. private _doPicking;
  72845. /**
  72846. * Gets the root container
  72847. */
  72848. get rootContainer(): Container3D;
  72849. /**
  72850. * Gets a boolean indicating if the given control is in the root child list
  72851. * @param control defines the control to check
  72852. * @returns true if the control is in the root child list
  72853. */
  72854. containsControl(control: Control3D): boolean;
  72855. /**
  72856. * Adds a control to the root child list
  72857. * @param control defines the control to add
  72858. * @returns the current manager
  72859. */
  72860. addControl(control: Control3D): GUI3DManager;
  72861. /**
  72862. * Removes a control from the root child list
  72863. * @param control defines the control to remove
  72864. * @returns the current container
  72865. */
  72866. removeControl(control: Control3D): GUI3DManager;
  72867. /**
  72868. * Releases all associated resources
  72869. */
  72870. dispose(): void;
  72871. }
  72872. }
  72873. declare module BABYLON.GUI {
  72874. /**
  72875. * Class used to transport BABYLON.Vector3 information for pointer events
  72876. */
  72877. export class Vector3WithInfo extends BABYLON.Vector3 {
  72878. /** defines the current mouse button index */
  72879. buttonIndex: number;
  72880. /**
  72881. * Creates a new Vector3WithInfo
  72882. * @param source defines the vector3 data to transport
  72883. * @param buttonIndex defines the current mouse button index
  72884. */
  72885. constructor(source: BABYLON.Vector3,
  72886. /** defines the current mouse button index */
  72887. buttonIndex?: number);
  72888. }
  72889. }
  72890. declare module BABYLON.GUI {
  72891. /**
  72892. * Class used as base class for controls
  72893. */
  72894. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  72895. /** Defines the control name */
  72896. name?: string | undefined;
  72897. /** @hidden */
  72898. _host: GUI3DManager;
  72899. private _node;
  72900. private _downCount;
  72901. private _enterCount;
  72902. private _downPointerIds;
  72903. private _isVisible;
  72904. /** Gets or sets the control position in world space */
  72905. get position(): BABYLON.Vector3;
  72906. set position(value: BABYLON.Vector3);
  72907. /** Gets or sets the control scaling in world space */
  72908. get scaling(): BABYLON.Vector3;
  72909. set scaling(value: BABYLON.Vector3);
  72910. /** Callback used to start pointer enter animation */
  72911. pointerEnterAnimation: () => void;
  72912. /** Callback used to start pointer out animation */
  72913. pointerOutAnimation: () => void;
  72914. /** Callback used to start pointer down animation */
  72915. pointerDownAnimation: () => void;
  72916. /** Callback used to start pointer up animation */
  72917. pointerUpAnimation: () => void;
  72918. /**
  72919. * An event triggered when the pointer move over the control
  72920. */
  72921. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  72922. /**
  72923. * An event triggered when the pointer move out of the control
  72924. */
  72925. onPointerOutObservable: BABYLON.Observable<Control3D>;
  72926. /**
  72927. * An event triggered when the pointer taps the control
  72928. */
  72929. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  72930. /**
  72931. * An event triggered when pointer is up
  72932. */
  72933. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  72934. /**
  72935. * An event triggered when a control is clicked on (with a mouse)
  72936. */
  72937. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  72938. /**
  72939. * An event triggered when pointer enters the control
  72940. */
  72941. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  72942. /**
  72943. * Gets or sets the parent container
  72944. */
  72945. parent: BABYLON.Nullable<Container3D>;
  72946. private _behaviors;
  72947. /**
  72948. * Gets the list of attached behaviors
  72949. * @see http://doc.babylonjs.com/features/behaviour
  72950. */
  72951. get behaviors(): BABYLON.Behavior<Control3D>[];
  72952. /**
  72953. * Attach a behavior to the control
  72954. * @see http://doc.babylonjs.com/features/behaviour
  72955. * @param behavior defines the behavior to attach
  72956. * @returns the current control
  72957. */
  72958. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  72959. /**
  72960. * Remove an attached behavior
  72961. * @see http://doc.babylonjs.com/features/behaviour
  72962. * @param behavior defines the behavior to attach
  72963. * @returns the current control
  72964. */
  72965. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  72966. /**
  72967. * Gets an attached behavior by name
  72968. * @param name defines the name of the behavior to look for
  72969. * @see http://doc.babylonjs.com/features/behaviour
  72970. * @returns null if behavior was not found else the requested behavior
  72971. */
  72972. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  72973. /** Gets or sets a boolean indicating if the control is visible */
  72974. get isVisible(): boolean;
  72975. set isVisible(value: boolean);
  72976. /**
  72977. * Creates a new control
  72978. * @param name defines the control name
  72979. */
  72980. constructor(
  72981. /** Defines the control name */
  72982. name?: string | undefined);
  72983. /**
  72984. * Gets a string representing the class name
  72985. */
  72986. get typeName(): string;
  72987. /**
  72988. * Get the current class name of the control.
  72989. * @returns current class name
  72990. */
  72991. getClassName(): string;
  72992. protected _getTypeName(): string;
  72993. /**
  72994. * Gets the transform node used by this control
  72995. */
  72996. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  72997. /**
  72998. * Gets the mesh used to render this control
  72999. */
  73000. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73001. /**
  73002. * Link the control as child of the given node
  73003. * @param node defines the node to link to. Use null to unlink the control
  73004. * @returns the current control
  73005. */
  73006. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  73007. /** @hidden **/
  73008. _prepareNode(scene: BABYLON.Scene): void;
  73009. /**
  73010. * Node creation.
  73011. * Can be overriden by children
  73012. * @param scene defines the scene where the node must be attached
  73013. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  73014. */
  73015. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73016. /**
  73017. * Affect a material to the given mesh
  73018. * @param mesh defines the mesh which will represent the control
  73019. */
  73020. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73021. /** @hidden */
  73022. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  73023. /** @hidden */
  73024. _onPointerEnter(target: Control3D): boolean;
  73025. /** @hidden */
  73026. _onPointerOut(target: Control3D): void;
  73027. /** @hidden */
  73028. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73029. /** @hidden */
  73030. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73031. /** @hidden */
  73032. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73033. /** @hidden */
  73034. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73035. /** @hidden */
  73036. _disposeNode(): void;
  73037. /**
  73038. * Releases all associated resources
  73039. */
  73040. dispose(): void;
  73041. }
  73042. }
  73043. declare module BABYLON.GUI {
  73044. /**
  73045. * Class used as a root to all buttons
  73046. */
  73047. export class AbstractButton3D extends Control3D {
  73048. /**
  73049. * Creates a new button
  73050. * @param name defines the control name
  73051. */
  73052. constructor(name?: string);
  73053. protected _getTypeName(): string;
  73054. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73055. }
  73056. }
  73057. declare module BABYLON.GUI {
  73058. /**
  73059. * Class used to create a button in 3D
  73060. */
  73061. export class Button3D extends AbstractButton3D {
  73062. /** @hidden */
  73063. protected _currentMaterial: BABYLON.Material;
  73064. private _facadeTexture;
  73065. private _content;
  73066. private _contentResolution;
  73067. private _contentScaleRatio;
  73068. /**
  73069. * Gets or sets the texture resolution used to render content (512 by default)
  73070. */
  73071. get contentResolution(): BABYLON.int;
  73072. set contentResolution(value: BABYLON.int);
  73073. /**
  73074. * Gets or sets the texture scale ratio used to render content (2 by default)
  73075. */
  73076. get contentScaleRatio(): number;
  73077. set contentScaleRatio(value: number);
  73078. protected _disposeFacadeTexture(): void;
  73079. protected _resetContent(): void;
  73080. /**
  73081. * Creates a new button
  73082. * @param name defines the control name
  73083. */
  73084. constructor(name?: string);
  73085. /**
  73086. * Gets or sets the GUI 2D content used to display the button's facade
  73087. */
  73088. get content(): Control;
  73089. set content(value: Control);
  73090. /**
  73091. * Apply the facade texture (created from the content property).
  73092. * This function can be overloaded by child classes
  73093. * @param facadeTexture defines the AdvancedDynamicTexture to use
  73094. */
  73095. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73096. protected _getTypeName(): string;
  73097. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73098. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73099. /**
  73100. * Releases all associated resources
  73101. */
  73102. dispose(): void;
  73103. }
  73104. }
  73105. declare module BABYLON.GUI {
  73106. /**
  73107. * Abstract class used to create a container panel deployed on the surface of a volume
  73108. */
  73109. export abstract class VolumeBasedPanel extends Container3D {
  73110. private _columns;
  73111. private _rows;
  73112. private _rowThenColum;
  73113. private _orientation;
  73114. protected _cellWidth: number;
  73115. protected _cellHeight: number;
  73116. /**
  73117. * Gets or sets the distance between elements
  73118. */
  73119. margin: number;
  73120. /**
  73121. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  73122. * | Value | Type | Description |
  73123. * | ----- | ----------------------------------- | ----------- |
  73124. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  73125. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  73126. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  73127. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  73128. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  73129. */
  73130. get orientation(): number;
  73131. set orientation(value: number);
  73132. /**
  73133. * Gets or sets the number of columns requested (10 by default).
  73134. * The panel will automatically compute the number of rows based on number of child controls.
  73135. */
  73136. get columns(): BABYLON.int;
  73137. set columns(value: BABYLON.int);
  73138. /**
  73139. * Gets or sets a the number of rows requested.
  73140. * The panel will automatically compute the number of columns based on number of child controls.
  73141. */
  73142. get rows(): BABYLON.int;
  73143. set rows(value: BABYLON.int);
  73144. /**
  73145. * Creates new VolumeBasedPanel
  73146. */
  73147. constructor();
  73148. protected _arrangeChildren(): void;
  73149. /** Child classes must implement this function to provide correct control positioning */
  73150. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73151. /** Child classes can implement this function to provide additional processing */
  73152. protected _finalProcessing(): void;
  73153. }
  73154. }
  73155. declare module BABYLON.GUI {
  73156. /**
  73157. * Class used to create a container panel deployed on the surface of a cylinder
  73158. */
  73159. export class CylinderPanel extends VolumeBasedPanel {
  73160. private _radius;
  73161. /**
  73162. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  73163. */
  73164. get radius(): BABYLON.float;
  73165. set radius(value: BABYLON.float);
  73166. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73167. private _cylindricalMapping;
  73168. }
  73169. }
  73170. declare module BABYLON.GUI {
  73171. /** @hidden */
  73172. export var fluentVertexShader: {
  73173. name: string;
  73174. shader: string;
  73175. };
  73176. }
  73177. declare module BABYLON.GUI {
  73178. /** @hidden */
  73179. export var fluentPixelShader: {
  73180. name: string;
  73181. shader: string;
  73182. };
  73183. }
  73184. declare module BABYLON.GUI {
  73185. /** @hidden */
  73186. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  73187. INNERGLOW: boolean;
  73188. BORDER: boolean;
  73189. HOVERLIGHT: boolean;
  73190. TEXTURE: boolean;
  73191. constructor();
  73192. }
  73193. /**
  73194. * Class used to render controls with fluent desgin
  73195. */
  73196. export class FluentMaterial extends BABYLON.PushMaterial {
  73197. /**
  73198. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  73199. */
  73200. innerGlowColorIntensity: number;
  73201. /**
  73202. * Gets or sets the inner glow color (white by default)
  73203. */
  73204. innerGlowColor: BABYLON.Color3;
  73205. /**
  73206. * Gets or sets alpha value (default is 1.0)
  73207. */
  73208. alpha: number;
  73209. /**
  73210. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  73211. */
  73212. albedoColor: BABYLON.Color3;
  73213. /**
  73214. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  73215. */
  73216. renderBorders: boolean;
  73217. /**
  73218. * Gets or sets border width (default is 0.5)
  73219. */
  73220. borderWidth: number;
  73221. /**
  73222. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  73223. */
  73224. edgeSmoothingValue: number;
  73225. /**
  73226. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  73227. */
  73228. borderMinValue: number;
  73229. /**
  73230. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  73231. */
  73232. renderHoverLight: boolean;
  73233. /**
  73234. * Gets or sets the radius used to render the hover light (default is 1.0)
  73235. */
  73236. hoverRadius: number;
  73237. /**
  73238. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  73239. */
  73240. hoverColor: BABYLON.Color4;
  73241. /**
  73242. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  73243. */
  73244. hoverPosition: BABYLON.Vector3;
  73245. private _albedoTexture;
  73246. /** Gets or sets the texture to use for albedo color */
  73247. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73248. /**
  73249. * Creates a new Fluent material
  73250. * @param name defines the name of the material
  73251. * @param scene defines the hosting scene
  73252. */
  73253. constructor(name: string, scene: BABYLON.Scene);
  73254. needAlphaBlending(): boolean;
  73255. needAlphaTesting(): boolean;
  73256. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73257. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73258. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73259. getActiveTextures(): BABYLON.BaseTexture[];
  73260. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73261. dispose(forceDisposeEffect?: boolean): void;
  73262. clone(name: string): FluentMaterial;
  73263. serialize(): any;
  73264. getClassName(): string;
  73265. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  73266. }
  73267. }
  73268. declare module BABYLON.GUI {
  73269. /**
  73270. * Class used to create a holographic button in 3D
  73271. */
  73272. export class HolographicButton extends Button3D {
  73273. private _backPlate;
  73274. private _textPlate;
  73275. private _frontPlate;
  73276. private _text;
  73277. private _imageUrl;
  73278. private _shareMaterials;
  73279. private _frontMaterial;
  73280. private _backMaterial;
  73281. private _plateMaterial;
  73282. private _pickedPointObserver;
  73283. private _tooltipFade;
  73284. private _tooltipTextBlock;
  73285. private _tooltipTexture;
  73286. private _tooltipMesh;
  73287. private _tooltipHoverObserver;
  73288. private _tooltipOutObserver;
  73289. private _disposeTooltip;
  73290. /**
  73291. * Rendering ground id of all the mesh in the button
  73292. */
  73293. set renderingGroupId(id: number);
  73294. get renderingGroupId(): number;
  73295. /**
  73296. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  73297. */
  73298. set tooltipText(text: BABYLON.Nullable<string>);
  73299. get tooltipText(): BABYLON.Nullable<string>;
  73300. /**
  73301. * Gets or sets text for the button
  73302. */
  73303. get text(): string;
  73304. set text(value: string);
  73305. /**
  73306. * Gets or sets the image url for the button
  73307. */
  73308. get imageUrl(): string;
  73309. set imageUrl(value: string);
  73310. /**
  73311. * Gets the back material used by this button
  73312. */
  73313. get backMaterial(): FluentMaterial;
  73314. /**
  73315. * Gets the front material used by this button
  73316. */
  73317. get frontMaterial(): FluentMaterial;
  73318. /**
  73319. * Gets the plate material used by this button
  73320. */
  73321. get plateMaterial(): BABYLON.StandardMaterial;
  73322. /**
  73323. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  73324. */
  73325. get shareMaterials(): boolean;
  73326. /**
  73327. * Creates a new button
  73328. * @param name defines the control name
  73329. */
  73330. constructor(name?: string, shareMaterials?: boolean);
  73331. protected _getTypeName(): string;
  73332. private _rebuildContent;
  73333. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73334. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73335. private _createBackMaterial;
  73336. private _createFrontMaterial;
  73337. private _createPlateMaterial;
  73338. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  73339. /**
  73340. * Releases all associated resources
  73341. */
  73342. dispose(): void;
  73343. }
  73344. }
  73345. declare module BABYLON.GUI {
  73346. /**
  73347. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  73348. */
  73349. export class MeshButton3D extends Button3D {
  73350. /** @hidden */
  73351. protected _currentMesh: BABYLON.Mesh;
  73352. /**
  73353. * Creates a new 3D button based on a mesh
  73354. * @param mesh mesh to become a 3D button
  73355. * @param name defines the control name
  73356. */
  73357. constructor(mesh: BABYLON.Mesh, name?: string);
  73358. protected _getTypeName(): string;
  73359. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73360. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73361. }
  73362. }
  73363. declare module BABYLON.GUI {
  73364. /**
  73365. * Class used to create a container panel deployed on the surface of a plane
  73366. */
  73367. export class PlanePanel extends VolumeBasedPanel {
  73368. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73369. }
  73370. }
  73371. declare module BABYLON.GUI {
  73372. /**
  73373. * Class used to create a container panel where items get randomized planar mapping
  73374. */
  73375. export class ScatterPanel extends VolumeBasedPanel {
  73376. private _iteration;
  73377. /**
  73378. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  73379. */
  73380. get iteration(): BABYLON.float;
  73381. set iteration(value: BABYLON.float);
  73382. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73383. private _scatterMapping;
  73384. protected _finalProcessing(): void;
  73385. }
  73386. }
  73387. declare module BABYLON.GUI {
  73388. /**
  73389. * Class used to create a container panel deployed on the surface of a sphere
  73390. */
  73391. export class SpherePanel extends VolumeBasedPanel {
  73392. private _radius;
  73393. /**
  73394. * Gets or sets the radius of the sphere where to project controls (5 by default)
  73395. */
  73396. get radius(): BABYLON.float;
  73397. set radius(value: BABYLON.float);
  73398. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73399. private _sphericalMapping;
  73400. }
  73401. }
  73402. declare module BABYLON.GUI {
  73403. /**
  73404. * Class used to create a stack panel in 3D on XY plane
  73405. */
  73406. export class StackPanel3D extends Container3D {
  73407. private _isVertical;
  73408. /**
  73409. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  73410. */
  73411. get isVertical(): boolean;
  73412. set isVertical(value: boolean);
  73413. /**
  73414. * Gets or sets the distance between elements
  73415. */
  73416. margin: number;
  73417. /**
  73418. * Creates new StackPanel
  73419. * @param isVertical
  73420. */
  73421. constructor(isVertical?: boolean);
  73422. protected _arrangeChildren(): void;
  73423. }
  73424. }
  73425. declare module BABYLON {
  73426. /**
  73427. * Configuration for glTF validation
  73428. */
  73429. export interface IGLTFValidationConfiguration {
  73430. /**
  73431. * The url of the glTF validator.
  73432. */
  73433. url: string;
  73434. }
  73435. /**
  73436. * glTF validation
  73437. */
  73438. export class GLTFValidation {
  73439. /**
  73440. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  73441. */
  73442. static Configuration: IGLTFValidationConfiguration;
  73443. private static _LoadScriptPromise;
  73444. /**
  73445. * Validate a glTF asset using the glTF-Validator.
  73446. * @param data The JSON of a glTF or the array buffer of a binary glTF
  73447. * @param rootUrl The root url for the glTF
  73448. * @param fileName The file name for the glTF
  73449. * @param getExternalResource The callback to get external resources for the glTF validator
  73450. * @returns A promise that resolves with the glTF validation results once complete
  73451. */
  73452. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  73453. }
  73454. }
  73455. declare module BABYLON {
  73456. /**
  73457. * Mode that determines the coordinate system to use.
  73458. */
  73459. export enum GLTFLoaderCoordinateSystemMode {
  73460. /**
  73461. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  73462. */
  73463. AUTO = 0,
  73464. /**
  73465. * Sets the useRightHandedSystem flag on the scene.
  73466. */
  73467. FORCE_RIGHT_HANDED = 1
  73468. }
  73469. /**
  73470. * Mode that determines what animations will start.
  73471. */
  73472. export enum GLTFLoaderAnimationStartMode {
  73473. /**
  73474. * No animation will start.
  73475. */
  73476. NONE = 0,
  73477. /**
  73478. * The first animation will start.
  73479. */
  73480. FIRST = 1,
  73481. /**
  73482. * All animations will start.
  73483. */
  73484. ALL = 2
  73485. }
  73486. /**
  73487. * Interface that contains the data for the glTF asset.
  73488. */
  73489. export interface IGLTFLoaderData {
  73490. /**
  73491. * The object that represents the glTF JSON.
  73492. */
  73493. json: Object;
  73494. /**
  73495. * The BIN chunk of a binary glTF.
  73496. */
  73497. bin: Nullable<IDataBuffer>;
  73498. }
  73499. /**
  73500. * Interface for extending the loader.
  73501. */
  73502. export interface IGLTFLoaderExtension {
  73503. /**
  73504. * The name of this extension.
  73505. */
  73506. readonly name: string;
  73507. /**
  73508. * Defines whether this extension is enabled.
  73509. */
  73510. enabled: boolean;
  73511. /**
  73512. * Defines the order of this extension.
  73513. * The loader sorts the extensions using these values when loading.
  73514. */
  73515. order?: number;
  73516. }
  73517. /**
  73518. * Loader state.
  73519. */
  73520. export enum GLTFLoaderState {
  73521. /**
  73522. * The asset is loading.
  73523. */
  73524. LOADING = 0,
  73525. /**
  73526. * The asset is ready for rendering.
  73527. */
  73528. READY = 1,
  73529. /**
  73530. * The asset is completely loaded.
  73531. */
  73532. COMPLETE = 2
  73533. }
  73534. /** @hidden */
  73535. export interface IGLTFLoader extends IDisposable {
  73536. readonly state: Nullable<GLTFLoaderState>;
  73537. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  73538. meshes: AbstractMesh[];
  73539. particleSystems: IParticleSystem[];
  73540. skeletons: Skeleton[];
  73541. animationGroups: AnimationGroup[];
  73542. }>;
  73543. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  73544. }
  73545. /**
  73546. * File loader for loading glTF files into a scene.
  73547. */
  73548. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  73549. /** @hidden */
  73550. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  73551. /** @hidden */
  73552. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  73553. /**
  73554. * Raised when the asset has been parsed
  73555. */
  73556. onParsedObservable: Observable<IGLTFLoaderData>;
  73557. private _onParsedObserver;
  73558. /**
  73559. * Raised when the asset has been parsed
  73560. */
  73561. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  73562. /**
  73563. * 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.
  73564. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  73565. * Defaults to true.
  73566. * @hidden
  73567. */
  73568. static IncrementalLoading: boolean;
  73569. /**
  73570. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  73571. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  73572. * @hidden
  73573. */
  73574. static HomogeneousCoordinates: boolean;
  73575. /**
  73576. * The coordinate system mode. Defaults to AUTO.
  73577. */
  73578. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  73579. /**
  73580. * The animation start mode. Defaults to FIRST.
  73581. */
  73582. animationStartMode: GLTFLoaderAnimationStartMode;
  73583. /**
  73584. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  73585. */
  73586. compileMaterials: boolean;
  73587. /**
  73588. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  73589. */
  73590. useClipPlane: boolean;
  73591. /**
  73592. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  73593. */
  73594. compileShadowGenerators: boolean;
  73595. /**
  73596. * Defines if the Alpha blended materials are only applied as coverage.
  73597. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  73598. * If true, no extra effects are applied to transparent pixels.
  73599. */
  73600. transparencyAsCoverage: boolean;
  73601. /**
  73602. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  73603. * Enabling will disable offline support and glTF validator.
  73604. * Defaults to false.
  73605. */
  73606. useRangeRequests: boolean;
  73607. /**
  73608. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  73609. */
  73610. createInstances: boolean;
  73611. /**
  73612. * Function called before loading a url referenced by the asset.
  73613. */
  73614. preprocessUrlAsync: (url: string) => Promise<string>;
  73615. /**
  73616. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  73617. */
  73618. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  73619. private _onMeshLoadedObserver;
  73620. /**
  73621. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  73622. */
  73623. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  73624. /**
  73625. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  73626. */
  73627. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  73628. private _onTextureLoadedObserver;
  73629. /**
  73630. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  73631. */
  73632. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  73633. /**
  73634. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  73635. */
  73636. readonly onMaterialLoadedObservable: Observable<Material>;
  73637. private _onMaterialLoadedObserver;
  73638. /**
  73639. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  73640. */
  73641. set onMaterialLoaded(callback: (material: Material) => void);
  73642. /**
  73643. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  73644. */
  73645. readonly onCameraLoadedObservable: Observable<Camera>;
  73646. private _onCameraLoadedObserver;
  73647. /**
  73648. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  73649. */
  73650. set onCameraLoaded(callback: (camera: Camera) => void);
  73651. /**
  73652. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  73653. * For assets with LODs, raised when all of the LODs are complete.
  73654. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  73655. */
  73656. readonly onCompleteObservable: Observable<void>;
  73657. private _onCompleteObserver;
  73658. /**
  73659. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  73660. * For assets with LODs, raised when all of the LODs are complete.
  73661. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  73662. */
  73663. set onComplete(callback: () => void);
  73664. /**
  73665. * Observable raised when an error occurs.
  73666. */
  73667. readonly onErrorObservable: Observable<any>;
  73668. private _onErrorObserver;
  73669. /**
  73670. * Callback raised when an error occurs.
  73671. */
  73672. set onError(callback: (reason: any) => void);
  73673. /**
  73674. * Observable raised after the loader is disposed.
  73675. */
  73676. readonly onDisposeObservable: Observable<void>;
  73677. private _onDisposeObserver;
  73678. /**
  73679. * Callback raised after the loader is disposed.
  73680. */
  73681. set onDispose(callback: () => void);
  73682. /**
  73683. * Observable raised after a loader extension is created.
  73684. * Set additional options for a loader extension in this event.
  73685. */
  73686. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  73687. private _onExtensionLoadedObserver;
  73688. /**
  73689. * Callback raised after a loader extension is created.
  73690. */
  73691. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  73692. /**
  73693. * Defines if the loader logging is enabled.
  73694. */
  73695. get loggingEnabled(): boolean;
  73696. set loggingEnabled(value: boolean);
  73697. /**
  73698. * Defines if the loader should capture performance counters.
  73699. */
  73700. get capturePerformanceCounters(): boolean;
  73701. set capturePerformanceCounters(value: boolean);
  73702. /**
  73703. * Defines if the loader should validate the asset.
  73704. */
  73705. validate: boolean;
  73706. /**
  73707. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  73708. */
  73709. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  73710. private _onValidatedObserver;
  73711. /**
  73712. * Callback raised after a loader extension is created.
  73713. */
  73714. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  73715. private _loader;
  73716. /**
  73717. * Name of the loader ("gltf")
  73718. */
  73719. name: string;
  73720. /** @hidden */
  73721. extensions: ISceneLoaderPluginExtensions;
  73722. /**
  73723. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  73724. */
  73725. dispose(): void;
  73726. /** @hidden */
  73727. _clear(): void;
  73728. /** @hidden */
  73729. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  73730. /** @hidden */
  73731. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  73732. /** @hidden */
  73733. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  73734. meshes: AbstractMesh[];
  73735. particleSystems: IParticleSystem[];
  73736. skeletons: Skeleton[];
  73737. animationGroups: AnimationGroup[];
  73738. }>;
  73739. /** @hidden */
  73740. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  73741. /** @hidden */
  73742. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  73743. /** @hidden */
  73744. canDirectLoad(data: string): boolean;
  73745. /** @hidden */
  73746. directLoad(scene: Scene, data: string): any;
  73747. /**
  73748. * The callback that allows custom handling of the root url based on the response url.
  73749. * @param rootUrl the original root url
  73750. * @param responseURL the response url if available
  73751. * @returns the new root url
  73752. */
  73753. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  73754. /** @hidden */
  73755. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  73756. /**
  73757. * The loader state or null if the loader is not active.
  73758. */
  73759. get loaderState(): Nullable<GLTFLoaderState>;
  73760. /**
  73761. * Returns a promise that resolves when the asset is completely loaded.
  73762. * @returns a promise that resolves when the asset is completely loaded.
  73763. */
  73764. whenCompleteAsync(): Promise<void>;
  73765. private _validate;
  73766. private _getLoader;
  73767. private _parseJson;
  73768. private _unpackBinaryAsync;
  73769. private _unpackBinaryV1Async;
  73770. private _unpackBinaryV2Async;
  73771. private static _parseVersion;
  73772. private static _compareVersion;
  73773. private static readonly _logSpaces;
  73774. private _logIndentLevel;
  73775. private _loggingEnabled;
  73776. /** @hidden */
  73777. _log: (message: string) => void;
  73778. /** @hidden */
  73779. _logOpen(message: string): void;
  73780. /** @hidden */
  73781. _logClose(): void;
  73782. private _logEnabled;
  73783. private _logDisabled;
  73784. private _capturePerformanceCounters;
  73785. /** @hidden */
  73786. _startPerformanceCounter: (counterName: string) => void;
  73787. /** @hidden */
  73788. _endPerformanceCounter: (counterName: string) => void;
  73789. private _startPerformanceCounterEnabled;
  73790. private _startPerformanceCounterDisabled;
  73791. private _endPerformanceCounterEnabled;
  73792. private _endPerformanceCounterDisabled;
  73793. }
  73794. }
  73795. declare module BABYLON.GLTF1 {
  73796. /**
  73797. * Enums
  73798. * @hidden
  73799. */
  73800. export enum EComponentType {
  73801. BYTE = 5120,
  73802. UNSIGNED_BYTE = 5121,
  73803. SHORT = 5122,
  73804. UNSIGNED_SHORT = 5123,
  73805. FLOAT = 5126
  73806. }
  73807. /** @hidden */
  73808. export enum EShaderType {
  73809. FRAGMENT = 35632,
  73810. VERTEX = 35633
  73811. }
  73812. /** @hidden */
  73813. export enum EParameterType {
  73814. BYTE = 5120,
  73815. UNSIGNED_BYTE = 5121,
  73816. SHORT = 5122,
  73817. UNSIGNED_SHORT = 5123,
  73818. INT = 5124,
  73819. UNSIGNED_INT = 5125,
  73820. FLOAT = 5126,
  73821. FLOAT_VEC2 = 35664,
  73822. FLOAT_VEC3 = 35665,
  73823. FLOAT_VEC4 = 35666,
  73824. INT_VEC2 = 35667,
  73825. INT_VEC3 = 35668,
  73826. INT_VEC4 = 35669,
  73827. BOOL = 35670,
  73828. BOOL_VEC2 = 35671,
  73829. BOOL_VEC3 = 35672,
  73830. BOOL_VEC4 = 35673,
  73831. FLOAT_MAT2 = 35674,
  73832. FLOAT_MAT3 = 35675,
  73833. FLOAT_MAT4 = 35676,
  73834. SAMPLER_2D = 35678
  73835. }
  73836. /** @hidden */
  73837. export enum ETextureWrapMode {
  73838. CLAMP_TO_EDGE = 33071,
  73839. MIRRORED_REPEAT = 33648,
  73840. REPEAT = 10497
  73841. }
  73842. /** @hidden */
  73843. export enum ETextureFilterType {
  73844. NEAREST = 9728,
  73845. LINEAR = 9728,
  73846. NEAREST_MIPMAP_NEAREST = 9984,
  73847. LINEAR_MIPMAP_NEAREST = 9985,
  73848. NEAREST_MIPMAP_LINEAR = 9986,
  73849. LINEAR_MIPMAP_LINEAR = 9987
  73850. }
  73851. /** @hidden */
  73852. export enum ETextureFormat {
  73853. ALPHA = 6406,
  73854. RGB = 6407,
  73855. RGBA = 6408,
  73856. LUMINANCE = 6409,
  73857. LUMINANCE_ALPHA = 6410
  73858. }
  73859. /** @hidden */
  73860. export enum ECullingType {
  73861. FRONT = 1028,
  73862. BACK = 1029,
  73863. FRONT_AND_BACK = 1032
  73864. }
  73865. /** @hidden */
  73866. export enum EBlendingFunction {
  73867. ZERO = 0,
  73868. ONE = 1,
  73869. SRC_COLOR = 768,
  73870. ONE_MINUS_SRC_COLOR = 769,
  73871. DST_COLOR = 774,
  73872. ONE_MINUS_DST_COLOR = 775,
  73873. SRC_ALPHA = 770,
  73874. ONE_MINUS_SRC_ALPHA = 771,
  73875. DST_ALPHA = 772,
  73876. ONE_MINUS_DST_ALPHA = 773,
  73877. CONSTANT_COLOR = 32769,
  73878. ONE_MINUS_CONSTANT_COLOR = 32770,
  73879. CONSTANT_ALPHA = 32771,
  73880. ONE_MINUS_CONSTANT_ALPHA = 32772,
  73881. SRC_ALPHA_SATURATE = 776
  73882. }
  73883. /** @hidden */
  73884. export interface IGLTFProperty {
  73885. extensions?: {
  73886. [key: string]: any;
  73887. };
  73888. extras?: Object;
  73889. }
  73890. /** @hidden */
  73891. export interface IGLTFChildRootProperty extends IGLTFProperty {
  73892. name?: string;
  73893. }
  73894. /** @hidden */
  73895. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  73896. bufferView: string;
  73897. byteOffset: number;
  73898. byteStride: number;
  73899. count: number;
  73900. type: string;
  73901. componentType: EComponentType;
  73902. max?: number[];
  73903. min?: number[];
  73904. name?: string;
  73905. }
  73906. /** @hidden */
  73907. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  73908. buffer: string;
  73909. byteOffset: number;
  73910. byteLength: number;
  73911. byteStride: number;
  73912. target?: number;
  73913. }
  73914. /** @hidden */
  73915. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  73916. uri: string;
  73917. byteLength?: number;
  73918. type?: string;
  73919. }
  73920. /** @hidden */
  73921. export interface IGLTFShader extends IGLTFChildRootProperty {
  73922. uri: string;
  73923. type: EShaderType;
  73924. }
  73925. /** @hidden */
  73926. export interface IGLTFProgram extends IGLTFChildRootProperty {
  73927. attributes: string[];
  73928. fragmentShader: string;
  73929. vertexShader: string;
  73930. }
  73931. /** @hidden */
  73932. export interface IGLTFTechniqueParameter {
  73933. type: number;
  73934. count?: number;
  73935. semantic?: string;
  73936. node?: string;
  73937. value?: number | boolean | string | Array<any>;
  73938. source?: string;
  73939. babylonValue?: any;
  73940. }
  73941. /** @hidden */
  73942. export interface IGLTFTechniqueCommonProfile {
  73943. lightingModel: string;
  73944. texcoordBindings: Object;
  73945. parameters?: Array<any>;
  73946. }
  73947. /** @hidden */
  73948. export interface IGLTFTechniqueStatesFunctions {
  73949. blendColor?: number[];
  73950. blendEquationSeparate?: number[];
  73951. blendFuncSeparate?: number[];
  73952. colorMask: boolean[];
  73953. cullFace: number[];
  73954. }
  73955. /** @hidden */
  73956. export interface IGLTFTechniqueStates {
  73957. enable: number[];
  73958. functions: IGLTFTechniqueStatesFunctions;
  73959. }
  73960. /** @hidden */
  73961. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  73962. parameters: {
  73963. [key: string]: IGLTFTechniqueParameter;
  73964. };
  73965. program: string;
  73966. attributes: {
  73967. [key: string]: string;
  73968. };
  73969. uniforms: {
  73970. [key: string]: string;
  73971. };
  73972. states: IGLTFTechniqueStates;
  73973. }
  73974. /** @hidden */
  73975. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  73976. technique?: string;
  73977. values: string[];
  73978. }
  73979. /** @hidden */
  73980. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  73981. attributes: {
  73982. [key: string]: string;
  73983. };
  73984. indices: string;
  73985. material: string;
  73986. mode?: number;
  73987. }
  73988. /** @hidden */
  73989. export interface IGLTFMesh extends IGLTFChildRootProperty {
  73990. primitives: IGLTFMeshPrimitive[];
  73991. }
  73992. /** @hidden */
  73993. export interface IGLTFImage extends IGLTFChildRootProperty {
  73994. uri: string;
  73995. }
  73996. /** @hidden */
  73997. export interface IGLTFSampler extends IGLTFChildRootProperty {
  73998. magFilter?: number;
  73999. minFilter?: number;
  74000. wrapS?: number;
  74001. wrapT?: number;
  74002. }
  74003. /** @hidden */
  74004. export interface IGLTFTexture extends IGLTFChildRootProperty {
  74005. sampler: string;
  74006. source: string;
  74007. format?: ETextureFormat;
  74008. internalFormat?: ETextureFormat;
  74009. target?: number;
  74010. type?: number;
  74011. babylonTexture?: Texture;
  74012. }
  74013. /** @hidden */
  74014. export interface IGLTFAmbienLight {
  74015. color?: number[];
  74016. }
  74017. /** @hidden */
  74018. export interface IGLTFDirectionalLight {
  74019. color?: number[];
  74020. }
  74021. /** @hidden */
  74022. export interface IGLTFPointLight {
  74023. color?: number[];
  74024. constantAttenuation?: number;
  74025. linearAttenuation?: number;
  74026. quadraticAttenuation?: number;
  74027. }
  74028. /** @hidden */
  74029. export interface IGLTFSpotLight {
  74030. color?: number[];
  74031. constantAttenuation?: number;
  74032. fallOfAngle?: number;
  74033. fallOffExponent?: number;
  74034. linearAttenuation?: number;
  74035. quadraticAttenuation?: number;
  74036. }
  74037. /** @hidden */
  74038. export interface IGLTFLight extends IGLTFChildRootProperty {
  74039. type: string;
  74040. }
  74041. /** @hidden */
  74042. export interface IGLTFCameraOrthographic {
  74043. xmag: number;
  74044. ymag: number;
  74045. zfar: number;
  74046. znear: number;
  74047. }
  74048. /** @hidden */
  74049. export interface IGLTFCameraPerspective {
  74050. aspectRatio: number;
  74051. yfov: number;
  74052. zfar: number;
  74053. znear: number;
  74054. }
  74055. /** @hidden */
  74056. export interface IGLTFCamera extends IGLTFChildRootProperty {
  74057. type: string;
  74058. }
  74059. /** @hidden */
  74060. export interface IGLTFAnimationChannelTarget {
  74061. id: string;
  74062. path: string;
  74063. }
  74064. /** @hidden */
  74065. export interface IGLTFAnimationChannel {
  74066. sampler: string;
  74067. target: IGLTFAnimationChannelTarget;
  74068. }
  74069. /** @hidden */
  74070. export interface IGLTFAnimationSampler {
  74071. input: string;
  74072. output: string;
  74073. interpolation?: string;
  74074. }
  74075. /** @hidden */
  74076. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  74077. channels?: IGLTFAnimationChannel[];
  74078. parameters?: {
  74079. [key: string]: string;
  74080. };
  74081. samplers?: {
  74082. [key: string]: IGLTFAnimationSampler;
  74083. };
  74084. }
  74085. /** @hidden */
  74086. export interface IGLTFNodeInstanceSkin {
  74087. skeletons: string[];
  74088. skin: string;
  74089. meshes: string[];
  74090. }
  74091. /** @hidden */
  74092. export interface IGLTFSkins extends IGLTFChildRootProperty {
  74093. bindShapeMatrix: number[];
  74094. inverseBindMatrices: string;
  74095. jointNames: string[];
  74096. babylonSkeleton?: Skeleton;
  74097. }
  74098. /** @hidden */
  74099. export interface IGLTFNode extends IGLTFChildRootProperty {
  74100. camera?: string;
  74101. children: string[];
  74102. skin?: string;
  74103. jointName?: string;
  74104. light?: string;
  74105. matrix: number[];
  74106. mesh?: string;
  74107. meshes?: string[];
  74108. rotation?: number[];
  74109. scale?: number[];
  74110. translation?: number[];
  74111. babylonNode?: Node;
  74112. }
  74113. /** @hidden */
  74114. export interface IGLTFScene extends IGLTFChildRootProperty {
  74115. nodes: string[];
  74116. }
  74117. /** @hidden */
  74118. export interface IGLTFRuntime {
  74119. extensions: {
  74120. [key: string]: any;
  74121. };
  74122. accessors: {
  74123. [key: string]: IGLTFAccessor;
  74124. };
  74125. buffers: {
  74126. [key: string]: IGLTFBuffer;
  74127. };
  74128. bufferViews: {
  74129. [key: string]: IGLTFBufferView;
  74130. };
  74131. meshes: {
  74132. [key: string]: IGLTFMesh;
  74133. };
  74134. lights: {
  74135. [key: string]: IGLTFLight;
  74136. };
  74137. cameras: {
  74138. [key: string]: IGLTFCamera;
  74139. };
  74140. nodes: {
  74141. [key: string]: IGLTFNode;
  74142. };
  74143. images: {
  74144. [key: string]: IGLTFImage;
  74145. };
  74146. textures: {
  74147. [key: string]: IGLTFTexture;
  74148. };
  74149. shaders: {
  74150. [key: string]: IGLTFShader;
  74151. };
  74152. programs: {
  74153. [key: string]: IGLTFProgram;
  74154. };
  74155. samplers: {
  74156. [key: string]: IGLTFSampler;
  74157. };
  74158. techniques: {
  74159. [key: string]: IGLTFTechnique;
  74160. };
  74161. materials: {
  74162. [key: string]: IGLTFMaterial;
  74163. };
  74164. animations: {
  74165. [key: string]: IGLTFAnimation;
  74166. };
  74167. skins: {
  74168. [key: string]: IGLTFSkins;
  74169. };
  74170. currentScene?: Object;
  74171. scenes: {
  74172. [key: string]: IGLTFScene;
  74173. };
  74174. extensionsUsed: string[];
  74175. extensionsRequired?: string[];
  74176. buffersCount: number;
  74177. shaderscount: number;
  74178. scene: Scene;
  74179. rootUrl: string;
  74180. loadedBufferCount: number;
  74181. loadedBufferViews: {
  74182. [name: string]: ArrayBufferView;
  74183. };
  74184. loadedShaderCount: number;
  74185. importOnlyMeshes: boolean;
  74186. importMeshesNames?: string[];
  74187. dummyNodes: Node[];
  74188. }
  74189. /** @hidden */
  74190. export interface INodeToRoot {
  74191. bone: Bone;
  74192. node: IGLTFNode;
  74193. id: string;
  74194. }
  74195. /** @hidden */
  74196. export interface IJointNode {
  74197. node: IGLTFNode;
  74198. id: string;
  74199. }
  74200. }
  74201. declare module BABYLON.GLTF1 {
  74202. /**
  74203. * Utils functions for GLTF
  74204. * @hidden
  74205. */
  74206. export class GLTFUtils {
  74207. /**
  74208. * Sets the given "parameter" matrix
  74209. * @param scene: the Scene object
  74210. * @param source: the source node where to pick the matrix
  74211. * @param parameter: the GLTF technique parameter
  74212. * @param uniformName: the name of the shader's uniform
  74213. * @param shaderMaterial: the shader material
  74214. */
  74215. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  74216. /**
  74217. * Sets the given "parameter" matrix
  74218. * @param shaderMaterial: the shader material
  74219. * @param uniform: the name of the shader's uniform
  74220. * @param value: the value of the uniform
  74221. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  74222. */
  74223. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  74224. /**
  74225. * Returns the wrap mode of the texture
  74226. * @param mode: the mode value
  74227. */
  74228. static GetWrapMode(mode: number): number;
  74229. /**
  74230. * Returns the byte stride giving an accessor
  74231. * @param accessor: the GLTF accessor objet
  74232. */
  74233. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  74234. /**
  74235. * Returns the texture filter mode giving a mode value
  74236. * @param mode: the filter mode value
  74237. */
  74238. static GetTextureFilterMode(mode: number): ETextureFilterType;
  74239. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  74240. /**
  74241. * Returns a buffer from its accessor
  74242. * @param gltfRuntime: the GLTF runtime
  74243. * @param accessor: the GLTF accessor
  74244. */
  74245. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  74246. /**
  74247. * Decodes a buffer view into a string
  74248. * @param view: the buffer view
  74249. */
  74250. static DecodeBufferToText(view: ArrayBufferView): string;
  74251. /**
  74252. * Returns the default material of gltf. Related to
  74253. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  74254. * @param scene: the Babylon.js scene
  74255. */
  74256. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  74257. private static _DefaultMaterial;
  74258. }
  74259. }
  74260. declare module BABYLON.GLTF1 {
  74261. /**
  74262. * Implementation of the base glTF spec
  74263. * @hidden
  74264. */
  74265. export class GLTFLoaderBase {
  74266. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  74267. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74268. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  74269. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74270. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  74271. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74272. }
  74273. /**
  74274. * glTF V1 Loader
  74275. * @hidden
  74276. */
  74277. export class GLTFLoader implements IGLTFLoader {
  74278. static Extensions: {
  74279. [name: string]: GLTFLoaderExtension;
  74280. };
  74281. static RegisterExtension(extension: GLTFLoaderExtension): void;
  74282. state: Nullable<GLTFLoaderState>;
  74283. dispose(): void;
  74284. private _importMeshAsync;
  74285. /**
  74286. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  74287. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  74288. * @param scene the scene the meshes should be added to
  74289. * @param data gltf data containing information of the meshes in a loaded file
  74290. * @param rootUrl root url to load from
  74291. * @param onProgress event that fires when loading progress has occured
  74292. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  74293. */
  74294. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  74295. meshes: AbstractMesh[];
  74296. particleSystems: IParticleSystem[];
  74297. skeletons: Skeleton[];
  74298. animationGroups: AnimationGroup[];
  74299. }>;
  74300. private _loadAsync;
  74301. /**
  74302. * Imports all objects from a loaded gltf file and adds them to the scene
  74303. * @param scene the scene the objects should be added to
  74304. * @param data gltf data containing information of the meshes in a loaded file
  74305. * @param rootUrl root url to load from
  74306. * @param onProgress event that fires when loading progress has occured
  74307. * @returns a promise which completes when objects have been loaded to the scene
  74308. */
  74309. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  74310. private _loadShadersAsync;
  74311. private _loadBuffersAsync;
  74312. private _createNodes;
  74313. }
  74314. /** @hidden */
  74315. export abstract class GLTFLoaderExtension {
  74316. private _name;
  74317. constructor(name: string);
  74318. get name(): string;
  74319. /**
  74320. * Defines an override for loading the runtime
  74321. * Return true to stop further extensions from loading the runtime
  74322. */
  74323. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  74324. /**
  74325. * Defines an onverride for creating gltf runtime
  74326. * Return true to stop further extensions from creating the runtime
  74327. */
  74328. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  74329. /**
  74330. * Defines an override for loading buffers
  74331. * Return true to stop further extensions from loading this buffer
  74332. */
  74333. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  74334. /**
  74335. * Defines an override for loading texture buffers
  74336. * Return true to stop further extensions from loading this texture data
  74337. */
  74338. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74339. /**
  74340. * Defines an override for creating textures
  74341. * Return true to stop further extensions from loading this texture
  74342. */
  74343. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  74344. /**
  74345. * Defines an override for loading shader strings
  74346. * Return true to stop further extensions from loading this shader data
  74347. */
  74348. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74349. /**
  74350. * Defines an override for loading materials
  74351. * Return true to stop further extensions from loading this material
  74352. */
  74353. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74354. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  74355. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  74356. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74357. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74358. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  74359. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74360. private static LoadTextureBufferAsync;
  74361. private static CreateTextureAsync;
  74362. private static ApplyExtensions;
  74363. }
  74364. }
  74365. declare module BABYLON.GLTF1 {
  74366. /** @hidden */
  74367. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  74368. private _bin;
  74369. constructor();
  74370. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  74371. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74372. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74373. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74374. }
  74375. }
  74376. declare module BABYLON.GLTF1 {
  74377. /** @hidden */
  74378. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  74379. constructor();
  74380. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  74381. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74382. private _loadTexture;
  74383. }
  74384. }
  74385. declare module BABYLON.GLTF2.Loader {
  74386. /**
  74387. * Loader interface with an index field.
  74388. */
  74389. export interface IArrayItem {
  74390. /**
  74391. * The index of this item in the array.
  74392. */
  74393. index: number;
  74394. }
  74395. /**
  74396. * Loader interface with additional members.
  74397. */
  74398. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  74399. /** @hidden */
  74400. _data?: Promise<ArrayBufferView>;
  74401. /** @hidden */
  74402. _babylonVertexBuffer?: Promise<VertexBuffer>;
  74403. }
  74404. /**
  74405. * Loader interface with additional members.
  74406. */
  74407. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  74408. }
  74409. /** @hidden */
  74410. export interface _IAnimationSamplerData {
  74411. input: Float32Array;
  74412. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  74413. output: Float32Array;
  74414. }
  74415. /**
  74416. * Loader interface with additional members.
  74417. */
  74418. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  74419. /** @hidden */
  74420. _data?: Promise<_IAnimationSamplerData>;
  74421. }
  74422. /**
  74423. * Loader interface with additional members.
  74424. */
  74425. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  74426. channels: IAnimationChannel[];
  74427. samplers: IAnimationSampler[];
  74428. /** @hidden */
  74429. _babylonAnimationGroup?: AnimationGroup;
  74430. }
  74431. /**
  74432. * Loader interface with additional members.
  74433. */
  74434. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  74435. /** @hidden */
  74436. _data?: Promise<ArrayBufferView>;
  74437. }
  74438. /**
  74439. * Loader interface with additional members.
  74440. */
  74441. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  74442. /** @hidden */
  74443. _data?: Promise<ArrayBufferView>;
  74444. /** @hidden */
  74445. _babylonBuffer?: Promise<Buffer>;
  74446. }
  74447. /**
  74448. * Loader interface with additional members.
  74449. */
  74450. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  74451. }
  74452. /**
  74453. * Loader interface with additional members.
  74454. */
  74455. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  74456. /** @hidden */
  74457. _data?: Promise<ArrayBufferView>;
  74458. }
  74459. /**
  74460. * Loader interface with additional members.
  74461. */
  74462. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  74463. }
  74464. /**
  74465. * Loader interface with additional members.
  74466. */
  74467. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  74468. }
  74469. /**
  74470. * Loader interface with additional members.
  74471. */
  74472. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  74473. baseColorTexture?: ITextureInfo;
  74474. metallicRoughnessTexture?: ITextureInfo;
  74475. }
  74476. /**
  74477. * Loader interface with additional members.
  74478. */
  74479. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  74480. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  74481. normalTexture?: IMaterialNormalTextureInfo;
  74482. occlusionTexture?: IMaterialOcclusionTextureInfo;
  74483. emissiveTexture?: ITextureInfo;
  74484. /** @hidden */
  74485. _data?: {
  74486. [babylonDrawMode: number]: {
  74487. babylonMaterial: Material;
  74488. babylonMeshes: AbstractMesh[];
  74489. promise: Promise<void>;
  74490. };
  74491. };
  74492. }
  74493. /**
  74494. * Loader interface with additional members.
  74495. */
  74496. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  74497. primitives: IMeshPrimitive[];
  74498. }
  74499. /**
  74500. * Loader interface with additional members.
  74501. */
  74502. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  74503. /** @hidden */
  74504. _instanceData?: {
  74505. babylonSourceMesh: Mesh;
  74506. promise: Promise<any>;
  74507. };
  74508. }
  74509. /**
  74510. * Loader interface with additional members.
  74511. */
  74512. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  74513. /**
  74514. * The parent glTF node.
  74515. */
  74516. parent?: INode;
  74517. /** @hidden */
  74518. _babylonTransformNode?: TransformNode;
  74519. /** @hidden */
  74520. _primitiveBabylonMeshes?: AbstractMesh[];
  74521. /** @hidden */
  74522. _babylonBones?: Bone[];
  74523. /** @hidden */
  74524. _numMorphTargets?: number;
  74525. }
  74526. /** @hidden */
  74527. export interface _ISamplerData {
  74528. noMipMaps: boolean;
  74529. samplingMode: number;
  74530. wrapU: number;
  74531. wrapV: number;
  74532. }
  74533. /**
  74534. * Loader interface with additional members.
  74535. */
  74536. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  74537. /** @hidden */
  74538. _data?: _ISamplerData;
  74539. }
  74540. /**
  74541. * Loader interface with additional members.
  74542. */
  74543. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  74544. }
  74545. /**
  74546. * Loader interface with additional members.
  74547. */
  74548. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  74549. /** @hidden */
  74550. _data?: {
  74551. babylonSkeleton: Skeleton;
  74552. promise: Promise<void>;
  74553. };
  74554. }
  74555. /**
  74556. * Loader interface with additional members.
  74557. */
  74558. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  74559. }
  74560. /**
  74561. * Loader interface with additional members.
  74562. */
  74563. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  74564. }
  74565. /**
  74566. * Loader interface with additional members.
  74567. */
  74568. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  74569. accessors?: IAccessor[];
  74570. animations?: IAnimation[];
  74571. buffers?: IBuffer[];
  74572. bufferViews?: IBufferView[];
  74573. cameras?: ICamera[];
  74574. images?: IImage[];
  74575. materials?: IMaterial[];
  74576. meshes?: IMesh[];
  74577. nodes?: INode[];
  74578. samplers?: ISampler[];
  74579. scenes?: IScene[];
  74580. skins?: ISkin[];
  74581. textures?: ITexture[];
  74582. }
  74583. }
  74584. declare module BABYLON.GLTF2 {
  74585. /**
  74586. * Interface for a glTF loader extension.
  74587. */
  74588. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  74589. /**
  74590. * Called after the loader state changes to LOADING.
  74591. */
  74592. onLoading?(): void;
  74593. /**
  74594. * Called after the loader state changes to READY.
  74595. */
  74596. onReady?(): void;
  74597. /**
  74598. * Define this method to modify the default behavior when loading scenes.
  74599. * @param context The context when loading the asset
  74600. * @param scene The glTF scene property
  74601. * @returns A promise that resolves when the load is complete or null if not handled
  74602. */
  74603. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  74604. /**
  74605. * Define this method to modify the default behavior when loading nodes.
  74606. * @param context The context when loading the asset
  74607. * @param node The glTF node property
  74608. * @param assign A function called synchronously after parsing the glTF properties
  74609. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  74610. */
  74611. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  74612. /**
  74613. * Define this method to modify the default behavior when loading cameras.
  74614. * @param context The context when loading the asset
  74615. * @param camera The glTF camera property
  74616. * @param assign A function called synchronously after parsing the glTF properties
  74617. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  74618. */
  74619. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  74620. /**
  74621. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  74622. * @param context The context when loading the asset
  74623. * @param primitive The glTF mesh primitive property
  74624. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  74625. */
  74626. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  74627. /**
  74628. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  74629. * @param context The context when loading the asset
  74630. * @param name The mesh name when loading the asset
  74631. * @param node The glTF node when loading the asset
  74632. * @param mesh The glTF mesh when loading the asset
  74633. * @param primitive The glTF mesh primitive property
  74634. * @param assign A function called synchronously after parsing the glTF properties
  74635. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  74636. */
  74637. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  74638. /**
  74639. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  74640. * @param context The context when loading the asset
  74641. * @param material The glTF material property
  74642. * @param assign A function called synchronously after parsing the glTF properties
  74643. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  74644. */
  74645. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  74646. /**
  74647. * Define this method to modify the default behavior when creating materials.
  74648. * @param context The context when loading the asset
  74649. * @param material The glTF material property
  74650. * @param babylonDrawMode The draw mode for the Babylon material
  74651. * @returns The Babylon material or null if not handled
  74652. */
  74653. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  74654. /**
  74655. * Define this method to modify the default behavior when loading material properties.
  74656. * @param context The context when loading the asset
  74657. * @param material The glTF material property
  74658. * @param babylonMaterial The Babylon material
  74659. * @returns A promise that resolves when the load is complete or null if not handled
  74660. */
  74661. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  74662. /**
  74663. * Define this method to modify the default behavior when loading texture infos.
  74664. * @param context The context when loading the asset
  74665. * @param textureInfo The glTF texture info property
  74666. * @param assign A function called synchronously after parsing the glTF properties
  74667. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  74668. */
  74669. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  74670. /**
  74671. * Define this method to modify the default behavior when loading animations.
  74672. * @param context The context when loading the asset
  74673. * @param animation The glTF animation property
  74674. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  74675. */
  74676. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  74677. /**
  74678. * @hidden Define this method to modify the default behavior when loading skins.
  74679. * @param context The context when loading the asset
  74680. * @param node The glTF node property
  74681. * @param skin The glTF skin property
  74682. * @returns A promise that resolves when the load is complete or null if not handled
  74683. */
  74684. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  74685. /**
  74686. * @hidden Define this method to modify the default behavior when loading uris.
  74687. * @param context The context when loading the asset
  74688. * @param property The glTF property associated with the uri
  74689. * @param uri The uri to load
  74690. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74691. */
  74692. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  74693. /**
  74694. * Define this method to modify the default behavior when loading buffer views.
  74695. * @param context The context when loading the asset
  74696. * @param bufferView The glTF buffer view property
  74697. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74698. */
  74699. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  74700. /**
  74701. * Define this method to modify the default behavior when loading buffers.
  74702. * @param context The context when loading the asset
  74703. * @param buffer The glTF buffer property
  74704. * @param byteOffset The byte offset to load
  74705. * @param byteLength The byte length to load
  74706. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74707. */
  74708. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  74709. }
  74710. }
  74711. declare module BABYLON.GLTF2 {
  74712. /**
  74713. * Helper class for working with arrays when loading the glTF asset
  74714. */
  74715. export class ArrayItem {
  74716. /**
  74717. * Gets an item from the given array.
  74718. * @param context The context when loading the asset
  74719. * @param array The array to get the item from
  74720. * @param index The index to the array
  74721. * @returns The array item
  74722. */
  74723. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  74724. /**
  74725. * Assign an `index` field to each item of the given array.
  74726. * @param array The array of items
  74727. */
  74728. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  74729. }
  74730. /**
  74731. * The glTF 2.0 loader
  74732. */
  74733. export class GLTFLoader implements IGLTFLoader {
  74734. /** @hidden */
  74735. _completePromises: Promise<any>[];
  74736. private _disposed;
  74737. private _parent;
  74738. private _state;
  74739. private _extensions;
  74740. private _rootUrl;
  74741. private _fileName;
  74742. private _uniqueRootUrl;
  74743. private _gltf;
  74744. private _bin;
  74745. private _babylonScene;
  74746. private _rootBabylonMesh;
  74747. private _defaultBabylonMaterialData;
  74748. private _progressCallback?;
  74749. private _requests;
  74750. private static readonly _DefaultSampler;
  74751. private static _RegisteredExtensions;
  74752. /**
  74753. * Registers a loader extension.
  74754. * @param name The name of the loader extension.
  74755. * @param factory The factory function that creates the loader extension.
  74756. */
  74757. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  74758. /**
  74759. * Unregisters a loader extension.
  74760. * @param name The name of the loader extension.
  74761. * @returns A boolean indicating whether the extension has been unregistered
  74762. */
  74763. static UnregisterExtension(name: string): boolean;
  74764. /**
  74765. * Gets the loader state.
  74766. */
  74767. get state(): Nullable<GLTFLoaderState>;
  74768. /**
  74769. * The object that represents the glTF JSON.
  74770. */
  74771. get gltf(): IGLTF;
  74772. /**
  74773. * The BIN chunk of a binary glTF.
  74774. */
  74775. get bin(): Nullable<IDataBuffer>;
  74776. /**
  74777. * The parent file loader.
  74778. */
  74779. get parent(): GLTFFileLoader;
  74780. /**
  74781. * The Babylon scene when loading the asset.
  74782. */
  74783. get babylonScene(): Scene;
  74784. /**
  74785. * The root Babylon mesh when loading the asset.
  74786. */
  74787. get rootBabylonMesh(): Mesh;
  74788. /** @hidden */
  74789. constructor(parent: GLTFFileLoader);
  74790. /** @hidden */
  74791. dispose(): void;
  74792. /** @hidden */
  74793. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74794. meshes: AbstractMesh[];
  74795. particleSystems: IParticleSystem[];
  74796. skeletons: Skeleton[];
  74797. animationGroups: AnimationGroup[];
  74798. }>;
  74799. /** @hidden */
  74800. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74801. private _loadAsync;
  74802. private _loadData;
  74803. private _setupData;
  74804. private _loadExtensions;
  74805. private _checkExtensions;
  74806. private _setState;
  74807. private _createRootNode;
  74808. /**
  74809. * Loads a glTF scene.
  74810. * @param context The context when loading the asset
  74811. * @param scene The glTF scene property
  74812. * @returns A promise that resolves when the load is complete
  74813. */
  74814. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  74815. private _forEachPrimitive;
  74816. private _getMeshes;
  74817. private _getSkeletons;
  74818. private _getAnimationGroups;
  74819. private _startAnimations;
  74820. /**
  74821. * Loads a glTF node.
  74822. * @param context The context when loading the asset
  74823. * @param node The glTF node property
  74824. * @param assign A function called synchronously after parsing the glTF properties
  74825. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  74826. */
  74827. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  74828. private _loadMeshAsync;
  74829. /**
  74830. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  74831. * @param context The context when loading the asset
  74832. * @param name The mesh name when loading the asset
  74833. * @param node The glTF node when loading the asset
  74834. * @param mesh The glTF mesh when loading the asset
  74835. * @param primitive The glTF mesh primitive property
  74836. * @param assign A function called synchronously after parsing the glTF properties
  74837. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  74838. */
  74839. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  74840. private _loadVertexDataAsync;
  74841. private _createMorphTargets;
  74842. private _loadMorphTargetsAsync;
  74843. private _loadMorphTargetVertexDataAsync;
  74844. private static _LoadTransform;
  74845. private _loadSkinAsync;
  74846. private _loadBones;
  74847. private _loadBone;
  74848. private _loadSkinInverseBindMatricesDataAsync;
  74849. private _updateBoneMatrices;
  74850. private _getNodeMatrix;
  74851. /**
  74852. * Loads a glTF camera.
  74853. * @param context The context when loading the asset
  74854. * @param camera The glTF camera property
  74855. * @param assign A function called synchronously after parsing the glTF properties
  74856. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  74857. */
  74858. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  74859. private _loadAnimationsAsync;
  74860. /**
  74861. * Loads a glTF animation.
  74862. * @param context The context when loading the asset
  74863. * @param animation The glTF animation property
  74864. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  74865. */
  74866. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  74867. /**
  74868. * @hidden Loads a glTF animation channel.
  74869. * @param context The context when loading the asset
  74870. * @param animationContext The context of the animation when loading the asset
  74871. * @param animation The glTF animation property
  74872. * @param channel The glTF animation channel property
  74873. * @param babylonAnimationGroup The babylon animation group property
  74874. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  74875. * @returns A void promise when the channel load is complete
  74876. */
  74877. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  74878. private _loadAnimationSamplerAsync;
  74879. private _loadBufferAsync;
  74880. /**
  74881. * Loads a glTF buffer view.
  74882. * @param context The context when loading the asset
  74883. * @param bufferView The glTF buffer view property
  74884. * @returns A promise that resolves with the loaded data when the load is complete
  74885. */
  74886. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  74887. private _loadAccessorAsync;
  74888. private _loadFloatAccessorAsync;
  74889. private _loadIndicesAccessorAsync;
  74890. private _loadVertexBufferViewAsync;
  74891. private _loadVertexAccessorAsync;
  74892. private _loadMaterialMetallicRoughnessPropertiesAsync;
  74893. /** @hidden */
  74894. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  74895. private _createDefaultMaterial;
  74896. /**
  74897. * Creates a Babylon material from a glTF material.
  74898. * @param context The context when loading the asset
  74899. * @param material The glTF material property
  74900. * @param babylonDrawMode The draw mode for the Babylon material
  74901. * @returns The Babylon material
  74902. */
  74903. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  74904. /**
  74905. * Loads properties from a glTF material into a Babylon material.
  74906. * @param context The context when loading the asset
  74907. * @param material The glTF material property
  74908. * @param babylonMaterial The Babylon material
  74909. * @returns A promise that resolves when the load is complete
  74910. */
  74911. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  74912. /**
  74913. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  74914. * @param context The context when loading the asset
  74915. * @param material The glTF material property
  74916. * @param babylonMaterial The Babylon material
  74917. * @returns A promise that resolves when the load is complete
  74918. */
  74919. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  74920. /**
  74921. * Loads the alpha properties from a glTF material into a Babylon material.
  74922. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  74923. * @param context The context when loading the asset
  74924. * @param material The glTF material property
  74925. * @param babylonMaterial The Babylon material
  74926. */
  74927. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  74928. /**
  74929. * Loads a glTF texture info.
  74930. * @param context The context when loading the asset
  74931. * @param textureInfo The glTF texture info property
  74932. * @param assign A function called synchronously after parsing the glTF properties
  74933. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  74934. */
  74935. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  74936. private _loadTextureAsync;
  74937. private _loadSampler;
  74938. /**
  74939. * Loads a glTF image.
  74940. * @param context The context when loading the asset
  74941. * @param image The glTF image property
  74942. * @returns A promise that resolves with the loaded data when the load is complete
  74943. */
  74944. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  74945. /**
  74946. * Loads a glTF uri.
  74947. * @param context The context when loading the asset
  74948. * @param property The glTF property associated with the uri
  74949. * @param uri The base64 or relative uri
  74950. * @returns A promise that resolves with the loaded data when the load is complete
  74951. */
  74952. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  74953. private _onProgress;
  74954. /**
  74955. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  74956. * @param babylonObject the Babylon object with metadata
  74957. * @param pointer the JSON pointer
  74958. */
  74959. static AddPointerMetadata(babylonObject: {
  74960. metadata: any;
  74961. }, pointer: string): void;
  74962. private static _GetTextureWrapMode;
  74963. private static _GetTextureSamplingMode;
  74964. private static _GetTypedArrayConstructor;
  74965. private static _GetTypedArray;
  74966. private static _GetNumComponents;
  74967. private static _ValidateUri;
  74968. private static _GetDrawMode;
  74969. private _compileMaterialsAsync;
  74970. private _compileShadowGeneratorsAsync;
  74971. private _forEachExtensions;
  74972. private _applyExtensions;
  74973. private _extensionsOnLoading;
  74974. private _extensionsOnReady;
  74975. private _extensionsLoadSceneAsync;
  74976. private _extensionsLoadNodeAsync;
  74977. private _extensionsLoadCameraAsync;
  74978. private _extensionsLoadVertexDataAsync;
  74979. private _extensionsLoadMeshPrimitiveAsync;
  74980. private _extensionsLoadMaterialAsync;
  74981. private _extensionsCreateMaterial;
  74982. private _extensionsLoadMaterialPropertiesAsync;
  74983. private _extensionsLoadTextureInfoAsync;
  74984. private _extensionsLoadAnimationAsync;
  74985. private _extensionsLoadSkinAsync;
  74986. private _extensionsLoadUriAsync;
  74987. private _extensionsLoadBufferViewAsync;
  74988. private _extensionsLoadBufferAsync;
  74989. /**
  74990. * Helper method called by a loader extension to load an glTF extension.
  74991. * @param context The context when loading the asset
  74992. * @param property The glTF property to load the extension from
  74993. * @param extensionName The name of the extension to load
  74994. * @param actionAsync The action to run
  74995. * @returns The promise returned by actionAsync or null if the extension does not exist
  74996. */
  74997. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  74998. /**
  74999. * Helper method called by a loader extension to load a glTF extra.
  75000. * @param context The context when loading the asset
  75001. * @param property The glTF property to load the extra from
  75002. * @param extensionName The name of the extension to load
  75003. * @param actionAsync The action to run
  75004. * @returns The promise returned by actionAsync or null if the extra does not exist
  75005. */
  75006. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75007. /**
  75008. * Checks for presence of an extension.
  75009. * @param name The name of the extension to check
  75010. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  75011. */
  75012. isExtensionUsed(name: string): boolean;
  75013. /**
  75014. * Increments the indentation level and logs a message.
  75015. * @param message The message to log
  75016. */
  75017. logOpen(message: string): void;
  75018. /**
  75019. * Decrements the indentation level.
  75020. */
  75021. logClose(): void;
  75022. /**
  75023. * Logs a message
  75024. * @param message The message to log
  75025. */
  75026. log(message: string): void;
  75027. /**
  75028. * Starts a performance counter.
  75029. * @param counterName The name of the performance counter
  75030. */
  75031. startPerformanceCounter(counterName: string): void;
  75032. /**
  75033. * Ends a performance counter.
  75034. * @param counterName The name of the performance counter
  75035. */
  75036. endPerformanceCounter(counterName: string): void;
  75037. }
  75038. }
  75039. declare module BABYLON.GLTF2.Loader.Extensions {
  75040. /**
  75041. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  75042. */
  75043. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  75044. /**
  75045. * The name of this extension.
  75046. */
  75047. readonly name: string;
  75048. /**
  75049. * Defines whether this extension is enabled.
  75050. */
  75051. enabled: boolean;
  75052. private _loader;
  75053. private _lights?;
  75054. /** @hidden */
  75055. constructor(loader: GLTFLoader);
  75056. /** @hidden */
  75057. dispose(): void;
  75058. /** @hidden */
  75059. onLoading(): void;
  75060. /** @hidden */
  75061. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75062. private _loadLightAsync;
  75063. }
  75064. }
  75065. declare module BABYLON.GLTF2.Loader.Extensions {
  75066. /**
  75067. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  75068. */
  75069. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  75070. /**
  75071. * The name of this extension.
  75072. */
  75073. readonly name: string;
  75074. /**
  75075. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  75076. */
  75077. dracoCompression?: DracoCompression;
  75078. /**
  75079. * Defines whether this extension is enabled.
  75080. */
  75081. enabled: boolean;
  75082. private _loader;
  75083. /** @hidden */
  75084. constructor(loader: GLTFLoader);
  75085. /** @hidden */
  75086. dispose(): void;
  75087. /** @hidden */
  75088. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75089. }
  75090. }
  75091. declare module BABYLON.GLTF2.Loader.Extensions {
  75092. /**
  75093. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  75094. */
  75095. export class KHR_lights implements IGLTFLoaderExtension {
  75096. /**
  75097. * The name of this extension.
  75098. */
  75099. readonly name: string;
  75100. /**
  75101. * Defines whether this extension is enabled.
  75102. */
  75103. enabled: boolean;
  75104. private _loader;
  75105. private _lights?;
  75106. /** @hidden */
  75107. constructor(loader: GLTFLoader);
  75108. /** @hidden */
  75109. dispose(): void;
  75110. /** @hidden */
  75111. onLoading(): void;
  75112. /** @hidden */
  75113. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75114. }
  75115. }
  75116. declare module BABYLON.GLTF2.Loader.Extensions {
  75117. /**
  75118. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  75119. */
  75120. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  75121. /**
  75122. * The name of this extension.
  75123. */
  75124. readonly name: string;
  75125. /**
  75126. * Defines whether this extension is enabled.
  75127. */
  75128. enabled: boolean;
  75129. /**
  75130. * Defines a number that determines the order the extensions are applied.
  75131. */
  75132. order: number;
  75133. private _loader;
  75134. /** @hidden */
  75135. constructor(loader: GLTFLoader);
  75136. /** @hidden */
  75137. dispose(): void;
  75138. /** @hidden */
  75139. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75140. private _loadSpecularGlossinessPropertiesAsync;
  75141. }
  75142. }
  75143. declare module BABYLON.GLTF2.Loader.Extensions {
  75144. /**
  75145. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  75146. */
  75147. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  75148. /**
  75149. * The name of this extension.
  75150. */
  75151. readonly name: string;
  75152. /**
  75153. * Defines whether this extension is enabled.
  75154. */
  75155. enabled: boolean;
  75156. /**
  75157. * Defines a number that determines the order the extensions are applied.
  75158. */
  75159. order: number;
  75160. private _loader;
  75161. /** @hidden */
  75162. constructor(loader: GLTFLoader);
  75163. /** @hidden */
  75164. dispose(): void;
  75165. /** @hidden */
  75166. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75167. private _loadUnlitPropertiesAsync;
  75168. }
  75169. }
  75170. declare module BABYLON.GLTF2.Loader.Extensions {
  75171. /**
  75172. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75173. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  75174. * !!! Experimental Extension Subject to Changes !!!
  75175. */
  75176. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  75177. /**
  75178. * The name of this extension.
  75179. */
  75180. readonly name: string;
  75181. /**
  75182. * Defines whether this extension is enabled.
  75183. */
  75184. enabled: boolean;
  75185. /**
  75186. * Defines a number that determines the order the extensions are applied.
  75187. */
  75188. order: number;
  75189. private _loader;
  75190. /** @hidden */
  75191. constructor(loader: GLTFLoader);
  75192. /** @hidden */
  75193. dispose(): void;
  75194. /** @hidden */
  75195. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75196. private _loadClearCoatPropertiesAsync;
  75197. }
  75198. }
  75199. declare module BABYLON.GLTF2.Loader.Extensions {
  75200. /**
  75201. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  75202. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75203. * !!! Experimental Extension Subject to Changes !!!
  75204. */
  75205. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  75206. /**
  75207. * The name of this extension.
  75208. */
  75209. readonly name: string;
  75210. /**
  75211. * Defines whether this extension is enabled.
  75212. */
  75213. enabled: boolean;
  75214. /**
  75215. * Defines a number that determines the order the extensions are applied.
  75216. */
  75217. order: number;
  75218. private _loader;
  75219. /** @hidden */
  75220. constructor(loader: GLTFLoader);
  75221. /** @hidden */
  75222. dispose(): void;
  75223. /** @hidden */
  75224. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75225. private _loadSheenPropertiesAsync;
  75226. }
  75227. }
  75228. declare module BABYLON.GLTF2.Loader.Extensions {
  75229. /**
  75230. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75231. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75232. * !!! Experimental Extension Subject to Changes !!!
  75233. */
  75234. export class KHR_materials_specular implements IGLTFLoaderExtension {
  75235. /**
  75236. * The name of this extension.
  75237. */
  75238. readonly name: string;
  75239. /**
  75240. * Defines whether this extension is enabled.
  75241. */
  75242. enabled: boolean;
  75243. /**
  75244. * Defines a number that determines the order the extensions are applied.
  75245. */
  75246. order: number;
  75247. private _loader;
  75248. /** @hidden */
  75249. constructor(loader: GLTFLoader);
  75250. /** @hidden */
  75251. dispose(): void;
  75252. /** @hidden */
  75253. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75254. private _loadSpecularPropertiesAsync;
  75255. }
  75256. }
  75257. declare module BABYLON.GLTF2.Loader.Extensions {
  75258. /**
  75259. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  75260. */
  75261. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  75262. /**
  75263. * The name of this extension.
  75264. */
  75265. readonly name: string;
  75266. /**
  75267. * Defines whether this extension is enabled.
  75268. */
  75269. enabled: boolean;
  75270. /** @hidden */
  75271. constructor(loader: GLTFLoader);
  75272. /** @hidden */
  75273. dispose(): void;
  75274. }
  75275. }
  75276. declare module BABYLON.GLTF2.Loader.Extensions {
  75277. /**
  75278. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  75279. */
  75280. export class KHR_texture_transform implements IGLTFLoaderExtension {
  75281. /**
  75282. * The name of this extension.
  75283. */
  75284. readonly name: string;
  75285. /**
  75286. * Defines whether this extension is enabled.
  75287. */
  75288. enabled: boolean;
  75289. private _loader;
  75290. /** @hidden */
  75291. constructor(loader: GLTFLoader);
  75292. /** @hidden */
  75293. dispose(): void;
  75294. /** @hidden */
  75295. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75296. }
  75297. }
  75298. declare module BABYLON.GLTF2.Loader.Extensions {
  75299. /**
  75300. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  75301. */
  75302. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  75303. /**
  75304. * The name of this extension.
  75305. */
  75306. readonly name: string;
  75307. /**
  75308. * Defines whether this extension is enabled.
  75309. */
  75310. enabled: boolean;
  75311. private _loader;
  75312. private _clips;
  75313. private _emitters;
  75314. /** @hidden */
  75315. constructor(loader: GLTFLoader);
  75316. /** @hidden */
  75317. dispose(): void;
  75318. /** @hidden */
  75319. onLoading(): void;
  75320. /** @hidden */
  75321. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75322. /** @hidden */
  75323. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75324. /** @hidden */
  75325. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75326. private _loadClipAsync;
  75327. private _loadEmitterAsync;
  75328. private _getEventAction;
  75329. private _loadAnimationEventAsync;
  75330. }
  75331. }
  75332. declare module BABYLON.GLTF2.Loader.Extensions {
  75333. /**
  75334. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  75335. */
  75336. export class MSFT_lod implements 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 a number that determines the order the extensions are applied.
  75347. */
  75348. order: number;
  75349. /**
  75350. * Maximum number of LODs to load, starting from the lowest LOD.
  75351. */
  75352. maxLODsToLoad: number;
  75353. /**
  75354. * Observable raised when all node LODs of one level are loaded.
  75355. * The event data is the index of the loaded LOD starting from zero.
  75356. * Dispose the loader to cancel the loading of the next level of LODs.
  75357. */
  75358. onNodeLODsLoadedObservable: Observable<number>;
  75359. /**
  75360. * Observable raised when all material LODs of one level are loaded.
  75361. * The event data is the index of the loaded LOD starting from zero.
  75362. * Dispose the loader to cancel the loading of the next level of LODs.
  75363. */
  75364. onMaterialLODsLoadedObservable: Observable<number>;
  75365. private _loader;
  75366. private _nodeIndexLOD;
  75367. private _nodeSignalLODs;
  75368. private _nodePromiseLODs;
  75369. private _materialIndexLOD;
  75370. private _materialSignalLODs;
  75371. private _materialPromiseLODs;
  75372. private _indexLOD;
  75373. private _bufferLODs;
  75374. /** @hidden */
  75375. constructor(loader: GLTFLoader);
  75376. /** @hidden */
  75377. dispose(): void;
  75378. /** @hidden */
  75379. onReady(): void;
  75380. /** @hidden */
  75381. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75382. /** @hidden */
  75383. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75384. /** @hidden */
  75385. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75386. /** @hidden */
  75387. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75388. private _loadBufferLOD;
  75389. /**
  75390. * Gets an array of LOD properties from lowest to highest.
  75391. */
  75392. private _getLODs;
  75393. private _disposeUnusedMaterials;
  75394. }
  75395. }
  75396. declare module BABYLON.GLTF2.Loader.Extensions {
  75397. /** @hidden */
  75398. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  75399. readonly name: string;
  75400. enabled: boolean;
  75401. private _loader;
  75402. constructor(loader: GLTFLoader);
  75403. dispose(): void;
  75404. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75405. }
  75406. }
  75407. declare module BABYLON.GLTF2.Loader.Extensions {
  75408. /** @hidden */
  75409. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  75410. readonly name: string;
  75411. enabled: boolean;
  75412. private _loader;
  75413. constructor(loader: GLTFLoader);
  75414. dispose(): void;
  75415. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75416. }
  75417. }
  75418. declare module BABYLON.GLTF2.Loader.Extensions {
  75419. /**
  75420. * Store glTF extras (if present) in BJS objects' metadata
  75421. */
  75422. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  75423. /**
  75424. * The name of this extension.
  75425. */
  75426. readonly name: string;
  75427. /**
  75428. * Defines whether this extension is enabled.
  75429. */
  75430. enabled: boolean;
  75431. private _loader;
  75432. private _assignExtras;
  75433. /** @hidden */
  75434. constructor(loader: GLTFLoader);
  75435. /** @hidden */
  75436. dispose(): void;
  75437. /** @hidden */
  75438. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75439. /** @hidden */
  75440. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75441. /** @hidden */
  75442. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75443. }
  75444. }
  75445. declare module BABYLON {
  75446. /**
  75447. * Class reading and parsing the MTL file bundled with the obj file.
  75448. */
  75449. export class MTLFileLoader {
  75450. /**
  75451. * Invert Y-Axis of referenced textures on load
  75452. */
  75453. static INVERT_TEXTURE_Y: boolean;
  75454. /**
  75455. * All material loaded from the mtl will be set here
  75456. */
  75457. materials: StandardMaterial[];
  75458. /**
  75459. * This function will read the mtl file and create each material described inside
  75460. * This function could be improve by adding :
  75461. * -some component missing (Ni, Tf...)
  75462. * -including the specific options available
  75463. *
  75464. * @param scene defines the scene the material will be created in
  75465. * @param data defines the mtl data to parse
  75466. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  75467. */
  75468. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  75469. /**
  75470. * Gets the texture for the material.
  75471. *
  75472. * If the material is imported from input file,
  75473. * We sanitize the url to ensure it takes the textre from aside the material.
  75474. *
  75475. * @param rootUrl The root url to load from
  75476. * @param value The value stored in the mtl
  75477. * @return The Texture
  75478. */
  75479. private static _getTexture;
  75480. }
  75481. }
  75482. declare module BABYLON {
  75483. /**
  75484. * Options for loading OBJ/MTL files
  75485. */
  75486. type MeshLoadOptions = {
  75487. /**
  75488. * Defines if UVs are optimized by default during load.
  75489. */
  75490. OptimizeWithUV: boolean;
  75491. /**
  75492. * Defines custom scaling of UV coordinates of loaded meshes.
  75493. */
  75494. UVScaling: Vector2;
  75495. /**
  75496. * Invert model on y-axis (does a model scaling inversion)
  75497. */
  75498. InvertY: boolean;
  75499. /**
  75500. * Invert Y-Axis of referenced textures on load
  75501. */
  75502. InvertTextureY: boolean;
  75503. /**
  75504. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  75505. */
  75506. ImportVertexColors: boolean;
  75507. /**
  75508. * Compute the normals for the model, even if normals are present in the file.
  75509. */
  75510. ComputeNormals: boolean;
  75511. /**
  75512. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  75513. */
  75514. SkipMaterials: boolean;
  75515. /**
  75516. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  75517. */
  75518. MaterialLoadingFailsSilently: boolean;
  75519. };
  75520. /**
  75521. * OBJ file type loader.
  75522. * This is a babylon scene loader plugin.
  75523. */
  75524. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75525. /**
  75526. * Defines if UVs are optimized by default during load.
  75527. */
  75528. static OPTIMIZE_WITH_UV: boolean;
  75529. /**
  75530. * Invert model on y-axis (does a model scaling inversion)
  75531. */
  75532. static INVERT_Y: boolean;
  75533. /**
  75534. * Invert Y-Axis of referenced textures on load
  75535. */
  75536. static get INVERT_TEXTURE_Y(): boolean;
  75537. static set INVERT_TEXTURE_Y(value: boolean);
  75538. /**
  75539. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  75540. */
  75541. static IMPORT_VERTEX_COLORS: boolean;
  75542. /**
  75543. * Compute the normals for the model, even if normals are present in the file.
  75544. */
  75545. static COMPUTE_NORMALS: boolean;
  75546. /**
  75547. * Defines custom scaling of UV coordinates of loaded meshes.
  75548. */
  75549. static UV_SCALING: Vector2;
  75550. /**
  75551. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  75552. */
  75553. static SKIP_MATERIALS: boolean;
  75554. /**
  75555. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  75556. *
  75557. * Defaults to true for backwards compatibility.
  75558. */
  75559. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  75560. /**
  75561. * Defines the name of the plugin.
  75562. */
  75563. name: string;
  75564. /**
  75565. * Defines the extension the plugin is able to load.
  75566. */
  75567. extensions: string;
  75568. /** @hidden */
  75569. obj: RegExp;
  75570. /** @hidden */
  75571. group: RegExp;
  75572. /** @hidden */
  75573. mtllib: RegExp;
  75574. /** @hidden */
  75575. usemtl: RegExp;
  75576. /** @hidden */
  75577. smooth: RegExp;
  75578. /** @hidden */
  75579. vertexPattern: RegExp;
  75580. /** @hidden */
  75581. normalPattern: RegExp;
  75582. /** @hidden */
  75583. uvPattern: RegExp;
  75584. /** @hidden */
  75585. facePattern1: RegExp;
  75586. /** @hidden */
  75587. facePattern2: RegExp;
  75588. /** @hidden */
  75589. facePattern3: RegExp;
  75590. /** @hidden */
  75591. facePattern4: RegExp;
  75592. /** @hidden */
  75593. facePattern5: RegExp;
  75594. private _meshLoadOptions;
  75595. /**
  75596. * Creates loader for .OBJ files
  75597. *
  75598. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  75599. */
  75600. constructor(meshLoadOptions?: MeshLoadOptions);
  75601. private static get currentMeshLoadOptions();
  75602. /**
  75603. * Calls synchronously the MTL file attached to this obj.
  75604. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  75605. * Without this function materials are not displayed in the first frame (but displayed after).
  75606. * In consequence it is impossible to get material information in your HTML file
  75607. *
  75608. * @param url The URL of the MTL file
  75609. * @param rootUrl
  75610. * @param onSuccess Callback function to be called when the MTL file is loaded
  75611. * @private
  75612. */
  75613. private _loadMTL;
  75614. /**
  75615. * Instantiates a OBJ file loader plugin.
  75616. * @returns the created plugin
  75617. */
  75618. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  75619. /**
  75620. * If the data string can be loaded directly.
  75621. *
  75622. * @param data string containing the file data
  75623. * @returns if the data can be loaded directly
  75624. */
  75625. canDirectLoad(data: string): boolean;
  75626. /**
  75627. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  75628. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75629. * @param scene the scene the meshes should be added to
  75630. * @param data the OBJ data to load
  75631. * @param rootUrl root url to load from
  75632. * @param onProgress event that fires when loading progress has occured
  75633. * @param fileName Defines the name of the file to load
  75634. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75635. */
  75636. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75637. meshes: AbstractMesh[];
  75638. particleSystems: IParticleSystem[];
  75639. skeletons: Skeleton[];
  75640. animationGroups: AnimationGroup[];
  75641. }>;
  75642. /**
  75643. * Imports all objects from the loaded OBJ data and adds them to the scene
  75644. * @param scene the scene the objects should be added to
  75645. * @param data the OBJ data to load
  75646. * @param rootUrl root url to load from
  75647. * @param onProgress event that fires when loading progress has occured
  75648. * @param fileName Defines the name of the file to load
  75649. * @returns a promise which completes when objects have been loaded to the scene
  75650. */
  75651. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75652. /**
  75653. * Load into an asset container.
  75654. * @param scene The scene to load into
  75655. * @param data The data to import
  75656. * @param rootUrl The root url for scene and resources
  75657. * @param onProgress The callback when the load progresses
  75658. * @param fileName Defines the name of the file to load
  75659. * @returns The loaded asset container
  75660. */
  75661. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75662. /**
  75663. * Read the OBJ file and create an Array of meshes.
  75664. * Each mesh contains all information given by the OBJ and the MTL file.
  75665. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  75666. *
  75667. * @param meshesNames
  75668. * @param scene Scene The scene where are displayed the data
  75669. * @param data String The content of the obj file
  75670. * @param rootUrl String The path to the folder
  75671. * @returns Array<AbstractMesh>
  75672. * @private
  75673. */
  75674. private _parseSolid;
  75675. }
  75676. }
  75677. declare module BABYLON {
  75678. /**
  75679. * STL file type loader.
  75680. * This is a babylon scene loader plugin.
  75681. */
  75682. export class STLFileLoader implements ISceneLoaderPlugin {
  75683. /** @hidden */
  75684. solidPattern: RegExp;
  75685. /** @hidden */
  75686. facetsPattern: RegExp;
  75687. /** @hidden */
  75688. normalPattern: RegExp;
  75689. /** @hidden */
  75690. vertexPattern: RegExp;
  75691. /**
  75692. * Defines the name of the plugin.
  75693. */
  75694. name: string;
  75695. /**
  75696. * Defines the extensions the stl loader is able to load.
  75697. * force data to come in as an ArrayBuffer
  75698. * we'll convert to string if it looks like it's an ASCII .stl
  75699. */
  75700. extensions: ISceneLoaderPluginExtensions;
  75701. /**
  75702. * Import meshes into a scene.
  75703. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  75704. * @param scene The scene to import into
  75705. * @param data The data to import
  75706. * @param rootUrl The root url for scene and resources
  75707. * @param meshes The meshes array to import into
  75708. * @param particleSystems The particle systems array to import into
  75709. * @param skeletons The skeletons array to import into
  75710. * @param onError The callback when import fails
  75711. * @returns True if successful or false otherwise
  75712. */
  75713. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  75714. /**
  75715. * Load into a scene.
  75716. * @param scene The scene to load into
  75717. * @param data The data to import
  75718. * @param rootUrl The root url for scene and resources
  75719. * @param onError The callback when import fails
  75720. * @returns true if successful or false otherwise
  75721. */
  75722. load(scene: Scene, data: any, rootUrl: string): boolean;
  75723. /**
  75724. * Load into an asset container.
  75725. * @param scene The scene to load into
  75726. * @param data The data to import
  75727. * @param rootUrl The root url for scene and resources
  75728. * @param onError The callback when import fails
  75729. * @returns The loaded asset container
  75730. */
  75731. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  75732. private _isBinary;
  75733. private _parseBinary;
  75734. private _parseASCII;
  75735. }
  75736. }
  75737. declare module BABYLON {
  75738. /**
  75739. * Class for generating OBJ data from a Babylon scene.
  75740. */
  75741. export class OBJExport {
  75742. /**
  75743. * Exports the geometry of a Mesh array in .OBJ file format (text)
  75744. * @param mesh defines the list of meshes to serialize
  75745. * @param materials defines if materials should be exported
  75746. * @param matlibname defines the name of the associated mtl file
  75747. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  75748. * @returns the OBJ content
  75749. */
  75750. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  75751. /**
  75752. * Exports the material(s) of a mesh in .MTL file format (text)
  75753. * @param mesh defines the mesh to extract the material from
  75754. * @returns the mtl content
  75755. */
  75756. static MTL(mesh: Mesh): string;
  75757. }
  75758. }
  75759. declare module BABYLON {
  75760. /** @hidden */
  75761. export var __IGLTFExporterExtension: number;
  75762. /**
  75763. * Interface for extending the exporter
  75764. * @hidden
  75765. */
  75766. export interface IGLTFExporterExtension {
  75767. /**
  75768. * The name of this extension
  75769. */
  75770. readonly name: string;
  75771. /**
  75772. * Defines whether this extension is enabled
  75773. */
  75774. enabled: boolean;
  75775. /**
  75776. * Defines whether this extension is required
  75777. */
  75778. required: boolean;
  75779. }
  75780. }
  75781. declare module BABYLON.GLTF2.Exporter {
  75782. /** @hidden */
  75783. export var __IGLTFExporterExtensionV2: number;
  75784. /**
  75785. * Interface for a glTF exporter extension
  75786. * @hidden
  75787. */
  75788. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  75789. /**
  75790. * Define this method to modify the default behavior before exporting a texture
  75791. * @param context The context when loading the asset
  75792. * @param babylonTexture The Babylon.js texture
  75793. * @param mimeType The mime-type of the generated image
  75794. * @returns A promise that resolves with the exported texture
  75795. */
  75796. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  75797. /**
  75798. * Define this method to get notified when a texture info is created
  75799. * @param context The context when loading the asset
  75800. * @param textureInfo The glTF texture info
  75801. * @param babylonTexture The Babylon.js texture
  75802. */
  75803. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  75804. /**
  75805. * Define this method to modify the default behavior when exporting texture info
  75806. * @param context The context when loading the asset
  75807. * @param meshPrimitive glTF mesh primitive
  75808. * @param babylonSubMesh Babylon submesh
  75809. * @param binaryWriter glTF serializer binary writer instance
  75810. * @returns nullable IMeshPrimitive promise
  75811. */
  75812. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  75813. /**
  75814. * Define this method to modify the default behavior when exporting a node
  75815. * @param context The context when exporting the node
  75816. * @param node glTF node
  75817. * @param babylonNode BabylonJS node
  75818. * @returns nullable INode promise
  75819. */
  75820. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  75821. /**
  75822. * Define this method to modify the default behavior when exporting a material
  75823. * @param material glTF material
  75824. * @param babylonMaterial BabylonJS material
  75825. * @returns nullable IMaterial promise
  75826. */
  75827. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  75828. /**
  75829. * Define this method to return additional textures to export from a material
  75830. * @param material glTF material
  75831. * @param babylonMaterial BabylonJS material
  75832. * @returns List of textures
  75833. */
  75834. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  75835. /** Gets a boolean indicating that this extension was used */
  75836. wasUsed: boolean;
  75837. /** Gets a boolean indicating that this extension is required for the file to work */
  75838. required: boolean;
  75839. /**
  75840. * Called after the exporter state changes to EXPORTING
  75841. */
  75842. onExporting?(): void;
  75843. }
  75844. }
  75845. declare module BABYLON.GLTF2.Exporter {
  75846. /**
  75847. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  75848. * @hidden
  75849. */
  75850. export class _GLTFMaterialExporter {
  75851. /**
  75852. * Represents the dielectric specular values for R, G and B
  75853. */
  75854. private static readonly _DielectricSpecular;
  75855. /**
  75856. * Allows the maximum specular power to be defined for material calculations
  75857. */
  75858. private static readonly _MaxSpecularPower;
  75859. /**
  75860. * Mapping to store textures
  75861. */
  75862. private _textureMap;
  75863. /**
  75864. * Numeric tolerance value
  75865. */
  75866. private static readonly _Epsilon;
  75867. /**
  75868. * Reference to the glTF Exporter
  75869. */
  75870. private _exporter;
  75871. constructor(exporter: _Exporter);
  75872. /**
  75873. * Specifies if two colors are approximately equal in value
  75874. * @param color1 first color to compare to
  75875. * @param color2 second color to compare to
  75876. * @param epsilon threshold value
  75877. */
  75878. private static FuzzyEquals;
  75879. /**
  75880. * Gets the materials from a Babylon scene and converts them to glTF materials
  75881. * @param scene babylonjs scene
  75882. * @param mimeType texture mime type
  75883. * @param images array of images
  75884. * @param textures array of textures
  75885. * @param materials array of materials
  75886. * @param imageData mapping of texture names to base64 textures
  75887. * @param hasTextureCoords specifies if texture coordinates are present on the material
  75888. */
  75889. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  75890. /**
  75891. * Makes a copy of the glTF material without the texture parameters
  75892. * @param originalMaterial original glTF material
  75893. * @returns glTF material without texture parameters
  75894. */
  75895. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  75896. /**
  75897. * Specifies if the material has any texture parameters present
  75898. * @param material glTF Material
  75899. * @returns boolean specifying if texture parameters are present
  75900. */
  75901. _hasTexturesPresent(material: IMaterial): boolean;
  75902. /**
  75903. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  75904. * @param babylonStandardMaterial
  75905. * @returns glTF Metallic Roughness Material representation
  75906. */
  75907. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  75908. /**
  75909. * Computes the metallic factor
  75910. * @param diffuse diffused value
  75911. * @param specular specular value
  75912. * @param oneMinusSpecularStrength one minus the specular strength
  75913. * @returns metallic value
  75914. */
  75915. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  75916. /**
  75917. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  75918. * @param glTFMaterial glTF material
  75919. * @param babylonMaterial Babylon material
  75920. */
  75921. private static _SetAlphaMode;
  75922. /**
  75923. * Converts a Babylon Standard Material to a glTF Material
  75924. * @param babylonStandardMaterial BJS Standard Material
  75925. * @param mimeType mime type to use for the textures
  75926. * @param images array of glTF image interfaces
  75927. * @param textures array of glTF texture interfaces
  75928. * @param materials array of glTF material interfaces
  75929. * @param imageData map of image file name to data
  75930. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75931. */
  75932. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  75933. private _finishMaterial;
  75934. /**
  75935. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  75936. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  75937. * @param mimeType mime type to use for the textures
  75938. * @param images array of glTF image interfaces
  75939. * @param textures array of glTF texture interfaces
  75940. * @param materials array of glTF material interfaces
  75941. * @param imageData map of image file name to data
  75942. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75943. */
  75944. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  75945. /**
  75946. * Converts an image typed array buffer to a base64 image
  75947. * @param buffer typed array buffer
  75948. * @param width width of the image
  75949. * @param height height of the image
  75950. * @param mimeType mimetype of the image
  75951. * @returns base64 image string
  75952. */
  75953. private _createBase64FromCanvasAsync;
  75954. /**
  75955. * Generates a white texture based on the specified width and height
  75956. * @param width width of the texture in pixels
  75957. * @param height height of the texture in pixels
  75958. * @param scene babylonjs scene
  75959. * @returns white texture
  75960. */
  75961. private _createWhiteTexture;
  75962. /**
  75963. * 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
  75964. * @param texture1 first texture to resize
  75965. * @param texture2 second texture to resize
  75966. * @param scene babylonjs scene
  75967. * @returns resized textures or null
  75968. */
  75969. private _resizeTexturesToSameDimensions;
  75970. /**
  75971. * Converts an array of pixels to a Float32Array
  75972. * Throws an error if the pixel format is not supported
  75973. * @param pixels - array buffer containing pixel values
  75974. * @returns Float32 of pixels
  75975. */
  75976. private _convertPixelArrayToFloat32;
  75977. /**
  75978. * Convert Specular Glossiness Textures to Metallic Roughness
  75979. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  75980. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  75981. * @param diffuseTexture texture used to store diffuse information
  75982. * @param specularGlossinessTexture texture used to store specular and glossiness information
  75983. * @param factors specular glossiness material factors
  75984. * @param mimeType the mime type to use for the texture
  75985. * @returns pbr metallic roughness interface or null
  75986. */
  75987. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  75988. /**
  75989. * Converts specular glossiness material properties to metallic roughness
  75990. * @param specularGlossiness interface with specular glossiness material properties
  75991. * @returns interface with metallic roughness material properties
  75992. */
  75993. private _convertSpecularGlossinessToMetallicRoughness;
  75994. /**
  75995. * Calculates the surface reflectance, independent of lighting conditions
  75996. * @param color Color source to calculate brightness from
  75997. * @returns number representing the perceived brightness, or zero if color is undefined
  75998. */
  75999. private _getPerceivedBrightness;
  76000. /**
  76001. * Returns the maximum color component value
  76002. * @param color
  76003. * @returns maximum color component value, or zero if color is null or undefined
  76004. */
  76005. private _getMaxComponent;
  76006. /**
  76007. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  76008. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76009. * @param mimeType mime type to use for the textures
  76010. * @param images array of glTF image interfaces
  76011. * @param textures array of glTF texture interfaces
  76012. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76013. * @param imageData map of image file name to data
  76014. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76015. * @returns glTF PBR Metallic Roughness factors
  76016. */
  76017. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  76018. private _getGLTFTextureSampler;
  76019. private _getGLTFTextureWrapMode;
  76020. private _getGLTFTextureWrapModesSampler;
  76021. /**
  76022. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  76023. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76024. * @param mimeType mime type to use for the textures
  76025. * @param images array of glTF image interfaces
  76026. * @param textures array of glTF texture interfaces
  76027. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76028. * @param imageData map of image file name to data
  76029. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76030. * @returns glTF PBR Metallic Roughness factors
  76031. */
  76032. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  76033. /**
  76034. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76035. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76036. * @param mimeType mime type to use for the textures
  76037. * @param images array of glTF image interfaces
  76038. * @param textures array of glTF texture interfaces
  76039. * @param materials array of glTF material interfaces
  76040. * @param imageData map of image file name to data
  76041. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76042. */
  76043. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76044. private setMetallicRoughnessPbrMaterial;
  76045. private getPixelsFromTexture;
  76046. /**
  76047. * Extracts a texture from a Babylon texture into file data and glTF data
  76048. * @param babylonTexture Babylon texture to extract
  76049. * @param mimeType Mime Type of the babylonTexture
  76050. * @return glTF texture info, or null if the texture format is not supported
  76051. */
  76052. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76053. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76054. /**
  76055. * Builds a texture from base64 string
  76056. * @param base64Texture base64 texture string
  76057. * @param baseTextureName Name to use for the texture
  76058. * @param mimeType image mime type for the texture
  76059. * @param images array of images
  76060. * @param textures array of textures
  76061. * @param imageData map of image data
  76062. * @returns glTF texture info, or null if the texture format is not supported
  76063. */
  76064. private _getTextureInfoFromBase64;
  76065. }
  76066. }
  76067. declare module BABYLON {
  76068. /**
  76069. * Class for holding and downloading glTF file data
  76070. */
  76071. export class GLTFData {
  76072. /**
  76073. * Object which contains the file name as the key and its data as the value
  76074. */
  76075. glTFFiles: {
  76076. [fileName: string]: string | Blob;
  76077. };
  76078. /**
  76079. * Initializes the glTF file object
  76080. */
  76081. constructor();
  76082. /**
  76083. * Downloads the glTF data as files based on their names and data
  76084. */
  76085. downloadFiles(): void;
  76086. }
  76087. }
  76088. declare module BABYLON {
  76089. /**
  76090. * Holds a collection of exporter options and parameters
  76091. */
  76092. export interface IExportOptions {
  76093. /**
  76094. * Function which indicates whether a babylon node should be exported or not
  76095. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  76096. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  76097. */
  76098. shouldExportNode?(node: Node): boolean;
  76099. /**
  76100. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  76101. * @param metadata source metadata to read from
  76102. * @returns the data to store to glTF node extras
  76103. */
  76104. metadataSelector?(metadata: any): any;
  76105. /**
  76106. * The sample rate to bake animation curves
  76107. */
  76108. animationSampleRate?: number;
  76109. /**
  76110. * Begin serialization without waiting for the scene to be ready
  76111. */
  76112. exportWithoutWaitingForScene?: boolean;
  76113. }
  76114. /**
  76115. * Class for generating glTF data from a Babylon scene.
  76116. */
  76117. export class GLTF2Export {
  76118. /**
  76119. * Exports the geometry of the scene to .gltf file format asynchronously
  76120. * @param scene Babylon scene with scene hierarchy information
  76121. * @param filePrefix File prefix to use when generating the glTF file
  76122. * @param options Exporter options
  76123. * @returns Returns an object with a .gltf file and associates texture names
  76124. * as keys and their data and paths as values
  76125. */
  76126. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76127. private static _PreExportAsync;
  76128. private static _PostExportAsync;
  76129. /**
  76130. * Exports the geometry of the scene to .glb file format asychronously
  76131. * @param scene Babylon scene with scene hierarchy information
  76132. * @param filePrefix File prefix to use when generating glb file
  76133. * @param options Exporter options
  76134. * @returns Returns an object with a .glb filename as key and data as value
  76135. */
  76136. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76137. }
  76138. }
  76139. declare module BABYLON.GLTF2.Exporter {
  76140. /**
  76141. * @hidden
  76142. */
  76143. export class _GLTFUtilities {
  76144. /**
  76145. * Creates a buffer view based on the supplied arguments
  76146. * @param bufferIndex index value of the specified buffer
  76147. * @param byteOffset byte offset value
  76148. * @param byteLength byte length of the bufferView
  76149. * @param byteStride byte distance between conequential elements
  76150. * @param name name of the buffer view
  76151. * @returns bufferView for glTF
  76152. */
  76153. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  76154. /**
  76155. * Creates an accessor based on the supplied arguments
  76156. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  76157. * @param name The name of the accessor
  76158. * @param type The type of the accessor
  76159. * @param componentType The datatype of components in the attribute
  76160. * @param count The number of attributes referenced by this accessor
  76161. * @param byteOffset The offset relative to the start of the bufferView in bytes
  76162. * @param min Minimum value of each component in this attribute
  76163. * @param max Maximum value of each component in this attribute
  76164. * @returns accessor for glTF
  76165. */
  76166. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  76167. /**
  76168. * Calculates the minimum and maximum values of an array of position floats
  76169. * @param positions Positions array of a mesh
  76170. * @param vertexStart Starting vertex offset to calculate min and max values
  76171. * @param vertexCount Number of vertices to check for min and max values
  76172. * @returns min number array and max number array
  76173. */
  76174. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  76175. min: number[];
  76176. max: number[];
  76177. };
  76178. /**
  76179. * Converts a new right-handed Vector3
  76180. * @param vector vector3 array
  76181. * @returns right-handed Vector3
  76182. */
  76183. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  76184. /**
  76185. * Converts a Vector3 to right-handed
  76186. * @param vector Vector3 to convert to right-handed
  76187. */
  76188. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  76189. /**
  76190. * Converts a three element number array to right-handed
  76191. * @param vector number array to convert to right-handed
  76192. */
  76193. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  76194. /**
  76195. * Converts a new right-handed Vector3
  76196. * @param vector vector3 array
  76197. * @returns right-handed Vector3
  76198. */
  76199. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  76200. /**
  76201. * Converts a Vector3 to right-handed
  76202. * @param vector Vector3 to convert to right-handed
  76203. */
  76204. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  76205. /**
  76206. * Converts a three element number array to right-handed
  76207. * @param vector number array to convert to right-handed
  76208. */
  76209. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  76210. /**
  76211. * Converts a Vector4 to right-handed
  76212. * @param vector Vector4 to convert to right-handed
  76213. */
  76214. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  76215. /**
  76216. * Converts a Vector4 to right-handed
  76217. * @param vector Vector4 to convert to right-handed
  76218. */
  76219. static _GetRightHandedArray4FromRef(vector: number[]): void;
  76220. /**
  76221. * Converts a Quaternion to right-handed
  76222. * @param quaternion Source quaternion to convert to right-handed
  76223. */
  76224. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  76225. /**
  76226. * Converts a Quaternion to right-handed
  76227. * @param quaternion Source quaternion to convert to right-handed
  76228. */
  76229. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  76230. static _NormalizeTangentFromRef(tangent: Vector4): void;
  76231. }
  76232. }
  76233. declare module BABYLON.GLTF2.Exporter {
  76234. /**
  76235. * Converts Babylon Scene into glTF 2.0.
  76236. * @hidden
  76237. */
  76238. export class _Exporter {
  76239. /**
  76240. * Stores the glTF to export
  76241. */
  76242. _glTF: IGLTF;
  76243. /**
  76244. * Stores all generated buffer views, which represents views into the main glTF buffer data
  76245. */
  76246. _bufferViews: IBufferView[];
  76247. /**
  76248. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  76249. */
  76250. _accessors: IAccessor[];
  76251. /**
  76252. * Stores all the generated nodes, which contains transform and/or mesh information per node
  76253. */
  76254. private _nodes;
  76255. /**
  76256. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  76257. */
  76258. private _scenes;
  76259. /**
  76260. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  76261. */
  76262. private _meshes;
  76263. /**
  76264. * Stores all the generated material information, which represents the appearance of each primitive
  76265. */
  76266. _materials: IMaterial[];
  76267. _materialMap: {
  76268. [materialID: number]: number;
  76269. };
  76270. /**
  76271. * Stores all the generated texture information, which is referenced by glTF materials
  76272. */
  76273. _textures: ITexture[];
  76274. /**
  76275. * Stores all the generated image information, which is referenced by glTF textures
  76276. */
  76277. _images: IImage[];
  76278. /**
  76279. * Stores all the texture samplers
  76280. */
  76281. _samplers: ISampler[];
  76282. /**
  76283. * Stores all the generated animation samplers, which is referenced by glTF animations
  76284. */
  76285. /**
  76286. * Stores the animations for glTF models
  76287. */
  76288. private _animations;
  76289. /**
  76290. * Stores the total amount of bytes stored in the glTF buffer
  76291. */
  76292. private _totalByteLength;
  76293. /**
  76294. * Stores a reference to the Babylon scene containing the source geometry and material information
  76295. */
  76296. _babylonScene: Scene;
  76297. /**
  76298. * Stores a map of the image data, where the key is the file name and the value
  76299. * is the image data
  76300. */
  76301. _imageData: {
  76302. [fileName: string]: {
  76303. data: Uint8Array;
  76304. mimeType: ImageMimeType;
  76305. };
  76306. };
  76307. /**
  76308. * Stores a map of the unique id of a node to its index in the node array
  76309. */
  76310. private _nodeMap;
  76311. /**
  76312. * Specifies if the Babylon scene should be converted to right-handed on export
  76313. */
  76314. _convertToRightHandedSystem: boolean;
  76315. /**
  76316. * Baked animation sample rate
  76317. */
  76318. private _animationSampleRate;
  76319. private _options;
  76320. private _localEngine;
  76321. _glTFMaterialExporter: _GLTFMaterialExporter;
  76322. private _extensions;
  76323. private static _ExtensionNames;
  76324. private static _ExtensionFactories;
  76325. private _applyExtension;
  76326. private _applyExtensions;
  76327. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  76328. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  76329. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  76330. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  76331. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  76332. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76333. private _forEachExtensions;
  76334. private _extensionsOnExporting;
  76335. /**
  76336. * Load glTF serializer extensions
  76337. */
  76338. private _loadExtensions;
  76339. /**
  76340. * Creates a glTF Exporter instance, which can accept optional exporter options
  76341. * @param babylonScene Babylon scene object
  76342. * @param options Options to modify the behavior of the exporter
  76343. */
  76344. constructor(babylonScene: Scene, options?: IExportOptions);
  76345. dispose(): void;
  76346. /**
  76347. * Registers a glTF exporter extension
  76348. * @param name Name of the extension to export
  76349. * @param factory The factory function that creates the exporter extension
  76350. */
  76351. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  76352. /**
  76353. * Un-registers an exporter extension
  76354. * @param name The name fo the exporter extension
  76355. * @returns A boolean indicating whether the extension has been un-registered
  76356. */
  76357. static UnregisterExtension(name: string): boolean;
  76358. /**
  76359. * Lazy load a local engine
  76360. */
  76361. _getLocalEngine(): Engine;
  76362. private reorderIndicesBasedOnPrimitiveMode;
  76363. /**
  76364. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  76365. * clock-wise during export to glTF
  76366. * @param submesh BabylonJS submesh
  76367. * @param primitiveMode Primitive mode of the mesh
  76368. * @param sideOrientation the winding order of the submesh
  76369. * @param vertexBufferKind The type of vertex attribute
  76370. * @param meshAttributeArray The vertex attribute data
  76371. * @param byteOffset The offset to the binary data
  76372. * @param binaryWriter The binary data for the glTF file
  76373. */
  76374. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  76375. /**
  76376. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  76377. * clock-wise during export to glTF
  76378. * @param submesh BabylonJS submesh
  76379. * @param primitiveMode Primitive mode of the mesh
  76380. * @param sideOrientation the winding order of the submesh
  76381. * @param vertexBufferKind The type of vertex attribute
  76382. * @param meshAttributeArray The vertex attribute data
  76383. * @param byteOffset The offset to the binary data
  76384. * @param binaryWriter The binary data for the glTF file
  76385. */
  76386. private reorderTriangleFillMode;
  76387. /**
  76388. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  76389. * clock-wise during export to glTF
  76390. * @param submesh BabylonJS submesh
  76391. * @param primitiveMode Primitive mode of the mesh
  76392. * @param sideOrientation the winding order of the submesh
  76393. * @param vertexBufferKind The type of vertex attribute
  76394. * @param meshAttributeArray The vertex attribute data
  76395. * @param byteOffset The offset to the binary data
  76396. * @param binaryWriter The binary data for the glTF file
  76397. */
  76398. private reorderTriangleStripDrawMode;
  76399. /**
  76400. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  76401. * clock-wise during export to glTF
  76402. * @param submesh BabylonJS submesh
  76403. * @param primitiveMode Primitive mode of the mesh
  76404. * @param sideOrientation the winding order of the submesh
  76405. * @param vertexBufferKind The type of vertex attribute
  76406. * @param meshAttributeArray The vertex attribute data
  76407. * @param byteOffset The offset to the binary data
  76408. * @param binaryWriter The binary data for the glTF file
  76409. */
  76410. private reorderTriangleFanMode;
  76411. /**
  76412. * Writes the vertex attribute data to binary
  76413. * @param vertices The vertices to write to the binary writer
  76414. * @param byteOffset The offset into the binary writer to overwrite binary data
  76415. * @param vertexAttributeKind The vertex attribute type
  76416. * @param meshAttributeArray The vertex attribute data
  76417. * @param binaryWriter The writer containing the binary data
  76418. */
  76419. private writeVertexAttributeData;
  76420. /**
  76421. * Writes mesh attribute data to a data buffer
  76422. * Returns the bytelength of the data
  76423. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  76424. * @param meshAttributeArray Array containing the attribute data
  76425. * @param binaryWriter The buffer to write the binary data to
  76426. * @param indices Used to specify the order of the vertex data
  76427. */
  76428. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  76429. /**
  76430. * Generates glTF json data
  76431. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  76432. * @param glTFPrefix Text to use when prefixing a glTF file
  76433. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  76434. * @returns json data as string
  76435. */
  76436. private generateJSON;
  76437. /**
  76438. * Generates data for .gltf and .bin files based on the glTF prefix string
  76439. * @param glTFPrefix Text to use when prefixing a glTF file
  76440. * @param dispose Dispose the exporter
  76441. * @returns GLTFData with glTF file data
  76442. */
  76443. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  76444. /**
  76445. * Creates a binary buffer for glTF
  76446. * @returns array buffer for binary data
  76447. */
  76448. private _generateBinaryAsync;
  76449. /**
  76450. * Pads the number to a multiple of 4
  76451. * @param num number to pad
  76452. * @returns padded number
  76453. */
  76454. private _getPadding;
  76455. /**
  76456. * @hidden
  76457. */
  76458. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  76459. /**
  76460. * Sets the TRS for each node
  76461. * @param node glTF Node for storing the transformation data
  76462. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  76463. */
  76464. private setNodeTransformation;
  76465. private getVertexBufferFromMesh;
  76466. /**
  76467. * Creates a bufferview based on the vertices type for the Babylon mesh
  76468. * @param kind Indicates the type of vertices data
  76469. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  76470. * @param binaryWriter The buffer to write the bufferview data to
  76471. */
  76472. private createBufferViewKind;
  76473. /**
  76474. * The primitive mode of the Babylon mesh
  76475. * @param babylonMesh The BabylonJS mesh
  76476. */
  76477. private getMeshPrimitiveMode;
  76478. /**
  76479. * Sets the primitive mode of the glTF mesh primitive
  76480. * @param meshPrimitive glTF mesh primitive
  76481. * @param primitiveMode The primitive mode
  76482. */
  76483. private setPrimitiveMode;
  76484. /**
  76485. * Sets the vertex attribute accessor based of the glTF mesh primitive
  76486. * @param meshPrimitive glTF mesh primitive
  76487. * @param attributeKind vertex attribute
  76488. * @returns boolean specifying if uv coordinates are present
  76489. */
  76490. private setAttributeKind;
  76491. /**
  76492. * Sets data for the primitive attributes of each submesh
  76493. * @param mesh glTF Mesh object to store the primitive attribute information
  76494. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  76495. * @param binaryWriter Buffer to write the attribute data to
  76496. */
  76497. private setPrimitiveAttributesAsync;
  76498. /**
  76499. * Creates a glTF scene based on the array of meshes
  76500. * Returns the the total byte offset
  76501. * @param babylonScene Babylon scene to get the mesh data from
  76502. * @param binaryWriter Buffer to write binary data to
  76503. */
  76504. private createSceneAsync;
  76505. /**
  76506. * Creates a mapping of Node unique id to node index and handles animations
  76507. * @param babylonScene Babylon Scene
  76508. * @param nodes Babylon transform nodes
  76509. * @param binaryWriter Buffer to write binary data to
  76510. * @returns Node mapping of unique id to index
  76511. */
  76512. private createNodeMapAndAnimationsAsync;
  76513. /**
  76514. * Creates a glTF node from a Babylon mesh
  76515. * @param babylonMesh Source Babylon mesh
  76516. * @param binaryWriter Buffer for storing geometry data
  76517. * @returns glTF node
  76518. */
  76519. private createNodeAsync;
  76520. }
  76521. /**
  76522. * @hidden
  76523. *
  76524. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  76525. */
  76526. export class _BinaryWriter {
  76527. /**
  76528. * Array buffer which stores all binary data
  76529. */
  76530. private _arrayBuffer;
  76531. /**
  76532. * View of the array buffer
  76533. */
  76534. private _dataView;
  76535. /**
  76536. * byte offset of data in array buffer
  76537. */
  76538. private _byteOffset;
  76539. /**
  76540. * Initialize binary writer with an initial byte length
  76541. * @param byteLength Initial byte length of the array buffer
  76542. */
  76543. constructor(byteLength: number);
  76544. /**
  76545. * Resize the array buffer to the specified byte length
  76546. * @param byteLength
  76547. */
  76548. private resizeBuffer;
  76549. /**
  76550. * Get an array buffer with the length of the byte offset
  76551. * @returns ArrayBuffer resized to the byte offset
  76552. */
  76553. getArrayBuffer(): ArrayBuffer;
  76554. /**
  76555. * Get the byte offset of the array buffer
  76556. * @returns byte offset
  76557. */
  76558. getByteOffset(): number;
  76559. /**
  76560. * Stores an UInt8 in the array buffer
  76561. * @param entry
  76562. * @param byteOffset If defined, specifies where to set the value as an offset.
  76563. */
  76564. setUInt8(entry: number, byteOffset?: number): void;
  76565. /**
  76566. * Gets an UInt32 in the array buffer
  76567. * @param entry
  76568. * @param byteOffset If defined, specifies where to set the value as an offset.
  76569. */
  76570. getUInt32(byteOffset: number): number;
  76571. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  76572. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  76573. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  76574. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  76575. /**
  76576. * Stores a Float32 in the array buffer
  76577. * @param entry
  76578. */
  76579. setFloat32(entry: number, byteOffset?: number): void;
  76580. /**
  76581. * Stores an UInt32 in the array buffer
  76582. * @param entry
  76583. * @param byteOffset If defined, specifies where to set the value as an offset.
  76584. */
  76585. setUInt32(entry: number, byteOffset?: number): void;
  76586. }
  76587. }
  76588. declare module BABYLON.GLTF2.Exporter {
  76589. /**
  76590. * @hidden
  76591. * Interface to store animation data.
  76592. */
  76593. export interface _IAnimationData {
  76594. /**
  76595. * Keyframe data.
  76596. */
  76597. inputs: number[];
  76598. /**
  76599. * Value data.
  76600. */
  76601. outputs: number[][];
  76602. /**
  76603. * Animation interpolation data.
  76604. */
  76605. samplerInterpolation: AnimationSamplerInterpolation;
  76606. /**
  76607. * Minimum keyframe value.
  76608. */
  76609. inputsMin: number;
  76610. /**
  76611. * Maximum keyframe value.
  76612. */
  76613. inputsMax: number;
  76614. }
  76615. /**
  76616. * @hidden
  76617. */
  76618. export interface _IAnimationInfo {
  76619. /**
  76620. * The target channel for the animation
  76621. */
  76622. animationChannelTargetPath: AnimationChannelTargetPath;
  76623. /**
  76624. * The glTF accessor type for the data.
  76625. */
  76626. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  76627. /**
  76628. * Specifies if quaternions should be used.
  76629. */
  76630. useQuaternion: boolean;
  76631. }
  76632. /**
  76633. * @hidden
  76634. * Utility class for generating glTF animation data from BabylonJS.
  76635. */
  76636. export class _GLTFAnimation {
  76637. /**
  76638. * @ignore
  76639. *
  76640. * Creates glTF channel animation from BabylonJS animation.
  76641. * @param babylonTransformNode - BabylonJS mesh.
  76642. * @param animation - animation.
  76643. * @param animationChannelTargetPath - The target animation channel.
  76644. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  76645. * @param useQuaternion - Specifies if quaternions are used.
  76646. * @returns nullable IAnimationData
  76647. */
  76648. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  76649. private static _DeduceAnimationInfo;
  76650. /**
  76651. * @ignore
  76652. * Create node animations from the transform node animations
  76653. * @param babylonNode
  76654. * @param runtimeGLTFAnimation
  76655. * @param idleGLTFAnimations
  76656. * @param nodeMap
  76657. * @param nodes
  76658. * @param binaryWriter
  76659. * @param bufferViews
  76660. * @param accessors
  76661. * @param convertToRightHandedSystem
  76662. */
  76663. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  76664. [key: number]: number;
  76665. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  76666. /**
  76667. * @ignore
  76668. * Create node animations from the animation groups
  76669. * @param babylonScene
  76670. * @param glTFAnimations
  76671. * @param nodeMap
  76672. * @param nodes
  76673. * @param binaryWriter
  76674. * @param bufferViews
  76675. * @param accessors
  76676. * @param convertToRightHandedSystem
  76677. */
  76678. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  76679. [key: number]: number;
  76680. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  76681. private static AddAnimation;
  76682. /**
  76683. * Create a baked animation
  76684. * @param babylonTransformNode BabylonJS mesh
  76685. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  76686. * @param animationChannelTargetPath animation target channel
  76687. * @param minFrame minimum animation frame
  76688. * @param maxFrame maximum animation frame
  76689. * @param fps frames per second of the animation
  76690. * @param inputs input key frames of the animation
  76691. * @param outputs output key frame data of the animation
  76692. * @param convertToRightHandedSystem converts the values to right-handed
  76693. * @param useQuaternion specifies if quaternions should be used
  76694. */
  76695. private static _CreateBakedAnimation;
  76696. private static _ConvertFactorToVector3OrQuaternion;
  76697. private static _SetInterpolatedValue;
  76698. /**
  76699. * Creates linear animation from the animation key frames
  76700. * @param babylonTransformNode BabylonJS mesh
  76701. * @param animation BabylonJS animation
  76702. * @param animationChannelTargetPath The target animation channel
  76703. * @param frameDelta The difference between the last and first frame of the animation
  76704. * @param inputs Array to store the key frame times
  76705. * @param outputs Array to store the key frame data
  76706. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  76707. * @param useQuaternion Specifies if quaternions are used in the animation
  76708. */
  76709. private static _CreateLinearOrStepAnimation;
  76710. /**
  76711. * Creates cubic spline animation from the animation key frames
  76712. * @param babylonTransformNode BabylonJS mesh
  76713. * @param animation BabylonJS animation
  76714. * @param animationChannelTargetPath The target animation channel
  76715. * @param frameDelta The difference between the last and first frame of the animation
  76716. * @param inputs Array to store the key frame times
  76717. * @param outputs Array to store the key frame data
  76718. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  76719. * @param useQuaternion Specifies if quaternions are used in the animation
  76720. */
  76721. private static _CreateCubicSplineAnimation;
  76722. private static _GetBasePositionRotationOrScale;
  76723. /**
  76724. * Adds a key frame value
  76725. * @param keyFrame
  76726. * @param animation
  76727. * @param outputs
  76728. * @param animationChannelTargetPath
  76729. * @param basePositionRotationOrScale
  76730. * @param convertToRightHandedSystem
  76731. * @param useQuaternion
  76732. */
  76733. private static _AddKeyframeValue;
  76734. /**
  76735. * Determine the interpolation based on the key frames
  76736. * @param keyFrames
  76737. * @param animationChannelTargetPath
  76738. * @param useQuaternion
  76739. */
  76740. private static _DeduceInterpolation;
  76741. /**
  76742. * Adds an input tangent or output tangent to the output data
  76743. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  76744. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  76745. * @param outputs The animation data by keyframe
  76746. * @param animationChannelTargetPath The target animation channel
  76747. * @param interpolation The interpolation type
  76748. * @param keyFrame The key frame with the animation data
  76749. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  76750. * @param useQuaternion Specifies if quaternions are used
  76751. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  76752. */
  76753. private static AddSplineTangent;
  76754. /**
  76755. * Get the minimum and maximum key frames' frame values
  76756. * @param keyFrames animation key frames
  76757. * @returns the minimum and maximum key frame value
  76758. */
  76759. private static calculateMinMaxKeyFrames;
  76760. }
  76761. }
  76762. declare module BABYLON.GLTF2.Exporter {
  76763. /** @hidden */
  76764. export var textureTransformPixelShader: {
  76765. name: string;
  76766. shader: string;
  76767. };
  76768. }
  76769. declare module BABYLON.GLTF2.Exporter.Extensions {
  76770. /**
  76771. * @hidden
  76772. */
  76773. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  76774. private _recordedTextures;
  76775. /** Name of this extension */
  76776. readonly name: string;
  76777. /** Defines whether this extension is enabled */
  76778. enabled: boolean;
  76779. /** Defines whether this extension is required */
  76780. required: boolean;
  76781. /** Reference to the glTF exporter */
  76782. private _wasUsed;
  76783. constructor(exporter: _Exporter);
  76784. dispose(): void;
  76785. /** @hidden */
  76786. get wasUsed(): boolean;
  76787. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  76788. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  76789. /**
  76790. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  76791. * @param babylonTexture
  76792. * @param offset
  76793. * @param rotation
  76794. * @param scale
  76795. * @param scene
  76796. */
  76797. private _textureTransformTextureAsync;
  76798. }
  76799. }
  76800. declare module BABYLON.GLTF2.Exporter.Extensions {
  76801. /**
  76802. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  76803. */
  76804. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  76805. /** The name of this extension. */
  76806. readonly name: string;
  76807. /** Defines whether this extension is enabled. */
  76808. enabled: boolean;
  76809. /** Defines whether this extension is required */
  76810. required: boolean;
  76811. /** Reference to the glTF exporter */
  76812. private _exporter;
  76813. private _lights;
  76814. /** @hidden */
  76815. constructor(exporter: _Exporter);
  76816. /** @hidden */
  76817. dispose(): void;
  76818. /** @hidden */
  76819. get wasUsed(): boolean;
  76820. /** @hidden */
  76821. onExporting(): void;
  76822. /**
  76823. * Define this method to modify the default behavior when exporting a node
  76824. * @param context The context when exporting the node
  76825. * @param node glTF node
  76826. * @param babylonNode BabylonJS node
  76827. * @returns nullable INode promise
  76828. */
  76829. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  76830. }
  76831. }
  76832. declare module BABYLON.GLTF2.Exporter.Extensions {
  76833. /**
  76834. * @hidden
  76835. */
  76836. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  76837. /** Name of this extension */
  76838. readonly name: string;
  76839. /** Defines whether this extension is enabled */
  76840. enabled: boolean;
  76841. /** Defines whether this extension is required */
  76842. required: boolean;
  76843. /** Reference to the glTF exporter */
  76844. private _textureInfos;
  76845. private _exportedTextures;
  76846. private _wasUsed;
  76847. constructor(exporter: _Exporter);
  76848. dispose(): void;
  76849. /** @hidden */
  76850. get wasUsed(): boolean;
  76851. private _getTextureIndex;
  76852. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  76853. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76854. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  76855. }
  76856. }
  76857. declare module BABYLON {
  76858. /**
  76859. * Class for generating STL data from a Babylon scene.
  76860. */
  76861. export class STLExport {
  76862. /**
  76863. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  76864. * @param meshes list defines the mesh to serialize
  76865. * @param download triggers the automatic download of the file.
  76866. * @param fileName changes the downloads fileName.
  76867. * @param binary changes the STL to a binary type.
  76868. * @param isLittleEndian toggle for binary type exporter.
  76869. * @returns the STL as UTF8 string
  76870. */
  76871. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  76872. }
  76873. }
  76874. declare module "babylonjs-gltf2interface" {
  76875. export = BABYLON.GLTF2;
  76876. }
  76877. /**
  76878. * Module for glTF 2.0 Interface
  76879. */
  76880. declare module BABYLON.GLTF2 {
  76881. /**
  76882. * The datatype of the components in the attribute
  76883. */
  76884. const enum AccessorComponentType {
  76885. /**
  76886. * Byte
  76887. */
  76888. BYTE = 5120,
  76889. /**
  76890. * Unsigned Byte
  76891. */
  76892. UNSIGNED_BYTE = 5121,
  76893. /**
  76894. * Short
  76895. */
  76896. SHORT = 5122,
  76897. /**
  76898. * Unsigned Short
  76899. */
  76900. UNSIGNED_SHORT = 5123,
  76901. /**
  76902. * Unsigned Int
  76903. */
  76904. UNSIGNED_INT = 5125,
  76905. /**
  76906. * Float
  76907. */
  76908. FLOAT = 5126,
  76909. }
  76910. /**
  76911. * Specifies if the attirbute is a scalar, vector, or matrix
  76912. */
  76913. const enum AccessorType {
  76914. /**
  76915. * Scalar
  76916. */
  76917. SCALAR = "SCALAR",
  76918. /**
  76919. * Vector2
  76920. */
  76921. VEC2 = "VEC2",
  76922. /**
  76923. * Vector3
  76924. */
  76925. VEC3 = "VEC3",
  76926. /**
  76927. * Vector4
  76928. */
  76929. VEC4 = "VEC4",
  76930. /**
  76931. * Matrix2x2
  76932. */
  76933. MAT2 = "MAT2",
  76934. /**
  76935. * Matrix3x3
  76936. */
  76937. MAT3 = "MAT3",
  76938. /**
  76939. * Matrix4x4
  76940. */
  76941. MAT4 = "MAT4",
  76942. }
  76943. /**
  76944. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  76945. */
  76946. const enum AnimationChannelTargetPath {
  76947. /**
  76948. * Translation
  76949. */
  76950. TRANSLATION = "translation",
  76951. /**
  76952. * Rotation
  76953. */
  76954. ROTATION = "rotation",
  76955. /**
  76956. * Scale
  76957. */
  76958. SCALE = "scale",
  76959. /**
  76960. * Weights
  76961. */
  76962. WEIGHTS = "weights",
  76963. }
  76964. /**
  76965. * Interpolation algorithm
  76966. */
  76967. const enum AnimationSamplerInterpolation {
  76968. /**
  76969. * The animated values are linearly interpolated between keyframes
  76970. */
  76971. LINEAR = "LINEAR",
  76972. /**
  76973. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  76974. */
  76975. STEP = "STEP",
  76976. /**
  76977. * The animation's interpolation is computed using a cubic spline with specified tangents
  76978. */
  76979. CUBICSPLINE = "CUBICSPLINE",
  76980. }
  76981. /**
  76982. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  76983. */
  76984. const enum CameraType {
  76985. /**
  76986. * A perspective camera containing properties to create a perspective projection matrix
  76987. */
  76988. PERSPECTIVE = "perspective",
  76989. /**
  76990. * An orthographic camera containing properties to create an orthographic projection matrix
  76991. */
  76992. ORTHOGRAPHIC = "orthographic",
  76993. }
  76994. /**
  76995. * The mime-type of the image
  76996. */
  76997. const enum ImageMimeType {
  76998. /**
  76999. * JPEG Mime-type
  77000. */
  77001. JPEG = "image/jpeg",
  77002. /**
  77003. * PNG Mime-type
  77004. */
  77005. PNG = "image/png",
  77006. }
  77007. /**
  77008. * The alpha rendering mode of the material
  77009. */
  77010. const enum MaterialAlphaMode {
  77011. /**
  77012. * The alpha value is ignored and the rendered output is fully opaque
  77013. */
  77014. OPAQUE = "OPAQUE",
  77015. /**
  77016. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  77017. */
  77018. MASK = "MASK",
  77019. /**
  77020. * 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)
  77021. */
  77022. BLEND = "BLEND",
  77023. }
  77024. /**
  77025. * The type of the primitives to render
  77026. */
  77027. const enum MeshPrimitiveMode {
  77028. /**
  77029. * Points
  77030. */
  77031. POINTS = 0,
  77032. /**
  77033. * Lines
  77034. */
  77035. LINES = 1,
  77036. /**
  77037. * Line Loop
  77038. */
  77039. LINE_LOOP = 2,
  77040. /**
  77041. * Line Strip
  77042. */
  77043. LINE_STRIP = 3,
  77044. /**
  77045. * Triangles
  77046. */
  77047. TRIANGLES = 4,
  77048. /**
  77049. * Triangle Strip
  77050. */
  77051. TRIANGLE_STRIP = 5,
  77052. /**
  77053. * Triangle Fan
  77054. */
  77055. TRIANGLE_FAN = 6,
  77056. }
  77057. /**
  77058. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77059. */
  77060. const enum TextureMagFilter {
  77061. /**
  77062. * Nearest
  77063. */
  77064. NEAREST = 9728,
  77065. /**
  77066. * Linear
  77067. */
  77068. LINEAR = 9729,
  77069. }
  77070. /**
  77071. * Minification filter. All valid values correspond to WebGL enums
  77072. */
  77073. const enum TextureMinFilter {
  77074. /**
  77075. * Nearest
  77076. */
  77077. NEAREST = 9728,
  77078. /**
  77079. * Linear
  77080. */
  77081. LINEAR = 9729,
  77082. /**
  77083. * Nearest Mip-Map Nearest
  77084. */
  77085. NEAREST_MIPMAP_NEAREST = 9984,
  77086. /**
  77087. * Linear Mipmap Nearest
  77088. */
  77089. LINEAR_MIPMAP_NEAREST = 9985,
  77090. /**
  77091. * Nearest Mipmap Linear
  77092. */
  77093. NEAREST_MIPMAP_LINEAR = 9986,
  77094. /**
  77095. * Linear Mipmap Linear
  77096. */
  77097. LINEAR_MIPMAP_LINEAR = 9987,
  77098. }
  77099. /**
  77100. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77101. */
  77102. const enum TextureWrapMode {
  77103. /**
  77104. * Clamp to Edge
  77105. */
  77106. CLAMP_TO_EDGE = 33071,
  77107. /**
  77108. * Mirrored Repeat
  77109. */
  77110. MIRRORED_REPEAT = 33648,
  77111. /**
  77112. * Repeat
  77113. */
  77114. REPEAT = 10497,
  77115. }
  77116. /**
  77117. * glTF Property
  77118. */
  77119. interface IProperty {
  77120. /**
  77121. * Dictionary object with extension-specific objects
  77122. */
  77123. extensions?: {
  77124. [key: string]: any;
  77125. };
  77126. /**
  77127. * Application-Specific data
  77128. */
  77129. extras?: any;
  77130. }
  77131. /**
  77132. * glTF Child of Root Property
  77133. */
  77134. interface IChildRootProperty extends IProperty {
  77135. /**
  77136. * The user-defined name of this object
  77137. */
  77138. name?: string;
  77139. }
  77140. /**
  77141. * Indices of those attributes that deviate from their initialization value
  77142. */
  77143. interface IAccessorSparseIndices extends IProperty {
  77144. /**
  77145. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77146. */
  77147. bufferView: number;
  77148. /**
  77149. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77150. */
  77151. byteOffset?: number;
  77152. /**
  77153. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  77154. */
  77155. componentType: AccessorComponentType;
  77156. }
  77157. /**
  77158. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  77159. */
  77160. interface IAccessorSparseValues extends IProperty {
  77161. /**
  77162. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77163. */
  77164. bufferView: number;
  77165. /**
  77166. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77167. */
  77168. byteOffset?: number;
  77169. }
  77170. /**
  77171. * Sparse storage of attributes that deviate from their initialization value
  77172. */
  77173. interface IAccessorSparse extends IProperty {
  77174. /**
  77175. * The number of attributes encoded in this sparse accessor
  77176. */
  77177. count: number;
  77178. /**
  77179. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  77180. */
  77181. indices: IAccessorSparseIndices;
  77182. /**
  77183. * 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
  77184. */
  77185. values: IAccessorSparseValues;
  77186. }
  77187. /**
  77188. * 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
  77189. */
  77190. interface IAccessor extends IChildRootProperty {
  77191. /**
  77192. * The index of the bufferview
  77193. */
  77194. bufferView?: number;
  77195. /**
  77196. * The offset relative to the start of the bufferView in bytes
  77197. */
  77198. byteOffset?: number;
  77199. /**
  77200. * The datatype of components in the attribute
  77201. */
  77202. componentType: AccessorComponentType;
  77203. /**
  77204. * Specifies whether integer data values should be normalized
  77205. */
  77206. normalized?: boolean;
  77207. /**
  77208. * The number of attributes referenced by this accessor
  77209. */
  77210. count: number;
  77211. /**
  77212. * Specifies if the attribute is a scalar, vector, or matrix
  77213. */
  77214. type: AccessorType;
  77215. /**
  77216. * Maximum value of each component in this attribute
  77217. */
  77218. max?: number[];
  77219. /**
  77220. * Minimum value of each component in this attribute
  77221. */
  77222. min?: number[];
  77223. /**
  77224. * Sparse storage of attributes that deviate from their initialization value
  77225. */
  77226. sparse?: IAccessorSparse;
  77227. }
  77228. /**
  77229. * Targets an animation's sampler at a node's property
  77230. */
  77231. interface IAnimationChannel extends IProperty {
  77232. /**
  77233. * The index of a sampler in this animation used to compute the value for the target
  77234. */
  77235. sampler: number;
  77236. /**
  77237. * The index of the node and TRS property to target
  77238. */
  77239. target: IAnimationChannelTarget;
  77240. }
  77241. /**
  77242. * The index of the node and TRS property that an animation channel targets
  77243. */
  77244. interface IAnimationChannelTarget extends IProperty {
  77245. /**
  77246. * The index of the node to target
  77247. */
  77248. node: number;
  77249. /**
  77250. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77251. */
  77252. path: AnimationChannelTargetPath;
  77253. }
  77254. /**
  77255. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77256. */
  77257. interface IAnimationSampler extends IProperty {
  77258. /**
  77259. * The index of an accessor containing keyframe input values, e.g., time
  77260. */
  77261. input: number;
  77262. /**
  77263. * Interpolation algorithm
  77264. */
  77265. interpolation?: AnimationSamplerInterpolation;
  77266. /**
  77267. * The index of an accessor, containing keyframe output values
  77268. */
  77269. output: number;
  77270. }
  77271. /**
  77272. * A keyframe animation
  77273. */
  77274. interface IAnimation extends IChildRootProperty {
  77275. /**
  77276. * An array of channels, each of which targets an animation's sampler at a node's property
  77277. */
  77278. channels: IAnimationChannel[];
  77279. /**
  77280. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77281. */
  77282. samplers: IAnimationSampler[];
  77283. }
  77284. /**
  77285. * Metadata about the glTF asset
  77286. */
  77287. interface IAsset extends IChildRootProperty {
  77288. /**
  77289. * A copyright message suitable for display to credit the content creator
  77290. */
  77291. copyright?: string;
  77292. /**
  77293. * Tool that generated this glTF model. Useful for debugging
  77294. */
  77295. generator?: string;
  77296. /**
  77297. * The glTF version that this asset targets
  77298. */
  77299. version: string;
  77300. /**
  77301. * The minimum glTF version that this asset targets
  77302. */
  77303. minVersion?: string;
  77304. }
  77305. /**
  77306. * A buffer points to binary geometry, animation, or skins
  77307. */
  77308. interface IBuffer extends IChildRootProperty {
  77309. /**
  77310. * 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
  77311. */
  77312. uri?: string;
  77313. /**
  77314. * The length of the buffer in bytes
  77315. */
  77316. byteLength: number;
  77317. }
  77318. /**
  77319. * A view into a buffer generally representing a subset of the buffer
  77320. */
  77321. interface IBufferView extends IChildRootProperty {
  77322. /**
  77323. * The index of the buffer
  77324. */
  77325. buffer: number;
  77326. /**
  77327. * The offset into the buffer in bytes
  77328. */
  77329. byteOffset?: number;
  77330. /**
  77331. * The lenth of the bufferView in bytes
  77332. */
  77333. byteLength: number;
  77334. /**
  77335. * The stride, in bytes
  77336. */
  77337. byteStride?: number;
  77338. }
  77339. /**
  77340. * An orthographic camera containing properties to create an orthographic projection matrix
  77341. */
  77342. interface ICameraOrthographic extends IProperty {
  77343. /**
  77344. * The floating-point horizontal magnification of the view. Must not be zero
  77345. */
  77346. xmag: number;
  77347. /**
  77348. * The floating-point vertical magnification of the view. Must not be zero
  77349. */
  77350. ymag: number;
  77351. /**
  77352. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  77353. */
  77354. zfar: number;
  77355. /**
  77356. * The floating-point distance to the near clipping plane
  77357. */
  77358. znear: number;
  77359. }
  77360. /**
  77361. * A perspective camera containing properties to create a perspective projection matrix
  77362. */
  77363. interface ICameraPerspective extends IProperty {
  77364. /**
  77365. * The floating-point aspect ratio of the field of view
  77366. */
  77367. aspectRatio?: number;
  77368. /**
  77369. * The floating-point vertical field of view in radians
  77370. */
  77371. yfov: number;
  77372. /**
  77373. * The floating-point distance to the far clipping plane
  77374. */
  77375. zfar?: number;
  77376. /**
  77377. * The floating-point distance to the near clipping plane
  77378. */
  77379. znear: number;
  77380. }
  77381. /**
  77382. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77383. */
  77384. interface ICamera extends IChildRootProperty {
  77385. /**
  77386. * An orthographic camera containing properties to create an orthographic projection matrix
  77387. */
  77388. orthographic?: ICameraOrthographic;
  77389. /**
  77390. * A perspective camera containing properties to create a perspective projection matrix
  77391. */
  77392. perspective?: ICameraPerspective;
  77393. /**
  77394. * Specifies if the camera uses a perspective or orthographic projection
  77395. */
  77396. type: CameraType;
  77397. }
  77398. /**
  77399. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  77400. */
  77401. interface IImage extends IChildRootProperty {
  77402. /**
  77403. * 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
  77404. */
  77405. uri?: string;
  77406. /**
  77407. * The image's MIME type
  77408. */
  77409. mimeType?: ImageMimeType;
  77410. /**
  77411. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  77412. */
  77413. bufferView?: number;
  77414. }
  77415. /**
  77416. * Material Normal Texture Info
  77417. */
  77418. interface IMaterialNormalTextureInfo extends ITextureInfo {
  77419. /**
  77420. * The scalar multiplier applied to each normal vector of the normal texture
  77421. */
  77422. scale?: number;
  77423. }
  77424. /**
  77425. * Material Occlusion Texture Info
  77426. */
  77427. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  77428. /**
  77429. * A scalar multiplier controlling the amount of occlusion applied
  77430. */
  77431. strength?: number;
  77432. }
  77433. /**
  77434. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  77435. */
  77436. interface IMaterialPbrMetallicRoughness {
  77437. /**
  77438. * The material's base color factor
  77439. */
  77440. baseColorFactor?: number[];
  77441. /**
  77442. * The base color texture
  77443. */
  77444. baseColorTexture?: ITextureInfo;
  77445. /**
  77446. * The metalness of the material
  77447. */
  77448. metallicFactor?: number;
  77449. /**
  77450. * The roughness of the material
  77451. */
  77452. roughnessFactor?: number;
  77453. /**
  77454. * The metallic-roughness texture
  77455. */
  77456. metallicRoughnessTexture?: ITextureInfo;
  77457. }
  77458. /**
  77459. * The material appearance of a primitive
  77460. */
  77461. interface IMaterial extends IChildRootProperty {
  77462. /**
  77463. * 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
  77464. */
  77465. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  77466. /**
  77467. * The normal map texture
  77468. */
  77469. normalTexture?: IMaterialNormalTextureInfo;
  77470. /**
  77471. * The occlusion map texture
  77472. */
  77473. occlusionTexture?: IMaterialOcclusionTextureInfo;
  77474. /**
  77475. * The emissive map texture
  77476. */
  77477. emissiveTexture?: ITextureInfo;
  77478. /**
  77479. * 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
  77480. */
  77481. emissiveFactor?: number[];
  77482. /**
  77483. * The alpha rendering mode of the material
  77484. */
  77485. alphaMode?: MaterialAlphaMode;
  77486. /**
  77487. * The alpha cutoff value of the material
  77488. */
  77489. alphaCutoff?: number;
  77490. /**
  77491. * Specifies whether the material is double sided
  77492. */
  77493. doubleSided?: boolean;
  77494. }
  77495. /**
  77496. * Geometry to be rendered with the given material
  77497. */
  77498. interface IMeshPrimitive extends IProperty {
  77499. /**
  77500. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  77501. */
  77502. attributes: {
  77503. [name: string]: number;
  77504. };
  77505. /**
  77506. * The index of the accessor that contains the indices
  77507. */
  77508. indices?: number;
  77509. /**
  77510. * The index of the material to apply to this primitive when rendering
  77511. */
  77512. material?: number;
  77513. /**
  77514. * The type of primitives to render. All valid values correspond to WebGL enums
  77515. */
  77516. mode?: MeshPrimitiveMode;
  77517. /**
  77518. * 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
  77519. */
  77520. targets?: {
  77521. [name: string]: number;
  77522. }[];
  77523. }
  77524. /**
  77525. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  77526. */
  77527. interface IMesh extends IChildRootProperty {
  77528. /**
  77529. * An array of primitives, each defining geometry to be rendered with a material
  77530. */
  77531. primitives: IMeshPrimitive[];
  77532. /**
  77533. * Array of weights to be applied to the Morph Targets
  77534. */
  77535. weights?: number[];
  77536. }
  77537. /**
  77538. * A node in the node hierarchy
  77539. */
  77540. interface INode extends IChildRootProperty {
  77541. /**
  77542. * The index of the camera referenced by this node
  77543. */
  77544. camera?: number;
  77545. /**
  77546. * The indices of this node's children
  77547. */
  77548. children?: number[];
  77549. /**
  77550. * The index of the skin referenced by this node
  77551. */
  77552. skin?: number;
  77553. /**
  77554. * A floating-point 4x4 transformation matrix stored in column-major order
  77555. */
  77556. matrix?: number[];
  77557. /**
  77558. * The index of the mesh in this node
  77559. */
  77560. mesh?: number;
  77561. /**
  77562. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  77563. */
  77564. rotation?: number[];
  77565. /**
  77566. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  77567. */
  77568. scale?: number[];
  77569. /**
  77570. * The node's translation along the x, y, and z axes
  77571. */
  77572. translation?: number[];
  77573. /**
  77574. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  77575. */
  77576. weights?: number[];
  77577. }
  77578. /**
  77579. * Texture sampler properties for filtering and wrapping modes
  77580. */
  77581. interface ISampler extends IChildRootProperty {
  77582. /**
  77583. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77584. */
  77585. magFilter?: TextureMagFilter;
  77586. /**
  77587. * Minification filter. All valid values correspond to WebGL enums
  77588. */
  77589. minFilter?: TextureMinFilter;
  77590. /**
  77591. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77592. */
  77593. wrapS?: TextureWrapMode;
  77594. /**
  77595. * T (V) wrapping mode. All valid values correspond to WebGL enums
  77596. */
  77597. wrapT?: TextureWrapMode;
  77598. }
  77599. /**
  77600. * The root nodes of a scene
  77601. */
  77602. interface IScene extends IChildRootProperty {
  77603. /**
  77604. * The indices of each root node
  77605. */
  77606. nodes: number[];
  77607. }
  77608. /**
  77609. * Joints and matrices defining a skin
  77610. */
  77611. interface ISkin extends IChildRootProperty {
  77612. /**
  77613. * 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
  77614. */
  77615. inverseBindMatrices?: number;
  77616. /**
  77617. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  77618. */
  77619. skeleton?: number;
  77620. /**
  77621. * 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)
  77622. */
  77623. joints: number[];
  77624. }
  77625. /**
  77626. * A texture and its sampler
  77627. */
  77628. interface ITexture extends IChildRootProperty {
  77629. /**
  77630. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  77631. */
  77632. sampler?: number;
  77633. /**
  77634. * The index of the image used by this texture
  77635. */
  77636. source: number;
  77637. }
  77638. /**
  77639. * Reference to a texture
  77640. */
  77641. interface ITextureInfo extends IProperty {
  77642. /**
  77643. * The index of the texture
  77644. */
  77645. index: number;
  77646. /**
  77647. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  77648. */
  77649. texCoord?: number;
  77650. }
  77651. /**
  77652. * The root object for a glTF asset
  77653. */
  77654. interface IGLTF extends IProperty {
  77655. /**
  77656. * An array of accessors. An accessor is a typed view into a bufferView
  77657. */
  77658. accessors?: IAccessor[];
  77659. /**
  77660. * An array of keyframe animations
  77661. */
  77662. animations?: IAnimation[];
  77663. /**
  77664. * Metadata about the glTF asset
  77665. */
  77666. asset: IAsset;
  77667. /**
  77668. * An array of buffers. A buffer points to binary geometry, animation, or skins
  77669. */
  77670. buffers?: IBuffer[];
  77671. /**
  77672. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  77673. */
  77674. bufferViews?: IBufferView[];
  77675. /**
  77676. * An array of cameras
  77677. */
  77678. cameras?: ICamera[];
  77679. /**
  77680. * Names of glTF extensions used somewhere in this asset
  77681. */
  77682. extensionsUsed?: string[];
  77683. /**
  77684. * Names of glTF extensions required to properly load this asset
  77685. */
  77686. extensionsRequired?: string[];
  77687. /**
  77688. * An array of images. An image defines data used to create a texture
  77689. */
  77690. images?: IImage[];
  77691. /**
  77692. * An array of materials. A material defines the appearance of a primitive
  77693. */
  77694. materials?: IMaterial[];
  77695. /**
  77696. * An array of meshes. A mesh is a set of primitives to be rendered
  77697. */
  77698. meshes?: IMesh[];
  77699. /**
  77700. * An array of nodes
  77701. */
  77702. nodes?: INode[];
  77703. /**
  77704. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  77705. */
  77706. samplers?: ISampler[];
  77707. /**
  77708. * The index of the default scene
  77709. */
  77710. scene?: number;
  77711. /**
  77712. * An array of scenes
  77713. */
  77714. scenes?: IScene[];
  77715. /**
  77716. * An array of skins. A skin is defined by joints and matrices
  77717. */
  77718. skins?: ISkin[];
  77719. /**
  77720. * An array of textures
  77721. */
  77722. textures?: ITexture[];
  77723. }
  77724. /**
  77725. * The glTF validation results
  77726. * @ignore
  77727. */
  77728. interface IGLTFValidationResults {
  77729. info: {
  77730. generator: string;
  77731. hasAnimations: boolean;
  77732. hasDefaultScene: boolean;
  77733. hasMaterials: boolean;
  77734. hasMorphTargets: boolean;
  77735. hasSkins: boolean;
  77736. hasTextures: boolean;
  77737. maxAttributesUsed: number;
  77738. primitivesCount: number
  77739. };
  77740. issues: {
  77741. messages: Array<string>;
  77742. numErrors: number;
  77743. numHints: number;
  77744. numInfos: number;
  77745. numWarnings: number;
  77746. truncated: boolean
  77747. };
  77748. mimeType: string;
  77749. uri: string;
  77750. validatedAt: string;
  77751. validatorVersion: string;
  77752. }
  77753. /**
  77754. * The glTF validation options
  77755. */
  77756. interface IGLTFValidationOptions {
  77757. /** Uri to use */
  77758. uri?: string;
  77759. /** Function used to load external resources */
  77760. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  77761. /** Boolean indicating that we need to validate accessor data */
  77762. validateAccessorData?: boolean;
  77763. /** max number of issues allowed */
  77764. maxIssues?: number;
  77765. /** Ignored issues */
  77766. ignoredIssues?: Array<string>;
  77767. /** Value to override severy settings */
  77768. severityOverrides?: Object;
  77769. }
  77770. /**
  77771. * The glTF validator object
  77772. * @ignore
  77773. */
  77774. interface IGLTFValidator {
  77775. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  77776. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  77777. }
  77778. }
  77779. declare module BABYLON {
  77780. /** @hidden */
  77781. export var cellPixelShader: {
  77782. name: string;
  77783. shader: string;
  77784. };
  77785. }
  77786. declare module BABYLON {
  77787. /** @hidden */
  77788. export var cellVertexShader: {
  77789. name: string;
  77790. shader: string;
  77791. };
  77792. }
  77793. declare module BABYLON {
  77794. export class CellMaterial extends BABYLON.PushMaterial {
  77795. private _diffuseTexture;
  77796. diffuseTexture: BABYLON.BaseTexture;
  77797. diffuseColor: BABYLON.Color3;
  77798. _computeHighLevel: boolean;
  77799. computeHighLevel: boolean;
  77800. private _disableLighting;
  77801. disableLighting: boolean;
  77802. private _maxSimultaneousLights;
  77803. maxSimultaneousLights: number;
  77804. private _renderId;
  77805. constructor(name: string, scene: BABYLON.Scene);
  77806. needAlphaBlending(): boolean;
  77807. needAlphaTesting(): boolean;
  77808. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77809. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77810. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77811. getAnimatables(): BABYLON.IAnimatable[];
  77812. getActiveTextures(): BABYLON.BaseTexture[];
  77813. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77814. dispose(forceDisposeEffect?: boolean): void;
  77815. getClassName(): string;
  77816. clone(name: string): CellMaterial;
  77817. serialize(): any;
  77818. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  77819. }
  77820. }
  77821. declare module BABYLON {
  77822. export class CustomShaderStructure {
  77823. FragmentStore: string;
  77824. VertexStore: string;
  77825. constructor();
  77826. }
  77827. export class ShaderSpecialParts {
  77828. constructor();
  77829. Fragment_Begin: string;
  77830. Fragment_Definitions: string;
  77831. Fragment_MainBegin: string;
  77832. Fragment_Custom_Diffuse: string;
  77833. Fragment_Before_Lights: string;
  77834. Fragment_Before_Fog: string;
  77835. Fragment_Custom_Alpha: string;
  77836. Fragment_Before_FragColor: string;
  77837. Vertex_Begin: string;
  77838. Vertex_Definitions: string;
  77839. Vertex_MainBegin: string;
  77840. Vertex_Before_PositionUpdated: string;
  77841. Vertex_Before_NormalUpdated: string;
  77842. Vertex_MainEnd: string;
  77843. }
  77844. export class CustomMaterial extends BABYLON.StandardMaterial {
  77845. static ShaderIndexer: number;
  77846. CustomParts: ShaderSpecialParts;
  77847. _isCreatedShader: boolean;
  77848. _createdShaderName: string;
  77849. _customUniform: string[];
  77850. _newUniforms: string[];
  77851. _newUniformInstances: any[];
  77852. _newSamplerInstances: BABYLON.Texture[];
  77853. FragmentShader: string;
  77854. VertexShader: string;
  77855. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  77856. ReviewUniform(name: string, arr: string[]): string[];
  77857. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  77858. constructor(name: string, scene: BABYLON.Scene);
  77859. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  77860. Fragment_Begin(shaderPart: string): CustomMaterial;
  77861. Fragment_Definitions(shaderPart: string): CustomMaterial;
  77862. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  77863. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  77864. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  77865. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  77866. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  77867. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  77868. Vertex_Begin(shaderPart: string): CustomMaterial;
  77869. Vertex_Definitions(shaderPart: string): CustomMaterial;
  77870. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  77871. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  77872. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  77873. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  77874. }
  77875. }
  77876. declare module BABYLON {
  77877. export class ShaderAlebdoParts {
  77878. constructor();
  77879. Fragment_Begin: string;
  77880. Fragment_Definitions: string;
  77881. Fragment_MainBegin: string;
  77882. Fragment_Custom_Albedo: string;
  77883. Fragment_Before_Lights: string;
  77884. Fragment_Custom_MetallicRoughness: string;
  77885. Fragment_Custom_MicroSurface: string;
  77886. Fragment_Before_Fog: string;
  77887. Fragment_Custom_Alpha: string;
  77888. Fragment_Before_FragColor: string;
  77889. Vertex_Begin: string;
  77890. Vertex_Definitions: string;
  77891. Vertex_MainBegin: string;
  77892. Vertex_Before_PositionUpdated: string;
  77893. Vertex_Before_NormalUpdated: string;
  77894. Vertex_MainEnd: string;
  77895. }
  77896. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  77897. static ShaderIndexer: number;
  77898. CustomParts: ShaderAlebdoParts;
  77899. _isCreatedShader: boolean;
  77900. _createdShaderName: string;
  77901. _customUniform: string[];
  77902. _newUniforms: string[];
  77903. _newUniformInstances: any[];
  77904. _newSamplerInstances: BABYLON.Texture[];
  77905. FragmentShader: string;
  77906. VertexShader: string;
  77907. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  77908. ReviewUniform(name: string, arr: string[]): string[];
  77909. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  77910. constructor(name: string, scene: BABYLON.Scene);
  77911. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  77912. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  77913. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  77914. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  77915. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  77916. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  77917. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  77918. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  77919. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  77920. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  77921. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  77922. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  77923. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  77924. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  77925. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  77926. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  77927. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  77928. }
  77929. }
  77930. declare module BABYLON {
  77931. /** @hidden */
  77932. export var firePixelShader: {
  77933. name: string;
  77934. shader: string;
  77935. };
  77936. }
  77937. declare module BABYLON {
  77938. /** @hidden */
  77939. export var fireVertexShader: {
  77940. name: string;
  77941. shader: string;
  77942. };
  77943. }
  77944. declare module BABYLON {
  77945. export class FireMaterial extends BABYLON.PushMaterial {
  77946. private _diffuseTexture;
  77947. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77948. private _distortionTexture;
  77949. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77950. private _opacityTexture;
  77951. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77952. diffuseColor: BABYLON.Color3;
  77953. speed: number;
  77954. private _scaledDiffuse;
  77955. private _renderId;
  77956. private _lastTime;
  77957. constructor(name: string, scene: BABYLON.Scene);
  77958. needAlphaBlending(): boolean;
  77959. needAlphaTesting(): boolean;
  77960. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77961. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77962. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77963. getAnimatables(): BABYLON.IAnimatable[];
  77964. getActiveTextures(): BABYLON.BaseTexture[];
  77965. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77966. getClassName(): string;
  77967. dispose(forceDisposeEffect?: boolean): void;
  77968. clone(name: string): FireMaterial;
  77969. serialize(): any;
  77970. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  77971. }
  77972. }
  77973. declare module BABYLON {
  77974. /** @hidden */
  77975. export var furPixelShader: {
  77976. name: string;
  77977. shader: string;
  77978. };
  77979. }
  77980. declare module BABYLON {
  77981. /** @hidden */
  77982. export var furVertexShader: {
  77983. name: string;
  77984. shader: string;
  77985. };
  77986. }
  77987. declare module BABYLON {
  77988. export class FurMaterial extends BABYLON.PushMaterial {
  77989. private _diffuseTexture;
  77990. diffuseTexture: BABYLON.BaseTexture;
  77991. private _heightTexture;
  77992. heightTexture: BABYLON.BaseTexture;
  77993. diffuseColor: BABYLON.Color3;
  77994. furLength: number;
  77995. furAngle: number;
  77996. furColor: BABYLON.Color3;
  77997. furOffset: number;
  77998. furSpacing: number;
  77999. furGravity: BABYLON.Vector3;
  78000. furSpeed: number;
  78001. furDensity: number;
  78002. furOcclusion: number;
  78003. furTexture: BABYLON.DynamicTexture;
  78004. private _disableLighting;
  78005. disableLighting: boolean;
  78006. private _maxSimultaneousLights;
  78007. maxSimultaneousLights: number;
  78008. highLevelFur: boolean;
  78009. _meshes: BABYLON.AbstractMesh[];
  78010. private _renderId;
  78011. private _furTime;
  78012. constructor(name: string, scene: BABYLON.Scene);
  78013. get furTime(): number;
  78014. set furTime(furTime: number);
  78015. needAlphaBlending(): boolean;
  78016. needAlphaTesting(): boolean;
  78017. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78018. updateFur(): void;
  78019. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78020. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78021. getAnimatables(): BABYLON.IAnimatable[];
  78022. getActiveTextures(): BABYLON.BaseTexture[];
  78023. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78024. dispose(forceDisposeEffect?: boolean): void;
  78025. clone(name: string): FurMaterial;
  78026. serialize(): any;
  78027. getClassName(): string;
  78028. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  78029. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  78030. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  78031. }
  78032. }
  78033. declare module BABYLON {
  78034. /** @hidden */
  78035. export var gradientPixelShader: {
  78036. name: string;
  78037. shader: string;
  78038. };
  78039. }
  78040. declare module BABYLON {
  78041. /** @hidden */
  78042. export var gradientVertexShader: {
  78043. name: string;
  78044. shader: string;
  78045. };
  78046. }
  78047. declare module BABYLON {
  78048. export class GradientMaterial extends BABYLON.PushMaterial {
  78049. private _maxSimultaneousLights;
  78050. maxSimultaneousLights: number;
  78051. topColor: BABYLON.Color3;
  78052. topColorAlpha: number;
  78053. bottomColor: BABYLON.Color3;
  78054. bottomColorAlpha: number;
  78055. offset: number;
  78056. scale: number;
  78057. smoothness: number;
  78058. private _disableLighting;
  78059. disableLighting: boolean;
  78060. private _renderId;
  78061. constructor(name: string, scene: BABYLON.Scene);
  78062. needAlphaBlending(): boolean;
  78063. needAlphaTesting(): boolean;
  78064. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78065. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78066. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78067. getAnimatables(): BABYLON.IAnimatable[];
  78068. dispose(forceDisposeEffect?: boolean): void;
  78069. clone(name: string): GradientMaterial;
  78070. serialize(): any;
  78071. getClassName(): string;
  78072. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  78073. }
  78074. }
  78075. declare module BABYLON {
  78076. /** @hidden */
  78077. export var gridPixelShader: {
  78078. name: string;
  78079. shader: string;
  78080. };
  78081. }
  78082. declare module BABYLON {
  78083. /** @hidden */
  78084. export var gridVertexShader: {
  78085. name: string;
  78086. shader: string;
  78087. };
  78088. }
  78089. declare module BABYLON {
  78090. /**
  78091. * The grid materials allows you to wrap any shape with a grid.
  78092. * Colors are customizable.
  78093. */
  78094. export class GridMaterial extends BABYLON.PushMaterial {
  78095. /**
  78096. * Main color of the grid (e.g. between lines)
  78097. */
  78098. mainColor: BABYLON.Color3;
  78099. /**
  78100. * Color of the grid lines.
  78101. */
  78102. lineColor: BABYLON.Color3;
  78103. /**
  78104. * The scale of the grid compared to unit.
  78105. */
  78106. gridRatio: number;
  78107. /**
  78108. * Allows setting an offset for the grid lines.
  78109. */
  78110. gridOffset: BABYLON.Vector3;
  78111. /**
  78112. * The frequency of thicker lines.
  78113. */
  78114. majorUnitFrequency: number;
  78115. /**
  78116. * The visibility of minor units in the grid.
  78117. */
  78118. minorUnitVisibility: number;
  78119. /**
  78120. * The grid opacity outside of the lines.
  78121. */
  78122. opacity: number;
  78123. /**
  78124. * Determine RBG output is premultiplied by alpha value.
  78125. */
  78126. preMultiplyAlpha: boolean;
  78127. private _opacityTexture;
  78128. opacityTexture: BABYLON.BaseTexture;
  78129. private _gridControl;
  78130. private _renderId;
  78131. /**
  78132. * constructor
  78133. * @param name The name given to the material in order to identify it afterwards.
  78134. * @param scene The scene the material is used in.
  78135. */
  78136. constructor(name: string, scene: BABYLON.Scene);
  78137. /**
  78138. * Returns wehter or not the grid requires alpha blending.
  78139. */
  78140. needAlphaBlending(): boolean;
  78141. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78142. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78143. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78144. /**
  78145. * Dispose the material and its associated resources.
  78146. * @param forceDisposeEffect will also dispose the used effect when true
  78147. */
  78148. dispose(forceDisposeEffect?: boolean): void;
  78149. clone(name: string): GridMaterial;
  78150. serialize(): any;
  78151. getClassName(): string;
  78152. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  78153. }
  78154. }
  78155. declare module BABYLON {
  78156. /** @hidden */
  78157. export var lavaPixelShader: {
  78158. name: string;
  78159. shader: string;
  78160. };
  78161. }
  78162. declare module BABYLON {
  78163. /** @hidden */
  78164. export var lavaVertexShader: {
  78165. name: string;
  78166. shader: string;
  78167. };
  78168. }
  78169. declare module BABYLON {
  78170. export class LavaMaterial extends BABYLON.PushMaterial {
  78171. private _diffuseTexture;
  78172. diffuseTexture: BABYLON.BaseTexture;
  78173. noiseTexture: BABYLON.BaseTexture;
  78174. fogColor: BABYLON.Color3;
  78175. speed: number;
  78176. movingSpeed: number;
  78177. lowFrequencySpeed: number;
  78178. fogDensity: number;
  78179. private _lastTime;
  78180. diffuseColor: BABYLON.Color3;
  78181. private _disableLighting;
  78182. disableLighting: boolean;
  78183. private _unlit;
  78184. unlit: boolean;
  78185. private _maxSimultaneousLights;
  78186. maxSimultaneousLights: number;
  78187. private _scaledDiffuse;
  78188. private _renderId;
  78189. constructor(name: string, scene: BABYLON.Scene);
  78190. needAlphaBlending(): boolean;
  78191. needAlphaTesting(): boolean;
  78192. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78193. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78194. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78195. getAnimatables(): BABYLON.IAnimatable[];
  78196. getActiveTextures(): BABYLON.BaseTexture[];
  78197. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78198. dispose(forceDisposeEffect?: boolean): void;
  78199. clone(name: string): LavaMaterial;
  78200. serialize(): any;
  78201. getClassName(): string;
  78202. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  78203. }
  78204. }
  78205. declare module BABYLON {
  78206. /** @hidden */
  78207. export var mixPixelShader: {
  78208. name: string;
  78209. shader: string;
  78210. };
  78211. }
  78212. declare module BABYLON {
  78213. /** @hidden */
  78214. export var mixVertexShader: {
  78215. name: string;
  78216. shader: string;
  78217. };
  78218. }
  78219. declare module BABYLON {
  78220. export class MixMaterial extends BABYLON.PushMaterial {
  78221. /**
  78222. * Mix textures
  78223. */
  78224. private _mixTexture1;
  78225. mixTexture1: BABYLON.BaseTexture;
  78226. private _mixTexture2;
  78227. mixTexture2: BABYLON.BaseTexture;
  78228. /**
  78229. * Diffuse textures
  78230. */
  78231. private _diffuseTexture1;
  78232. diffuseTexture1: BABYLON.Texture;
  78233. private _diffuseTexture2;
  78234. diffuseTexture2: BABYLON.Texture;
  78235. private _diffuseTexture3;
  78236. diffuseTexture3: BABYLON.Texture;
  78237. private _diffuseTexture4;
  78238. diffuseTexture4: BABYLON.Texture;
  78239. private _diffuseTexture5;
  78240. diffuseTexture5: BABYLON.Texture;
  78241. private _diffuseTexture6;
  78242. diffuseTexture6: BABYLON.Texture;
  78243. private _diffuseTexture7;
  78244. diffuseTexture7: BABYLON.Texture;
  78245. private _diffuseTexture8;
  78246. diffuseTexture8: BABYLON.Texture;
  78247. /**
  78248. * Uniforms
  78249. */
  78250. diffuseColor: BABYLON.Color3;
  78251. specularColor: BABYLON.Color3;
  78252. specularPower: number;
  78253. private _disableLighting;
  78254. disableLighting: boolean;
  78255. private _maxSimultaneousLights;
  78256. maxSimultaneousLights: number;
  78257. private _renderId;
  78258. constructor(name: string, scene: BABYLON.Scene);
  78259. needAlphaBlending(): boolean;
  78260. needAlphaTesting(): boolean;
  78261. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78262. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78263. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78264. getAnimatables(): BABYLON.IAnimatable[];
  78265. getActiveTextures(): BABYLON.BaseTexture[];
  78266. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78267. dispose(forceDisposeEffect?: boolean): void;
  78268. clone(name: string): MixMaterial;
  78269. serialize(): any;
  78270. getClassName(): string;
  78271. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  78272. }
  78273. }
  78274. declare module BABYLON {
  78275. /** @hidden */
  78276. export var normalPixelShader: {
  78277. name: string;
  78278. shader: string;
  78279. };
  78280. }
  78281. declare module BABYLON {
  78282. /** @hidden */
  78283. export var normalVertexShader: {
  78284. name: string;
  78285. shader: string;
  78286. };
  78287. }
  78288. declare module BABYLON {
  78289. export class NormalMaterial extends BABYLON.PushMaterial {
  78290. private _diffuseTexture;
  78291. diffuseTexture: BABYLON.BaseTexture;
  78292. diffuseColor: BABYLON.Color3;
  78293. private _disableLighting;
  78294. disableLighting: boolean;
  78295. private _maxSimultaneousLights;
  78296. maxSimultaneousLights: number;
  78297. private _renderId;
  78298. constructor(name: string, scene: BABYLON.Scene);
  78299. needAlphaBlending(): boolean;
  78300. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78301. needAlphaTesting(): boolean;
  78302. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78303. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78304. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78305. getAnimatables(): BABYLON.IAnimatable[];
  78306. getActiveTextures(): BABYLON.BaseTexture[];
  78307. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78308. dispose(forceDisposeEffect?: boolean): void;
  78309. clone(name: string): NormalMaterial;
  78310. serialize(): any;
  78311. getClassName(): string;
  78312. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  78313. }
  78314. }
  78315. declare module BABYLON {
  78316. /** @hidden */
  78317. export var shadowOnlyPixelShader: {
  78318. name: string;
  78319. shader: string;
  78320. };
  78321. }
  78322. declare module BABYLON {
  78323. /** @hidden */
  78324. export var shadowOnlyVertexShader: {
  78325. name: string;
  78326. shader: string;
  78327. };
  78328. }
  78329. declare module BABYLON {
  78330. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  78331. private _renderId;
  78332. private _activeLight;
  78333. constructor(name: string, scene: BABYLON.Scene);
  78334. shadowColor: BABYLON.Color3;
  78335. needAlphaBlending(): boolean;
  78336. needAlphaTesting(): boolean;
  78337. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78338. get activeLight(): BABYLON.IShadowLight;
  78339. set activeLight(light: BABYLON.IShadowLight);
  78340. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78341. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78342. clone(name: string): ShadowOnlyMaterial;
  78343. serialize(): any;
  78344. getClassName(): string;
  78345. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  78346. }
  78347. }
  78348. declare module BABYLON {
  78349. /** @hidden */
  78350. export var simplePixelShader: {
  78351. name: string;
  78352. shader: string;
  78353. };
  78354. }
  78355. declare module BABYLON {
  78356. /** @hidden */
  78357. export var simpleVertexShader: {
  78358. name: string;
  78359. shader: string;
  78360. };
  78361. }
  78362. declare module BABYLON {
  78363. export class SimpleMaterial extends BABYLON.PushMaterial {
  78364. private _diffuseTexture;
  78365. diffuseTexture: BABYLON.BaseTexture;
  78366. diffuseColor: BABYLON.Color3;
  78367. private _disableLighting;
  78368. disableLighting: boolean;
  78369. private _maxSimultaneousLights;
  78370. maxSimultaneousLights: number;
  78371. private _renderId;
  78372. constructor(name: string, scene: BABYLON.Scene);
  78373. needAlphaBlending(): boolean;
  78374. needAlphaTesting(): boolean;
  78375. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78376. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78377. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78378. getAnimatables(): BABYLON.IAnimatable[];
  78379. getActiveTextures(): BABYLON.BaseTexture[];
  78380. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78381. dispose(forceDisposeEffect?: boolean): void;
  78382. clone(name: string): SimpleMaterial;
  78383. serialize(): any;
  78384. getClassName(): string;
  78385. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  78386. }
  78387. }
  78388. declare module BABYLON {
  78389. /** @hidden */
  78390. export var skyPixelShader: {
  78391. name: string;
  78392. shader: string;
  78393. };
  78394. }
  78395. declare module BABYLON {
  78396. /** @hidden */
  78397. export var skyVertexShader: {
  78398. name: string;
  78399. shader: string;
  78400. };
  78401. }
  78402. declare module BABYLON {
  78403. /**
  78404. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  78405. * @see https://doc.babylonjs.com/extensions/sky
  78406. */
  78407. export class SkyMaterial extends BABYLON.PushMaterial {
  78408. /**
  78409. * Defines the overall luminance of sky in interval ]0, 1[.
  78410. */
  78411. luminance: number;
  78412. /**
  78413. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  78414. */
  78415. turbidity: number;
  78416. /**
  78417. * Defines the sky appearance (light intensity).
  78418. */
  78419. rayleigh: number;
  78420. /**
  78421. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  78422. */
  78423. mieCoefficient: number;
  78424. /**
  78425. * Defines the amount of haze particles following the Mie scattering theory.
  78426. */
  78427. mieDirectionalG: number;
  78428. /**
  78429. * Defines the distance of the sun according to the active scene camera.
  78430. */
  78431. distance: number;
  78432. /**
  78433. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  78434. * "inclined".
  78435. */
  78436. inclination: number;
  78437. /**
  78438. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  78439. * an object direction and a reference direction.
  78440. */
  78441. azimuth: number;
  78442. /**
  78443. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  78444. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  78445. */
  78446. sunPosition: BABYLON.Vector3;
  78447. /**
  78448. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  78449. * .sunPosition property.
  78450. */
  78451. useSunPosition: boolean;
  78452. /**
  78453. * Defines an offset vector used to get a horizon offset.
  78454. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  78455. */
  78456. cameraOffset: BABYLON.Vector3;
  78457. private _cameraPosition;
  78458. private _renderId;
  78459. /**
  78460. * Instantiates a new sky material.
  78461. * This material allows to create dynamic and texture free
  78462. * effects for skyboxes by taking care of the atmosphere state.
  78463. * @see https://doc.babylonjs.com/extensions/sky
  78464. * @param name Define the name of the material in the scene
  78465. * @param scene Define the scene the material belong to
  78466. */
  78467. constructor(name: string, scene: BABYLON.Scene);
  78468. /**
  78469. * Specifies if the material will require alpha blending
  78470. * @returns a boolean specifying if alpha blending is needed
  78471. */
  78472. needAlphaBlending(): boolean;
  78473. /**
  78474. * Specifies if this material should be rendered in alpha test mode
  78475. * @returns false as the sky material doesn't need alpha testing.
  78476. */
  78477. needAlphaTesting(): boolean;
  78478. /**
  78479. * Get the texture used for alpha test purpose.
  78480. * @returns null as the sky material has no texture.
  78481. */
  78482. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78483. /**
  78484. * Get if the submesh is ready to be used and all its information available.
  78485. * Child classes can use it to update shaders
  78486. * @param mesh defines the mesh to check
  78487. * @param subMesh defines which submesh to check
  78488. * @param useInstances specifies that instances should be used
  78489. * @returns a boolean indicating that the submesh is ready or not
  78490. */
  78491. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78492. /**
  78493. * Binds the submesh to this material by preparing the effect and shader to draw
  78494. * @param world defines the world transformation matrix
  78495. * @param mesh defines the mesh containing the submesh
  78496. * @param subMesh defines the submesh to bind the material to
  78497. */
  78498. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78499. /**
  78500. * Get the list of animatables in the material.
  78501. * @returns the list of animatables object used in the material
  78502. */
  78503. getAnimatables(): BABYLON.IAnimatable[];
  78504. /**
  78505. * Disposes the material
  78506. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78507. */
  78508. dispose(forceDisposeEffect?: boolean): void;
  78509. /**
  78510. * Makes a duplicate of the material, and gives it a new name
  78511. * @param name defines the new name for the duplicated material
  78512. * @returns the cloned material
  78513. */
  78514. clone(name: string): SkyMaterial;
  78515. /**
  78516. * Serializes this material in a JSON representation
  78517. * @returns the serialized material object
  78518. */
  78519. serialize(): any;
  78520. /**
  78521. * Gets the current class name of the material e.g. "SkyMaterial"
  78522. * Mainly use in serialization.
  78523. * @returns the class name
  78524. */
  78525. getClassName(): string;
  78526. /**
  78527. * Creates a sky material from parsed material data
  78528. * @param source defines the JSON representation of the material
  78529. * @param scene defines the hosting scene
  78530. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  78531. * @returns a new sky material
  78532. */
  78533. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  78534. }
  78535. }
  78536. declare module BABYLON {
  78537. /** @hidden */
  78538. export var terrainPixelShader: {
  78539. name: string;
  78540. shader: string;
  78541. };
  78542. }
  78543. declare module BABYLON {
  78544. /** @hidden */
  78545. export var terrainVertexShader: {
  78546. name: string;
  78547. shader: string;
  78548. };
  78549. }
  78550. declare module BABYLON {
  78551. export class TerrainMaterial extends BABYLON.PushMaterial {
  78552. private _mixTexture;
  78553. mixTexture: BABYLON.BaseTexture;
  78554. private _diffuseTexture1;
  78555. diffuseTexture1: BABYLON.Texture;
  78556. private _diffuseTexture2;
  78557. diffuseTexture2: BABYLON.Texture;
  78558. private _diffuseTexture3;
  78559. diffuseTexture3: BABYLON.Texture;
  78560. private _bumpTexture1;
  78561. bumpTexture1: BABYLON.Texture;
  78562. private _bumpTexture2;
  78563. bumpTexture2: BABYLON.Texture;
  78564. private _bumpTexture3;
  78565. bumpTexture3: BABYLON.Texture;
  78566. diffuseColor: BABYLON.Color3;
  78567. specularColor: BABYLON.Color3;
  78568. specularPower: number;
  78569. private _disableLighting;
  78570. disableLighting: boolean;
  78571. private _maxSimultaneousLights;
  78572. maxSimultaneousLights: number;
  78573. private _renderId;
  78574. constructor(name: string, scene: BABYLON.Scene);
  78575. needAlphaBlending(): boolean;
  78576. needAlphaTesting(): boolean;
  78577. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78578. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78579. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78580. getAnimatables(): BABYLON.IAnimatable[];
  78581. getActiveTextures(): BABYLON.BaseTexture[];
  78582. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78583. dispose(forceDisposeEffect?: boolean): void;
  78584. clone(name: string): TerrainMaterial;
  78585. serialize(): any;
  78586. getClassName(): string;
  78587. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  78588. }
  78589. }
  78590. declare module BABYLON {
  78591. /** @hidden */
  78592. export var triplanarPixelShader: {
  78593. name: string;
  78594. shader: string;
  78595. };
  78596. }
  78597. declare module BABYLON {
  78598. /** @hidden */
  78599. export var triplanarVertexShader: {
  78600. name: string;
  78601. shader: string;
  78602. };
  78603. }
  78604. declare module BABYLON {
  78605. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  78606. mixTexture: BABYLON.BaseTexture;
  78607. private _diffuseTextureX;
  78608. diffuseTextureX: BABYLON.BaseTexture;
  78609. private _diffuseTextureY;
  78610. diffuseTextureY: BABYLON.BaseTexture;
  78611. private _diffuseTextureZ;
  78612. diffuseTextureZ: BABYLON.BaseTexture;
  78613. private _normalTextureX;
  78614. normalTextureX: BABYLON.BaseTexture;
  78615. private _normalTextureY;
  78616. normalTextureY: BABYLON.BaseTexture;
  78617. private _normalTextureZ;
  78618. normalTextureZ: BABYLON.BaseTexture;
  78619. tileSize: number;
  78620. diffuseColor: BABYLON.Color3;
  78621. specularColor: BABYLON.Color3;
  78622. specularPower: number;
  78623. private _disableLighting;
  78624. disableLighting: boolean;
  78625. private _maxSimultaneousLights;
  78626. maxSimultaneousLights: number;
  78627. private _renderId;
  78628. constructor(name: string, scene: BABYLON.Scene);
  78629. needAlphaBlending(): boolean;
  78630. needAlphaTesting(): boolean;
  78631. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78632. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78633. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78634. getAnimatables(): BABYLON.IAnimatable[];
  78635. getActiveTextures(): BABYLON.BaseTexture[];
  78636. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78637. dispose(forceDisposeEffect?: boolean): void;
  78638. clone(name: string): TriPlanarMaterial;
  78639. serialize(): any;
  78640. getClassName(): string;
  78641. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  78642. }
  78643. }
  78644. declare module BABYLON {
  78645. /** @hidden */
  78646. export var waterPixelShader: {
  78647. name: string;
  78648. shader: string;
  78649. };
  78650. }
  78651. declare module BABYLON {
  78652. /** @hidden */
  78653. export var waterVertexShader: {
  78654. name: string;
  78655. shader: string;
  78656. };
  78657. }
  78658. declare module BABYLON {
  78659. export class WaterMaterial extends BABYLON.PushMaterial {
  78660. renderTargetSize: BABYLON.Vector2;
  78661. private _bumpTexture;
  78662. bumpTexture: BABYLON.BaseTexture;
  78663. diffuseColor: BABYLON.Color3;
  78664. specularColor: BABYLON.Color3;
  78665. specularPower: number;
  78666. private _disableLighting;
  78667. disableLighting: boolean;
  78668. private _maxSimultaneousLights;
  78669. maxSimultaneousLights: number;
  78670. /**
  78671. * @param {number}: Represents the wind force
  78672. */
  78673. windForce: number;
  78674. /**
  78675. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  78676. */
  78677. windDirection: BABYLON.Vector2;
  78678. /**
  78679. * @param {number}: Wave height, represents the height of the waves
  78680. */
  78681. waveHeight: number;
  78682. /**
  78683. * @param {number}: Bump height, represents the bump height related to the bump map
  78684. */
  78685. bumpHeight: number;
  78686. /**
  78687. * @param {boolean}: Add a smaller moving bump to less steady waves.
  78688. */
  78689. private _bumpSuperimpose;
  78690. bumpSuperimpose: boolean;
  78691. /**
  78692. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  78693. */
  78694. private _fresnelSeparate;
  78695. fresnelSeparate: boolean;
  78696. /**
  78697. * @param {boolean}: bump Waves modify the reflection.
  78698. */
  78699. private _bumpAffectsReflection;
  78700. bumpAffectsReflection: boolean;
  78701. /**
  78702. * @param {number}: The water color blended with the refraction (near)
  78703. */
  78704. waterColor: BABYLON.Color3;
  78705. /**
  78706. * @param {number}: The blend factor related to the water color
  78707. */
  78708. colorBlendFactor: number;
  78709. /**
  78710. * @param {number}: The water color blended with the reflection (far)
  78711. */
  78712. waterColor2: BABYLON.Color3;
  78713. /**
  78714. * @param {number}: The blend factor related to the water color (reflection, far)
  78715. */
  78716. colorBlendFactor2: number;
  78717. /**
  78718. * @param {number}: Represents the maximum length of a wave
  78719. */
  78720. waveLength: number;
  78721. /**
  78722. * @param {number}: Defines the waves speed
  78723. */
  78724. waveSpeed: number;
  78725. /**
  78726. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  78727. * will avoid calculating useless pixels in the pixel shader of the water material.
  78728. */
  78729. disableClipPlane: boolean;
  78730. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  78731. private _mesh;
  78732. private _refractionRTT;
  78733. private _reflectionRTT;
  78734. private _reflectionTransform;
  78735. private _lastTime;
  78736. private _lastDeltaTime;
  78737. private _renderId;
  78738. private _useLogarithmicDepth;
  78739. private _waitingRenderList;
  78740. private _imageProcessingConfiguration;
  78741. private _imageProcessingObserver;
  78742. /**
  78743. * Gets a boolean indicating that current material needs to register RTT
  78744. */
  78745. get hasRenderTargetTextures(): boolean;
  78746. /**
  78747. * Constructor
  78748. */
  78749. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  78750. get useLogarithmicDepth(): boolean;
  78751. set useLogarithmicDepth(value: boolean);
  78752. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  78753. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  78754. addToRenderList(node: any): void;
  78755. enableRenderTargets(enable: boolean): void;
  78756. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  78757. get renderTargetsEnabled(): boolean;
  78758. needAlphaBlending(): boolean;
  78759. needAlphaTesting(): boolean;
  78760. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78761. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78762. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78763. private _createRenderTargets;
  78764. getAnimatables(): BABYLON.IAnimatable[];
  78765. getActiveTextures(): BABYLON.BaseTexture[];
  78766. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78767. dispose(forceDisposeEffect?: boolean): void;
  78768. clone(name: string): WaterMaterial;
  78769. serialize(): any;
  78770. getClassName(): string;
  78771. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  78772. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  78773. }
  78774. }
  78775. declare module BABYLON {
  78776. /** @hidden */
  78777. export var asciiartPixelShader: {
  78778. name: string;
  78779. shader: string;
  78780. };
  78781. }
  78782. declare module BABYLON {
  78783. /**
  78784. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  78785. *
  78786. * It basically takes care rendering the font front the given font size to a texture.
  78787. * This is used later on in the postprocess.
  78788. */
  78789. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  78790. private _font;
  78791. private _text;
  78792. private _charSize;
  78793. /**
  78794. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  78795. */
  78796. get charSize(): number;
  78797. /**
  78798. * Create a new instance of the Ascii Art FontTexture class
  78799. * @param name the name of the texture
  78800. * @param font the font to use, use the W3C CSS notation
  78801. * @param text the caracter set to use in the rendering.
  78802. * @param scene the scene that owns the texture
  78803. */
  78804. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  78805. /**
  78806. * Gets the max char width of a font.
  78807. * @param font the font to use, use the W3C CSS notation
  78808. * @return the max char width
  78809. */
  78810. private getFontWidth;
  78811. /**
  78812. * Gets the max char height of a font.
  78813. * @param font the font to use, use the W3C CSS notation
  78814. * @return the max char height
  78815. */
  78816. private getFontHeight;
  78817. /**
  78818. * Clones the current AsciiArtTexture.
  78819. * @return the clone of the texture.
  78820. */
  78821. clone(): AsciiArtFontTexture;
  78822. /**
  78823. * Parses a json object representing the texture and returns an instance of it.
  78824. * @param source the source JSON representation
  78825. * @param scene the scene to create the texture for
  78826. * @return the parsed texture
  78827. */
  78828. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  78829. }
  78830. /**
  78831. * Option available in the Ascii Art Post Process.
  78832. */
  78833. export interface IAsciiArtPostProcessOptions {
  78834. /**
  78835. * The font to use following the w3c font definition.
  78836. */
  78837. font?: string;
  78838. /**
  78839. * The character set to use in the postprocess.
  78840. */
  78841. characterSet?: string;
  78842. /**
  78843. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  78844. * This number is defined between 0 and 1;
  78845. */
  78846. mixToTile?: number;
  78847. /**
  78848. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  78849. * This number is defined between 0 and 1;
  78850. */
  78851. mixToNormal?: number;
  78852. }
  78853. /**
  78854. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  78855. *
  78856. * Simmply add it to your scene and let the nerd that lives in you have fun.
  78857. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  78858. */
  78859. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  78860. /**
  78861. * The font texture used to render the char in the post process.
  78862. */
  78863. private _asciiArtFontTexture;
  78864. /**
  78865. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  78866. * This number is defined between 0 and 1;
  78867. */
  78868. mixToTile: number;
  78869. /**
  78870. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  78871. * This number is defined between 0 and 1;
  78872. */
  78873. mixToNormal: number;
  78874. /**
  78875. * Instantiates a new Ascii Art Post Process.
  78876. * @param name the name to give to the postprocess
  78877. * @camera the camera to apply the post process to.
  78878. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  78879. */
  78880. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  78881. }
  78882. }
  78883. declare module BABYLON {
  78884. /** @hidden */
  78885. export var digitalrainPixelShader: {
  78886. name: string;
  78887. shader: string;
  78888. };
  78889. }
  78890. declare module BABYLON {
  78891. /**
  78892. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  78893. *
  78894. * It basically takes care rendering the font front the given font size to a texture.
  78895. * This is used later on in the postprocess.
  78896. */
  78897. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  78898. private _font;
  78899. private _text;
  78900. private _charSize;
  78901. /**
  78902. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  78903. */
  78904. get charSize(): number;
  78905. /**
  78906. * Create a new instance of the Digital Rain FontTexture class
  78907. * @param name the name of the texture
  78908. * @param font the font to use, use the W3C CSS notation
  78909. * @param text the caracter set to use in the rendering.
  78910. * @param scene the scene that owns the texture
  78911. */
  78912. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  78913. /**
  78914. * Gets the max char width of a font.
  78915. * @param font the font to use, use the W3C CSS notation
  78916. * @return the max char width
  78917. */
  78918. private getFontWidth;
  78919. /**
  78920. * Gets the max char height of a font.
  78921. * @param font the font to use, use the W3C CSS notation
  78922. * @return the max char height
  78923. */
  78924. private getFontHeight;
  78925. /**
  78926. * Clones the current DigitalRainFontTexture.
  78927. * @return the clone of the texture.
  78928. */
  78929. clone(): DigitalRainFontTexture;
  78930. /**
  78931. * Parses a json object representing the texture and returns an instance of it.
  78932. * @param source the source JSON representation
  78933. * @param scene the scene to create the texture for
  78934. * @return the parsed texture
  78935. */
  78936. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  78937. }
  78938. /**
  78939. * Option available in the Digital Rain Post Process.
  78940. */
  78941. export interface IDigitalRainPostProcessOptions {
  78942. /**
  78943. * The font to use following the w3c font definition.
  78944. */
  78945. font?: string;
  78946. /**
  78947. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  78948. * This number is defined between 0 and 1;
  78949. */
  78950. mixToTile?: number;
  78951. /**
  78952. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  78953. * This number is defined between 0 and 1;
  78954. */
  78955. mixToNormal?: number;
  78956. }
  78957. /**
  78958. * DigitalRainPostProcess helps rendering everithing in digital rain.
  78959. *
  78960. * Simmply add it to your scene and let the nerd that lives in you have fun.
  78961. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  78962. */
  78963. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  78964. /**
  78965. * The font texture used to render the char in the post process.
  78966. */
  78967. private _digitalRainFontTexture;
  78968. /**
  78969. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  78970. * This number is defined between 0 and 1;
  78971. */
  78972. mixToTile: number;
  78973. /**
  78974. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  78975. * This number is defined between 0 and 1;
  78976. */
  78977. mixToNormal: number;
  78978. /**
  78979. * Instantiates a new Digital Rain Post Process.
  78980. * @param name the name to give to the postprocess
  78981. * @camera the camera to apply the post process to.
  78982. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  78983. */
  78984. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  78985. }
  78986. }
  78987. declare module BABYLON {
  78988. /** @hidden */
  78989. export var brickProceduralTexturePixelShader: {
  78990. name: string;
  78991. shader: string;
  78992. };
  78993. }
  78994. declare module BABYLON {
  78995. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  78996. private _numberOfBricksHeight;
  78997. private _numberOfBricksWidth;
  78998. private _jointColor;
  78999. private _brickColor;
  79000. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79001. updateShaderUniforms(): void;
  79002. get numberOfBricksHeight(): number;
  79003. set numberOfBricksHeight(value: number);
  79004. get numberOfBricksWidth(): number;
  79005. set numberOfBricksWidth(value: number);
  79006. get jointColor(): BABYLON.Color3;
  79007. set jointColor(value: BABYLON.Color3);
  79008. get brickColor(): BABYLON.Color3;
  79009. set brickColor(value: BABYLON.Color3);
  79010. /**
  79011. * Serializes this brick procedural texture
  79012. * @returns a serialized brick procedural texture object
  79013. */
  79014. serialize(): any;
  79015. /**
  79016. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  79017. * @param parsedTexture defines parsed texture data
  79018. * @param scene defines the current scene
  79019. * @param rootUrl defines the root URL containing brick procedural texture information
  79020. * @returns a parsed Brick Procedural BABYLON.Texture
  79021. */
  79022. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  79023. }
  79024. }
  79025. declare module BABYLON {
  79026. /** @hidden */
  79027. export var cloudProceduralTexturePixelShader: {
  79028. name: string;
  79029. shader: string;
  79030. };
  79031. }
  79032. declare module BABYLON {
  79033. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  79034. private _skyColor;
  79035. private _cloudColor;
  79036. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79037. updateShaderUniforms(): void;
  79038. get skyColor(): BABYLON.Color4;
  79039. set skyColor(value: BABYLON.Color4);
  79040. get cloudColor(): BABYLON.Color4;
  79041. set cloudColor(value: BABYLON.Color4);
  79042. /**
  79043. * Serializes this cloud procedural texture
  79044. * @returns a serialized cloud procedural texture object
  79045. */
  79046. serialize(): any;
  79047. /**
  79048. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  79049. * @param parsedTexture defines parsed texture data
  79050. * @param scene defines the current scene
  79051. * @param rootUrl defines the root URL containing cloud procedural texture information
  79052. * @returns a parsed Cloud Procedural BABYLON.Texture
  79053. */
  79054. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  79055. }
  79056. }
  79057. declare module BABYLON {
  79058. /** @hidden */
  79059. export var fireProceduralTexturePixelShader: {
  79060. name: string;
  79061. shader: string;
  79062. };
  79063. }
  79064. declare module BABYLON {
  79065. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  79066. private _time;
  79067. private _speed;
  79068. private _autoGenerateTime;
  79069. private _fireColors;
  79070. private _alphaThreshold;
  79071. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79072. updateShaderUniforms(): void;
  79073. render(useCameraPostProcess?: boolean): void;
  79074. static get PurpleFireColors(): BABYLON.Color3[];
  79075. static get GreenFireColors(): BABYLON.Color3[];
  79076. static get RedFireColors(): BABYLON.Color3[];
  79077. static get BlueFireColors(): BABYLON.Color3[];
  79078. get autoGenerateTime(): boolean;
  79079. set autoGenerateTime(value: boolean);
  79080. get fireColors(): BABYLON.Color3[];
  79081. set fireColors(value: BABYLON.Color3[]);
  79082. get time(): number;
  79083. set time(value: number);
  79084. get speed(): BABYLON.Vector2;
  79085. set speed(value: BABYLON.Vector2);
  79086. get alphaThreshold(): number;
  79087. set alphaThreshold(value: number);
  79088. /**
  79089. * Serializes this fire procedural texture
  79090. * @returns a serialized fire procedural texture object
  79091. */
  79092. serialize(): any;
  79093. /**
  79094. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  79095. * @param parsedTexture defines parsed texture data
  79096. * @param scene defines the current scene
  79097. * @param rootUrl defines the root URL containing fire procedural texture information
  79098. * @returns a parsed Fire Procedural BABYLON.Texture
  79099. */
  79100. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  79101. }
  79102. }
  79103. declare module BABYLON {
  79104. /** @hidden */
  79105. export var grassProceduralTexturePixelShader: {
  79106. name: string;
  79107. shader: string;
  79108. };
  79109. }
  79110. declare module BABYLON {
  79111. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  79112. private _grassColors;
  79113. private _groundColor;
  79114. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79115. updateShaderUniforms(): void;
  79116. get grassColors(): BABYLON.Color3[];
  79117. set grassColors(value: BABYLON.Color3[]);
  79118. get groundColor(): BABYLON.Color3;
  79119. set groundColor(value: BABYLON.Color3);
  79120. /**
  79121. * Serializes this grass procedural texture
  79122. * @returns a serialized grass procedural texture object
  79123. */
  79124. serialize(): any;
  79125. /**
  79126. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  79127. * @param parsedTexture defines parsed texture data
  79128. * @param scene defines the current scene
  79129. * @param rootUrl defines the root URL containing grass procedural texture information
  79130. * @returns a parsed Grass Procedural BABYLON.Texture
  79131. */
  79132. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  79133. }
  79134. }
  79135. declare module BABYLON {
  79136. /** @hidden */
  79137. export var marbleProceduralTexturePixelShader: {
  79138. name: string;
  79139. shader: string;
  79140. };
  79141. }
  79142. declare module BABYLON {
  79143. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  79144. private _numberOfTilesHeight;
  79145. private _numberOfTilesWidth;
  79146. private _amplitude;
  79147. private _jointColor;
  79148. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79149. updateShaderUniforms(): void;
  79150. get numberOfTilesHeight(): number;
  79151. set numberOfTilesHeight(value: number);
  79152. get amplitude(): number;
  79153. set amplitude(value: number);
  79154. get numberOfTilesWidth(): number;
  79155. set numberOfTilesWidth(value: number);
  79156. get jointColor(): BABYLON.Color3;
  79157. set jointColor(value: BABYLON.Color3);
  79158. /**
  79159. * Serializes this marble procedural texture
  79160. * @returns a serialized marble procedural texture object
  79161. */
  79162. serialize(): any;
  79163. /**
  79164. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  79165. * @param parsedTexture defines parsed texture data
  79166. * @param scene defines the current scene
  79167. * @param rootUrl defines the root URL containing marble procedural texture information
  79168. * @returns a parsed Marble Procedural BABYLON.Texture
  79169. */
  79170. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  79171. }
  79172. }
  79173. declare module BABYLON {
  79174. /** @hidden */
  79175. export var normalMapProceduralTexturePixelShader: {
  79176. name: string;
  79177. shader: string;
  79178. };
  79179. }
  79180. declare module BABYLON {
  79181. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  79182. private _baseTexture;
  79183. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79184. updateShaderUniforms(): void;
  79185. render(useCameraPostProcess?: boolean): void;
  79186. resize(size: any, generateMipMaps: any): void;
  79187. get baseTexture(): BABYLON.Texture;
  79188. set baseTexture(texture: BABYLON.Texture);
  79189. /**
  79190. * Serializes this normal map procedural texture
  79191. * @returns a serialized normal map procedural texture object
  79192. */
  79193. serialize(): any;
  79194. /**
  79195. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  79196. * @param parsedTexture defines parsed texture data
  79197. * @param scene defines the current scene
  79198. * @param rootUrl defines the root URL containing normal map procedural texture information
  79199. * @returns a parsed Normal Map Procedural BABYLON.Texture
  79200. */
  79201. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  79202. }
  79203. }
  79204. declare module BABYLON {
  79205. /** @hidden */
  79206. export var perlinNoiseProceduralTexturePixelShader: {
  79207. name: string;
  79208. shader: string;
  79209. };
  79210. }
  79211. declare module BABYLON {
  79212. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  79213. time: number;
  79214. timeScale: number;
  79215. translationSpeed: number;
  79216. private _currentTranslation;
  79217. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79218. updateShaderUniforms(): void;
  79219. render(useCameraPostProcess?: boolean): void;
  79220. resize(size: any, generateMipMaps: any): void;
  79221. /**
  79222. * Serializes this perlin noise procedural texture
  79223. * @returns a serialized perlin noise procedural texture object
  79224. */
  79225. serialize(): any;
  79226. /**
  79227. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  79228. * @param parsedTexture defines parsed texture data
  79229. * @param scene defines the current scene
  79230. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  79231. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  79232. */
  79233. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  79234. }
  79235. }
  79236. declare module BABYLON {
  79237. /** @hidden */
  79238. export var roadProceduralTexturePixelShader: {
  79239. name: string;
  79240. shader: string;
  79241. };
  79242. }
  79243. declare module BABYLON {
  79244. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  79245. private _roadColor;
  79246. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79247. updateShaderUniforms(): void;
  79248. get roadColor(): BABYLON.Color3;
  79249. set roadColor(value: BABYLON.Color3);
  79250. /**
  79251. * Serializes this road procedural texture
  79252. * @returns a serialized road procedural texture object
  79253. */
  79254. serialize(): any;
  79255. /**
  79256. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  79257. * @param parsedTexture defines parsed texture data
  79258. * @param scene defines the current scene
  79259. * @param rootUrl defines the root URL containing road procedural texture information
  79260. * @returns a parsed Road Procedural BABYLON.Texture
  79261. */
  79262. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  79263. }
  79264. }
  79265. declare module BABYLON {
  79266. /** @hidden */
  79267. export var starfieldProceduralTexturePixelShader: {
  79268. name: string;
  79269. shader: string;
  79270. };
  79271. }
  79272. declare module BABYLON {
  79273. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  79274. private _time;
  79275. private _alpha;
  79276. private _beta;
  79277. private _zoom;
  79278. private _formuparam;
  79279. private _stepsize;
  79280. private _tile;
  79281. private _brightness;
  79282. private _darkmatter;
  79283. private _distfading;
  79284. private _saturation;
  79285. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79286. updateShaderUniforms(): void;
  79287. get time(): number;
  79288. set time(value: number);
  79289. get alpha(): number;
  79290. set alpha(value: number);
  79291. get beta(): number;
  79292. set beta(value: number);
  79293. get formuparam(): number;
  79294. set formuparam(value: number);
  79295. get stepsize(): number;
  79296. set stepsize(value: number);
  79297. get zoom(): number;
  79298. set zoom(value: number);
  79299. get tile(): number;
  79300. set tile(value: number);
  79301. get brightness(): number;
  79302. set brightness(value: number);
  79303. get darkmatter(): number;
  79304. set darkmatter(value: number);
  79305. get distfading(): number;
  79306. set distfading(value: number);
  79307. get saturation(): number;
  79308. set saturation(value: number);
  79309. /**
  79310. * Serializes this starfield procedural texture
  79311. * @returns a serialized starfield procedural texture object
  79312. */
  79313. serialize(): any;
  79314. /**
  79315. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  79316. * @param parsedTexture defines parsed texture data
  79317. * @param scene defines the current scene
  79318. * @param rootUrl defines the root URL containing startfield procedural texture information
  79319. * @returns a parsed Starfield Procedural BABYLON.Texture
  79320. */
  79321. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  79322. }
  79323. }
  79324. declare module BABYLON {
  79325. /** @hidden */
  79326. export var woodProceduralTexturePixelShader: {
  79327. name: string;
  79328. shader: string;
  79329. };
  79330. }
  79331. declare module BABYLON {
  79332. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  79333. private _ampScale;
  79334. private _woodColor;
  79335. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79336. updateShaderUniforms(): void;
  79337. get ampScale(): number;
  79338. set ampScale(value: number);
  79339. get woodColor(): BABYLON.Color3;
  79340. set woodColor(value: BABYLON.Color3);
  79341. /**
  79342. * Serializes this wood procedural texture
  79343. * @returns a serialized wood procedural texture object
  79344. */
  79345. serialize(): any;
  79346. /**
  79347. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  79348. * @param parsedTexture defines parsed texture data
  79349. * @param scene defines the current scene
  79350. * @param rootUrl defines the root URL containing wood procedural texture information
  79351. * @returns a parsed Wood Procedural BABYLON.Texture
  79352. */
  79353. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  79354. }
  79355. }